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

Issue: CleanUpIncompleteSessions cron fails. #1247

Open mohit-sharma-rp opened 6 days ago

mohit-sharma-rp commented 6 days ago

What I expected

CleanUpIncompleteSessions cron should be run without any error.

What happened instead

When the CleanUpIncompleteSessions cron job runs, it throws the following error: Error in log: ERROR strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/amzn/amazon-pay-api-sdk-php/Amazon/Pay/API/Client.php on line 43

Steps to reproduce the issue

Your setup

More details about the issue:

The error occurs when the cron job runs to clean up incomplete transactions at this line: https://github.com/amzn/amazon-payments-magento-2-plugin/blob/5.17.1/Cron/CleanUpIncompleteSessions.php#L122 A null value is passed to the getCheckoutSession method, causing the error and preventing the cron job from completing.

Solution:

After passing the transaction store the cron job completed without any errors, and the order status was updated to "Cancelled". $amazonSession = $this->amazonPayAdapter->getCheckoutSession($transactionData['store_id'], $checkoutSessionId);

sgabhart22 commented 6 days ago

Hi @mohit-sharma-rp ,

Interesting find, I'm a little surprised this hasn't come up yet... certainly looks like that call couldn't succeed without supplying the store code. You're more than welcome to open a PR for this issue if you'd like; we wouldn't merge it directly but could cherry pick your code into our next release branch if everything looks good. Thanks again for the report!

Cheers, Spencer

mohit-sharma-rp commented 4 days ago

Hi @sgabhart22 PR is opened for this issue https://github.com/amzn/amazon-payments-magento-2-plugin/pull/1248