From 13f5f576b50776548a93533579fb6a92914e1bc5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 31 Dec 2020 17:23:43 +0530 Subject: [PATCH] Fix getting cc details from payment_methods --- hosting/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index c14d18bf..48238afe 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -169,8 +169,12 @@ class HostingOrder(AssignPermissionsMixin, models.Model): def set_stripe_charge(self, stripe_charge): self.stripe_charge_id = stripe_charge.id - self.last4 = stripe_charge.source.last4 - self.cc_brand = stripe_charge.source.brand + if stripe_charge.source is None: + self.last4 = stripe_charge.payment_method_details.card.last4 + self.cc_brand = stripe_charge.payment_method_details.card.brand + else: + self.last4 = stripe_charge.source.last4 + self.cc_brand = stripe_charge.source.brand self.save() def set_subscription_id(self, subscription_id, cc_details):