Do clear session vars at the end

This commit is contained in:
PCoder 2020-12-23 14:33:32 +05:30
parent 480e38fbc9
commit 0c1b7b1885
2 changed files with 25 additions and 27 deletions

View file

@ -103,8 +103,6 @@ def create_vm(billing_address_data, stripe_customer_id, specs,
create_vm_task.delay(vm_template_id, user, specs, template, order.id) create_vm_task.delay(vm_template_id, user, specs, template, order.id)
clear_all_session_vars(request)
def clear_all_session_vars(request): def clear_all_session_vars(request):
if request.session is not None: if request.session is not None:

View file

@ -717,6 +717,30 @@ class OrderConfirmationView(DetailView, FormView):
stripe_utils = StripeUtils() stripe_utils = StripeUtils()
logger.debug("user=%s stripe_api_cus_id=%s" % (user, stripe_api_cus_id)) logger.debug("user=%s stripe_api_cus_id=%s" % (user, stripe_api_cus_id))
card_details_response = None card_details_response = None
new_user_hosting_key_id = None
card_id = None
generic_payment_type = None
generic_payment_details = None
stripe_subscription_obj = None
if 'generic_payment_details' in request.session:
generic_payment_details = request.session[
'generic_payment_details']
if 'generic_payment_type' in request.session:
generic_payment_type = request.session['generic_payment_type']
if 'new_user_hosting_key_id' in self.request.session:
new_user_hosting_key_id = request.session[
'new_user_hosting_key_id']
if 'card_id' in request.session:
card_id = request.session.get('card_id')
req = {
'scheme': self.request.scheme,
'host': self.request.get_host(),
'language': get_language(),
'new_user_hosting_key_id': new_user_hosting_key_id,
'card_id': card_id,
'generic_payment_type': generic_payment_type,
'generic_payment_details': generic_payment_details
}
if 'token' in request.session: if 'token' in request.session:
card_details = stripe_utils.get_cards_details_from_token( card_details = stripe_utils.get_cards_details_from_token(
@ -899,31 +923,6 @@ class OrderConfirmationView(DetailView, FormView):
logger.debug(stripe_subscription_obj) logger.debug(stripe_subscription_obj)
latest_invoice = stripe.Invoice.retrieve( latest_invoice = stripe.Invoice.retrieve(
stripe_subscription_obj.latest_invoice) stripe_subscription_obj.latest_invoice)
new_user_hosting_key_id = None
card_id = None
generic_payment_type = None
generic_payment_details = None
if 'generic_payment_details' in request.session:
generic_payment_details = request.session[
'generic_payment_details']
if 'generic_payment_type' in request.session:
generic_payment_type = request.session['generic_payment_type']
if 'new_user_hosting_key_id' in self.request.session:
new_user_hosting_key_id = request.session[
'new_user_hosting_key_id']
if 'card_id' in request.session:
card_id = request.session.get('card_id')
req = {
'scheme': self.request.scheme,
'host': self.request.get_host(),
'language': get_language(),
'new_user_hosting_key_id': new_user_hosting_key_id,
'card_id': card_id,
'generic_payment_type': generic_payment_type,
'generic_payment_details': generic_payment_details
}
subscription_status = '' subscription_status = ''
if stripe_subscription_obj: if stripe_subscription_obj:
subscription_status = stripe_subscription_obj.status subscription_status = stripe_subscription_obj.status
@ -1043,6 +1042,7 @@ class OrderConfirmationView(DetailView, FormView):
' We will send you a confirmation email as soon as' ' We will send you a confirmation email as soon as'
' it is ready.')) ' it is ready.'))
} }
clear_all_session_vars(request)
return JsonResponse(response) return JsonResponse(response)