forked from uncloud/uncloud
cleanup/in between commit
This commit is contained in:
parent
f7c68b5ca5
commit
e51edab2f5
11 changed files with 107 additions and 99 deletions
|
|
@ -47,10 +47,6 @@ def handle_stripe_error(f):
|
|||
# XXX: maybe send email
|
||||
logging.error(str(e))
|
||||
raise Exception(common_message)
|
||||
except Exception as e:
|
||||
# maybe send email
|
||||
logging.error(str(e))
|
||||
raise Exception(common_message)
|
||||
|
||||
return handle_problems
|
||||
|
||||
|
|
@ -103,3 +99,25 @@ def create_customer(name, email):
|
|||
@handle_stripe_error
|
||||
def get_customer(customer_id):
|
||||
return stripe.Customer.retrieve(customer_id)
|
||||
|
||||
@handle_stripe_error
|
||||
def get_customer_cards(customer_id):
|
||||
print(f"getting cards for: {customer_id}")
|
||||
|
||||
cards = []
|
||||
stripe_cards = stripe.PaymentMethod.list(
|
||||
customer=customer_id,
|
||||
type="card",
|
||||
)
|
||||
|
||||
for stripe_card in stripe_cards["data"]:
|
||||
card = {}
|
||||
card['brand'] = stripe_card["card"]["brand"]
|
||||
card['last4'] = stripe_card["card"]["last4"]
|
||||
card['month'] = stripe_card["card"]["exp_month"]
|
||||
card['year'] = stripe_card["card"]["exp_year"]
|
||||
card['id'] = stripe_card["card"]["id"]
|
||||
|
||||
cards.append(card)
|
||||
|
||||
return cards
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue