Skip to content

Commit

Permalink
Release any schedule before cancelling.
Browse files Browse the repository at this point in the history
You cannot cancel a subscription with a schedule.
  • Loading branch information
dracos committed Oct 2, 2024
1 parent 59aabc2 commit 70cbf9c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions subscriptions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ class SubscriptionCancelView(StripeObjectMixin, DeleteView):

def form_valid(self, form):
if self.object:
if self.object.schedule:
stripe.SubscriptionSchedule.release(self.object.schedule)
stripe.Subscription.modify(self.object.id, cancel_at_period_end=True)
messages.add_message(self.request, messages.INFO, 'Your subscription has been cancelled.')
return HttpResponseRedirect(self.success_url)
Expand Down

0 comments on commit 70cbf9c

Please sign in to comment.