Add set_as_default parameter for associate_customer_card method

This commit is contained in:
PCoder 2017-10-28 15:13:38 +02:00
parent 38168e8f8f
commit 73169e825d
1 changed files with 6 additions and 2 deletions

View File

@ -79,9 +79,13 @@ class StripeUtils(object):
customer.save()
@handleStripeError
def associate_customer_card(self, stripe_customer_id, token):
def associate_customer_card(self, stripe_customer_id, token,
set_as_default=False):
customer = stripe.Customer.retrieve(stripe_customer_id)
customer.sources.create(source=token)
card = customer.sources.create(source=token)
if set_as_default:
customer.default_source = card.id
customer.save()
@handleStripeError
def dissociate_customer_card(self, stripe_customer_id, card_id):