def create_by_stripe_token(self, user, stripe_token): if user.has_customer() and stripe_token: source = create_card(user, stripe_token) return self.create(card_id=source.id, last4=source.last4, token=stripe_token, brand=source.brand, user=user, default=not user.has_billing_profiles)
def create_by_stripe_token(cls, user, stripe_token): if user.customer_id and stripe_token: card = create_card(user, stripe_token) return user.billingprofile_set.create( card_id=card.id, last4=card.last4, brand=card.brand, token=stripe_token, default=not user.has_billing_profile())