Closed ethan-stone closed 1 year ago
interesting, this seems solid to me. One other point stripe mentions is that you can use the "API to fetch any missing objects". Even though just listening for customer.subscription.updated
seems like a good way to do it, in the future could likely also integrate checks on missing objects?
Need to adjust stripe webhooks to handle events better. Especially the fact that the order of events is not guaranteed. Did not know this prior.
https://stripe.com/docs/webhooks/best-practices
I think the only place where this is a problem is when the checkout session completes. A subscription is created with the status
incomplete
, and then stripe attempts to charge the customer, and then immediately the subscription status is updated based on the result of the charge. Since these events are so close I think we should just ignore thecustomer.subscription.created
event entirely and just listen forcustomer.subscription.updated
and we both create and update the subscription in that one event.I'll implement this tomorrow as described. @Lucas-Kohorst if you have a chance can you look into this and see if my thought process is sound. The webhook is in
web/src/pages/api/stripe/webhook/index.ts