/** * @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; }
public function testGetOrderIdForPaymentStartFail() { $this->checkoutSuccessValidator->expects($this->once())->method('isValid')->willReturn(false); $this->request->expects($this->once())->method('getParam')->with($this->equalTo('id'))->willReturn(null); $this->assertFalse($this->model->getOrderIdForPaymentStart()); }