Skip to content
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

fix(payments-plugin, Mollie): Ignore completed state to prevent unneccesary error throwing #2569

Merged

Conversation

martijnvdbrug
Copy link
Collaborator

@martijnvdbrug martijnvdbrug commented Dec 7, 2023

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:

  1. Customer pays with Klarna
  2. Webhook authorized comes in from Mollie: The order is transitioned to PaymentAuthorized
  3. Autocapture is triggered: The payment is settled, then the existing payment for the order is settled, transitioning the order to PaymentSettled
  4. Within 200ms, we receive a webhook from Mollie with status 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 to PaymentSettled, resulting in the incorrect error while the order is settled as it should.

Screenshots

image
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:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

⚡ Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for effervescent-donut-4977b2 canceled.

Name Link
🔨 Latest commit 48e863e
🔍 Latest deploy log https://app.netlify.com/sites/effervescent-donut-4977b2/deploys/65717faa3c59000008a230c5

@martijnvdbrug
Copy link
Collaborator Author

CI test throws an Error: listen EADDRINUSE: address already in use :::3011. Local tests run just fine:
image

@michaelbromley michaelbromley merged commit ed80c68 into vendure-ecommerce:master Dec 11, 2023
17 of 18 checks passed
@michaelbromley
Copy link
Member

Thanks for the detailed explanation & fix Martijn! 👍

@martijnvdbrug martijnvdbrug deleted the fix/mollie-logging branch December 12, 2023 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants