Fix the bug where trying to unsubscribe a customer with no subscription throws an error.
This commit is contained in:
parent
d7cae4fbca
commit
1f1565fdaa
1 changed files with 4 additions and 2 deletions
|
@ -1217,8 +1217,10 @@ def subscribe(user, plan, token, accepted_plans):
|
|||
cus = stripe.Customer.retrieve(user.stripe_id)
|
||||
|
||||
if plan_found['price'] == 0:
|
||||
cus.cancel_subscription()
|
||||
cus.save()
|
||||
if cus.subscription is not None:
|
||||
# We only have to cancel the subscription if they actually have one
|
||||
cus.cancel_subscription()
|
||||
cus.save()
|
||||
|
||||
response_json = {
|
||||
'plan': plan,
|
||||
|
|
Reference in a new issue