From 6ef8a03de70d90d952c4ee3b584624ccfca58dde Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Sat, 30 Sep 2017 01:02:59 +0200 Subject: [PATCH] Respond with JSON --- hosting/views.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index ca215a4d..c39a2bcd 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -788,8 +788,19 @@ class OrdersHostingDetailView(LoginRequiredMixin, msg = subscription_result.get('error') messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment') - return HttpResponseRedirect( - reverse('hosting:payment') + '#payment_error') + response = { + 'status': False, + 'redirect': "{url}#{section}".format( + url=reverse('hosting:payment'), + section='payment_error'), + 'msg_title': str(_('Error.')), + 'msg_body': str( + _('There was a payment related error.' + ' On close of this popup, you will be redirected back to' + ' the payment page.')) + } + return HttpResponse(json.dumps(response), + content_type="application/json") user = { 'name': self.request.user.name, 'email': self.request.user.email,