From 959290e62ce320f727088b98563ec21ec7b995b5 Mon Sep 17 00:00:00 2001 From: Juan Pablo Senn <32602005+juanpsenn@users.noreply.github.com> Date: Thu, 19 Oct 2023 02:12:24 +0000 Subject: [PATCH 1/3] Added capture amount to DummyProvider --- 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..ba380da50 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 = 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()) From f79cc4262884fe44a14d51b85452aa64f727a26c Mon Sep 17 00:00:00 2001 From: Juan Pablo Senn <32602005+juanpsenn@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:58:07 -0300 Subject: [PATCH 2/3] Update payments/dummy/__init__.py Co-authored-by: Hugo --- payments/dummy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payments/dummy/__init__.py b/payments/dummy/__init__.py index ba380da50..0316c4419 100644 --- a/payments/dummy/__init__.py +++ b/payments/dummy/__init__.py @@ -68,7 +68,7 @@ def process_data(self, payment, request): def capture(self, payment, amount=None): payment.change_status(PaymentStatus.CONFIRMED) - payment.captured_amount = payment.total + payment.captured_amount = (amount or payment.total) return amount def release(self, payment): From 9ab4050ff725c02b4f355f9b52f1e3f6d1c735dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:58:16 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- payments/dummy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payments/dummy/__init__.py b/payments/dummy/__init__.py index 0316c4419..f1d77d32b 100644 --- a/payments/dummy/__init__.py +++ b/payments/dummy/__init__.py @@ -68,7 +68,7 @@ def process_data(self, payment, request): def capture(self, payment, amount=None): payment.change_status(PaymentStatus.CONFIRMED) - payment.captured_amount = (amount or payment.total) + payment.captured_amount = amount or payment.total return amount def release(self, payment):