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
105 stars 76 forks source link

Order "Processing" without payment #1236

Open darektw opened 2 months ago

darektw commented 2 months ago

What I expected

I expect orders with a processing status that have invoices created after payment.

What happened instead

There are orders that have a processing status, no invoice, even though the payment has been cancelled.

What actual results you or customer got

Dispatched orders that have not been paid for.

Reproduction path

Unfortunately, I do not yet know the exact steps to repeat this error. It only occurs with some orders.

In the previous version 5.16.1 everything worked correctly.

We observe the following errors in the logs:

var/log/paywithamazon.log-[2024-04-25T22:04:45.899437+00:00] amazonClientLogger.ERROR: 
Exception: Warning: Undefined variable $order in 
/var/www/magento/releases/20240424T160438/vendor/amzn/amazon-pay-magento-2-module/Model/CheckoutSessionManagement.php on line 781 
in /var/www/magento/releases/20240424T160438/vendor/magento/framework/App/ErrorHandler.php:62

Your setup

dimitriBouteille commented 2 months ago

Hi @darektw

I also have the problem. I have just proposed an MR, hoping that it is quickly validated :rocket:

markfischmann commented 2 months ago

Hello @darektw and @dimitriBouteille, I was wondering if you both also had the issue where these specific orders can't be canceled ?

I have the exact same issue that you describe where an order is placed, no invoice is created but the order is in the "processing" state. The order status message is something like "Authorization of X Euros, Transaction ID YYY". The thing is, the Transaction ID can't be found in Amazon Seller Central, and when trying to cancel the Order, I have the following error :

[2024-05-02T15:02:09.025721+00:00] amazonClientLogger.DEBUG: closeChargePermission <-  ["1","<some_id_here>","MerchantClosed",true] []
[2024-05-02T15:02:09.026458+00:00] amazonClientLogger.ERROR: closeChargePermission ->  {"reasonCode":"ResourceNotFound","message":"Resource you are trying to access is not available. Requested path '/live/v2/chargePermissions/<some_id_here>/close'","status":404} []

Is it in any way related to your issue ?

I have tried changing the Authorization Mode to "Automatic". It seems to fix the issues of Orders without payment being in the "Processing" state. Can't really confirm anything yet.

jonesio commented 2 months ago

@markfischmann We are also seeing this issue which is a major problem since "processing" should indicate that an order payment is correctly received and can be dispatched.

Debugging so far has revealed that the updateCheckoutSession REST API endpoint and subsequent placeOrder controller endpoint is hit (hence the order being placed) but the subsequent completeSession controller is not in instances where the payment does not actually complete. This leads to no "errors" being shown in the logs but the Amazon Pay session close/payment capture does not actually complete as intended.

We have seen instances whereby orders are marked as processing even if the Auth has subsequently been declined etc.

Order status should be Pending Payment (or similar) until the Auth and subsequent Capture have been 100% confirmed.

Ref: https://github.com/amzn/amazon-payments-magento-2-plugin/issues/1186 - As mentioned in a recent comment. We too had no issues when using 5.16.1 This appears to be a new issue introduced in 5.17.0

markfischmann commented 2 months ago

It seems that with the new 5.17.0 update, orders are being placed when there is a potential error with the payment transaction. If you change the "Authorization Mode" to "Automatic", you will have an order placed with the "Payment Review" status, and a pending invoice that you can either cancel or capture manually.

dallin-beargroup commented 2 months ago

@darektw @dimitriBouteille @markfischmann Thank you all for your investigation, and the feedback. We are working to get this fixed. Please let us know if you've come across any other helpful details.

dimitriBouteille commented 2 months ago

Hi @dallin-beargroup To avoid this kind of problem in the future, it might be good to use code quality tools (phpstan, PHPMD Mess Detector, ...) ❤️

dallin-beargroup commented 2 months ago

We are working to roll out the next minor version addressing these issues. In the meantime you can use this patch to stop orders moving into a processing state before authorization. github-issue-1236_initial_order_state.txt source

@dimitriBouteille Thank you for your suggested fix. I was unable to recreate the symptoms with undefined variables, but I did test it alone, and along side the above patch, and everything appeared to function normally. We will keep it under review and likely will roll it into the next minor release.

faisal2010 commented 1 month ago

Hi @dallin-beargroup , do you have an ETA for next release with this issue fixed, as we disabled the extension for now. As we have high order volume, causing issues to ship orders without payments.

Thank you

sgabhart22 commented 1 month ago

Hello @faisal2010 ,

We're trying to wrap up testing for the 5.17.1 release, which will include these fixes plus a few other minor patches. Hopefully this could go live next week.

Thanks, Spencer

sgabhart22 commented 4 weeks ago

Hi everyone,

I'm happy to finally announce that version 5.17.1 is live on the Marketplace! We'll close this issue shortly, but of course, please don't hesitate to reach out with future problems. We appreciate all your contributions!

Thanks, Spencer

kestraly commented 3 weeks ago

Experiencing this issue after updating to 5.17.1. Starting the debug

kestraly commented 3 weeks ago

My issue is the plugin now uses type MIXED and is no longer PHP7.4 compatible

sgabhart22 commented 1 week ago

Hi @kestraly , you've probably addressed this on your own at this point, but for anyone else who may come across this, I'll drop a patch here for PHP 7.4 compatibility despite it having been EOL for quite some time now. We can remove the mixed references in the function signatures in the next patch version.

php74-compat.patch.txt

Thanks, Spencer