#Tanuki-webhook
1 messages · Page 1 of 1 (latest)
@tired trail no there is not, we document that they explicitly can not be in order https://stripe.com/docs/webhooks/best-practices#event-ordering
hm.... the checkout.session.completed can be sent after customer.subscription.updatedd ?
it could be yes
i mean the minimum i need is the customer id that is generated from the checkout session (from the first purchase only), if i receive another event before... ><
you can get the customer ID from all of those events though
Yes but the checkout has a metadata that allow me to bind customerid to my app's user
so in general the way to approach this is to retrieve the relevant object(let's say the subscription object in this case) and sync your system against that, making API requests if needed to pull extra information
Or maybe i'm doing it wrong
make sense to me!
but yeah the order can't be guranteed so you'll need to workaround this somehow
my question would be, do you need any event other than checkout.session.completed ? I don' think you do
since when handling that event, you can just retrieve session.subscription from the API and you get all the same context the other events would have
i need at least to listen to customer.subscription.updated as i use renewable subscriptions and i follow the subscription workflow by listening to customer.subscription.created / customer.subscription.deleted too
then I'd just ignore customer.subscription.updated if it relates to the start of a subscription
since your handler for checkout.session.completed can take the load instead
you can do that by checking subscription.latest_invocie.billing_reason (https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason) or maybe just comparing the created time of the event to the created time of the subscription object to see if they're really close
ok i'm thinking about all that
maybe create the customer myself before the first checkout can save me time / queries too ?
you could do that as well potentially yep! not a bad idea