]> git.parisson.com Git - teleforma.git/commitdiff
Do not raise when payment failed due to SuspiciousOperation
authorYoan Le Clanche <yoanl@pilotsystems.net>
Wed, 1 Jul 2026 14:56:21 +0000 (16:56 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Wed, 1 Jul 2026 15:01:34 +0000 (17:01 +0200)
teleforma/views/payment.py

index 54b3c4f2df1242856c3006c2617f29119488b3f7..e50e5077b6f24012cac188f866828ab76c6d2d42 100644 (file)
@@ -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)