src/base/Gateway.php
protected function createPaymentRequest(Transaction $transaction, $card = null, $itemBag = null): array
    {
        $params = ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash];

        $request = [
            'amount' => $transaction->paymentAmount,
            'currency' => $transaction->paymentCurrency,
            'transactionId' => $transaction->hash,
            'description' => Craft::t('commerce', 'Order').' #'.$transaction->orderId,
            'clientIp' => Craft::$app->getRequest()->userIP,
            'transactionReference' => $transaction->hash,
            'returnUrl' => UrlHelper::actionUrl('commerce/payments/complete-payment', $params),
            'cancelUrl' => UrlHelper::siteUrl($transaction->order->cancelUrl),
        ];

        // Set the webhook url.
        if ($this->supportsWebhooks()) {
            $request['notifyUrl'] = $this->getWebhookUrl($params);
            $request['notifyUrl'] = str_replace('rc.craft.local', 'umbushka.eu.ngrok.io', $request['notifyUrl']);
        }

        // Do not use IPv6 loopback
        if ($request['clientIp'] ===  '::1') {
            $request['clientIp'] = '127.0.0.1';
        }

        // custom gateways may wish to access the order directly
        $request['order'] = $transaction->order;
        $request['orderId'] = $transaction->order->id;

        // Stripe only params
        $request['receiptEmail'] = $transaction->order->email;

        // Paypal only params
        $request['noShipping'] = 1;
        $request['allowNote'] = 0;
        $request['addressOverride'] = 1;
        $request['buttonSource'] = 'ccommerce_SP';

        if ($card) {
            $request['card'] = $card;
        }

        if ($itemBag) {
            $request['items'] = $itemBag;
        }

        return $request;
    }
protected function createPaymentRequest(Transaction $transaction, $card = null, $itemBag = null): array
    {
        $params = ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash];

        $request = [
            'amount' => $transaction->paymentAmount,
            'currency' => $transaction->paymentCurrency,
            'transactionId' => $transaction->hash,
            'description' => Craft::t('commerce', 'Order').' #'.$transaction->orderId,
            'clientIp' => Craft::$app->getRequest()->userIP,
            'transactionReference' => $transaction->hash,
            'returnUrl' => UrlHelper::actionUrl('commerce/payments/complete-payment', $params),
            'cancelUrl' => UrlHelper::siteUrl($transaction->order->cancelUrl),
        ];

        // Set the webhook url.
        if ($this->supportsWebhooks()) {
            $request['notifyUrl'] = $this->getWebhookUrl($params);
            $request['notifyUrl'] = str_replace('rc.craft.local', 'umbushka.eu.ngrok.io', $request['notifyUrl']);
        }

        // Do not use IPv6 loopback
        if ($request['clientIp'] ===  '::1') {
            $request['clientIp'] = '127.0.0.1';
        }

        // custom gateways may wish to access the order directly
        $request['order'] = $transaction->order;
        $request['orderId'] = $transaction->order->id;

        // Stripe only params
        $request['receiptEmail'] = $transaction->order->email;

        // Paypal only params
        $request['noShipping'] = 1;
        $request['allowNote'] = 0;
        $request['addressOverride'] = 1;
        $request['buttonSource'] = 'ccommerce_SP';

        if ($card) {
            $request['card'] = $card;
        }

        if ($itemBag) {
            $request['items'] = $itemBag;
        }

        return $request;
    }
protected function createPaymentRequest ( Transaction $ transaction , $ card = null , $ itemBag = null ) : array { $ params = [ 'commerceTransactionId' => $ transaction -> id , 'commerceTransactionHash' => $ transaction -> hash ] ; $ request = [ 'amount' => $ transaction -> paymentAmount , 'currency' => $ transaction -> paymentCurrency , 'transactionId' => $ transaction -> hash , 'description' => Craft :: t ( 'commerce' , 'Order' ) . ' #' . $ transaction -> orderId , 'clientIp' => Craft :: $ app -> getRequest ( ) -> userIP , 'transactionReference' => $ transaction -> hash , 'returnUrl' => UrlHelper :: actionUrl ( 'commerce/payments/complete-payment' , $ params ) , 'cancelUrl' => UrlHelper :: siteUrl ( $ transaction -> order -> cancelUrl ) , ] ; // Set the webhook url. if ( $ this -> supportsWebhooks ( ) ) { $ request [ 'notifyUrl' ] = $ this -> getWebhookUrl ( $ params ) ; $ request [ 'notifyUrl' ] = str_replace ( 'rc.craft.local' , 'umbushka.eu.ngrok.io' , $ request [ 'notifyUrl' ] ) ; } // Do not use IPv6 loopback if ( $ request [ 'clientIp' ] === '::1' ) { $ request [ 'clientIp' ] = '127.0.0.1' ; } // custom gateways may wish to access the order directly $ request [ 'order' ] = $ transaction -> order ; $ request [ 'orderId' ] = $ transaction -> order -> id ; // Stripe only params $ request [ 'receiptEmail' ] = $ transaction -> order -> email ; // Paypal only params $ request [ 'noShipping' ] = 1 ; $ request [ 'allowNote' ] = 0 ; $ request [ 'addressOverride' ] = 1 ; $ request [ 'buttonSource' ] = 'ccommerce_SP' ; if ( $ card ) { $ request [ 'card' ] = $ card ; } if ( $ itemBag ) { $ request [ 'items' ] = $ itemBag ; } return $ request ; }
Create the parameters for a payment request based on a trasaction and optional card and item list.

@param Transaction $transaction The transaction that is basis for this request.
@param CreditCard  $card        The credit card being used
@param ItemBag     $itemBag     The item list.

@return array
@throws \yii\base\Exception
Create the parameters for a payment request based on a trasaction and optional card and item list .