From f044b83b8f1be5220270dbb12980459c5d2a7b69 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 3 Oct 2017 13:06:26 +0200 Subject: [PATCH] Add Stripe unsubscribe_customer method --- utils/stripe_utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index 8fcf0ab1..58840be0 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -232,6 +232,17 @@ class StripeUtils(object): ) return subscription_result + @handleStripeError + def unsubscribe_customer(self, subscription_id): + """ + Cancels a given subscription + + :param subscription_id: The Stripe subscription id string + :return: + """ + sub = stripe.Subscription.retrieve(subscription_id) + return sub.delete() + @handleStripeError def make_payment(self, customer, amount, token): charge = self.stripe.Charge.create(