From 165299eea551bbcc840e61d6a1bcec57eb9fac43 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Mar 2021 17:17:13 +0100 Subject: [PATCH 1/3] Add support for adjustAuthorisation verb Based on https://github.com/Adyen/adyen-python-api-library/pull/113 by @shtouff --- Adyen/services.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Adyen/services.py b/Adyen/services.py index 81b40ee9..0237282c 100644 --- a/Adyen/services.py +++ b/Adyen/services.py @@ -128,6 +128,7 @@ class AdyenPayment(AdyenServiceBase): API calls currently implemented: authorise authorise3d + adjustAuthorisation cancel capture refund @@ -170,6 +171,12 @@ def authorise3d(self, request, idempotency_key=None, **kwargs): return self.client.call_api(request, self.service, action, idempotency_key, **kwargs) + def adjustAuthorisation(self, request, **kwargs): + action = "adjustAuthorisation" + + return self.client.call_api(request, self.service, + action, **kwargs) + def cancel(self, request, idempotency_key=None, **kwargs): action = "cancel" From 7f554f89bfe548de35e12d04ec0212e048d7eec9 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Apr 2021 16:06:30 +0200 Subject: [PATCH 2/3] Test adjustAuthorisation --- test/ModificationTest.py | 13 +++++++++++++ test/mocks/adjust-authorisation-received.json | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 test/mocks/adjust-authorisation-received.json diff --git a/test/ModificationTest.py b/test/ModificationTest.py index 153a97c5..2d96a79f 100644 --- a/test/ModificationTest.py +++ b/test/ModificationTest.py @@ -83,6 +83,19 @@ def test_cancel_received(self): result = self.ady.payment.cancel(request) self.assertEqual("[cancel-received]", result.message['response']) + def test_adjust_authorisation_received(self): + request = {} + request['merchantAccount'] = "YourMerchantAccount" + request['reference'] = "YourReference" + request['modificationAmount'] = {"value": "1234", "currency": "EUR"} + request['originalReference'] = "YourOriginalReference" + self.ady.client = self.test.create_client_from_file(200, request, + 'test/mocks/' + 'adjust-authorisation-received' + '.json') + result = self.ady.payment.adjustAuthorisation(request) + self.assertEqual("[adjustAuthorisation-received]", result.message['response']) + TestModifications.client.http_force = "requests" suite = unittest.TestLoader().loadTestsFromTestCase(TestModifications) diff --git a/test/mocks/adjust-authorisation-received.json b/test/mocks/adjust-authorisation-received.json new file mode 100644 index 00000000..618958f0 --- /dev/null +++ b/test/mocks/adjust-authorisation-received.json @@ -0,0 +1,4 @@ +{ + "pspReference": "PSP_REFERENCE", + "response": "[adjustAuthorisation-received]" +} \ No newline at end of file From 3fd8bdc6d14acd45a02fac78a5b69a81dc4e2541 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Apr 2021 16:29:46 +0200 Subject: [PATCH 3/3] Fix E501: lines too long --- test/ModificationTest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/ModificationTest.py b/test/ModificationTest.py index 2d96a79f..a20b03a1 100644 --- a/test/ModificationTest.py +++ b/test/ModificationTest.py @@ -91,10 +91,12 @@ def test_adjust_authorisation_received(self): request['originalReference'] = "YourOriginalReference" self.ady.client = self.test.create_client_from_file(200, request, 'test/mocks/' - 'adjust-authorisation-received' - '.json') + 'adjust-' + 'authorisation-' + 'received.json') result = self.ady.payment.adjustAuthorisation(request) - self.assertEqual("[adjustAuthorisation-received]", result.message['response']) + self.assertEqual("[adjustAuthorisation-received]", + result.message['response']) TestModifications.client.http_force = "requests"