#nacho_446
1 messages · Page 1 of 1 (latest)
Hello
Yeah you are going to need logic in your Webhook handler to ingest this data correctly.
You will want to know whether it is the initial Invoice or a renewal Invoice
One way you can determine that is actually by looking at the billing_reason: https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
I have a question does the webhook send the data to each event one by one or at once
I'm not sure what you mean by that exactly. A Webhook contains an Event as the data. A Webhook endpoint will receive a Webhook for every Event of the types that it is listening for.
I listen for the checkout.session.completed and invoice.paid
My problem is if the checkout.session.completed runs first before the invoice.paid
Or should I put the invoice.paid first so when it checks if the payment is not successful if goes to the next event type
We never guarantee ordering of Events (see: https://stripe.com/docs/webhooks#event-ordering)
So you will always want to be resilient.
What you want to determine is which Event you are going to use to ingest the data into your database
Then you write code to filter the other Event so that you don't ingest it when you don't want it