Closed bmitchell-ldg closed 1 year ago
Hi @bmitchell-ldg
Thank you for reporting this issue.
We noticed that even "cannot create invoice" error message is displayed, the invoice is successfully created. Here is an example:
We will continue investigating the issue to avoid the appearance of this error message during payment capture process.
Thank you. Regards,
Was able to reproduce as well.
The steps to reproduce are accurate, and the issue definitely centers aroundPayment : Charge when order is placed.
As noted, the order appears to be in good health with exception to the extra order comment from \Amazon\Pay\Model\AsyncManagement\Charge::capture
The second order comment (not throwing err) comes from \Amazon\Pay\Model\CheckoutSessionManagement::addCaptureComment
This needs further review.
Hello @bmitchell-ldg ,
Thanks again for the call out here, definitely an annoying bit of noise on order history comments if nothing else. I've done some testing with Auth & Capture ('Charge when the order is placed') and both Authorization Modes, and I believe a reasonable solution is to also check the auth mode before calling the asyncCharge function. It seems like everything behaves as expected if the auth mode is Immediate, but we only see this errant comment in Automatic mode.
The attached patch should address this reasonably, since in Automatic mode, the capture will be initiated asynchronously later if it can't be done right away anyway. Please let us know if you're able to try it out or have any different solutions!
Thanks again, Spencer
Thank you Spencer, i will apply that patch now and let you know if it resolves the issues. Thanks, Bev
Hello @sgabhart22 , The patch has been applied and resolved the issue. Thanks, Bev
Great news @bmitchell-ldg ! I appreciate the patience and feedback here, we'll go ahead and close this issue for now but keep our internal ticket open for tracking. This fix (or something very similar) will likely be included in an upcoming release.
Thanks again, Spencer
What I expected
No errors when placing orders
What happened instead
The order is invoiced, moves to processing and is captured as expected but the following error is thrown "Cannot create invoice for Order"![Screenshot 2023-07-04 at 10 09 07](https://github.com/amzn/amazon-payments-magento-2-plugin/assets/3041320/32c252a3-758a-4f8e-a221-168fba206d12)
Steps to reproduce the issue
Place an order with the below config set and the error is thrown for every order
Your setup
Findings so far: in Charge.php the loadInvoice function doesn't return any invoices.
![Screenshot 2023-07-04 at 10 07 31](https://github.com/amzn/amazon-payments-magento-2-plugin/assets/3041320/b3f179b6-928d-4c7a-a251-49685e379f66)
The invoice exists in M2, but it doesn't have the TRANSACTION_ID associated to it at this point.
CheckoutSessionManagement.php line 768 is where the capture is made
![2](https://github.com/amzn/amazon-payments-magento-2-plugin/assets/3041320/efc0c529-6dd6-43e8-9378-0d10091fd452)
In that capture loadInvoice is used and loadInvoice is the function filtering on TRANSACTION_ID![3](https://github.com/amzn/amazon-payments-magento-2-plugin/assets/3041320/ea181c1b-d353-42e2-a5e5-087e41d8c99a)
But if you go back to CheckoutSessionManagement.php the TRANSACTION_ID isn’t populated with the $chargeId until further down line 810
Seems like the transaction_id is being populated too late.
To make sure it wasn't a conflict caused by a custom module or 3rd party module we also disabled everything back to core Magento using the Luma theme and the error was still thrown.