From 2b8bd7b691a3c01f840ed8e48fbc8a21a9fd7fb0 Mon Sep 17 00:00:00 2001 From: Aashish Gurung <101558497+aashishgurung@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:02:55 +0700 Subject: [PATCH 1/2] Fixed redirect issue on cancelled card payment. (#470) * Fixed redirect issue on cancelled card payment. * Remove reference to deleted trait in controllers. --------- Co-authored-by: Aashish --- Controller/Callback/Offsite.php | 16 ++++------- Controller/Callback/Threedsecure.php | 8 +++--- .../Callback/Traits/FailedChargeTrait.php | 27 ------------------- 3 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 Controller/Callback/Traits/FailedChargeTrait.php diff --git a/Controller/Callback/Offsite.php b/Controller/Callback/Offsite.php index 457077e6..e01779e2 100644 --- a/Controller/Callback/Offsite.php +++ b/Controller/Callback/Offsite.php @@ -15,14 +15,10 @@ use Omise\Payment\Model\Config\Cc as Config; use Magento\Checkout\Model\Session as CheckoutSession; use Psr\Log\LoggerInterface; -use Omise\Payment\Controller\Callback\Traits\FailedChargeTrait; use Magento\Framework\App\Request\Http; -use Omise\Payment\Model\Config\Atome; class Offsite extends Action { - use FailedChargeTrait; - /** * @var string */ @@ -118,10 +114,9 @@ public function execute() } $paymentMethod = $payment->getMethod(); - $shopeePayFailed = $this->helper->hasShopeepayFailed($paymentMethod, $charge->isSuccessful()); - if ($charge->isFailed() || $shopeePayFailed) { - return $this->handleFailure($charge, $shopeePayFailed); + if ($charge->isFailed()) { + return $this->handleFailure($charge); } // Do not proceed if webhook is enabled @@ -148,9 +143,8 @@ public function execute() * Mark order as failed * * @param object $charge - * @param boolean $shopeePayFailed {TODO: Remove this once backend issue is fixed} */ - private function handleFailure($charge, $shopeePayFailed) + private function handleFailure($charge) { // restoring the cart $this->checkoutSession->restoreQuote(); @@ -161,8 +155,8 @@ private function handleFailure($charge, $shopeePayFailed) "Payment failed. $failureMessage, please contact our support if you have any questions." ); - // pass shopeePayFailed to avoid webhook to cancel payment - return $this->processFailedCharge($errorMessage, $shopeePayFailed); + // This cancels the order, logs error and displays message in cart page + throw new \Magento\Framework\Exception\LocalizedException($errorMessage); } /** diff --git a/Controller/Callback/Threedsecure.php b/Controller/Callback/Threedsecure.php index e334fdbd..a7a26608 100644 --- a/Controller/Callback/Threedsecure.php +++ b/Controller/Callback/Threedsecure.php @@ -9,20 +9,16 @@ use Magento\Sales\Model\Order\Payment\Transaction; use Omise\Payment\Gateway\Validator\Message\Invalid; use Omise\Payment\Model\Config\Cc as Config; -use Omise\Payment\Model\Config\CcGooglePay; use Omise\Payment\Model\Validator\Payment\AuthorizeResultValidator; use Omise\Payment\Model\Validator\Payment\CaptureResultValidator; use Omise\Payment\Helper\OmiseEmailHelper; use Omise\Payment\Helper\OmiseHelper; use Magento\Checkout\Model\Session as CheckoutSession; use Psr\Log\LoggerInterface; -use Omise\Payment\Controller\Callback\Traits\FailedChargeTrait; use Magento\Framework\App\Request\Http; class Threedsecure extends Action { - use FailedChargeTrait; - /** * @var string */ @@ -146,7 +142,9 @@ public function execute() if ($result instanceof Invalid) { // restoring the cart $this->checkoutSession->restoreQuote(); - return $this->processFailedCharge($result->getMessage()); + + // This cancels the order, logs error and displays message in cart page + throw new \Magento\Framework\Exception\LocalizedException($result->getMessage()); } // Do not proceed if webhook is enabled diff --git a/Controller/Callback/Traits/FailedChargeTrait.php b/Controller/Callback/Traits/FailedChargeTrait.php deleted file mode 100644 index 08a6385d..00000000 --- a/Controller/Callback/Traits/FailedChargeTrait.php +++ /dev/null @@ -1,27 +0,0 @@ -config->isWebhookEnabled()) { - $this->logger->debug($errorMessage); - $this->messageManager->addErrorMessage($errorMessage); - return $this->redirect(self::PATH_CART); - } - - // If webhook is not enabled then this will - // 1. Cancel the order - // 2. Set the error message to display in cart page - // 3. Log the error message - throw new \Magento\Framework\Exception\LocalizedException($errorMessage); - } -} From 0676439e29bdfecc3a14187a81fcd8f92a07627a Mon Sep 17 00:00:00 2001 From: Aashish Date: Mon, 12 Feb 2024 13:23:02 +0700 Subject: [PATCH 2/2] Updated metadata for v3.6.1 --- CHANGELOG.md | 3 +++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index add82870..a26c8b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## [v3.6.1 _(Feb, 12, 2024)_](https://github.com/omise/omise-magento/releases/tag/v3.6.1) +- Fixed redirect issue on cancelled card payment. (PR: [#470](https://github.com/omise/omise-magento/pull/470)) + ## [v3.6.0 _(Jan, 23, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.6.0) - Add truemoney jumpapp. (PR: [#466](https://github.com/omise/omise-magento/pull/466)) - Updated README.md. (PR: [#464](https://github.com/omise/omise-magento/pull/464)) diff --git a/composer.json b/composer.json index 364de48d..c73076c5 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "email": "support@omise.co" } ], - "version": "3.6.0", + "version": "3.6.1", "minimum-stability": "stable", "type": "magento2-module", "license": "MIT", diff --git a/etc/module.xml b/etc/module.xml index f653edd4..d6d716d1 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +