From 6a7373523e2f0d71e11916b81081cb972e0aa6cd Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 23 Dec 2020 20:39:41 +0530 Subject: [PATCH] Set default card before making payments --- datacenterlight/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 388d78b2..a59cb325 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -792,6 +792,10 @@ class OrderConfirmationView(DetailView, FormView): 'brand': user_card_detail.brand, 'card_id': user_card_detail.card_id } + UserCardDetail.set_default_card( + stripe_api_cus_id=stripe_api_cus_id, + stripe_source_id=user_card_detail.card_id + ) logger.debug("card_details_dict=%s" % card_details_dict) else: response = { @@ -1142,11 +1146,11 @@ def do_provisioning(request, user, stripe_api_cus_id, card_details_response, 'brand': user_card_detail.brand, 'card_id': user_card_detail.card_id } - if not user_card_detail.preferred: - UserCardDetail.set_default_card( - stripe_api_cus_id=stripe_api_cus_id, - stripe_source_id=user_card_detail.card_id - ) + #if not user_card_detail.preferred: + UserCardDetail.set_default_card( + stripe_api_cus_id=stripe_api_cus_id, + stripe_source_id=user_card_detail.card_id + ) else: logger.debug("card_id was NOT in request, using " "card_details_response")