Adyen / adyen-magento2

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

[ECP-9481] Orders cannot be canceled in v9 #2748

Closed JonasFolletete closed 3 weeks ago

JonasFolletete commented 2 months ago

Describe the bug Prior to version 9, there was a way to cancel pending orders by using the payment-details route : https://github.com/Adyen/adyen-magento2/commit/35ebd16b2e6ab0d6890b53bcacab8f0f85297ea7#diff-12bbc66d935c4130a664605599d72213df5a15629e4831bab735b1b6f2b4a295L99-L111

The cancelledparameter is still used in the javascription plugin, but doesn't seem to work anymore : https://github.com/Adyen/adyen-magento2/blob/4d4406a8b786f166fb0c60683a42336231b55308/view/frontend/web/js/view/payment/method-renderer/adyen-pm-method.js#L142

Is there a new route to do the same thing ?

Thank you very much.

To Reproduce

When I call the route payment-details : adyen/guest-carts/${cart-token}/payments-details with the payload : { payload: "{"cancelled":true}", orderId: ${orderId} }

The plugin gives me the following error : Internal Error. Details are available in Magento log file. Warning: Undefined array key "details" in /app/do357cqtkw3dk_stg/vendor/adyen/module-payment/Helper/PaymentsDetails.php on line 114

Expected behavior

The order should be cancelled.

Magento version 2.4.5

Plugin version 9.8.0

khushboo-singhvi commented 1 month ago

Hello @JonasFolletete,

Thank you for bringing this to our attention.

We have created an internal ticket to cleanup the code wherein with V9, we only depend on the result of the PaymentDetails call, if the response has error, then we cancel the order, otherwise for all other scenarios we wait for OFFER_CLOSE notification. And we deprecated cancelling pending orders as we did on V8. I think we need some code cleanup on the frontend for V9.

Regards! Khushboo

JonasFolletete commented 1 month ago

Hello @khushboo-singhvi ,

Thank you for your answer, I think it is still important to be able to manually cancel an order.

Otherwise every time a user tries a new payment method (without finalizing the payment), this will create a new order and lock the stock until the offer closes.

For example : • The customer tries to buy a product with only one item in stock • He initiates the payment with PayPal • We create a pending order • Finally, he decides to pay with Klarna • We won't be able to create an order because the stock is already committed to the one created with PayPal

Do you have any solution for that ? We need to be able to cancel the first order. Thank you very much !

khushboo-singhvi commented 1 month ago

Hello @JonasFolletete,

Thank you for pointing a vey specific case. We are bainstorming internally and will soon come out with the solution where can cancel the order and move ahead.

Regards! Khushboo