fix(payments-plugin, Mollie): Ignore completed state to prevent unneccesary error throwing #2569
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a customer pays with Klarna/pay-later, and autocapture is enabled in the Mollie plugin, an error is thrown:
Failed to process incoming webhook: "Unhandled incoming Mollie status 'completed' for order XXXXXXX with status 'AddingItems'"
However, this should not be an error, because autocapture makes sure the order is transitioned to PaymentSettled.
This is what happens when a customer pays with Klarna and
autocapture=true
in the Mollie plugin:authorized
comes in from Mollie: The order is transitioned toPaymentAuthorized
PaymentSettled
completed
, because we settled the payment in Mollie. But, I suspect the previous transaction (the transition to PaymentSettled) isn't committed yet, because the logs will say"Unhandled incoming Mollie status 'completed' for order XXXXXXX with status 'AddingItems'"
.TL;DR: The
completed
webhook comes in before Vendure has transitioned the order toPaymentSettled
, resulting in the incorrect error while the order is settled as it should.Screenshots
Here you can see there is only ~180ms between settlement (
Settled payment for XXX
) and the incoming webhook (Processing status completed for xx
)Checklist
📌 Always:
⚡ Most of the time: