/** * Copies paytype from payment additional data to session. * * @param \Magento\Checkout\Model\PaymentInformationManagement $subject * @param $cartId * @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod */ public function beforeSavePaymentInformationAndPlaceOrder(\Magento\Checkout\Model\PaymentInformationManagement $subject, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod) { if ($paymentMethod->getMethod() === \Orba\Payupl\Model\Payupl::CODE) { $additionalData = $paymentMethod->getAdditionalData(); $this->session->setPaytype(isset($additionalData['paytype']) ? $additionalData['paytype'] : null); } }
public function execute() { $resultRedirect = $this->resultRedirectFactory->create(); $payuplOrderId = $this->context->getRequest()->getParam('id'); $orderId = $this->paymentHelper->getOrderIdIfCanRepeat($payuplOrderId); if ($orderId) { $resultRedirect->setPath('orba_payupl/payment/repeat_start'); $this->session->setLastOrderId($orderId); } else { $resultRedirect->setPath('orba_payupl/payment/repeat_error'); $this->messageManager->addError(__('The repeat payment link is invalid.')); } return $resultRedirect; }
/** * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { /** * @var $clientOrderHelper \Orba\Payupl\Model\Client\OrderInterface * @var $resultRedirect \Magento\Framework\Controller\Result\Redirect */ $resultRedirect = $this->resultRedirectFactory->create(); $redirectUrl = 'checkout/cart'; $redirectParams = []; $orderId = $this->orderHelper->getOrderIdForPaymentStart(); if ($orderId) { $order = $this->orderHelper->loadOrderById($orderId); if ($this->orderHelper->canStartFirstPayment($order)) { try { $client = $this->clientFactory->create(); $clientOrderHelper = $client->getOrderHelper(); $orderData = $clientOrderHelper->getDataForOrderCreate($order); $result = $client->orderCreate($orderData); $this->orderHelper->addNewOrderTransaction($order, $result['orderId'], $result['extOrderId'], $clientOrderHelper->getNewStatus()); $this->orderHelper->setNewOrderStatus($order); $redirectUrl = $result['redirectUri']; } catch (LocalizedException $e) { $this->logger->critical($e); $redirectUrl = 'orba_payupl/payment/end'; $redirectParams = ['exception' => '1']; } $this->session->setLastOrderId($orderId); } } $resultRedirect->setPath($redirectUrl, $redirectParams); return $resultRedirect; }
/** * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { /** * @var $clientOrderHelper \Orba\Payupl\Model\Client\OrderInterface */ $resultRedirect = $this->resultRedirectFactory->create(); $redirectUrl = '/'; try { if ($this->successValidator->isValid()) { $redirectUrl = 'orba_payupl/payment/error'; $this->session->setLastOrderId(null); $clientOrderHelper = $this->getClientOrderHelper(); if ($this->orderHelper->paymentSuccessCheck() && $clientOrderHelper->paymentSuccessCheck()) { $redirectUrl = 'checkout/onepage/success'; } } else { if ($this->session->getLastOrderId()) { $redirectUrl = 'orba_payupl/payment/repeat_error'; $clientOrderHelper = $this->getClientOrderHelper(); if ($this->orderHelper->paymentSuccessCheck() && $clientOrderHelper->paymentSuccessCheck()) { $redirectUrl = 'orba_payupl/payment/repeat_success'; } } } } catch (LocalizedException $e) { $this->logger->critical($e); } $resultRedirect->setPath($redirectUrl); return $resultRedirect; }
/** * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { /** * @var $clientOrderHelper \Orba\Payupl\Model\Client\OrderInterface */ $resultRedirect = $this->resultRedirectFactory->create(); $orderId = $this->session->getLastOrderId(); $redirectParams = []; if ($orderId) { try { $client = $this->clientFactory->create(); $clientOrderHelper = $client->getOrderHelper(); $order = $this->orderHelper->loadOrderById($orderId); $orderData = $clientOrderHelper->getDataForOrderCreate($order); $result = $client->orderCreate($orderData); $this->orderHelper->addNewOrderTransaction($order, $result['orderId'], $result['extOrderId'], $clientOrderHelper->getNewStatus()); $this->orderHelper->setNewOrderStatus($order); $redirectUrl = $result['redirectUri']; } catch (LocalizedException $e) { $redirectUrl = 'orba_payupl/payment/end'; $redirectParams = ['exception' => '1']; } } else { $redirectUrl = 'orba_payupl/payment/repeat_error'; } $resultRedirect->setPath($redirectUrl, $redirectParams); return $resultRedirect; }
/** * @param \Magento\Sales\Model\Order $order * @return array */ public function getBasicData(\Magento\Sales\Model\Order $order) { $incrementId = $order->getIncrementId(); $billingAddress = $order->getBillingAddress(); $data = ['amount' => $order->getGrandTotal() * 100, 'desc' => __('Order # %1', [$incrementId]), 'first_name' => $billingAddress->getFirstname(), 'last_name' => $billingAddress->getLastname(), 'email' => $order->getCustomerEmail(), 'session_id' => $this->extOrderIdHelper->generate($order), 'order_id' => $incrementId]; $paytype = $this->session->getPaytype(); if ($paytype) { $data['pay_type'] = $paytype; $this->session->setPaytype(null); } return $data; }
/** * @return string|false */ public function getPaymentUrl() { $orderId = $this->session->getLastOrderId(); if ($orderId) { $repeatPaymentUrl = $this->paymentHelper->getRepeatPaymentUrl($orderId); if (!$repeatPaymentUrl) { return $this->paymentHelper->getStartPaymentUrl($orderId); } return $repeatPaymentUrl; } return false; }
public function execute() { if ($this->session->getLastOrderId()) { $this->session->setLastOrderId(null); $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('Thank you for your payment!')); return $resultPage; } else { $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('/'); return $resultRedirect; } }
/** * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { /** * @var $resultRedirect \Magento\Framework\Controller\Result\Redirect * @var $resultPage \Magento\Framework\View\Result\Page */ $orderCreateData = $this->session->getOrderCreateData(); if ($orderCreateData) { $this->session->setOrderCreateData(null); $resultPage = $this->resultPageFactory->create(true, ['template' => 'Orba_Payupl::emptyroot.phtml']); $resultPage->addHandle($resultPage->getDefaultLayoutHandle()); $resultPage->getLayout()->getBlock('orba.payupl.classic.form')->setOrderCreateData($orderCreateData); return $resultPage; } else { $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('/'); return $resultRedirect; } }
/** * @inheritDoc */ public function create(array $data) { $this->session->setOrderCreateData($data); return ['orderId' => md5($data['session_id']), 'extOrderId' => $data['session_id'], 'redirectUri' => $this->urlBuilder->getUrl('orba_payupl/classic/form')]; }