Attempt to merge master into task/3747/multiple_cards_support

This commit is contained in:
PCoder 2018-06-12 08:13:48 +02:00
commit cf00ff6bd8
269 changed files with 8500 additions and 29554 deletions

View file

@ -237,12 +237,14 @@ class StripeUtils(object):
return return_value
@handleStripeError
def subscribe_customer_to_plan(self, customer, plans):
def subscribe_customer_to_plan(self, customer, plans, trial_end=None):
"""
Subscribes the given customer to the list of given plans
:param customer: The stripe customer identifier
:param plans: A list of stripe plans.
:param trial_end: An integer representing when the Stripe subscription
is supposed to end
Ref: https://stripe.com/docs/api/python#create_subscription-items
e.g.
plans = [
@ -254,11 +256,21 @@ class StripeUtils(object):
"""
subscription_result = self.stripe.Subscription.create(
customer=customer,
items=plans,
customer=customer, items=plans, trial_end=trial_end
)
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(