Check and set param for payment.

@param StripeMethod $paymentMethod Payment method
@param float        $amount        Amount

@return StripeTransaction Charge params

@throws PaymentAmountsNotMatchException
@throws PaymentOrderNotFoundException
199312
private function prepareData(StripeMethod $paymentMethod, $amount)
    {
        /// first check that amounts are the same
        $cartAmount = intval($this->paymentBridge->getAmount());

        /**
         * If both amounts are different, execute Exception.
         */
        if (abs($amount - $cartAmount) > 0.00001) {
            throw new PaymentAmountsNotMatchException();
        }

        /**
         * At this point, order must be created given a cart, and placed in PaymentBridge.
         *
         * So, $this->paymentBridge->getOrder() must return an object
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderLoad(
                $this->paymentBridge,
                $paymentMethod
            );

        /**
         * Order Not found Exception must be thrown just here.
         */
        if (!$this->paymentBridge->getOrder()) {
            throw new PaymentOrderNotFoundException();
        }

        /**
         * Order exists right here.
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderCreated(
                $this->paymentBridge,
                $paymentMethod
            );

        return new StripeTransaction(
            $paymentMethod->getApiToken(),
            $cartAmount,
            $this->paymentBridge->getCurrency()
        );
    }
112495
public function getHppPaymentMethodFee($paymentMethod)
    {
        $paymentMethod = str_replace('adyen_hpp_', '', $paymentMethod);

        $paymentFees = $this->getHppPaymentMethodFees();

        if ($paymentFees && is_array($paymentFees) && !empty($paymentFees)) {
            foreach ($paymentFees as $paymentFee) {
                if (isset($paymentFee['code']) && $paymentFee['code'] == $paymentMethod) {
                    if (isset($paymentFee['amount'])) {
                        return $paymentFee['amount'];
                    }
                }
            }
        }

        return null;
    }
1238872
public function updateFromEmbeddedApiResponse(array $data, string $currency, ShippingMethodInterface $shippingMethod = null): ShippingMethodInterface
    {
        if (!$shippingMethod) {
            $shippingMethod = $this->getShippingMethod($data['id']);
        }

        if (!$shippingMethod->getId()) {
            // only update when we create a new entity because this is the embedded method
            $shippingMethod
                ->setFee(DandomainFoundation\createMoney((string) $currency, $data['fee']))
                ->setFeeInclVat($data['feeInclVat'])
                ->setName($data['name']);
        }

        return $shippingMethod;
    }
648906
public function makePaymentUsingExistingPaymentMethod($accountID, $paymentMethodID, $amount)
    {
        return $this->httpHelper->post("/accounts/" . intval($accountID) . "/transactions/payments", [
            'payment_method_id' => intval($paymentMethodID),
            'amount' => trim($amount),
            'auto_apply' => true,
        ]);
    }
1179757
public function create($amount, $payment, $options = [])
    {
        $params = [];

        $params = $this->addPaymentMethod($params, $payment, $options);
        $params = $this->addOrder($params, $amount, $options);
        $params = $this->addCustomer($params, $options);

        return $this->gateway->commit('post', $this->gateway->buildUrlFromString('charges'), $params);
    }
474512
protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction)
    {
        if (!$paymentTransaction->isFinished())
        {
            throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id');
        }

        if (!$paymentTransaction->getPayment()->isPaid())
        {
            throw new ValidationException("Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first");
        }
    }
1318440
public function void($paymentId, $amount)
    {

        $this->debugData[] = __METHOD__;

        $method = 'PUT';
        $uri = $this->config['apiUri'] . \sprintf('/sales/%s/void', $paymentId);
        $options = [
            'headers' => $this->headers
        ];

        if ($amount) {
            $uri .= sprintf('?amount=%s', (float)$amount);
        }

        $this->debugData[][__LINE__]['method'] = $method;
        $this->debugData[][__LINE__]['uri'] = $uri;
        $this->debugData[][__LINE__]['options'] = $uri;

        try {

            $response = $this->http()->request($method, $uri, $options);

            $this->debugData[][__LINE__]['response'] = $response;

            $result = \json_decode($response->getBody()->getContents(), true);

            $this->debugData[][__LINE__]['result'] = $result;

        } catch (RequestException $e) {

            $result = array(
                'code'=>$e->getCode(),
                'message'=>$e->getMessage()
                );

            $this->debugData[][__LINE__]['exception'] = $e->getMessage();

        }

        return $result;
    }
889327
public function transact($amount, $orderId, $invoiceNumber = null)
    {
        $this->transaction = [
            'amount' => $amount,
            'orderId' => $orderId,
            'invoiceNumber' => $invoiceNumber ?: $orderId,
        ];

        return $this->initiateTransaction();
    }
1130492
public function setAmount($amount)
    {
        if (!Icepay_Parameter_Validation::amount($amount))
            throw new Exception('Please enter a valid amount (in cents)', 1003);

        $this->amount = $amount;
        return $this;
    }
595774
public function capture($payment, $amount)
        {
            $error = false;
            // check for payment
            if($amount > 0) {
                $payment->setAmount($amount);

                // Map magento keys to moneris way
                $transaction = $this->_build($payment, self::TRANSACTION_COMPLETION);
                $response = $this->_send($transaction);

                if($response->getResponseCode() > 0 && $response->getResponseCode() <= self::ERROR_CODE_LIMIT) {
                    $payment->setStatus(self::STATUS_SUCCESS);
                } else if($response->getResponseCode() > self::ERROR_CODE_LIMIT && $response->getResponseCode() < self::ERROR_CODE_UPPER_LIMIT) {
                    $error = $this->_errors[$response->getResponseCode()];
                } else {
                    $error = 'Incomplete transaction.';
                }
            } else {
                $error = 'Invalid amount for authorization.';
            }

            // we've got something bad here.
            if ($error !== false) {
                $this->_log($error);
            }
            return $this;
        }
1277648
public function returnCheck(HpsCheck $check, $amount, $clientTransactionId = null)
    {
        //TODO: implement replacement
        throw new HpsException('Check action RETURN not currently supported');
        return $this->_buildTransaction('RETURN', $check, $amount, $clientTransactionId);
    }
196937
public function selectPaymentMethodByCode($name)
    {
        if (!isset($this->_paymentMethodsArray))
            throw new Exception("No data loaded");
        foreach ($this->_paymentMethodsArray as $paymentMethod) {
            if ($paymentMethod["PaymentMethodCode"] == strtoupper($name)) {
                $this->_methodData = $paymentMethod;
                break;
            }
        }
        return $this;
    }
1273977
private function addCreditCard(HpsPayPlanPaymentMethod $paymentMethod)
    {
        $data = $paymentMethod->getEditableFieldsWithValues();
        $data['customerKey'] = $paymentMethod->customerKey;
        if (isset($paymentMethod->accountNumber)) {
            $data['accountNumber'] = $paymentMethod->accountNumber;
        } else if (isset($paymentMethod->paymentToken)) {
            $data['paymentToken'] = $paymentMethod->paymentToken;
        }
        $result = $this->doRequest($data, array(
            'verb'     => 'POST',
            'endpoint' => 'paymentMethodsCreditCard',
        ));
        return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
    }
1308437
public function authorize($amount = null)
    {
        if (is_null($amount)) {
            $amount = $this->getAmount()->total;
        }
        $path = sprintf('/%s/%s?payment_id=%s&amount=%s', self::SIMULATOR_PATH, 'authorize', $this->getId(), $amount);
        $response = $this->httpRequest($path, Requests::GET);

        if (empty($response)) {
            return true;
        }

        return false;
    }
859106
function calc_order_amount($amount, $paypalCurrency, $applyFormatting = false) {
    global $currencies;
    $amount = ($amount * $currencies->get_value($paypalCurrency));
    if ($paypalCurrency == 'JPY' || (int)$currencies->get_decimal_places($paypalCurrency) == 0) {
      $amount = (int)$amount;
      $applyFormatting = FALSE;
    }
    return ($applyFormatting ? number_format($amount, $currencies->get_decimal_places($paypalCurrency)) : $amount);
  }
1107081
static public function isPaymentMethod($paymentMethod) {
    return ((string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_CREDITCARD ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_TODITOCASH ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_BANKTRANSFER ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_DIRECTDEBIT ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_WECHAT ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_LINE ||
        (string) $paymentMethod == Connect2PayClient::PAYMENT_METHOD_ALIPAY);
  }
251024
public function setAmount($amount)
    {
        $amount = (int) (string) $amount;

        if (!Icepay_Parameter_Validation::amount($amount))
            throw new Exception('Amount not valid');
        $this->data->ic_amount = $amount;
        return $this;
    }