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 06754662 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

Cancel 'new' on state orders on authorization success=false notification (#891)

Orders paid by alternative payment methods have the state new after
order creation therefore when an authorization success=false
notification is being processed close orders with state new as well not
just the payment_review state ones

Apply getNotificationsCanCancel() for all cases not just when the order
is in payment_review state
parent f575b550
...@@ -487,10 +487,13 @@ class Cron ...@@ -487,10 +487,13 @@ class Cron
// check if success is true of false // check if success is true of false
if (strcmp($this->_success, 'false') == 0 || strcmp($this->_success, '0') == 0) { if (strcmp($this->_success, 'false') == 0 || strcmp($this->_success, '0') == 0) {
/* /*
* Only cancel the order when it is in state pending, payment review or * Only cancel the order when it is in state new, pending_payment, or payment review
* After order creation alternative payment methods (HPP) has state new and status pending
* while card payments has payment_review state and status
* if the ORDER_CLOSED is failed (means split payment has not be successful) * if the ORDER_CLOSED is failed (means split payment has not be successful)
*/ */
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT || if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_NEW ||
$this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT ||
$this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW ||
$this->_eventCode == Notification::ORDER_CLOSED $this->_eventCode == Notification::ORDER_CLOSED
) { ) {
...@@ -512,13 +515,20 @@ class Cron ...@@ -512,13 +515,20 @@ class Cron
if ($previousAdyenEventCode != "AUTHORISATION : TRUE" || if ($previousAdyenEventCode != "AUTHORISATION : TRUE" ||
$this->_eventCode == Notification::ORDER_CLOSED $this->_eventCode == Notification::ORDER_CLOSED
) { ) {
if ($this->configHelper->getNotificationsCanCancel($this->_order->getStoreId())) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled // Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW && if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW
$this->configHelper->getNotificationsCanCancel($this->_order->getStoreId())
) { ) {
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW); $this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
} }
$this->_holdCancelOrder(false); $this->_holdCancelOrder(false);
} else {
$this->_adyenLogger->addAdyenNotificationCronjob(
'order is not cancelled because "notifications_can_cancel" configuration' .
'is false.'
);
}
} else { } else {
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode); $this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
......
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