Do not create paymentintent for subscription
This commit is contained in:
parent
ba3c5ddd1d
commit
e024a3a7a6
1 changed files with 25 additions and 21 deletions
|
@ -694,24 +694,31 @@ 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
|
||||||
# the customer
|
if ('generic_payment_type' not in request.session or
|
||||||
stripe_utils = StripeUtils()
|
(request.session['generic_payment_details']['recurring'])):
|
||||||
payment_intent_response = stripe_utils.get_payment_intent(
|
# Obtain PaymentIntent so that we can initiate and charge
|
||||||
int(amount_to_charge * 100),
|
# the customer
|
||||||
customer=request.session['customer']
|
is_subscription = True
|
||||||
)
|
logger.debug("CASE: Subscription")
|
||||||
payment_intent = payment_intent_response.get(
|
|
||||||
'response_object')
|
|
||||||
if not payment_intent:
|
|
||||||
logger.error("Could not create payment_intent %s" %
|
|
||||||
str(payment_intent_response))
|
|
||||||
else:
|
else:
|
||||||
logger.debug("payment_intent.client_secret = %s" %
|
logger.debug("CASE: One time payment")
|
||||||
str(payment_intent.client_secret))
|
stripe_utils = StripeUtils()
|
||||||
context.update({
|
payment_intent_response = stripe_utils.get_payment_intent(
|
||||||
'payment_intent_secret': payment_intent.client_secret
|
int(amount_to_charge * 100),
|
||||||
})
|
customer=request.session['customer']
|
||||||
|
)
|
||||||
|
payment_intent = payment_intent_response.get(
|
||||||
|
'response_object')
|
||||||
|
if not payment_intent:
|
||||||
|
logger.error("Could not create payment_intent %s" %
|
||||||
|
str(payment_intent_response))
|
||||||
|
else:
|
||||||
|
logger.debug("payment_intent.client_secret = %s" %
|
||||||
|
str(payment_intent.client_secret))
|
||||||
|
context.update({
|
||||||
|
'payment_intent_secret': payment_intent.client_secret
|
||||||
|
})
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
'site_url': reverse('datacenterlight:index'),
|
'site_url': reverse('datacenterlight:index'),
|
||||||
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue