From 73169e825d2d0e4ce46f1667a294f46931b1b69a Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 28 Oct 2017 15:13:38 +0200 Subject: [PATCH] Add set_as_default parameter for associate_customer_card method --- utils/stripe_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index b9884ebf..e43304ca 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -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):