mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Fixing bug in subscription cancellation using latest stripe api.
This commit is contained in:
parent
13b0da1f85
commit
0fda7644f9
1 changed files with 5 additions and 3 deletions
|
@ -463,11 +463,13 @@ class Profile(models.Model):
|
||||||
stripe.api_key = settings.STRIPE_SECRET
|
stripe.api_key = settings.STRIPE_SECRET
|
||||||
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
||||||
try:
|
try:
|
||||||
stripe_customer.cancel_subscription()
|
subscriptions = stripe.Subscription.list(customer=stripe_customer)
|
||||||
|
for subscription in subscriptions.data:
|
||||||
|
stripe.Subscription.delete(subscription['subscription'])
|
||||||
|
logging.user(self.user, "~FRCanceling Stripe subscription: %s" % subscription['subscription'])
|
||||||
except stripe.error.InvalidRequestError:
|
except stripe.error.InvalidRequestError:
|
||||||
logging.user(self.user, "~FRFailed to cancel Stripe subscription")
|
logging.user(self.user, "~FRFailed to cancel Stripe subscription")
|
||||||
|
return
|
||||||
logging.user(self.user, "~FRCanceling Stripe subscription")
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue