We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 88e7d0e4 authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

[PW-2286]: Avoiding order cancellation in Result controller (#719)

* [PW-2286]: Avoiding order cancellation in Result controller

* Update Controller/Process/Result.php
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* [PW-2286]: Simplifying switch in Result.php

* Update Controller/Process/Result.php
Co-authored-by: default avatarMarcos Garcia <marcos.asgarcia@gmail.com>

* Update Controller/Process/Result.php
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
Co-authored-by: default avatarMarcos Garcia <marcos.asgarcia@gmail.com>
parent 6d7e8fd1
...@@ -107,7 +107,14 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -107,7 +107,14 @@ class Result extends \Magento\Framework\App\Action\Action
$session->getQuote()->setIsActive(false)->save(); $session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]); $this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
} else { } else {
$this->_cancel($response); $this->_adyenLogger->addAdyenResult(
sprintf(
'Payment for order %s was unsuccessful, ' .
'it will be cancelled when the OFFER_CLOSED notification has been processed.',
$this->_order->getIncrementId()
)
);
$this->restoreCart($response);
$failReturnPath = $this->_adyenHelper->getAdyenAbstractConfigData('return_path'); $failReturnPath = $this->_adyenHelper->getAdyenAbstractConfigData('return_path');
$this->_redirect($failReturnPath); $this->_redirect($failReturnPath);
} }
...@@ -121,17 +128,13 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -121,17 +128,13 @@ class Result extends \Magento\Framework\App\Action\Action
/** /**
* @param $response * @param $response
*/ */
protected function _cancel($response) protected function restoreCart($response)
{ {
$session = $this->_session; $session = $this->_session;
// restore the quote // restore the quote
$session->restoreQuote(); $session->restoreQuote();
$order = $this->_order;
$this->_adyenHelper->cancelOrder($order);
if (isset($response['authResult']) && $response['authResult'] == \Adyen\Payment\Model\Notification::CANCELLED) { if (isset($response['authResult']) && $response['authResult'] == \Adyen\Payment\Model\Notification::CANCELLED) {
$this->messageManager->addError(__('You have cancelled the order. Please try again')); $this->messageManager->addError(__('You have cancelled the order. Please try again'));
} else { } else {
...@@ -270,17 +273,13 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -270,17 +273,13 @@ class Result extends \Magento\Framework\App\Action\Action
$this->_adyenLogger->addAdyenResult('Do nothing wait for the notification'); $this->_adyenLogger->addAdyenResult('Do nothing wait for the notification');
break; break;
case Notification::CANCELLED: case Notification::CANCELLED:
$this->_adyenLogger->addAdyenResult('Cancel or Hold the order'); case Notification::ERROR:
$this->_adyenLogger->addAdyenResult('Cancel or Hold the order on OFFER_CLOSED notification');
$result = false; $result = false;
break; break;
case Notification::REFUSED: case Notification::REFUSED:
// if refused there will be a AUTHORIZATION : FALSE notification send only exception is idea // if refused there will be a AUTHORIZATION : FALSE notification send only exception is idea
$this->_adyenLogger->addAdyenResult('Cancel or Hold the order'); $this->_adyenLogger->addAdyenResult('Cancel or Hold the order on AUTHORISATION success = false notification');
$result = false;
break;
case Notification::ERROR:
//attempt to hold/cancel
$this->_adyenLogger->addAdyenResult('Cancel or Hold the order');
$result = false; $result = false;
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment