#mounirmtl
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.
Hi there ๐ thank you for flagging this, that does look like a typo on our end.
Instead you'll want to make a request to update the Subscription, and set the cancel_at_period_end parameter to true when doing so:
https://stripe.com/docs/api/subscriptions/update#update_subscription-cancel_at_period_end
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Sorry for the late response..
Do we want to do that right before canceling? Or can we set this flag at subscription creation?
nevermind. I noticed we could do it at subscription creation
If you're going to cancel immediately, no there isn't a point to use that parameter, you'd instead make a request to immediately cancel the Subscription:
https://stripe.com/docs/api/subscriptions/cancel
Setting it at creation will cause the Subscription to only last one billing period. That isn't something I've seen most people want but should be available to you if that's the behavior you're after.
Oh I see. So if we want the subscription to continue until the end of the billing period, we just need to update the subscription with this flag and it will automatically be canceled at the end of the period?
Yup, it configures the Subscription to be cancelled at the end of the current billing period.
I see and when a subscription is canceled, the webhook that is hit is customer.subscription.deleted?
Exactly. And that won't be triggered when the Subscription is updated with cancel_at_period_end, it only triggers when the Subscription actually is cancelled.
Is there a way to know when a subscription has been canceled before it's been deleted?
should I check the flag on the updated webhook?
I don't understand the question, cancelling and deleting Subscriptions are the same thing in Stripe.
Oh oh, you want to know if the Subscription has been updated to be cancelled at the end of the current period?
yes
Gotcha! You're spot on then. You'll want to listen for customer.subscription.updated and check whether cancel_at_period_end has changed and if so what it is set to.
Does that mean I need to keep track of cancel_at_period_end for every updated event received to know if it has changed? Or can I assume that if it's set the subscription will be canceled
๐ hoppingin here since toby had to head out
Neither
๐ Have a nice rest of the day toby
You can check the data.previous_attributes hash on the Event:
https://stripe.com/docs/api/events/object#event_object-data-previous_attributes
that field lists the previous values for any fields that changed. So you can look there to see if you see cancel_at_period_end, then check whether it was being set to true or false so you know what you need to do downstream.
Oh awesome. Thank you
Any time! Alright, I'm actually stepping away this time, hope you have a great day as well! If there's anything else, please let karbi know. ๐
๐ Will do. Thank you for your time. Extremely appreciated
karbi, if cancel_at_period_end has been set to true, does that mean the cancel_at field will always be there?
and will always reflect when the susbcription will be canceled?
Yes, if cancel_at_period_end is set to true, the cancel_at will also be set
can cancel_at_period_end be changed from true to false?
Yup!
lol. So we can cancel a cancellation... That's becoming very meta ๐
Actually that's normal behavior. I've seen that in many subscription based product. That's just me being weird. Sorry ๐
No worries! It's definitely a bit weird to wrap your head around - a lot of subscription flows like that make way more sense when you think of real world examples ๐
One more question,
For subscription boxes where there's some time required to fulfill an order from a subscription.
How can we configure stripe to notify us the next billing cycle has started? So we can internally create a new order to be fulfilled
Usually you'd listen for customer.subscription.updated and check for whether current_period_start has changed to know whether a new cycle has started