#blkprnt

1 messages · Page 1 of 1 (latest)

azure canyonBOT
cerulean anchor
#

customer.subscription.updated should notify you of the change in the Price record related to the Subscription.

boreal kettle
#

will stripe automatically handle doing the prorating?

cerulean anchor
#

That depends on how you have configured the Customer Portal

boreal kettle
#

i imagine the new subscription type will also be reflected in the event payload?

cerulean anchor
#

But the Event object itself will also include what the previous attributes were as well

boreal kettle
#

for example, going from Monthly Subscription -> Yearly Access. When i get the customer.subscription.updated event, will the subscription object show that the new subscription is Yearly Access?

#

i'm looking at the documentation for the the Subscription object, and i'm not sure which attribute reflects if the subscription would be Monthly Subscription or Yearly Access

cerulean anchor
#

That would be defined by the change in the Price ID from one with a monthly billing period to one with an annual billing period. You would likely want to retrieve the Price object (maybe expand the Product as well) to verify this. https://stripe.com/docs/api/prices/object

boreal kettle
cerulean anchor
#

Yes

boreal kettle
#

i see its a list. in my use case a user can only purchase one type of subscription at a time. in this case the size of the list should always be 1 correct?

cerulean anchor
#

If that's the only Price object that is included in the Subscription then yes

boreal kettle
#

okay cool thank you

#

also i was wondering, when i get these webhook events, is there any reason i should be saving the event subscription or invoice objects in my own db? i can't think of any reasons why i may need them. What does stripe usually recommend here?

cerulean anchor
#

That is very dependent on how you are operating your business. In my test integration I use the webhook events to keep my local records in sync with Stripe. That way I don't need to make Stripe API calls to get the current state of my records.

boreal kettle
#

do you store the event the same way you receive it or just the fields you think you'll need?

cerulean anchor
#

I store the data.object record. So a Subscription object if that is what the event relates to

boreal kettle
#

i see so you don't store the metadata on the event itself?

cerulean anchor
#

To be clear, I built a test integration to be familiar with how Stripe works (as part of my work at the company). The specifics are just for my own education

boreal kettle
#

makes sense. i don't see an immediate need for saving the event, but also don't want to regret not saving it

cerulean anchor
boreal kettle
#

got you. i think i'll just save the data.object. thank you for your help. this was very helpful

cerulean anchor
#

Happy to help 🙂 it's why we're here