Handle SCA in dcl flow

This commit is contained in:
PCoder 2020-10-11 17:11:20 +05:30
parent 676a358832
commit 4c7b9eaa52

View file

@ -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'):