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"
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.
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
In that capture loadInvoice is used and loadInvoice is the function filtering on TRANSACTION_ID
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.