diff --git a/make_post_sell/models/stripe_user_shop.py b/make_post_sell/models/stripe_user_shop.py index cb65935..0cb195f 100644 --- a/make_post_sell/models/stripe_user_shop.py +++ b/make_post_sell/models/stripe_user_shop.py @@ -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()