コード例 #1
0
ファイル: Start.php プロジェクト: ORBA/magento2_payupl
 /**
  * @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;
 }
コード例 #2
0
ファイル: Start.php プロジェクト: ORBA/magento2_payupl
 /**
  * @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;
 }
コード例 #3
0
ファイル: Payment.php プロジェクト: tozwierz/magento2_payupl
 /**
  * @param int $orderId
  * @return string|false
  */
 public function getRepeatPaymentUrl($orderId)
 {
     $order = $this->orderHelper->loadOrderById($orderId);
     if ($order && $this->orderHelper->canRepeatPayment($order)) {
         return $this->_urlBuilder->getUrl('orba_payupl/payment/repeat', ['id' => $this->transactionResource->getLastPayuplOrderIdByOrderId($orderId)]);
     }
     return false;
 }
コード例 #4
0
 public function testGetOrderByIdSuccess()
 {
     $orderId = 1;
     $order = $this->getOrderMock();
     $order->expects($this->once())->method('load')->with($this->equalTo($orderId))->will($this->returnSelf());
     $order->expects($this->once())->method('getId')->willReturn($orderId);
     $this->orderFactory->expects($this->once())->method('create')->willReturn($order);
     $this->assertEquals($order, $this->model->loadOrderById($orderId));
 }