amzn / amazon-payments-magento-2-plugin

Extension to enable Amazon Pay on Magento 2
https://amzn.github.io/amazon-payments-magento-2-plugin/
Apache License 2.0
109 stars 77 forks source link

amazonCheckoutSessionId is missing #1161

Closed alex-kaigorodov closed 1 year ago

alex-kaigorodov commented 1 year ago

What I expected

amazonCheckoutSessionId get parameter is returned with amazon_pay/checkout/completeSession request after a successful transaction.

What happened instead

If we initiate an Amazon Pay process with a button from a cart page, then on the last step a customer is redirected to amazon_pay/checkout/completeSession without amazonCheckoutSessionId parameter. That leads to a situation when an order is not placed due to an error (CheckoutSessionManagement lines 657-663), but a transaction in Amazon Pay is created and an amount is authorized. Important to note, that if we select Amazon Pay as a payment method on a payment step of a checkout then customer returns with a amazonCheckoutSessionId as expected.

Setup

My question is: In which cases a customer can be redirected to the amazon_pay/checkout/completeSession after a transaction that looks like a successful one? I haven't found any information about such a case on the web and the official Amazon Pay documentation also states that a customer should return to the checkoutResultReturnUrl with a session id parameter. Is this a normal situation or an edge case not covered by the extension?

lbale commented 1 year ago

Hello Alex,

The amazonSessionId parameter is mandatory and is needed to be able to finish the transaction correctly, so it is not possible to continue the execution without having that information. Those lines of code are there to ensure that the execution of the method does not throw unexpected errors in the event that for some reason all the corresponding data is not received. There should be no valid case where that instance is reached without the corresponding session id parameter. If for some reason you have experienced cases where a scenario like this occurs, please provide us with information on how we could reproduce the error. Thanks

alex-kaigorodov commented 1 year ago

Thanks for the information.