stubbing in methods to help with stripe refactor work.

modified:   make_post_sell/models/stripe_user_shop.py
This commit is contained in:
Russell Ballestrini 2022-08-08 10:51:53 -04:00
parent 712b5d6563
commit db6f1ac795

View file

@ -38,6 +38,25 @@ class StripeUserShop(RBase, Base):
"""Return this object's remote API stripe Customer object."""
return self.shop.stripe_customer(self.user)
@property
def stripe_customer_default_source(self):
if self.stripe_customer:
if self.stripe_customer.default_source:
return self.stripe_customer.sources.retrieve(
self.stripe_customer.default_source
)
return None
@property
def stripe_active_card(self):
cards = self.shop.stripe.Customer.list_payment_methods(self.stripe_customer, type="card")["data"]
for card in cards:
#print(card)
if card.id == self.active_card_id:
return card
def get_all_stripe_user_shop_objects(dbsession):
return dbsession.query(StripeUserShop).all()