From d161a285b8a26b47a3ff70e1bd9bde6e75440d16 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 11:08:00 +0530 Subject: [PATCH] Added get_card_details function to stripe_utils --- utils/stripe_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index 29b45d8e..3b20b708 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -77,6 +77,16 @@ class StripeUtils(object): } return new_card_data + @handleStripeError + def get_card_details(self, customer_id, token): + customer = stripe.Customer.retrieve(customer_id) + credit_card_raw_data = customer.sources.data.pop() + card_details = { + 'last4': credit_card_raw_data.last4, + 'brand': credit_card_raw_data.brand + } + return card_details + def check_customer(self, id, user, token): customers = self.stripe.Customer.all() if not customers.get('data'):