From 4c7b9eaa52d99048f22471d7c4f85ed879fe877a Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 11 Oct 2020 17:11:20 +0530 Subject: [PATCH] Handle SCA in dcl flow --- datacenterlight/views.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 3acc75c0..7dde0fa6 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -953,6 +953,23 @@ class OrderConfirmationView(DetailView, FormView): tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], ) stripe_subscription_obj = subscription_result.get('response_object') + logger.debug(stripe_subscription_obj) + latest_invoice = stripe.Invoice.retrieve( + stripe_subscription_obj.latest_invoice) + ret = stripe.PaymentIntent.confirm( + latest_invoice.payment_intent + ) + if ret.status == 'requires_action': + pi = stripe.PaymentIntent.retrieve( + latest_invoice.payment_intent + ) + context = { + 'sid': stripe_subscription_obj.id, + 'payment_intent_secret': pi.client_secret, + 'STRIPE_PUBLISHABLE_KEY': settings.STRIPE_API_PUBLIC_KEY, + 'showSCA': True + } + return JsonResponse(context) # Check if the subscription was approved and is active if (stripe_subscription_obj is None or stripe_subscription_obj.status != 'active'):