From 0009da02619e794537d88fa9494e35594ed1bb0c Mon Sep 17 00:00:00 2001 From: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:10:31 +0100 Subject: [PATCH] fix(medusa-payment-stripe): Resend capture event to ensure auto-capture (#3100) --- .changeset/selfish-pianos-wonder.md | 5 +++++ .../medusa-payment-stripe/src/api/routes/hooks/stripe.js | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/selfish-pianos-wonder.md diff --git a/.changeset/selfish-pianos-wonder.md b/.changeset/selfish-pianos-wonder.md new file mode 100644 index 000000000000..af5e3ef9ac7c --- /dev/null +++ b/.changeset/selfish-pianos-wonder.md @@ -0,0 +1,5 @@ +--- +"medusa-payment-stripe": patch +--- + +fix(medusa-payment-stripe): Resend capture event to ensure auto-capture diff --git a/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js b/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js index 7fedd778460c..5ef9a075ec9e 100644 --- a/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js +++ b/packages/medusa-payment-stripe/src/api/routes/hooks/stripe.js @@ -31,6 +31,9 @@ export default async (req, res) => { await manager.transaction(async (manager) => { await orderService.withTransaction(manager).capturePayment(order.id) }) + } else { + // If we receive the event, before the order is created, we respond with 404 as this will trigger Stripe to resend the event later + return res.sendStatus(404) } break case "payment_intent.amount_capturable_updated":