From 2c28dd4019ca984cb8a858ffcb1e1996197415a1 Mon Sep 17 00:00:00 2001 From: Juan Pablo Senn <32602005+juanpsenn@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:12:57 -0300 Subject: [PATCH] Added captured amount to DummyProvider (#382) Fixes: https://github.com/jazzband/django-payments/issues/374 See: https://github.com/jazzband/django-payments/pull/382 --- payments/dummy/__init__.py | 2 ++ payments/dummy/test_dummy.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/payments/dummy/__init__.py b/payments/dummy/__init__.py index 800cd31cd..f1d77d32b 100644 --- a/payments/dummy/__init__.py +++ b/payments/dummy/__init__.py @@ -62,11 +62,13 @@ def process_data(self, payment, request): if verification_result: payment.change_status(verification_result) if payment.status in [PaymentStatus.CONFIRMED, PaymentStatus.PREAUTH]: + payment.captured_amount = payment.total return HttpResponseRedirect(payment.get_success_url()) return HttpResponseRedirect(payment.get_failure_url()) def capture(self, payment, amount=None): payment.change_status(PaymentStatus.CONFIRMED) + payment.captured_amount = amount or payment.total return amount def release(self, payment): diff --git a/payments/dummy/test_dummy.py b/payments/dummy/test_dummy.py index 37f6bc32c..4d9efdf9c 100644 --- a/payments/dummy/test_dummy.py +++ b/payments/dummy/test_dummy.py @@ -22,6 +22,7 @@ class Payment: total = 100 status = PaymentStatus.WAITING fraud_status = "" + captured_amount = 0 def get_process_url(self): return "http://example.com" @@ -50,6 +51,7 @@ def test_process_data_supports_verification_result(self): request.GET = {"verification_result": verification_status} response = provider.process_data(self.payment, request) self.assertEqual(self.payment.status, verification_status) + self.assertEqual(self.payment.captured_amount, 100) self.assertEqual(response.status_code, 302) self.assertEqual(response["location"], self.payment.get_success_url())