From 36505db5a2b205ac5e4727996071990d79e58235 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 1 Jan 2021 01:35:59 +0530 Subject: [PATCH] set default_payment_method --- datacenterlight/views.py | 1 + hosting/views.py | 1 + utils/stripe_utils.py | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 226985cf..9f31952e 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -980,6 +980,7 @@ class OrderConfirmationView(DetailView, FormView): discount['stripe_coupon_id'] else ""), tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], + default_payment_method=request.session['id_payment_method'] ) stripe_subscription_obj = subscription_result.get('response_object') logger.debug(stripe_subscription_obj) diff --git a/hosting/views.py b/hosting/views.py index f18a22b7..441e33b5 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1201,6 +1201,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView): discount['stripe_coupon_id'] else ""), tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], + default_payment_method=request.session['id_payment_method'] ) stripe_subscription_obj = subscription_result.get('response_object') latest_invoice = stripe.Invoice.retrieve(stripe_subscription_obj.latest_invoice) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index d04a24cb..7ef306bf 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -329,10 +329,12 @@ class StripeUtils(object): @handleStripeError def subscribe_customer_to_plan(self, customer, plans, trial_end=None, - coupon="", tax_rates=list()): + coupon="", tax_rates=list(), + default_payment_method=""): """ Subscribes the given customer to the list of given plans + :param default_payment_method: :param tax_rates: :param coupon: :param customer: The stripe customer identifier @@ -355,7 +357,8 @@ class StripeUtils(object): customer=customer, items=plans, trial_end=trial_end, coupon=coupon, default_tax_rates=tax_rates, - payment_behavior='allow_incomplete' + payment_behavior='allow_incomplete', + default_payment_method=default_payment_method ) logger.debug("Done subscribing") return subscription_result