-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ECP-9281] Cannot create second capture invoice until webhook responds to first capture invoice #2666
Comments
Hello @pignion, Thank you for reporting this issue and providing detailed steps to reproduce. We've investigated the problem and considered various potential solutions. After careful consideration, we've decided to maintain the current implementation of setting the order state to payment_review. This approach, while causing some limitations, is crucial for preventing order fulfillment before successful captures are confirmed. This is especially important as capture requests might fail, and our plugin can only be notified of the outcome via webhooks. We are open for more suggestions. Please let us know if you have any other proposed solution to the issue. Regards! |
Describe the bug
Cannot create second capture invoice until webhook responds to first capture invoice.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A second invoice is created, a second capture request is sent to Adyen
Actual behavior
The following validation error message:
This means an automated invoicing system (such as ours) that calls Magento's Web APIs for invoicing would not be able to know whether it is safe to call the Web API, because it would not know whether the order is still waiting for a CAPTURE webhook. Sending multiple invoices in close time proximity for a single order is not uncommon, and a trial and error approach to this is not feasible in our environment, which processes incoming Magento Web API calls asynchronously.
Magento version
2.4.5-p5
Plugin version
9.4.1
Additional context
When an invoice that is set to capture is submitted (via webservice or admin), Adyen’s module sets the state of the order to
payment_pending
until Adyen calls a CAPTURE webhoook.vendor/adyen/module-payment/Gateway/Response/PaymentCaptureDetailsHandler.php:66
Once the CAPTURE webhoook is called, if the order hasn’t been completely invoiced, the status is set back to its pre-invoice state (this isn't particularly desired behavior either).
vendor/adyen/module-payment/Helper/Order.php:310
Submitting another invoice before receiving the CAPTURE webhook for the previous invoice prevents Magento from being able to create the invoice because
payment_pending
is not a state where magento allows invoices to be created:vendor/magento/module-sales/Model/Order/Validation/CanInvoice.php:42
The text was updated successfully, but these errors were encountered: