-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(medusa-payment-stripe): Add delay to Stripe webhook #5838
Conversation
🦋 Changeset detectedLatest commit: 7d99018 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Ignored Deployments
|
8e06a32
to
3f99ed5
Compare
3f99ed5
to
910c831
Compare
/snapshot-this |
🚀 A snapshot release has been made for this PRTest the snapshots by updating your yarn add @medusajs/admin@7.1.9-snapshot-20231212154115 yarn add @medusajs/admin-ui@2.1.10-snapshot-20231212154115 yarn add @medusajs/core-flows@0.0.3-snapshot-20231212154115 yarn add @medusajs/ui@2.2.4-snapshot-20231212154115 yarn add @medusajs/link-modules@0.2.5-snapshot-20231212154115 yarn add @medusajs/medusa@1.19.0-snapshot-20231212154115 yarn add @medusajs/medusa-cli@1.3.22-snapshot-20231212154115 yarn add medusa-payment-klarna@1.4.0-snapshot-20231212154115 yarn add medusa-payment-stripe@6.0.7-snapshot-20231212154115 yarn add medusa-react@9.0.12-snapshot-20231212154115 yarn add @medusajs/modules-sdk@1.12.5-snapshot-20231212154115 yarn add @medusajs/orchestration@0.5.1-snapshot-20231212154115 yarn add @medusajs/pricing@0.1.6-snapshot-20231212154115 yarn add @medusajs/product@0.3.6-snapshot-20231212154115 yarn add @medusajs/types@1.11.9-snapshot-20231212154115 yarn add @medusajs/utils@1.11.2-snapshot-20231212154115
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very clean, we need to test it :)
…a into feat/stripe-webhook-delay
@adrien2p, have tested this locally on my machine :) |
Splendide, you ve used the stripe cli? |
Used their console + ngrok |
Ok works too, eaiser with the cli 😅 |
I see, felt like it was pretty easy with the console. I'll have to try the CLI next time |
Should we move forward with this one? |
Yes, let me get it up to speed so we can merge :) |
@carlos-r-l-rodrigues, would you like to give this a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hey there, a question: would it be possible/beneficial to update medusa-payment-paypal plugin in the same way? I think it might fix some issues I'm meeting on it, but I am not sure about it. Thanks |
@piereligio, I'll look into how much effort it would require. PayPal can be cumbersome to work with directly through their SDKs. Are you aware, that you can use PayPal via Stripe (which is also supported by this plugin)? |
Oh, I had no idea, thanks for the info! But how can I add more payment methods in stripe? I enabled automatic_payment_methods from medusa-config.js, but nothing changed. Basically in the storefront I only see the credit card option, with the fields for it. For now I enabled Google Pay and Apple Pay (PayPal is pending). Do I need to write my own custom code for storefront? |
What
Instead of processing webhook events immediately, we fire an event to perform the work in the background. The primary reason for changing the webhook is that the previous implementation led to occasional conflicts due to a race condition between the client's and the webhook's request to complete a cart. Now, we emit an event with a configurable delay (defaults to 2s) to prevent this from happening
This approach was preferred over adding a timeout directly to the webhook execution, as it is generally best practice to respond to a webhook event immediately after receiving it.