#cnguyen85
1 messages · Page 1 of 1 (latest)
Hi there!
- To know when a subscription is deleted:
customer.subscription.deleted - To know if a subscription will be canceled in the future:
customer.subscription.updated, and check thecancel_atproperty
- To know if a Subscription is in a trial, check it's
status
If we cancel the subscription at the end of the cycle (cancel_at), we will have a customer.subscription.deleted at this moment, no ?
And for the end of trial, I check customer.subscription.updated and I have to check if the updated attribute is status ? And if the status was trial and the new one is active ?
If we cancel the subscription at the end of the cycle (cancel_at), we will have a customer.subscription.deleted at this moment, no ?
No
You will get a customer.subscription.updated event
And the cancel_at property should be set.
ok so, to do some stuff when a user cancel a subscription, there is 2 things to check :
- Subscription canceled is stoppped directly => customer.subscription.deleted
- Subscription is canceled but at the end of the cycle => customer.subscription.updated
On the 2nd usecase, I have to check if the updated attributes is cancel_at. Right ?
That's correct
OK. And the best way is always to check the updated attributes, correct ?
Hi 👋 jumping in as my teammate needed to step away. Yes, checking the details provided in previous_attributes is a good way to review what changes an Event is informing you about.
ok
So, to check a end of trial, I listen the customer.subscription.updated webhook. And I have to check if the current status is active and the previous_attributes.status is trial ?
Yup
ty
and there is an event when the cancel_at is today ?
or what is the event when it's the end of the subscription
customer.subscription.deleted is triggered when the Subscription ends. You can use Test Clocks to create a Subscription and move it through it's entire lifecycle in test mode, allowing you to see exactly what Events will be generated when:
https://stripe.com/docs/billing/testing/test-clocks
ssok so I just have to handle deleted. It's because it was not the answer from soma
got it
Sorry, maybe I'm missing a nuance that you're including, because they pointed you to that Event in their first message.
Are you saying you're making an update call to set cancel_at to the same date as it currently is?