From 5d9b9eb6398bcf3347acf6d4be6d9ea297c3ab74 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Wed, 1 Jul 2026 16:56:21 +0200 Subject: [PATCH] Do not raise when payment failed due to SuspiciousOperation --- teleforma/views/payment.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/teleforma/views/payment.py b/teleforma/views/payment.py index 54b3c4f2..e50e5077 100644 --- a/teleforma/views/payment.py +++ b/teleforma/views/payment.py @@ -197,8 +197,14 @@ def bank_success(request, merchant_id): """ Bank success callback """ - log.info("bank_auto %r" % request.POST) - info = check_payment_info(request.POST) + log.info("bank_success %r" % request.POST) + try: + info = check_payment_info(request.POST) + except SuspiciousOperation: + # Browser-facing endpoint: reloads, back button, bots or GET redirects + # can hit this URL without the expected Seal/Data. Redirect to the + # failure page instead of raising a 400 with a full traceback. + return HttpResponseRedirect('/echec-de-paiement') order_id = info['order_id'] if info['valid']: payment = Payment.objects.get(pk=order_id) -- 2.47.3