Reputation: 1398
I've been checking the Stripe documentation, and it suggests that we respond as soon as possible with a 200 code "It must be before we process it in our database".
Link: https://stripe.com/docs/webhooks#acknowledge-events-immediately.
I have some doubts:
Is it strictly required to always send Stripe response code 200?
In which cases is it necessary to send Stripe another response code? Like these: https://stripe.com/docs/api/errors
What would happen if after sending the 200 code to Stripe, the system for some reason fails to process an event in my database, update an invoice, subscription etc ... I can respond to Stripe with a 402 response so that it will forward me that same event, would it be a good practice?
How can I ask Stripe to send the same event again?
After sending Stripe a 200 response code, can Stripe retry sending the same event?
Upvotes: 2
Views: 1707
Reputation: 39827
Your questions, especially the last 3, are all centered around the issue of a failure on your end after Stripe notifies you of an event.
**(The more below section)
From Stripe's perspective, the event has occurred, and it was successful. The webhook is a notification to your system on what happened and most likely has a short timeout for awaiting a response (which is why they ask for the quick 200 response). Stripe will not renotify you of the same event multiple times as they have done so once, multiple times would be redundant from Stripe's perspective.
Given this, you should think of your own application's structure a bit differently.
Upvotes: 3