Handle PaymentMethod type in set_default_card

This commit is contained in:
PCoder 2020-12-31 15:24:47 +05:30
parent ba92c8e416
commit 41de724904

View file

@ -673,6 +673,10 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
stripe_utils = StripeUtils()
cus_response = stripe_utils.get_customer(stripe_api_cus_id)
cu = cus_response['response_object']
if stripe_source_id.startswith("pm"):
# card is a payment method
cu.invoice_settings.default_payment_method = stripe_source_id
else:
cu.default_source = stripe_source_id
cu.save()
UserCardDetail.save_default_card_local(