From 8759e2a4b5491c904b4dc3a46143878a74363c7b Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 28 Oct 2017 15:14:42 +0200 Subject: [PATCH] Save default card only if Stripe's default_source is not None --- hosting/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hosting/models.py b/hosting/models.py index a72c4d7e..ae047628 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -285,7 +285,8 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): cus_response = stripe_utils.get_customer(stripe_api_cus_id) cu = cus_response['response_object'] default_source = cu.default_source - self._save_default_card(stripe_api_cus_id, default_source) + if default_source is not None: + self._save_default_card(stripe_api_cus_id, default_source) def _save_default_card(self, stripe_api_cus_id, card_id): stripe_cust = StripeCustomer.objects.get(stripe_id=stripe_api_cus_id)