Skip to content

Commit

Permalink
Redirect to basket page when payment fails in Auth.net - EDLY-5903 (#138
Browse files Browse the repository at this point in the history
)

Co-authored-by: Taimoor  Ahmed <taimoor.ahmed@A006-00933.local>
  • Loading branch information
taimoor-ahmed-1 and Taimoor Ahmed authored Aug 25, 2023
1 parent 10a1455 commit da9f169
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ecommerce/extensions/payment/views/authorizenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import logging

from django.conf import settings
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from oscar.apps.partner import strategy
Expand Down Expand Up @@ -276,7 +278,9 @@ def post(self, request): # pylint: disable=unused-argument
if form.is_valid():
return self.form_valid(form)
except (TransactionDeclined) as exp:
return HttpResponse('Transcaction was declined due to {}'.format(str(exp)), status=400)
messages.add_message(request, messages.ERROR, 'Payment error: {}'.format(str(exp)))
basket_url = reverse('basket:summary')
return HttpResponseRedirect(basket_url)

return self.form_invalid(form)

Expand Down

0 comments on commit da9f169

Please sign in to comment.