#.abishek
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
Hello! For your first question, yes. Have a look at current_period_end: https://stripe.com/docs/api/subscriptions/object#subscription_object-current_period_end
For your second question, not sure what you mean by "expiry date". Can you provide more specific details?
expiry date - when the subscription actually terminates. I am sending an email to the customer that the subscription is cancelled and will terminate on x date. so just trying to figure out where I can get that date. Stripe allows the option to terminate the subscription immediately or at the end of the term.
If you set the Subscription to cancel at the end of the period it would be the same property as above, current_period_end.
If you cancel it immediately then you know exactly when it was canceled.
ok, the reason I ask is, we let our customers use the Customer Portal, so it would help if I know what is the expiry date for my second question
Sorry, not sure I fully understand. Can you describe an example scenario?
so, our app allows the customer to use the Customer Portal to cancel their subscriptions
I think the Customer Portal has the option to cancel immediately or at the end of the term. Correct
If you configure it to allow that, yes.
Are you looking for canceled_at? https://stripe.com/docs/api/subscriptions/object#subscription_object-canceled_at
yes, so if someone clicks "Cancel Immediately", I want to know when the subscription will actually expires. Will canceled_at be the one to look at?
we receive a webhook trigger for customer.subscription.canceled, so I need to figure if the subscription is being canceled at the end of the term or immediately.
The customer.subscription.canceled won't fire until the Subscription is actually canceled.
You'll get customer.subscription.updated if the Subscription is updated to cancel at the end of the current period.
If the Subscription is canceled immediately you'll get customer.subscription.canceled immediately though.
Likewise, canceled_at won't be populated until the Subscirption is canceled.
ah, ok, i was not aware of that
so, what should I look for when on the customer.subscription.updated to know that the user has cancelled the plan and will completely cancel by the end of the term
since you mentioned cancel_at will only be applied when the subscription is cancelled. So that will not be set on the customer.subscription.updated webhook event
I think the Customer Portal will set cancel_at_period_end to true: https://stripe.com/docs/api/subscriptions/object#subscription_object-cancel_at_period_end
So if that's set to true the Subscription will cancel at current_period_end.
ok, that makes sense. glad you clarified it. thank you very much
Also be aware there's a cancel_at property that can be set to an arbitrary point in the future: https://stripe.com/docs/api/subscriptions/object#subscription_object-cancel_at
So you might want to check that too.
ok, thank you very much for that. appreciate it
Happy to help!
// customer.subscription.updated webhook check
if(subscription.cancel_at_period_end === true && subscription.cancel_at >= now()) {
// send email for future date subscription cancel
}
is that correct?
just clarifying if I am on the same page
I can't provide code reviews here, but I will say that it's more likely cancel_at will be null instead of a timestamp.
I recommend you test in test mode to make sure it works the way you expect.
ok, sounds good. thank you
You can use Test Clocks to advance time in test mode so you can test Subscription changes over time without waiting: https://stripe.com/docs/billing/testing/test-clocks
👍
can a cancelled plan be resubscribed? or do I have to create a new subscription for this?
You would need to create a new Subscription.
what about stopping the cancellation if end of term is selected
You can set cancel_at_period_end to false.
Sorry, I can't explain how every aspect of Stripe works. Best way to find out is to try this all out in test mode.
If you run into issues in test mode we can help unblock you.
ok