Do not create paymentintent for subscription

This commit is contained in:
PCoder 2021-01-01 00:34:35 +05:30
parent ba3c5ddd1d
commit e024a3a7a6

View file

@ -694,8 +694,15 @@ class OrderConfirmationView(DetailView, FormView):
'keys': get_all_public_keys(self.request.user) 'keys': get_all_public_keys(self.request.user)
}) })
# Obtain PaymentIntent so that we can initiate and charge/subscribe is_subscription = False
if ('generic_payment_type' not in request.session or
(request.session['generic_payment_details']['recurring'])):
# Obtain PaymentIntent so that we can initiate and charge
# the customer # the customer
is_subscription = True
logger.debug("CASE: Subscription")
else:
logger.debug("CASE: One time payment")
stripe_utils = StripeUtils() stripe_utils = StripeUtils()
payment_intent_response = stripe_utils.get_payment_intent( payment_intent_response = stripe_utils.get_payment_intent(
int(amount_to_charge * 100), int(amount_to_charge * 100),
@ -730,10 +737,7 @@ class OrderConfirmationView(DetailView, FormView):
reverse('datacenterlight:index') reverse('datacenterlight:index')
}, },
'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
'is_subscription': 'true' if ( 'is_subscription': str(is_subscription).lower()
'generic_payment_type' not in request.session or
(request.session['generic_payment_details']['recurring'])
) else 'false'
}) })
logger.debug("Request %s" % create_incomplete_intent_request( logger.debug("Request %s" % create_incomplete_intent_request(
self.request)) self.request))