question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to cancel stripe subscription at period end

See original GitHub issue

Python 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ob-stripecommented, Jan 10, 2019

The documentation is now fixed!

1reaction
IlianIlievcommented, Oct 21, 2018

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 a cancel 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 )

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found