#daniqwlkd

1 messages ยท Page 1 of 1 (latest)

viscid scrollBOT
gaunt torrent
humble viper
#

Hey, thanks!

#

Re 1): I have this issue where I receive webhooks for subscriptions, and sometimes I get them out-of-order, ex:

  1. customer.subscription.updated (status:active)
  2. customer.subscription.created (status:incomplete)
gaunt torrent
#

Recommended coding your webhook integration so you don't rely on event order

#

We don't guarantee order of delivery of events

humble viper
#

Of course, afaik it's at-least-once semantics, no linearizability.

#

Would it be a horrible idea to just retrieve the latest subscription object from the API whenever I get a Webhook? ๐Ÿ˜›

gaunt torrent
#

Depends on the event type and how often you're getting them

#

We have api rate limits

humble viper
#

it's for customer.subscription.create / customer.subscription.update / customer.subscription.delete

#

of course this is useless if the subscription api is eventually consistent (could run into the same issue w/ out-of-order events, except i'd get the outdated data from an api, not the event)

gaunt torrent
#

If you retrieve the subscription via our api you should get accurate data back

#

at retrieval

humble viper
#

ah

#

that'd be neat

#

what i'm afraid of with the created timestamp is that it doesn't include nanos, so if the events happen on the same second I'm cooked

gaunt torrent
#

Can you explain your situation a bit more? Why do you need these events in order? Often with subscriptions people get by on just listening to invoice.paid, invoice.payment_failed, and customer.subscription.deleted

humble viper
#

I'm running a simple subscription service, 14 days free trial, pretty basic. I'd like to keep track of subscriptions basically and keep Stripe and my system in sync.

#

Currently, I'm listening for customer.subscription.deleted, customer.subscription.updated, customer.subscription.created to sync the "status" of the subscription (using the object from the event).

gaunt torrent
#

Is there a particular reason you can't get by on the 3 events I mentioned?

#

They have most data people need

humble viper
#

this is literally what i'm doing

#

it works just fine, except when I receive the events out-of-order, so I'll likely opt for retrieving the latest state from the API (as opposed from the event's payload), now that I know it's consistent

#

btw โ€“ first time, surprisingly nice docs for how complicated this could be.

gaunt torrent
#

up to you on what you want to do. I just personally prefer the approach i linked

humble viper
#

cheers, thanks for the help

gaunt torrent
#

no problem

humble viper
#

i'll do pretty much this, except get the sub from the API