diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py index b9edc994..bbcb16ab 100644 --- a/datacenterlight/utils.py +++ b/datacenterlight/utils.py @@ -96,7 +96,7 @@ def clear_all_session_vars(request): if request.session is not None: for session_var in ['specs', 'template', 'billing_address', 'billing_address_data', 'card_id', - 'token', 'customer','generic_payment_type', + 'token', 'customer', 'generic_payment_type', 'generic_payment_details', 'product_id']: if session_var in request.session: - del request.session[session_var] \ No newline at end of file + del request.session[session_var] diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 0086e880..19faa2d1 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -398,7 +398,8 @@ class PaymentOrderView(FormView): "description": generic_payment_form.cleaned_data.get( 'description' ), - "product_id": product.id + "product_id": product.id, + "product_slug": product.product_slug } request.session["generic_payment_details"] = ( gp_details @@ -570,7 +571,14 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('datacenterlight:payment'), + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -609,7 +617,16 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('hosting:payment'), + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session + ['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -664,8 +681,12 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=(reverse('datacenterlight:payment') + - "?type=generic"), + url=(reverse('show_product', kwargs={ + 'product_slug': gp_details['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -736,8 +757,16 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('datacenterlight:payment'), - section='payment_error'), + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in request.session else + reverse('datacenterlight:payment') + ), + section='payment_error' + ), 'msg_title': str(_('Error.')), 'msg_body': str( _('There was a payment related error.'