Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

Payment refused order coming with no status #2452

Open sushantjw opened 9 months ago

sushantjw commented 9 months ago

Describe the bug When the payment is refused for the order the order does not get any cancellation request and stays with null status.

To Reproduce

  1. Place an order and checkout with an unsupported card.

Expected behavior Get a cancellation request if the order is not further proceeded.

Magento version 2.4.6-p3

Plugin version 8.18.1

Screenshots image

**Desktop

Additional context Adyen Log: ERROR: Unhandled order state '' {"orderId":"361373","orderIncrementId":"1001423590","orderState":null,"orderStatus":null,"pspReference":"L36XBG7HCXTZ9V72"} {"uid":"79d7d9f"}

hossam-adyen commented 9 months ago

Hi @sushantjw, thanks for opening this issue, with the given steps I wasn't able to reproduce this issue and we don't expect an order with null status when we process notifications

https://github.com/Adyen/adyen-magento2/blob/eaa06ecb89ecfb4561e465fb97f3f02e5ee957a6/Helper/Webhook.php#L169-L177

sushantjw commented 9 months ago

Hey @hossam-adyen, thank you for the reply. We have list of orders which don't have any state and status all created through failed payment. The Adyen event log all show that these orders have failed authorization due to unsupported card or failed 3DS. From my understanding, these orders should get cancellation event which doesn't seems to be there in Adyen event log.

hossam-adyen commented 9 months ago

Dear @sushantjw,

Upon processing, those orders failed to be canceled due to the lack of a current state. This is unexpected, as orders should always have a state at this stage. Could you please investigate the logs from both Magento and Adyen to determine why these orders were created without a state?

sushantjw commented 9 months ago
 if ($action) {
            if ($methodInstance->isInitializeNeeded()) {
                $stateObject = new \Magento\Framework\DataObject();
                // For method initialization we have to use original config value for payment action
                $methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
                $orderState = $stateObject->getData('state') ?: $orderState;
                $orderStatus = $stateObject->getData('status') ?: $orderStatus;
                $isCustomerNotified = $stateObject->hasData('is_notified')
                    ? $stateObject->getData('is_notified')
                    : $isCustomerNotified;
            } else {
                $orderState = Order::STATE_PROCESSING;
                $this->processAction($action, $order);
                $orderState = $order->getState() ? $order->getState() : $orderState;
                $orderStatus = $order->getStatus() ? $order->getStatus() : $orderStatus;
            }
        } 
...
...
...
...
$this->updateOrder($order, $orderState, $orderStatus, $isCustomerNotified);

This is the place() method in Magento (https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Sales/Model/Order/Payment.php)

When I use invalid card the function executes the else block and calls $this->processAction($action, $order); method. The order state and status are never commited at this step and the execution throws an exception so it doesn't hit the update order code and never saves the order state and status.

The JCB card that I am currently testing with always comes with empty state and status. Note: JCB is not accepted card in our merchant account.

hossam-adyen commented 8 months ago

Hi @sushantjw, thanks for the insights, to take this further, can you share the exception that you are mentioning with the stack trace for this case?

pvkooten commented 7 months ago

can also confirm this issue on Adobe Commerce ver. 2.4.6-p3 Adyen version 9.3.

we also do have this issue for a long time, we tried to figure out with support and sent a lot of logs. maybe you can get something out case: 03141095

also what @sushantjw says is similar to our situation, The JCB card that I am currently testing with always comes with empty state and status. Note: JCB is not accepted card in our merchant account.

pvkooten commented 6 months ago

@hossam-adyen do you perhaps have any update?

wilfriedwolf commented 6 months ago

Same here. Adobe Commerce Version: 2.4.5-p5 Adyen Version: 9.4.1

Not opened a case with the adyen support yet, since there seems to be some ongoing, but @hossam-adyen feel free to ask questions if this can help.

pvkooten commented 2 weeks ago

Also confirmed 2.4.6-p6 Adyen Version 9.8.1