/** * Process PayPal API's processable errors * * @param \Magento\Paypal\Model\Api\ProcessableException $exception * @return void */ protected function _processPaypalApiError($exception) { switch ($exception->getCode()) { case ApiProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED: case ApiProcessableException::API_TRANSACTION_EXPIRED: $this->getResponse()->setRedirect($this->_getQuote()->getPayment()->getCheckoutRedirectUrl()); break; case ApiProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL: $this->_redirectSameToken(); break; case ApiProcessableException::API_UNABLE_TRANSACTION_COMPLETE: if ($this->_config->getPaymentAction() == \Magento\Payment\Model\Method\AbstractMethod::ACTION_ORDER) { $paypalTransactionData = $this->_getCheckoutSession()->getPaypalTransactionData(); $this->getResponse()->setRedirect($this->_config->getExpressCheckoutOrderUrl($paypalTransactionData['transaction_id'])); } else { $this->_redirectSameToken(); } break; default: $this->_redirectToCartAndShowError($exception->getUserMessage()); break; } }
/** * @param int $code * @param string $msg * @return void * @dataProvider getUserMessageDataProvider */ public function testGetUserMessage($code, $msg) { $this->model = new ProcessableException(__($msg), null, $code); $this->assertEquals($msg, $this->model->getUserMessage()); }
/** * @param int $code * @param string $msg * @return void * @dataProvider getUserMessageDataProvider */ public function testGetUserMessage($code, $msg) { $this->objectManager = new ObjectManager($this); $this->model = new \Magento\Paypal\Model\Api\ProcessableException(__($msg), null, $code); $this->assertEquals($msg, $this->model->getUserMessage()); }
/** * @dataProvider getUserMessageDataProvider */ public function testGetUserMessage($code, $msg) { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject('Magento\\Paypal\\Model\\Api\\ProcessableException', ['message' => $msg, 'code' => $code]); $this->assertEquals($msg, $this->model->getUserMessage()); }