/** * @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; }
/** * @param string $methodName * @param array $args * @return \stdClass|false */ public function call($methodName, array $args = []) { try { return $this->_rawMethod->call($methodName, $args); } catch (\Exception $e) { $this->_logger->critical($e); return false; } }
/** * @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; }
/** * @inheritDoc */ public function paymentSuccessCheck() { $errorCode = $this->request->getParam('error'); if ($errorCode) { $extOrderId = $this->request->getParam('session_id'); $this->logger->error('Payment error ' . $errorCode . ' for transaction ' . $extOrderId . '.'); return false; } return true; }
/** * @inheritDoc */ public function create($orderId = '', $description = '', $amount = null) { $realPayuplOrderId = $this->transactionResource->getExtOrderIdByPayuplOrderId($orderId); if ($realPayuplOrderId) { $posId = $this->orderDataGetter->getPosId(); $ts = $this->orderDataGetter->getTs(); $sig = $this->orderDataGetter->getSigForOrderRetrieve(['pos_id' => $posId, 'session_id' => $realPayuplOrderId, 'ts' => $ts]); $authData = ['posId' => $posId, 'sessionId' => $realPayuplOrderId, 'ts' => $ts, 'sig' => $sig]; $getResult = $this->methodCaller->call('refundGet', [$authData]); if ($getResult) { $createResult = $this->methodCaller->call('refundAdd', [$authData, ['refundsHash' => $getResult->refsHash, 'amount' => $amount, 'desc' => $description, 'autoData' => true]]); if ($createResult < 0) { $this->logger->error('Refund error ' . $createResult . ' for transaction ' . $orderId); } return $createResult === 0; } } return false; }
public function execute() { /** * @var $client \Orba\Payupl\Model\Client */ $request = $this->context->getRequest(); try { $client = $this->clientFactory->create(); $response = $client->orderConsumeNotification($request); $clientOrderHelper = $client->getOrderHelper(); if ($clientOrderHelper->canProcessNotification($response['payuplOrderId'])) { return $clientOrderHelper->processNotification($response['payuplOrderId'], $response['status'], $response['amount']); } } catch (LocalizedException $e) { $this->logger->critical($e); } /** * @var $resultForward \Magento\Framework\Controller\Result\Forward */ $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; }