#blkprnt
1 messages · Page 1 of 1 (latest)
customer.subscription.updated should notify you of the change in the Price record related to the Subscription.
will stripe automatically handle doing the prorating?
That depends on how you have configured the Customer Portal
i imagine the new subscription type will also be reflected in the event payload?
I'm not sure what you mean "new subscription type". The event data payload will include the Subscription object reflecting the Customer's changes: https://stripe.com/docs/api/events/types#event_types-customer.subscription.updated
But the Event object itself will also include what the previous attributes were as well
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
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
would that be in the subscription object? https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-price
Yes
Specifically in the items.data.price property: https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-price
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?
If that's the only Price object that is included in the Subscription then yes
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?
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.
do you store the event the same way you receive it or just the fields you think you'll need?
I store the data.object record. So a Subscription object if that is what the event relates to
i see so you don't store the metadata on the event itself?
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
makes sense. i don't see an immediate need for saving the event, but also don't want to regret not saving it
You can review past events up to 30 days: https://stripe.com/docs/api/events/list
got you. i think i'll just save the data.object. thank you for your help. this was very helpful
Happy to help 🙂 it's why we're here