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

Cannot Process Credit Memo - Deprecated functionality: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /vendor/amzn/amazon-pay-magento-2-module/Gateway/Request/SettlementRequestBuilder.php on line 131 #1249

Open amcguireweb opened 1 month ago

amcguireweb commented 1 month ago

What I expected

To process credit memo successfully.

What happened instead

Error: Deprecated functionality: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /vendor/amzn/amazon-pay-magento-2-module/Gateway/Request/SettlementRequestBuilder.php on line 131

Steps to reproduce the issue

Submit order with Amazon Pay as payment method, and then attempt to process a credit memo.

Your setup

Line 131: rtrim($paymentDO->getPayment()->getParentTransactionId(), '-capture'),

For some reason, $paymentDO->getPayment()->getParentTransactionId() = null here.

sgabhart22 commented 1 month ago

Hi @amcguireweb ,

This is a bit of a peculiar issue that we got a similar report of some months back... there should always be separate transactions recorded for authorizations and captures, but it appears that on some installations, a capture can be recorded in the sales_payment_transaction table without a parent auth. I've never been successful in reproducing this. But the auth transaction contains the Amazon Pay charge ID that we need to reference to properly process the refund through Amazon.

At any rate, I've come up with a patch that should identify the charge ID from information we have available in the capture transaction record in the case that there is no parent transaction. Please let us know if you continue to have issues with refunds!

gh-1249.patch.txt

Thanks, Spencer