Skip to content

Commit

Permalink
Merge pull request #23 from hit-pay/Update_Return_Url
Browse files Browse the repository at this point in the history
2.1.3-Updated Return URL page, removed the order canceling if any php…
  • Loading branch information
spacemonkey92 authored Aug 14, 2024
2 parents 671b1a3 + 7516133 commit 59457f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
39 changes: 19 additions & 20 deletions Controller/Pay/Confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<script>window.top.location.href = "'.$model->getCheckoutCartUrl().'";</script>';
return $this->getResponse()->setRedirect($model->getCheckoutSuccessUrl());
}
exit;
}
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="SoftBuild_HitPay" setup_version="2.1.2">
<module name="SoftBuild_HitPay" setup_version="2.1.3">
<sequence>
<module name="Magento_Payment" />
<module name="Magento_Checkout"/>
Expand Down

0 comments on commit 59457f9

Please sign in to comment.