diff --git a/Adyen/__init__.py b/Adyen/__init__.py index 10fbad5e..dab3d02a 100644 --- a/Adyen/__init__.py +++ b/Adyen/__init__.py @@ -25,7 +25,8 @@ AdyenLegalEntityManagementApi, AdyenDataProtectionApi, AdyenTransfersApi, - AdyenStoredValueApi + AdyenStoredValueApi, + AdyenBalancePlatformApi ) from .httpclient import HTTPClient @@ -45,6 +46,7 @@ def __init__(self, **kwargs): self.dataProtection = AdyenDataProtectionApi(client=self.client) self.transfers = AdyenTransfersApi(client=self.client) self.storedValue = AdyenStoredValueApi(client=self.client) + self.balancePlatform = AdyenBalancePlatformApi(client=self.client) _base_adyen_obj = Adyen() @@ -59,4 +61,4 @@ def __init__(self, **kwargs): dataProtection = _base_adyen_obj.dataProtection transfers = _base_adyen_obj.transfers storedValue = _base_adyen_obj.storedValue - +balancePlatform = _base_adyen_obj.balancePlatform diff --git a/Adyen/client.py b/Adyen/client.py index 1e2a2df7..61325a13 100644 --- a/Adyen/client.py +++ b/Adyen/client.py @@ -94,7 +94,8 @@ def __init__( api_legal_entity_management_version=None, api_data_protection_version=None, api_transfers_version=None, - api_stored_value_version=None + api_stored_value_version=None, + api_balance_platform_version=None ): self.username = username self.password = password @@ -126,6 +127,7 @@ def __init__( self.api_data_protection_version = api_data_protection_version or settings.API_DATA_PROTECION_VERSION self.api_transfers_version = api_transfers_version or settings.API_TRANSFERS_VERSION self.api_stored_value_version = api_stored_value_version or settings.API_STORED_VALUE_VERSION + self.api_balance_platform_version = api_balance_platform_version or settings.API_BALANCE_PLATFORM_VERSION def _determine_base_url_and_version(self, platform, service): @@ -191,6 +193,13 @@ def _determine_base_url_and_version(self, platform, service): 'base_url': { 'live': settings.BASE_LEGAL_ENTITY_MANAGEMENT_URL.format(platform), 'test': settings.BASE_LEGAL_ENTITY_MANAGEMENT_URL.format(platform) + }, + }, + 'balancePlatform': { + 'version': self.api_balance_platform_version, + 'base_url': { + 'live': settings.BASE_CONFIGURATION_URL.format(platform), + 'test': settings.BASE_CONFIGURATION_URL.format(platform) } }, 'dataProtection': { @@ -215,6 +224,7 @@ def _determine_base_url_and_version(self, platform, service): } } } + version = versions_and_urls[service]['version'] base_url = versions_and_urls[service]['base_url'][platform] # Match urls that require a live prefix and do not have one diff --git a/Adyen/services/__init__.py b/Adyen/services/__init__.py index d055b4a3..3249bfa5 100644 --- a/Adyen/services/__init__.py +++ b/Adyen/services/__init__.py @@ -10,3 +10,4 @@ from .dataProtection import AdyenDataProtectionApi from .transfers import AdyenTransfersApi from .storedValue import AdyenStoredValueApi +from .balancePlatform import AdyenBalancePlatformApi diff --git a/Adyen/services/balancePlatform/__init__.py b/Adyen/services/balancePlatform/__init__.py new file mode 100644 index 00000000..df8b8042 --- /dev/null +++ b/Adyen/services/balancePlatform/__init__.py @@ -0,0 +1,32 @@ +from ..base import AdyenServiceBase +from .account_holders_api import AccountHoldersApi +from .balance_accounts_api import BalanceAccountsApi +from .bank_account_validation_api import BankAccountValidationApi +from .documents_api import DocumentsApi +from .legal_entities_api import LegalEntitiesApi +from .payment_instrument_groups_api import PaymentInstrumentGroupsApi +from .payment_instruments_api import PaymentInstrumentsApi +from .platform_api import PlatformApi +from .transaction_rules_api import TransactionRulesApi +from .transfer_instruments_api import TransferInstrumentsApi + + +class AdyenBalancePlatformApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(AdyenBalancePlatformApi, self).__init__(client=client) + self.account_holders_api = AccountHoldersApi(client=client) + self.balance_accounts_api = BalanceAccountsApi(client=client) + self.bank_account_validation_api = BankAccountValidationApi(client=client) + self.documents_api = DocumentsApi(client=client) + self.legal_entities_api = LegalEntitiesApi(client=client) + self.payment_instrument_groups_api = PaymentInstrumentGroupsApi(client=client) + self.payment_instruments_api = PaymentInstrumentsApi(client=client) + self.platform_api = PlatformApi(client=client) + self.transaction_rules_api = TransactionRulesApi(client=client) + self.transfer_instruments_api = TransferInstrumentsApi(client=client) diff --git a/Adyen/services/balancePlatform/account_holders_api.py b/Adyen/services/balancePlatform/account_holders_api.py new file mode 100644 index 00000000..7914dd6e --- /dev/null +++ b/Adyen/services/balancePlatform/account_holders_api.py @@ -0,0 +1,46 @@ +from ..base import AdyenServiceBase + + +class AccountHoldersApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(AccountHoldersApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_account_holder(self, id, idempotency_key=None, **kwargs): + """ + Get an account holder + """ + endpoint = f"/accountHolders/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_balance_accounts_of_account_holder(self, id, idempotency_key=None, **kwargs): + """ + Get all balance accounts of an account holder + """ + endpoint = f"/accountHolders/{id}/balanceAccounts" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_account_holder(self, request, id, idempotency_key=None, **kwargs): + """ + Update an account holder + """ + endpoint = f"/accountHolders/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_account_holder(self, request, idempotency_key=None, **kwargs): + """ + Create an account holder + """ + endpoint = f"/accountHolders" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/balance_accounts_api.py b/Adyen/services/balancePlatform/balance_accounts_api.py new file mode 100644 index 00000000..044dad05 --- /dev/null +++ b/Adyen/services/balancePlatform/balance_accounts_api.py @@ -0,0 +1,46 @@ +from ..base import AdyenServiceBase + + +class BalanceAccountsApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(BalanceAccountsApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_balance_account(self, id, idempotency_key=None, **kwargs): + """ + Get a balance account + """ + endpoint = f"/balanceAccounts/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_payment_instruments_for_balance_account(self, id, idempotency_key=None, **kwargs): + """ + Get all payment instruments for a balance account + """ + endpoint = f"/balanceAccounts/{id}/paymentInstruments" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_balance_account(self, request, id, idempotency_key=None, **kwargs): + """ + Update a balance account + """ + endpoint = f"/balanceAccounts/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_balance_account(self, request, idempotency_key=None, **kwargs): + """ + Create a balance account + """ + endpoint = f"/balanceAccounts" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/bank_account_validation_api.py b/Adyen/services/balancePlatform/bank_account_validation_api.py new file mode 100644 index 00000000..bdb07fa0 --- /dev/null +++ b/Adyen/services/balancePlatform/bank_account_validation_api.py @@ -0,0 +1,22 @@ +from ..base import AdyenServiceBase + + +class BankAccountValidationApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(BankAccountValidationApi, self).__init__(client=client) + self.service = "balancePlatform" + + def validate_bank_account_identification(self, request, idempotency_key=None, **kwargs): + """ + Validate a bank account + """ + endpoint = f"/validateBankAccountIdentification" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/documents_api.py b/Adyen/services/balancePlatform/documents_api.py new file mode 100644 index 00000000..b66dd3fc --- /dev/null +++ b/Adyen/services/balancePlatform/documents_api.py @@ -0,0 +1,46 @@ +from ..base import AdyenServiceBase + + +class DocumentsApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(DocumentsApi, self).__init__(client=client) + self.service = "balancePlatform" + + def delete_document(self, id, idempotency_key=None, **kwargs): + """ + Delete a document + """ + endpoint = f"/documents/{id}" + method = "DELETE" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_document(self, id, idempotency_key=None, **kwargs): + """ + Get a document + """ + endpoint = f"/documents/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_document(self, request, id, idempotency_key=None, **kwargs): + """ + Update a document + """ + endpoint = f"/documents/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def upload_document_for_verification_checks(self, request, idempotency_key=None, **kwargs): + """ + Upload a document for verification checks + """ + endpoint = f"/documents" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/legal_entities_api.py b/Adyen/services/balancePlatform/legal_entities_api.py new file mode 100644 index 00000000..76d9f87c --- /dev/null +++ b/Adyen/services/balancePlatform/legal_entities_api.py @@ -0,0 +1,38 @@ +from ..base import AdyenServiceBase + + +class LegalEntitiesApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(LegalEntitiesApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_legal_entity(self, id, idempotency_key=None, **kwargs): + """ + Get a legal entity + """ + endpoint = f"/legalEntities/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_legal_entity(self, request, id, idempotency_key=None, **kwargs): + """ + Update a legal entity + """ + endpoint = f"/legalEntities/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_legal_entity(self, request, idempotency_key=None, **kwargs): + """ + Create a legal entity + """ + endpoint = f"/legalEntities" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/payment_instrument_groups_api.py b/Adyen/services/balancePlatform/payment_instrument_groups_api.py new file mode 100644 index 00000000..3fff153e --- /dev/null +++ b/Adyen/services/balancePlatform/payment_instrument_groups_api.py @@ -0,0 +1,38 @@ +from ..base import AdyenServiceBase + + +class PaymentInstrumentGroupsApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(PaymentInstrumentGroupsApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_payment_instrument_group(self, id, idempotency_key=None, **kwargs): + """ + Get a payment instrument group + """ + endpoint = f"/paymentInstrumentGroups/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_transaction_rules_for_payment_instrument_group(self, id, idempotency_key=None, **kwargs): + """ + Get all transaction rules for a payment instrument group + """ + endpoint = f"/paymentInstrumentGroups/{id}/transactionRules" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_payment_instrument_group(self, request, idempotency_key=None, **kwargs): + """ + Create a payment instrument group + """ + endpoint = f"/paymentInstrumentGroups" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/payment_instruments_api.py b/Adyen/services/balancePlatform/payment_instruments_api.py new file mode 100644 index 00000000..65e4d78e --- /dev/null +++ b/Adyen/services/balancePlatform/payment_instruments_api.py @@ -0,0 +1,54 @@ +from ..base import AdyenServiceBase + + +class PaymentInstrumentsApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(PaymentInstrumentsApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_payment_instrument(self, id, idempotency_key=None, **kwargs): + """ + Get a payment instrument + """ + endpoint = f"/paymentInstruments/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_reveal_information_of_payment_instrument(self, id, idempotency_key=None, **kwargs): + """ + Get the reveal information of a payment instrument + """ + endpoint = f"/paymentInstruments/{id}/reveal" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_transaction_rules_for_payment_instrument(self, id, idempotency_key=None, **kwargs): + """ + Get all transaction rules for a payment instrument + """ + endpoint = f"/paymentInstruments/{id}/transactionRules" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_payment_instrument(self, request, id, idempotency_key=None, **kwargs): + """ + Update a payment instrument + """ + endpoint = f"/paymentInstruments/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_payment_instrument(self, request, idempotency_key=None, **kwargs): + """ + Create a payment instrument + """ + endpoint = f"/paymentInstruments" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/platform_api.py b/Adyen/services/balancePlatform/platform_api.py new file mode 100644 index 00000000..96ca9255 --- /dev/null +++ b/Adyen/services/balancePlatform/platform_api.py @@ -0,0 +1,30 @@ +from ..base import AdyenServiceBase + + +class PlatformApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(PlatformApi, self).__init__(client=client) + self.service = "balancePlatform" + + def get_balance_platform(self, id, idempotency_key=None, **kwargs): + """ + Get a balance platform + """ + endpoint = f"/balancePlatforms/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_account_holders_under_balance_platform(self, id, idempotency_key=None, **kwargs): + """ + Get all account holders under a balance platform + """ + endpoint = f"/balancePlatforms/{id}/accountHolders" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/transaction_rules_api.py b/Adyen/services/balancePlatform/transaction_rules_api.py new file mode 100644 index 00000000..1c58e252 --- /dev/null +++ b/Adyen/services/balancePlatform/transaction_rules_api.py @@ -0,0 +1,46 @@ +from ..base import AdyenServiceBase + + +class TransactionRulesApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(TransactionRulesApi, self).__init__(client=client) + self.service = "balancePlatform" + + def delete_transaction_rule(self, transactionRuleId, idempotency_key=None, **kwargs): + """ + Delete a transaction rule + """ + endpoint = f"/transactionRules/{transactionRuleId}" + method = "DELETE" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_transaction_rule(self, transactionRuleId, idempotency_key=None, **kwargs): + """ + Get a transaction rule + """ + endpoint = f"/transactionRules/{transactionRuleId}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_transaction_rule(self, request, transactionRuleId, idempotency_key=None, **kwargs): + """ + Update a transaction rule + """ + endpoint = f"/transactionRules/{transactionRuleId}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_transaction_rule(self, request, idempotency_key=None, **kwargs): + """ + Create a transaction rule + """ + endpoint = f"/transactionRules" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/services/balancePlatform/transfer_instruments_api.py b/Adyen/services/balancePlatform/transfer_instruments_api.py new file mode 100644 index 00000000..d1383359 --- /dev/null +++ b/Adyen/services/balancePlatform/transfer_instruments_api.py @@ -0,0 +1,46 @@ +from ..base import AdyenServiceBase + + +class TransferInstrumentsApi(AdyenServiceBase): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, client=None): + super(TransferInstrumentsApi, self).__init__(client=client) + self.service = "balancePlatform" + + def delete_transfer_instrument(self, id, idempotency_key=None, **kwargs): + """ + Delete a transfer instrument + """ + endpoint = f"/transferInstruments/{id}" + method = "DELETE" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_transfer_instrument(self, id, idempotency_key=None, **kwargs): + """ + Get a transfer instrument + """ + endpoint = f"/transferInstruments/{id}" + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_transfer_instrument(self, request, id, idempotency_key=None, **kwargs): + """ + Update a transfer instrument + """ + endpoint = f"/transferInstruments/{id}" + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_transfer_instrument(self, request, idempotency_key=None, **kwargs): + """ + Create a transfer instrument + """ + endpoint = f"/transferInstruments" + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + diff --git a/Adyen/settings.py b/Adyen/settings.py index 0b1ceebc..2f8d55aa 100644 --- a/Adyen/settings.py +++ b/Adyen/settings.py @@ -1,5 +1,6 @@ # Those constants are used from the library only BASE_DATA_PROTECION_URL = "https://ca-{}.adyen.com/ca/services/DataProtectionService" +BASE_CONFIGURATION_URL = "https://balanceplatform-api-{}.adyen.com/bcl" BASE_TERMINAL_URL = "https://postfmapi-{}.adyen.com/postfmapi/terminal" BASE_TRANSFERS_URL = "https://balanceplatform-api-{}.adyen.com/btl" BASE_MANAGEMENT_URL = "https://management-{}.adyen.com" @@ -11,6 +12,7 @@ ENDPOINT_CHECKOUT_LIVE_SUFFIX = "https://{live_prefix}-checkout-live" \ ".adyenpayments.com/checkout" BASE_STORED_VALUE_URL = "https://pal-{}.adyen.com/pal/servlet/StoredValue" +API_BALANCE_PLATFORM_VERSION = "v1" API_BIN_LOOKUP_VERSION = "v52" API_CHECKOUT_VERSION = "v70" API_CHECKOUT_UTILITY_VERSION = "v1" diff --git a/Makefile b/Makefile index ad38790d..f9455c98 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ recurring: spec=RecurringService-v68 payouts: spec=PayoutService-v68 management: spec=ManagementService-v1 legalEntityManagement: spec=LegalEntityService-v2 -balancePlatform: spec=BalancePlatformService-v2 +balancePlatform: spec=BalancePlatformService-v1 platformsAccount: spec=AccountService-v6 platformsFund: spec=FundService-v6 platformsNotificationConfiguration: spec=NotificationConfigurationService-v6 diff --git a/test/ConfigurationTest.py b/test/ConfigurationTest.py new file mode 100644 index 00000000..3953ccfc --- /dev/null +++ b/test/ConfigurationTest.py @@ -0,0 +1,119 @@ +import Adyen +import unittest +from Adyen import settings + +try: + from BaseTest import BaseTest +except ImportError: + from .BaseTest import BaseTest + + +class TestManagement(unittest.TestCase): + adyen = Adyen.Adyen() + + client = adyen.client + test = BaseTest(adyen) + client.xapikey = "YourXapikey" + client.platform = "test" + balance_platform_version = settings.API_BALANCE_PLATFORM_VERSION + + def test_creating_balance_account(self): + request = { + "accountHolderId": "AH32272223222B59K6ZKBBFNQ", + "description": "S.Hopper - Main balance account" + } + self.adyen.client = self.test.create_client_from_file(200, request, + "test/mocks/configuration/" + "balance-account-created.json") + result = self.adyen.balancePlatform.balance_accounts_api.create_balance_account(request) + self.assertEqual('AH32272223222B59K6ZKBBFNQ', result.message['accountHolderId']) + self.adyen.client.http_client.request.assert_called_once_with( + 'POST', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/balanceAccounts', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=request, + xapikey="YourXapikey" + ) + + def test_creating_account_holder(self): + request = { + "description": "Liable account holder used for international payments and payouts", + "reference": "S.Eller-001", + "legalEntityId": "LE322JV223222D5GG42KN6869" + } + self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/configuration/" + "account-holder-created.json") + result = self.adyen.balancePlatform.account_holders_api.create_account_holder(request) + self.assertEqual("LE322JV223222D5GG42KN6869", result.message['legalEntityId']) + self.adyen.client.http_client.request.assert_called_once_with( + 'POST', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/accountHolders', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=request, + xapikey="YourXapikey" + ) + + def test_get_balance_platform(self): + platform_id = "YOUR_BALANCE_PLATFORM" + self.adyen.client = self.test.create_client_from_file(200, None, "test/mocks/configuration/" + "balance-platform-retrieved.json") + result = self.adyen.balancePlatform.platform_api.get_balance_platform(platform_id) + self.assertEqual(platform_id, result.message['id']) + self.adyen.client.http_client.request.assert_called_once_with( + 'GET', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/balancePlatforms/{platform_id}', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=None, + xapikey="YourXapikey" + ) + + def test_creating_payment_instrument(self): + request = { + "type": "bankAccount", + "description": "YOUR_DESCRIPTION", + "balanceAccountId": "BA3227C223222B5CTBLR8BWJB", + "issuingCountryCode": "NL" + } + self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/configuration/" + "business-account-created.json") + result = self.adyen.balancePlatform.payment_instruments_api.create_payment_instrument(request) + self.assertEqual("BA3227C223222B5CTBLR8BWJB", result.message["balanceAccountId"]) + self.adyen.client.http_client.request.assert_called_once_with( + 'POST', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/paymentInstruments', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=request, + xapikey="YourXapikey" + ) + + def test_creating_payment_instrument_group(self): + request = { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "txVariant": "mc" + } + self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/configuration/" + "payment-instrument-group-created.json") + result = self.adyen.balancePlatform.payment_instrument_groups_api.create_payment_instrument_group(request) + self.assertEqual("YOUR_BALANCE_PLATFORM", result.message['balancePlatform']) + self.adyen.client.http_client.request.assert_called_once_with( + 'POST', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/paymentInstrumentGroups', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=request, + xapikey="YourXapikey" + ) + + def test_get_transaction_rule(self): + transactionRuleId = "TR32272223222B5CMD3V73HXG" + self.adyen.client = self.test.create_client_from_file(200, {}, "test/mocks/configuration/" + "transaction-rule-retrieved.json") + result = self.adyen.balancePlatform.transaction_rules_api.get_transaction_rule(transactionRuleId) + self.assertEqual(transactionRuleId, result.message['transactionRule']['id']) + self.adyen.client.http_client.request.assert_called_once_with( + 'GET', + f'https://balanceplatform-api-test.adyen.com/bcl/{self.balance_platform_version}/' + f'transactionRules/{transactionRuleId}', + headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION}, + json=None, + xapikey="YourXapikey" + ) diff --git a/test/mocks/configuration/account-holder-created.json b/test/mocks/configuration/account-holder-created.json new file mode 100644 index 00000000..ce411695 --- /dev/null +++ b/test/mocks/configuration/account-holder-created.json @@ -0,0 +1,34 @@ +{ + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "description": "Liable account holder used for international payments and payouts", + "legalEntityId": "LE322JV223222D5GG42KN6869", + "reference": "S.Eller-001", + "capabilities": { + "receiveFromPlatformPayments": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "receiveFromBalanceAccount": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "sendToBalanceAccount": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "sendToTransferInstrument": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + } + }, + "id": "AH3227C223222D5HCNS646PW8", + "status": "active" +} \ No newline at end of file diff --git a/test/mocks/configuration/balance-account-created.json b/test/mocks/configuration/balance-account-created.json new file mode 100644 index 00000000..55a24260 --- /dev/null +++ b/test/mocks/configuration/balance-account-created.json @@ -0,0 +1,15 @@ +{ + "accountHolderId": "AH32272223222B59K6ZKBBFNQ", + "defaultCurrencyCode": "EUR", + "reference": "S.Hopper - Main balance account", + "balances": [ + { + "available": 0, + "balance": 0, + "currency": "EUR", + "reserved": 0 + } + ], + "id": "BA32272223222B59CZ3T52DKZ", + "status": "active" +} \ No newline at end of file diff --git a/test/mocks/configuration/balance-platform-retrieved.json b/test/mocks/configuration/balance-platform-retrieved.json new file mode 100644 index 00000000..fbacdf6f --- /dev/null +++ b/test/mocks/configuration/balance-platform-retrieved.json @@ -0,0 +1,4 @@ +{ + "id": "YOUR_BALANCE_PLATFORM", + "status": "Active" +} \ No newline at end of file diff --git a/test/mocks/configuration/business-account-created.json b/test/mocks/configuration/business-account-created.json new file mode 100644 index 00000000..4c6ee55e --- /dev/null +++ b/test/mocks/configuration/business-account-created.json @@ -0,0 +1,10 @@ +{ + "balanceAccountId": "BA3227C223222B5CTBLR8BWJB", + "issuingCountryCode": "NL", + "status": "Active", + "type": "bankAccount", + "bankAccount": { + "iban": "NL20ADYB2017000035" + }, + "id": "PI322LJ223222B5DJS7CD9LWL" +} \ No newline at end of file diff --git a/test/mocks/configuration/payment-instrument-group-created.json b/test/mocks/configuration/payment-instrument-group-created.json new file mode 100644 index 00000000..09ebbd43 --- /dev/null +++ b/test/mocks/configuration/payment-instrument-group-created.json @@ -0,0 +1,5 @@ +{ + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "txVariant": "mc", + "id": "PG3227C223222B5CMD3FJFKGZ" +} \ No newline at end of file diff --git a/test/mocks/configuration/transaction-rule-retrieved.json b/test/mocks/configuration/transaction-rule-retrieved.json new file mode 100644 index 00000000..8477e371 --- /dev/null +++ b/test/mocks/configuration/transaction-rule-retrieved.json @@ -0,0 +1,15 @@ +{ + "transactionRule": { + "description": "Allow 5 transactions per month", + "interval": { + "type": "monthly" + }, + "maxTransactions": 5, + "paymentInstrumentId": "PI3227C223222B59KGTXP884R", + "reference": "myRule12345", + "startDate": "2021-01-25T12:46:35", + "status": "active", + "type": "velocity", + "id": "TR32272223222B5CMD3V73HXG" + } +} \ No newline at end of file