Add get_cards_details_from_token function
This commit is contained in:
parent
167e3589d4
commit
7d69d8d5d4
1 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
import logging
|
||||
|
||||
import stripe
|
||||
from django.conf import settings
|
||||
|
||||
from datacenterlight.models import StripePlan
|
||||
|
||||
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY
|
||||
|
@ -102,6 +104,18 @@ class StripeUtils(object):
|
|||
}
|
||||
return card_details
|
||||
|
||||
@handleStripeError
|
||||
def get_cards_details_from_token(self, token):
|
||||
stripe_token = stripe.Token.retrieve(token)
|
||||
card_details = {
|
||||
'last4': stripe_token.card.last4,
|
||||
'brand': stripe_token.card.brand,
|
||||
'exp_month': stripe_token.card.exp_month,
|
||||
'exp_year': stripe_token.card.exp_year,
|
||||
'fingerprint': stripe_token.card.fingerprint
|
||||
}
|
||||
return card_details
|
||||
|
||||
def check_customer(self, id, user, token):
|
||||
customers = self.stripe.Customer.all()
|
||||
if not customers.get('data'):
|
||||
|
|
Loading…
Reference in a new issue