#jeffnv-subscription

1 messages · Page 1 of 1 (latest)

feral bough
#

Yes, you'd listen for customer.subscription.updated events which should notify you every time the subscription updates

white frost
#

rockin'

#

so down to the second it updates?

feral bough
#

What do you mean by down to the second it updates?

white frost
#

well

#

so i charge my customers "overage" if they use more units than we allow

#

but that resets every period

#

so they use a unit in the first second of a new period

#

i might charge them for overage even though it's a new cycle?

feral bough
#

I see - so your concern here is that your internal system needs to be notified of the change to the current period as quickly as possible so that # of units used can be attributed to the right period

white frost
#

correct

feral bough
#

Yeah so I'm not sure we can fully guarantee the webhook event will be sent right at the second the subscription is updated. A lot of different things can happen both on our end and yours that could cause delays so you may need to take a slightly different approach. Just shooting out some ideas - when you have units being used very close to when the subscription is about to cycle you can pull/retrieve the Subscription to confirm whether the period has been changed. Alternatively, you could check the timestamp of current_period_end of your subscription and compare it to the current timestamp when a new unit is used - if the current timestamp is AFTER the current_period_end then you know the period of the Subscription isn't accurate and you need to wait for the webhook event or re-retrieve the Subscription to confirm

white frost
#

ah good call

#

thanks for the brainstorm!