/** * Order Payment * @param \Magento\Payment\Model\InfoInterface $payment * @param float $amount * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function order(\Magento\Payment\Model\InfoInterface $payment, $amount) { $order = $payment->getOrder(); $orderId = ltrim($order->getIncrementId(), '0'); $data = ['transaction_id' => $this->getModuleHelper()->genTransactionId($orderId), 'transaction_types' => $this->getConfigHelper()->getTransactionTypes(), 'order' => ['currency' => $order->getBaseCurrencyCode(), 'language' => $this->getModuleHelper()->getLocale(), 'amount' => $amount, 'usage' => $this->getModuleHelper()->buildOrderUsage(), 'description' => $this->getModuleHelper()->buildOrderDescriptionText($order), 'customer' => ['email' => $this->getCheckoutSession()->getQuote()->getCustomerEmail()], 'billing' => $order->getBillingAddress(), 'shipping' => $order->getShippingAddress()], 'urls' => ['notify' => $this->getModuleHelper()->getNotificationUrl($this->getCode()), 'return_success' => $this->getModuleHelper()->getReturnUrl($this->getCode(), "success"), 'return_cancel' => $this->getModuleHelper()->getReturnUrl($this->getCode(), "cancel"), 'return_failure' => $this->getModuleHelper()->getReturnUrl($this->getCode(), "failure")]]; $this->getConfigHelper()->initGatewayClient(); try { $responseObject = $this->checkout($data); $payment->setTransactionId($responseObject->unique_id); $payment->setIsTransactionPending(true); $payment->setIsTransactionClosed(false); $this->getModuleHelper()->setPaymentTransactionAdditionalInfo($payment, $responseObject); $this->getCheckoutSession()->setEmerchantPayCheckoutRedirectUrl($responseObject->redirect_url); return $this; } catch (\Exception $e) { $this->getLogger()->error($e->getMessage()); $this->getModuleHelper()->maskException($e); } }