Merge pull request #670 from pcoder/task/5690/redirect-on-payment-error

Task/5690/redirect on payment error
This commit is contained in:
Pcoder 2018-10-06 07:59:40 +02:00 committed by GitHub
commit 733fb9fc43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 9 deletions

View file

@ -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]
del request.session[session_var]

View file

@ -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.'