cleanup/in between commit

This commit is contained in:
Nico Schottelius 2020-12-26 11:22:51 +01:00
commit e51edab2f5
11 changed files with 107 additions and 99 deletions

View file

@ -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