diff --git a/Controller/Pay/Confirmation.php b/Controller/Pay/Confirmation.php index 6bd1793..49b454f 100644 --- a/Controller/Pay/Confirmation.php +++ b/Controller/Pay/Confirmation.php @@ -42,39 +42,38 @@ public function execute() return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl(['order_id' => $orderId])); } - $model->log('Order Status:'.$order->getStatus()); if (isset($params['status']) && $params['status'] == 'canceled') { - throw new \Exception(__('Transaction canceled by customer/gateway. ')); - } - - $savedPaymentId = $this->helper->getPaymentResponseSingle($order->getId(), 'payment_id'); - - $reference = trim($params['reference']); - if ($savedPaymentId != $reference) { - throw new \Exception(__('Transaction references check failed. ')); + $error_message = __('Transaction canceled by customer/gateway. '); + $model->log('Return:'.$error_message); + $message = __('HitPay Payment is failed. '.$error_message); + + if ($order && $order->getId() > 0) { + $order->cancel(); + $order->addStatusHistoryComment($message, \Magento\Sales\Model\Order::STATE_CANCELED); + $order->save(); + $session->restoreQuote(); + } + $this->messageManager->addError($message); + return $this->getResponse()->setRedirect($model->getCheckoutCartUrl()); } return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl(['order_id' => $orderId])); } else { - throw new \Exception(__('No relation found with this transaction in the store.')); + $error_message = __('No relation found with this transaction in the store. '); + $model->log('Return:'.$error_message); + return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl()); } } else { - throw new \Exception(__('Empty response received from gateway.')); + $error_message = __('Empty response received from gateway. '); + $model->log('Return:'.$error_message); + return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl()); } } catch (\Exception $e) { $error_message = $e->getMessage(); $model->log('Return from Gateway Catch'); $model->log('Exception:'.$e->getMessage()); - $message = __('HitPay Payment is failed. '.$error_message); - if ($order && $order->getId() > 0) { - $order->cancel(); - $order->addStatusHistoryComment($message, \Magento\Sales\Model\Order::STATE_CANCELED); - $order->save(); - $session->restoreQuote(); - } - $this->messageManager->addError($message); - echo ''; + return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl()); } exit; } diff --git a/README.md b/README.md index dfeee84..65f4c31 100644 --- a/README.md +++ b/README.md @@ -163,3 +163,7 @@ If you click the Credit Memo button in other pages, Magento will provide option * Fixed Admin refund error for multi-store * Fixed Success page status display loader issue when reloading the page * Plugin tested on Magento 2.4.7-p1 + += 2.1.3 = +* Aug 2, 2024 +* Updated Return URL page, removed the order canceling if any php error/warning/notice occurs and removed the comparison of the order references. diff --git a/etc/module.xml b/etc/module.xml index ec5c26e..e03ad04 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +