Description
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
- Setup Amazon pay configuration at website specific.
- Authorization Mode should be set to 'Immediate' in the admin configuration for Amazon Pay payment
- Added a product to the cart
- Go to the cart page, and click on the Amazon Pay button to proceed to checkout.
- Use a credit card in Amazon Pay where the payment is declined.
- Place the order but do not click on the 'Cancel and return to merchant' link and close the window.
- Run the
amazon_pay_cleanup_sessions
cron job using n98 command and it will throw error
Your setup
- Magento version: 2.4.6-p7
- Amazon Pay Extension Version: 5.17.1
- Magento Edition: Enterprise Cloud
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);