From 8d2c120b4330b4dc6f22801c97317929072589dc Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 26 Oct 2017 12:29:16 +0200 Subject: [PATCH] Associate newly added card with customer from hosting --- hosting/views.py | 4 ++++ membership/models.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 207c95c9..f082ae1b 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -626,6 +626,10 @@ class SettingsView(LoginRequiredMixin, FormView): exp_year=card_details_response['exp_year'], card_id=card_details_response['card_id'] ) + stripe_utils.associate_customer_card( + request.user.stripecustomer.stripe_id, + token + ) msg = _( "Successfully associated the card with your account" ) diff --git a/membership/models.py b/membership/models.py index ca403347..dc76a8dc 100644 --- a/membership/models.py +++ b/membership/models.py @@ -212,8 +212,8 @@ class StripeCustomer(models.Model): stripe_customer.user, token) if "deleted" in customer and customer["deleted"]: raise StripeCustomer.DoesNotExist() - if not customer.sources.data: - stripe_utils.update_customer_token(customer, token) + #if not customer.sources.data: + # stripe_utils.update_customer_token(customer, token) return stripe_customer except StripeCustomer.DoesNotExist: user = CustomUser.objects.get(email=email)