Unable to cancel stripe subscription at period end
See original GitHub issuePython 3.6.5
stripe 2.10.1
According to the docs https://stripe.com/docs/billing/subscriptions/canceling-pausing I am doing the following:
stripe_subscription = stripe.Subscription.retrieve(self.stripe_id)
stripe_subscription.update(cancel_at_period_end=True)
However it throws an error: TypeError: update() got an unexpected keyword argument 'cancel_at_period_end'
I have managed to get it working by changing it to:
stripe_subscription = stripe.Subscription.retrieve(self.stripe_id)
stripe_subscription.update({'cancel_at_period_end': True})
stripe_subscription.save()
However either the code or the documentation need to be updated. However for I think it will it will be better if we can do the following:
subscription.cancel() # cancels subscription immediately
subscription.cancel(at_period_end=True) # cancels subscription at period end
Both methods should commit the change so there is no need to call .save()
explicitly.
I am willing to provide a fix in a PR if this sounds good to you.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Cancel subscriptions | Stripe Documentation
If you choose to cancel at the end of the period, cancel_at_period_end is set to true and the subscription cancels at the end...
Read more >How can I cancel a subscription item in Stripe at end of billing ...
A subscription_item (as well as a plan ) doesn't currently support deleting it automatically at the end of the billing period.
Read more >How to Cancel a Subscription in Stripe - Thinkific Help Center
Search for and open the customer record in Stripe · Scroll to Active Subscriptions · Click on the '...' to the right of...
Read more >Cancelling a stripe subscription on 'period end'
Update phases on subscription schedule object to pass only current phase. Set end_behavior to 'cancel'. Stripe::SubscriptionSchedule.update( ...
Read more >Reactivate/Un-cancel my Subscription! > Stripe Level 2
It says that if you use the at_period_end method of canceling, and the subscription has not yet reached the period end, then reactivating...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The documentation is now fixed!
Hi @ob-stripe , and thank for the quick reply.
Yes, it is mostly an issue with the documentation but I had no idea where report it so I posted here.
Regarding the library itself - I still find the cancellation process a bit confusing. It uses
delete
to cancel a subscription, but the subscription is not actually deleted and just marked as cancelled. I checked the REST API and apparently this is the situation there (it uses the DELETE method) for cancelling it, so I can kind of understand why the library uses that method. However I still think that having acancel
method will be more convenient and clear for developers so if you ever decide to go in that direction just ping me, I’ll be happy to help )