#alko89

1 messages · Page 1 of 1 (latest)

restive wrenBOT
mortal swan
#

Hi! We don't have a single article about this.
What's your use case?

gaunt wren
#

I thought so 😄

Essentially we have a subscription mapping in our DB which maps the subscription items to Stripe subscription (where we can then send usages)

Now I want to improve the logic to allow scheduling subscriptions

For creating a subscription is easy, just create a mapping when we receive a subscription create webhook

Updating is a bit more tricky since I can't be sure what triggered the subscription update webhook and we rely on update webhook for other things as well

Ideally there might be a flag in subscription update that tells me if the webhook was triggered by subscription schedule that I missed?

mortal swan
#

Why can't you update the mapping on every Subscription update?

#

You can also see what was updated in the data.previous_attributes property of the webhook event and make a decision based on this. If it's just current_period_end it means that a new period has started.

gaunt wren
#

probably could, but sounds a bit wasteful, I'll check the previous_attributes option, thanks!

gaunt wren
#

quick question, is previous_attributes the same type as data?

#

so Stripe.Subscription if the data is subscription

plush hill
#

Yes, the fields will map to the Subscription object

gaunt wren
#

perfect! Thanks