#chrisp-subscription-webhook
1 messages ยท Page 1 of 1 (latest)
Hi ๐ when the trial ends, the Subscription will change state and update some its fields, so a customer.subscription.updated event will be triggered.
You can then check the data.previous_attributes hash on the event to see if it shows that the Subscriptions previous status was trialing.
https://stripe.com/docs/api/events/types#event_types-customer.subscription.updated
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hi Toby. So that's when there is an update on the status right? Is the event customer.subscription.updated get triggered without the status change. Like the next time it gets updated but it not the status that's get updated, will the data.previous_attributes still show the status trialing? Sorry I'm having a hard time formulating my questions but can you follow what I'm getting at?
๐ stepping in as toby needs to step away.
Catching up
I don't fully understand your question but customer.subscription.updated will fire whenever anything on the Subscription object changes
Not just status
Okay understood. So for my question will just add an example. So first the status is trialing right, then trial ends so the event gets fired. so data.previous_attributes status is trialing right? Then later the subscription gets updated on some other property then event gets fired the second time. will the value of data.previous_attributes status still be the value of the previous status which is trialling? or will it be the active? But I think I know the answer already as I was typing but just want to hear it from you. Don't want to assume
No the previous_attributes will not contain any property that wasn't updated.
So if the property isn't within previous_attributes then you know it has stayed the same
ohh okay, I was thinking that the previous_attributes would contain all previous values. so only the updated properties. Okay noted.
Thank you for that information.
Sure thing!
Sorry I have a follow up question still.
so let's say my scenario is that the previous plan has a trial. then then trial period ends then the user changes a plan. how would that look like? will the previous_attribute status be still trialling? Sorry for this question, It's my first time implementing stripe.
Sorry, server got a bit busy
Honestly the best thing to do is to test this stuff out!
You can use our test clocks feature to see exactly how everything will behave: https://stripe.com/docs/billing/testing/test-clocks
That said... in your scenario it will depend no the billing cycle of the new price
But no, the previous_attribute won't still be trialing if the trial is over
It would either be active or past_due at that point for status
ahh okay understood. Yes will definitely test this out with test clock but just wanted to have an idea on what to expect. You were a great help good sir. Thanks