From 9ebf57e1d2742753a1192b4a5700a88d8025453f Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Thu, 9 Jan 2020 12:14:05 +0100 Subject: [PATCH 01/10] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..17a0592c --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at support@adyen.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq From 68ae3973c58deb86e4d41f10b76c2efcf38738bd Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Thu, 6 Feb 2020 11:49:56 +0100 Subject: [PATCH 02/10] Preserve provided ApplicationInfo (#99) * Preserve provided ApplicationInfo * Fix typo --- Adyen/client.py | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Adyen/client.py b/Adyen/client.py index b986413a..cd22c367 100644 --- a/Adyen/client.py +++ b/Adyen/client.py @@ -288,13 +288,22 @@ def call_api(self, request_data, service, action, idempotency=False, if not message.get('merchantAccount'): message['merchantAccount'] = self.merchant_account + # Add application info - request_data['applicationInfo'] = { - "adyenLibrary": { - "name": settings.LIB_NAME, - "version": settings.LIB_VERSION + if 'applicationInfo' in request_data: + request_data['applicationInfo'].update({ + "adyenLibrary": { + "name": settings.LIB_NAME, + "version": settings.LIB_VERSION + } + }) + else: + request_data['applicationInfo'] = { + "adyenLibrary": { + "name": settings.LIB_NAME, + "version": settings.LIB_VERSION + } } - } # Adyen requires this header to be set and uses the combination of # merchant account and merchant reference to determine uniqueness. headers = {} @@ -443,12 +452,20 @@ def call_checkout_api(self, request_data, action, **kwargs): if not request_data.get('merchantAccount'): request_data['merchantAccount'] = self.merchant_account - request_data['applicationInfo'] = { - "adyenLibrary": { - "name": settings.LIB_NAME, - "version": settings.LIB_VERSION + if 'applicationInfo' in request_data: + request_data['applicationInfo'].update({ + "adyenLibrary": { + "name": settings.LIB_NAME, + "version": settings.LIB_VERSION + } + }) + else: + request_data['applicationInfo'] = { + "adyenLibrary": { + "name": settings.LIB_NAME, + "version": settings.LIB_VERSION + } } - } # Adyen requires this header to be set and uses the combination of # merchant account and merchant reference to determine uniqueness. headers = {} From 7e539a538255450e1343bdc89ef18c1e354d4022 Mon Sep 17 00:00:00 2001 From: Alessio Zampatti Date: Fri, 27 Mar 2020 13:55:14 +0100 Subject: [PATCH 03/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d9299b7..1227d210 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ ady.payment.client.app_name = "your app name" ## Documentation * https://docs.adyen.com/developers/development-resources/libraries -* https://docs.adyen.com/developers/checkout/api-integration +* https://docs.adyen.com/developers/checkout ## Support If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com. From c75af72e5717f687f38ce179d981e7ad072e7683 Mon Sep 17 00:00:00 2001 From: Daniel Duque Date: Mon, 6 Apr 2020 18:28:40 +0200 Subject: [PATCH 04/10] Add HMAC signature calculation for webhooks --- Adyen/util.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ test/UtilTest.py | 40 +++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/Adyen/util.py b/Adyen/util.py index 580ff314..6156876d 100644 --- a/Adyen/util.py +++ b/Adyen/util.py @@ -44,3 +44,53 @@ def is_valid_hmac(dict_object, hmac_key): merchant_sign = generate_hpp_sig(dict_object, hmac_key) merchant_sign_str = merchant_sign.decode("utf-8") return merchant_sign_str == expected_sign + + +def generate_notification_sig(dict_object, hmac_key): + if 'issuerId' in dict_object: + if dict_object['issuerId'] == "": + del dict_object['issuerId'] + + if not isinstance(dict_object, dict): + raise ValueError("Must Provide dictionary object") + + def escape_val(val): + if isinstance(val, int): + return val + return val.replace('\\', '\\\\').replace(':', '\\:') + + hmac_key = binascii.a2b_hex(hmac_key) + + request_dict = dict(dict_object) + request_dict['value'] = request_dict['amount']['value'] + request_dict['currency'] = request_dict['amount']['currency'] + + element_orders = [ + 'pspReference', + 'originalReference', + 'merchantAccountCode', + 'merchantReference', + 'value', + 'currency', + 'eventCode', + 'success', + ] + + signing_string = ':'.join( + map(escape_val, map(str, ( + request_dict.get(element, '') for element in element_orders)))) + + hm = hmac.new(hmac_key, signing_string.encode('utf-8'), hashlib.sha256) + return base64.b64encode(hm.digest()) + + +def is_valid_hmac_notification(dict_object, hmac_key): + if 'additionalData' in dict_object: + if dict_object['additionalData']['hmacSignature'] == "": + raise ValueError("Must Provide hmacSignature in additionalData") + else: + expected_sign = dict_object['additionalData']['hmacSignature'] + del dict_object['additionalData'] + merchant_sign = generate_notification_sig(dict_object, hmac_key) + merchant_sign_str = merchant_sign.decode("utf-8") + return merchant_sign_str == expected_sign diff --git a/test/UtilTest.py b/test/UtilTest.py index acaf1012..9cd9b334 100644 --- a/test/UtilTest.py +++ b/test/UtilTest.py @@ -1,15 +1,19 @@ import unittest import Adyen -from Adyen import generate_hpp_sig -from Adyen.util import is_valid_hmac +from Adyen.util import ( + generate_hpp_sig, + is_valid_hmac, + generate_notification_sig, + is_valid_hmac_notification, +) class UtilTest(unittest.TestCase): ady = Adyen.Adyen() client = ady.client - def test_notification_request_item_hmac(self): + def test_hpp_request_item_hmac(self): request = { "pspReference": "pspReference", "originalReference": "originalReference", @@ -31,3 +35,33 @@ def test_notification_request_item_hmac(self): request['additionalData'] = {'hmacSignature': hmac_calculation_str} hmac_validate = is_valid_hmac(request, key) self.assertTrue(hmac_validate) + + def test_notification_request_item_hmac(self): + request = { + "pspReference": "7914073381342284", + "merchantReference": "TestPayment-1407325143704", + "merchantAccountCode": "TestMerchant", + "amount": { + "currency": "EUR", + "value": 1130 + }, + "eventCode": "AUTHORISATION", + "success": "true", + "eventDate": "2019-05-06T17:15:34.121+02:00", + "operations": [ + "CANCEL", + "CAPTURE", + "REFUND" + ], + "paymentMethod": "visa", + } + key = "44782DEF547AAA06C910C43932B1EB0C" \ + "71FC68D9D0C057550C48EC2ACF6BA056" + hmac_calculation = generate_notification_sig(request, key) + hmac_calculation_str = hmac_calculation.decode("utf-8") + expected_hmac = "coqCmt/IZ4E3CzPvMY8zTjQVL5hYJUiBRg8UU+iCWo0=" + self.assertTrue(hmac_calculation_str != "") + self.assertEqual(hmac_calculation_str, expected_hmac) + request['additionalData'] = {'hmacSignature': hmac_calculation_str} + hmac_validate = is_valid_hmac_notification(request, key) + self.assertTrue(hmac_validate) From 372def7a70e3e036b8598b381e00d9f0bf543aea Mon Sep 17 00:00:00 2001 From: Ohad Benita <30605246+ohadbenita@users.noreply.github.com> Date: Mon, 11 May 2020 14:18:15 +0300 Subject: [PATCH 05/10] BinLookup: Add getCostEstimate. (#106) Add support for getCostEstimate which is one of the two APIs exposed by the BinLookup service. --- Adyen/__init__.py | 6 +- Adyen/services.py | 23 ++++++ test/mocks/BinLookupTest.py | 81 +++++++++++++++++++ ...etcostestimate-error-invalid-data-422.json | 6 ++ .../binlookup/getcostestimate-success.json | 19 +++++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 test/mocks/BinLookupTest.py create mode 100644 test/mocks/binlookup/getcostestimate-error-invalid-data-422.json create mode 100644 test/mocks/binlookup/getcostestimate-success.json diff --git a/Adyen/__init__.py b/Adyen/__init__.py index 03a00f75..413bb8d2 100644 --- a/Adyen/__init__.py +++ b/Adyen/__init__.py @@ -15,11 +15,13 @@ from .client import AdyenClient from .services import ( AdyenBase, + AdyenBinLookup, AdyenRecurring, AdyenPayment, AdyenThirdPartyPayout, AdyenHPP, - AdyenCheckoutApi) + AdyenCheckoutApi +) from .httpclient import HTTPClient @@ -28,6 +30,7 @@ class Adyen(AdyenBase): def __init__(self, **kwargs): self.client = AdyenClient(**kwargs) self.payment = AdyenPayment(client=self.client) + self.binlookup = AdyenBinLookup(client=self.client) self.payout = AdyenThirdPartyPayout(client=self.client) self.hpp = AdyenHPP(client=self.client) self.recurring = AdyenRecurring(client=self.client) @@ -40,3 +43,4 @@ def __init__(self, **kwargs): payment = _base_adyen_obj.payment payout = _base_adyen_obj.payout checkout = _base_adyen_obj.checkout +binlookup = _base_adyen_obj.binlookup diff --git a/Adyen/services.py b/Adyen/services.py index 470508b1..515c87cb 100644 --- a/Adyen/services.py +++ b/Adyen/services.py @@ -315,3 +315,26 @@ def payment_result(self, request="", **kwargs): def origin_keys(self, request="", **kwargs): action = "originKeys" return self.client.call_checkout_api(request, action, **kwargs) + + +class AdyenBinLookup(AdyenServiceBase): + """This represents the Adyen API Bin Lookup service. + + API call currently implemented: getCostEstimate. + Please refer to the Bin Lookup Manual for specifics around the API. + https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview + + Args: + client (AdyenAPIClient, optional): An API client for the service to + use. If not provided, a new API client will be created. + """ + + def __init__(self, client=None): + super(AdyenBinLookup, self).__init__(client=client) + self.service = "BinLookup" + + def get_cost_estimate(self, request="", **kwargs): + + action = "getCostEstimate" + + return self.client.call_api(request, self.service, action, **kwargs) diff --git a/test/mocks/BinLookupTest.py b/test/mocks/BinLookupTest.py new file mode 100644 index 00000000..9ace1fa1 --- /dev/null +++ b/test/mocks/BinLookupTest.py @@ -0,0 +1,81 @@ +import Adyen +import unittest +from BaseTest import BaseTest + + +class TestBinLookup(unittest.TestCase): + ady = Adyen.Adyen() + + client = ady.client + test = BaseTest(ady) + client.username = "YourWSUser" + client.password = "YourWSPassword" + client.platform = "test" + client.app_name = "appname" + + def test_get_cost_estimate_success(self): + request = { + 'merchantAccount': 'YourMerchantAccount', + 'amount': '1000' + } + + expected = { + 'cardBin': { + 'bin': '458012', + 'commercial': False, + 'fundingSource': 'CHARGE', + 'fundsAvailability': 'N', + 'issuingBank': 'Bank Of America', + 'issuingCountry': 'US', 'issuingCurrency': 'USD', + 'paymentMethod': 'Y', + 'summary': '6789' + }, + 'costEstimateAmount': { + 'currency': 'USD', 'value': 1234 + }, + 'resultCode': 'Success', + 'surchargeType': 'PASSTHROUGH' + } + + self.ady.client = self.test.create_client_from_file( + status=200, + request=request, + filename='test/mocks/binlookup/getcostestimate-success.json' + ) + + result = self.ady.binlookup.get_cost_estimate(request) + self.assertEqual(expected, result.message) + + def test_get_cost_estimate_error_mocked(self): + request = { + 'merchantAccount': 'YourMerchantAccount', + 'amount': '1000' + } + + self.ady.client = self.test.create_client_from_file( + status=200, + request=request, + filename=( + "test/mocks/binlookup/" + "getcostestimate-error-invalid-data-422.json" + ) + ) + + result = self.ady.binlookup.get_cost_estimate(request) + self.assertEqual(422, result.message['status']) + self.assertEqual("101", result.message['errorCode']) + self.assertEqual("Invalid card number", result.message['message']) + self.assertEqual("validation", result.message['errorType']) + + +TestBinLookup.client.http_force = "requests" +suite = unittest.TestLoader().loadTestsFromTestCase(TestBinLookup) +unittest.TextTestRunner(verbosity=2).run(suite) +TestBinLookup.client.http_force = "pycurl" +TestBinLookup.client.http_init = False +suite = unittest.TestLoader().loadTestsFromTestCase(TestBinLookup) +unittest.TextTestRunner(verbosity=2).run(suite) +TestBinLookup.client.http_force = "other" +TestBinLookup.client.http_init = False +suite = unittest.TestLoader().loadTestsFromTestCase(TestBinLookup) +unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/test/mocks/binlookup/getcostestimate-error-invalid-data-422.json b/test/mocks/binlookup/getcostestimate-error-invalid-data-422.json new file mode 100644 index 00000000..ce814f1e --- /dev/null +++ b/test/mocks/binlookup/getcostestimate-error-invalid-data-422.json @@ -0,0 +1,6 @@ +{ + "status": 422, + "errorCode": "101", + "message": "Invalid card number", + "errorType": "validation" +} \ No newline at end of file diff --git a/test/mocks/binlookup/getcostestimate-success.json b/test/mocks/binlookup/getcostestimate-success.json new file mode 100644 index 00000000..45affc97 --- /dev/null +++ b/test/mocks/binlookup/getcostestimate-success.json @@ -0,0 +1,19 @@ +{ + "cardBin": { + "bin": "458012", + "commercial": false, + "fundingSource": "CHARGE", + "fundsAvailability": "N", + "issuingBank": "Bank Of America", + "issuingCountry": "US", + "issuingCurrency": "USD", + "paymentMethod": "Y", + "summary": "6789" + }, + "costEstimateAmount": { + "currency": "USD", + "value": 1234 + }, + "resultCode": "Success", + "surchargeType": "PASSTHROUGH" +} From dacd0b180513e43040e53f1b1fed3768411eef50 Mon Sep 17 00:00:00 2001 From: Patrick van der Leer Date: Mon, 11 May 2020 16:36:49 +0200 Subject: [PATCH 06/10] Bunch of fixes (#105) * Fixes numerous non-optional parameters * Fixes PEP8 violations in client * Fixes import with backwards compt. * Re-formatted a bunch of tests * Fixes DeprecationWarning for assertRaisesRegexp * Quick and dirty fix for user_agent when empty app_name * Fixes E127 over in test/PaymentTest --- Adyen/client.py | 15 +- Adyen/httpclient.py | 2 + Adyen/services.py | 38 ++--- test/CheckoutTest.py | 6 +- test/CheckoutUtilityTest.py | 9 +- test/DetermineEndpointTest.py | 34 ++-- test/DirectoryLookupTest.py | 49 +++--- test/ModificationTest.py | 7 +- test/PaymentTest.py | 32 ++-- test/RecurringTest.py | 7 +- test/ThirdPartyPayoutTest.py | 283 ++++++++++++++++++---------------- 11 files changed, 268 insertions(+), 214 deletions(-) diff --git a/Adyen/client.py b/Adyen/client.py index cd22c367..353e3326 100644 --- a/Adyen/client.py +++ b/Adyen/client.py @@ -93,7 +93,8 @@ def __init__(self, username=None, password=None, xapikey=None, self.http_force = http_force self.live_endpoint_prefix = live_endpoint_prefix - def _determine_api_url(self, platform, service, action): + @staticmethod + def _determine_api_url(platform, service, action): """This returns the Adyen API endpoint based on the provided platform, service and action. @@ -111,7 +112,8 @@ def _determine_api_url(self, platform, service, action): api_version = settings.API_PAYMENT_VERSION return '/'.join([base_uri, service, api_version, action]) - def _determine_hpp_url(self, platform, action): + @staticmethod + def _determine_hpp_url(platform, action): """This returns the Adyen HPP endpoint based on the provided platform, and action. @@ -144,6 +146,9 @@ def _determine_checkout_url(self, platform, action): by running 'settings. ENDPOINT_CHECKOUT_LIVE_SUFFIX = 'Your live suffix'""" raise AdyenEndpointInvalidFormat(errorstring) + else: + raise AdyenEndpointInvalidFormat("invalid config") + if action == "paymentsDetails": action = "payments/details" if action == "paymentsResult": @@ -272,6 +277,7 @@ def call_api(self, request_data, service, action, idempotency=False, # platform at self object has highest priority. fallback to root module # and ensure that it is set to either 'live' or 'test'. + platform = None if self.platform: platform = self.platform elif 'platform' in kwargs: @@ -425,6 +431,7 @@ def call_checkout_api(self, request_data, action, **kwargs): # xapi at self object has highest priority. fallback to root module # and ensure that it is set. + xapikey = False if self.xapikey: xapikey = self.xapikey elif 'xapikey' in kwargs: @@ -437,6 +444,7 @@ def call_checkout_api(self, request_data, action, **kwargs): # platform at self object has highest priority. fallback to root module # and ensure that it is set to either 'live' or 'test'. + platform = None if self.platform: platform = self.platform elif 'platform' in kwargs: @@ -716,7 +724,8 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref, psp=psp_ref, headers=headers, error_code=response_obj.get("errorCode")) - def _error_from_hpp(self, html): + @staticmethod + def _error_from_hpp(html): # Must be updated when Adyen response is changed: match_obj = re.search(r'>Error:\s*(.*?) Date: Wed, 13 May 2020 07:22:03 +0200 Subject: [PATCH 07/10] update readme with a link to contact support --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1227d210..f7a5edc3 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ ady.payment.client.app_name = "your app name" * https://docs.adyen.com/developers/checkout ## Support -If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com. +If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420). ## Contributing We strongly encourage you to join us in contributing to this repository so everyone can benefit from: From 4bea519ef062f9bd33b8573455d6a903c6e580f1 Mon Sep 17 00:00:00 2001 From: alessio Date: Fri, 15 May 2020 15:53:59 +0200 Subject: [PATCH 08/10] Update version to 2.3.0 --- Adyen/settings.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Adyen/settings.py b/Adyen/settings.py index 49a09c7e..26c4d9c6 100644 --- a/Adyen/settings.py +++ b/Adyen/settings.py @@ -9,5 +9,5 @@ API_RECURRING_VERSION = "v25" API_PAYMENT_VERSION = "v49" API_PAYOUT_VERSION = "v30" -LIB_VERSION = "2.2.0" +LIB_VERSION = "2.3.0" LIB_NAME = "adyen-python-api-library" diff --git a/setup.py b/setup.py index 4d942233..6d849ab0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Adyen', packages=['Adyen'], - version='2.2.0', + version='2.3.0', maintainer='Adyen', maintainer_email='support@adyen.com', description='Adyen Python Api', From 5b5539f37be00f373cd724478f8a60625ce47334 Mon Sep 17 00:00:00 2001 From: alessio Date: Mon, 18 May 2020 10:07:44 +0200 Subject: [PATCH 09/10] Revert to assertRaisesRegexp for temporary python 2 compatibility --- test/ModificationTest.py | 2 +- test/PaymentTest.py | 4 ++-- test/RecurringTest.py | 2 +- test/ThirdPartyPayoutTest.py | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/ModificationTest.py b/test/ModificationTest.py index f341030a..21ed10d2 100644 --- a/test/ModificationTest.py +++ b/test/ModificationTest.py @@ -39,7 +39,7 @@ def test_capture_error_167(self): 'test/mocks/' 'capture-error-167' '.json') - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.payment.capture, diff --git a/test/PaymentTest.py b/test/PaymentTest.py index a2a6c021..33305563 100644 --- a/test/PaymentTest.py +++ b/test/PaymentTest.py @@ -194,7 +194,7 @@ def test_error_401_mocked(self): 'authorise' '-error-' '010.json') - self.assertRaisesRegex(Adyen.AdyenAPIAuthenticationError, + self.assertRaisesRegexp(Adyen.AdyenAPIAuthenticationError, "Unable to authenticate with Adyen's Servers." " Please verify the credentials set with the" " Adyen base class. Please reach out to your" @@ -389,7 +389,7 @@ def test_error_401_mocked(self): 'authorise' '-error-' '010.json') - self.assertRaisesRegex(Adyen.AdyenAPIAuthenticationError, + self.assertRaisesRegexp(Adyen.AdyenAPIAuthenticationError, "Unable to authenticate with Adyen's Servers." " Please verify the credentials set with the" " Adyen base class. Please reach out to your" diff --git a/test/RecurringTest.py b/test/RecurringTest.py index 09406312..bebf91b6 100644 --- a/test/RecurringTest.py +++ b/test/RecurringTest.py @@ -63,7 +63,7 @@ def test_disable_803(self): 'recurring/' 'disable-error-803' '.json') - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.recurring.disable, diff --git a/test/ThirdPartyPayoutTest.py b/test/ThirdPartyPayoutTest.py index 614ad12b..ed0a278b 100644 --- a/test/ThirdPartyPayoutTest.py +++ b/test/ThirdPartyPayoutTest.py @@ -40,7 +40,7 @@ def test_confirm_missing_reference(self): } resp = 'test/mocks/payout/confirm-missing-reference.json' self.ady.client = self.test.create_client_from_file(500, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPIValidationError, "Received validation error with errorCode: 702," " message: Required field 'merchantAccount' is null," @@ -68,7 +68,7 @@ def test_decline_missing_reference(self): } resp = 'test/mocks/payout/decline-missing-reference.json' self.ady.client = self.test.create_client_from_file(500, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPIValidationError, "Received validation error with errorCode: 702," " message: Required field 'merchantAccount' is null," @@ -140,7 +140,7 @@ def test_submit_invalid_recurring_reference(self): } resp = 'test/mocks/payout/submit-invalid-reference.json' self.ady.client = self.test.create_client_from_file(422, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.payout.submit, @@ -169,7 +169,7 @@ def test_store_detail_and_submit_missing_reference(self): resp = 'test/mocks/payout/submit-missing-reference.json' self.ady.client = self.test.create_client_from_file(422, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.payout.store_detail_and_submit, @@ -192,7 +192,7 @@ def test_store_detail_and_submit_missing_payment(self): } resp = 'test/mocks/payout/storeDetailAndSubmit-missing-payment.json' self.ady.client = self.test.create_client_from_file(422, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.payout.store_detail_and_submit, @@ -220,7 +220,7 @@ def test_store_detail_and_submit_invalid_iban(self): } resp = 'test/mocks/payout/storeDetailAndSubmit-invalid-iban.json' self.ady.client = self.test.create_client_from_file(422, request, resp) - self.assertRaisesRegex( + self.assertRaisesRegexp( Adyen.AdyenAPICommunicationError, "Unexpected error", self.ady.payout.store_detail_and_submit, From 167314d56052fd6b23014315944367f0cb1a979e Mon Sep 17 00:00:00 2001 From: alessio Date: Mon, 18 May 2020 10:22:56 +0200 Subject: [PATCH 10/10] Fix indentation codestyle --- test/PaymentTest.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/PaymentTest.py b/test/PaymentTest.py index 33305563..82c06545 100644 --- a/test/PaymentTest.py +++ b/test/PaymentTest.py @@ -195,11 +195,11 @@ def test_error_401_mocked(self): '-error-' '010.json') self.assertRaisesRegexp(Adyen.AdyenAPIAuthenticationError, - "Unable to authenticate with Adyen's Servers." - " Please verify the credentials set with the" - " Adyen base class. Please reach out to your" - " Adyen Admin if the problem persists", - self.adyen.payment.authorise, request) + "Unable to authenticate with Adyen's Servers." + " Please verify the credentials set with the" + " Adyen base class. Please reach out to your" + " Adyen Admin if the problem persists", + self.adyen.payment.authorise, request) class TestPaymentsWithXapiKey(unittest.TestCase): @@ -390,11 +390,11 @@ def test_error_401_mocked(self): '-error-' '010.json') self.assertRaisesRegexp(Adyen.AdyenAPIAuthenticationError, - "Unable to authenticate with Adyen's Servers." - " Please verify the credentials set with the" - " Adyen base class. Please reach out to your" - " Adyen Admin if the problem persists", - self.adyen.payment.authorise, request) + "Unable to authenticate with Adyen's Servers." + " Please verify the credentials set with the" + " Adyen base class. Please reach out to your" + " Adyen Admin if the problem persists", + self.adyen.payment.authorise, request) TestPayments.client.http_force = "requests"