From c2e0ea70e49f4d24b725679df3db8b3860887a3c Mon Sep 17 00:00:00 2001 From: Skia Date: Tue, 4 Jan 2022 14:45:19 +0100 Subject: [PATCH] eboutic: change HTTP return code to avoid blaming the bank's service --- eboutic/tests.py | 8 ++++---- eboutic/views.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eboutic/tests.py b/eboutic/tests.py index 0587fde9..9d0bf2de 100644 --- a/eboutic/tests.py +++ b/eboutic/tests.py @@ -191,10 +191,10 @@ class EbouticTest(TestCase): ) response = self.generate_bank_valid_answer_from_page_content(response.content) - self.assertTrue(response.status_code == 400) - self.assertTrue( - "Payment failed with error: SuspiciousOperation('Basket total and amount do not match'" - in response.content.decode("utf-8") + self.assertEqual(response.status_code, 500) + self.assertIn( + "Basket processing failed with error: SuspiciousOperation('Basket total and amount do not match'", + response.content.decode("utf-8"), ) def test_buy_refill_product_with_credit_card(self): diff --git a/eboutic/views.py b/eboutic/views.py index 35b5e09b..05c91e68 100644 --- a/eboutic/views.py +++ b/eboutic/views.py @@ -301,9 +301,11 @@ class EtransactionAutoAnswer(View): i.validate() b.delete() except Exception as e: - return HttpResponse("Payment failed with error: " + repr(e), status=400) + return HttpResponse( + "Basket processing failed with error: " + repr(e), status=500 + ) return HttpResponse() else: return HttpResponse( - "Payment failed with error: " + request.GET["Error"], status=400 + "Payment failed with error: " + request.GET["Error"], status=202 )