Remove token parameter from stripe_utils.get_card_details

and add additional paramters to uniquely identify a card
This commit is contained in:
PCoder 2018-07-07 01:08:45 +02:00
parent 4c06a9e730
commit 8d42ca3200
2 changed files with 7 additions and 4 deletions

View file

@ -86,8 +86,7 @@ class CeleryTaskTestCase(TestCase):
token=self.token token=self.token
) )
card_details = self.stripe_utils.get_card_details( card_details = self.stripe_utils.get_card_details(
stripe_customer.stripe_id, stripe_customer.stripe_id
self.token
) )
card_details_dict = card_details.get('error') card_details_dict = card_details.get('error')
self.assertEquals(card_details_dict, None) self.assertEquals(card_details_dict, None)

View file

@ -109,12 +109,16 @@ class StripeUtils(object):
return new_card_data return new_card_data
@handleStripeError @handleStripeError
def get_card_details(self, customer_id, token): def get_card_details(self, customer_id):
customer = stripe.Customer.retrieve(customer_id) customer = stripe.Customer.retrieve(customer_id)
credit_card_raw_data = customer.sources.data.pop() credit_card_raw_data = customer.sources.data.pop()
card_details = { card_details = {
'last4': credit_card_raw_data.last4, 'last4': credit_card_raw_data.last4,
'brand': credit_card_raw_data.brand 'brand': credit_card_raw_data.brand,
'exp_month': credit_card_raw_data.exp_month,
'exp_year': credit_card_raw_data.exp_year,
'fingerprint': credit_card_raw_data.fingerprint,
'card_id': credit_card_raw_data.id
} }
return card_details return card_details