diff --git a/Adyen/__init__.py b/Adyen/__init__.py index 3f04f79c..a0f8c93f 100644 --- a/Adyen/__init__.py +++ b/Adyen/__init__.py @@ -21,7 +21,8 @@ AdyenThirdPartyPayout, AdyenManagementApi, AdyenCheckoutApi, - AdyenTerminal + AdyenTerminal, + AdyenLegalEntityManagementApi ) from .httpclient import HTTPClient @@ -37,6 +38,7 @@ def __init__(self, **kwargs): self.checkout = AdyenCheckoutApi(client=self.client) self.terminal = AdyenTerminal(client=self.client) self.management = AdyenManagementApi(client=self.client) + self.legalEntityManagement = AdyenLegalEntityManagementApi(client=self.client) _base_adyen_obj = Adyen() @@ -47,3 +49,4 @@ def __init__(self, **kwargs): binlookup = _base_adyen_obj.binlookup terminal = _base_adyen_obj.terminal management = _base_adyen_obj.management +legalEntityManagement = _base_adyen_obj.legalEntityManagement diff --git a/Adyen/client.py b/Adyen/client.py index 42fe0e22..6cf145e7 100644 --- a/Adyen/client.py +++ b/Adyen/client.py @@ -89,6 +89,7 @@ def __init__( api_payout_version=None, api_recurring_version=None, api_terminal_version=None, + api_legal_entity_management_version=None, ): self.username = username self.password = password @@ -116,6 +117,7 @@ def __init__( self.api_payout_version = api_payout_version or settings.API_PAYOUT_VERSION self.api_recurring_version = api_recurring_version or settings.API_RECURRING_VERSION self.api_terminal_version = api_terminal_version or settings.API_TERMINAL_VERSION + self.api_legal_entity_management_version = api_legal_entity_management_version or settings.API_LEGAL_ENTITY_MANAGEMENT_VERSION def _determine_base_url_and_version(self, platform, service): @@ -175,6 +177,13 @@ def _determine_base_url_and_version(self, platform, service): 'live': settings.BASE_MANAGEMENT_URL.format(platform), 'test': settings.BASE_MANAGEMENT_URL.format(platform) } + }, + 'legalEntityManagement': { + 'version': self.api_legal_entity_management_version, + 'base_url': { + 'live': settings.BASE_LEGAL_ENTITY_MANAGEMENT_URL.format(platform), + 'test': settings.BASE_LEGAL_ENTITY_MANAGEMENT_URL.format(platform) + } } } version = versions_and_urls[service]['version'] diff --git a/Adyen/services/__init__.py b/Adyen/services/__init__.py index a726ab5d..7b5488e5 100644 --- a/Adyen/services/__init__.py +++ b/Adyen/services/__init__.py @@ -5,4 +5,5 @@ from .payouts import AdyenThirdPartyPayout from .recurring import AdyenRecurring from .terminal import AdyenTerminal -from .management import AdyenManagementApi \ No newline at end of file +from .management import AdyenManagementApi +from .legalEntityManagement import AdyenLegalEntityManagementApi \ No newline at end of file diff --git a/Adyen/services/legalEntityManagement/__init__.py b/Adyen/services/legalEntityManagement/__init__.py new file mode 100644 index 00000000..fa4e9d1d --- /dev/null +++ b/Adyen/services/legalEntityManagement/__init__.py @@ -0,0 +1,34 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +from ..base import AdyenServiceBase +from .business_lines_api import BusinessLinesApi +from .documents_api import DocumentsApi +from .hosted_onboarding_api import HostedOnboardingApi +from .legal_entities_api import LegalEntitiesApi +from .terms_of_service_api import TermsOfServiceApi +from .transfer_instruments_api import TransferInstrumentsApi + + +class AdyenLegalEntityManagementApi(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(AdyenLegalEntityManagementApi, self).__init__(client=client) + self.business_lines_api = BusinessLinesApi(client=client) + self.documents_api = DocumentsApi(client=client) + self.hosted_onboarding_api = HostedOnboardingApi(client=client) + self.legal_entities_api = LegalEntitiesApi(client=client) + self.terms_of_service_api = TermsOfServiceApi(client=client) + self.transfer_instruments_api = TransferInstrumentsApi(client=client) diff --git a/Adyen/services/legalEntityManagement/business_lines_api.py b/Adyen/services/legalEntityManagement/business_lines_api.py new file mode 100644 index 00000000..c64a9c69 --- /dev/null +++ b/Adyen/services/legalEntityManagement/business_lines_api.py @@ -0,0 +1,55 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +from ..base import AdyenServiceBase + + +class BusinessLinesApi(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(BusinessLinesApi, self).__init__(client=client) + self.service = "legalEntityManagement" + + def get_business_line(self, id, idempotency_key=None, **kwargs): + """ + Get a business line + """ + endpoint = f"/businessLines/{id}" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def update_business_line(self, request, id, idempotency_key=None, **kwargs): + """ + Update a business line + """ + endpoint = f"/businessLines/{id}" + endpoint = endpoint.replace('/', '', 1) + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def create_business_line(self, request, idempotency_key=None, **kwargs): + """ + Create a business line + """ + endpoint = f"/businessLines" + endpoint = endpoint.replace('/', '', 1) + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + + + + diff --git a/Adyen/services/legalEntityManagement/documents_api.py b/Adyen/services/legalEntityManagement/documents_api.py new file mode 100644 index 00000000..e7e22390 --- /dev/null +++ b/Adyen/services/legalEntityManagement/documents_api.py @@ -0,0 +1,64 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +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 = "legalEntityManagement" + + def delete_document(self, id, idempotency_key=None, **kwargs): + """ + Delete a document + """ + endpoint = f"/documents/{id}" + endpoint = endpoint.replace('/', '', 1) + 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}" + endpoint = endpoint.replace('/', '', 1) + 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}" + endpoint = endpoint.replace('/', '', 1) + 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" + endpoint = endpoint.replace('/', '', 1) + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + + + + diff --git a/Adyen/services/legalEntityManagement/hosted_onboarding_api.py b/Adyen/services/legalEntityManagement/hosted_onboarding_api.py new file mode 100644 index 00000000..673f8b6e --- /dev/null +++ b/Adyen/services/legalEntityManagement/hosted_onboarding_api.py @@ -0,0 +1,55 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +from ..base import AdyenServiceBase + + +class HostedOnboardingApi(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(HostedOnboardingApi, self).__init__(client=client) + self.service = "legalEntityManagement" + + def list_hosted_onboarding_page_themes(self, idempotency_key=None, **kwargs): + """ + Get a list of hosted onboarding page themes + """ + endpoint = f"/themes" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_onboarding_link_theme(self, id, idempotency_key=None, **kwargs): + """ + Get an onboarding link theme + """ + endpoint = f"/themes/{id}" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_link_to_adyenhosted_onboarding_page(self, request, id, idempotency_key=None, **kwargs): + """ + Get a link to an Adyen-hosted onboarding page + """ + endpoint = f"/legalEntities/{id}/onboardingLinks" + endpoint = endpoint.replace('/', '', 1) + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + + + + diff --git a/Adyen/services/legalEntityManagement/legal_entities_api.py b/Adyen/services/legalEntityManagement/legal_entities_api.py new file mode 100644 index 00000000..b20bd1af --- /dev/null +++ b/Adyen/services/legalEntityManagement/legal_entities_api.py @@ -0,0 +1,64 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +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 = "legalEntityManagement" + + def get_legal_entity(self, id, idempotency_key=None, **kwargs): + """ + Get a legal entity + """ + endpoint = f"/legalEntities/{id}" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_all_business_lines_under_legal_entity(self, id, idempotency_key=None, **kwargs): + """ + Get all business lines under a legal entity + """ + endpoint = f"/legalEntities/{id}/businessLines" + endpoint = endpoint.replace('/', '', 1) + 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}" + endpoint = endpoint.replace('/', '', 1) + 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" + endpoint = endpoint.replace('/', '', 1) + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + + + + diff --git a/Adyen/services/legalEntityManagement/terms_of_service_api.py b/Adyen/services/legalEntityManagement/terms_of_service_api.py new file mode 100644 index 00000000..a681a06b --- /dev/null +++ b/Adyen/services/legalEntityManagement/terms_of_service_api.py @@ -0,0 +1,64 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +from ..base import AdyenServiceBase + + +class TermsOfServiceApi(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(TermsOfServiceApi, self).__init__(client=client) + self.service = "legalEntityManagement" + + def get_terms_of_service_information_for_legal_entity(self, id, idempotency_key=None, **kwargs): + """ + Get Terms of Service information for a legal entity + """ + endpoint = f"/legalEntities/{id}/termsOfServiceAcceptanceInfos" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_terms_of_service_status(self, id, idempotency_key=None, **kwargs): + """ + Get Terms of Service status + """ + endpoint = f"/legalEntities/{id}/termsOfServiceStatus" + endpoint = endpoint.replace('/', '', 1) + method = "GET" + return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) + + def accept_terms_of_service(self, request, id, termsOfServiceDocumentId, idempotency_key=None, **kwargs): + """ + Accept Terms of Service + """ + endpoint = f"/legalEntities/{id}/termsOfService/{termsOfServiceDocumentId}" + endpoint = endpoint.replace('/', '', 1) + method = "PATCH" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + def get_terms_of_service_document(self, request, id, idempotency_key=None, **kwargs): + """ + Get Terms of Service document + """ + endpoint = f"/legalEntities/{id}/termsOfService" + endpoint = endpoint.replace('/', '', 1) + method = "POST" + return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) + + + + + diff --git a/Adyen/services/legalEntityManagement/transfer_instruments_api.py b/Adyen/services/legalEntityManagement/transfer_instruments_api.py new file mode 100644 index 00000000..6e63d1f5 --- /dev/null +++ b/Adyen/services/legalEntityManagement/transfer_instruments_api.py @@ -0,0 +1,64 @@ +""" + Legal Entity Management API + + The Legal Entity Management API enables you to manage legal entities that contain information required for verification. ## Authentication To connect to the Legal Entity Management API, you must use the basic authentication credentials of your web service user. If you don't have one, contact the [Adyen Support Team](https://www.adyen.help/hc/en-us/requests/new). Use the web service user credentials to authenticate your request, for example: ``` curl -U \"ws12345@Scope.BalancePlatform_YourBalancePlatform\":\"YourWsPassword\" \\ -H \"Content-Type: application/json\" \\ ... ``` Note that when going live, you need to generate new web service user credentials to access the [live endpoints](https://docs.adyen.com/development-resources/live-endpoints). ## Versioning The Legal Entity Management API supports versioning of its endpoints through a version suffix in the endpoint URL. This suffix has the following format: \"vXX\", where XX is the version number. For example: ``` https://kyc-test.adyen.com/lem/v2/legalEntities ``` ## Going live When going live, your Adyen contact will provide your API credential for the live environment. You can then use the username and password to send requests to `https://kyc-live.adyen.com/lem/v2`. # noqa: E501 + + The version of the OpenAPI document: 2 + Contact: developer-experience@adyen.com + Generated by: https://openapi-generator.tech +""" + +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 = "legalEntityManagement" + + def delete_transfer_instrument(self, id, idempotency_key=None, **kwargs): + """ + Delete a transfer instrument + """ + endpoint = f"/transferInstruments/{id}" + endpoint = endpoint.replace('/', '', 1) + 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}" + endpoint = endpoint.replace('/', '', 1) + 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}" + endpoint = endpoint.replace('/', '', 1) + 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" + endpoint = endpoint.replace('/', '', 1) + 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 879b0118..9aadf8ba 100644 --- a/Adyen/settings.py +++ b/Adyen/settings.py @@ -1,13 +1,14 @@ # Those constants are used from the library only BASE_TERMINAL_URL = "https://postfmapi-{}.adyen.com/postfmapi/terminal" BASE_MANAGEMENT_URL = "https://management-{}.adyen.com" +BASE_LEGAL_ENTITY_MANAGEMENT_URL = "https://kyc-{}.adyen.com/lem" PAL_LIVE_ENDPOINT_URL_TEMPLATE = "https://{live_prefix}-pal-live" \ ".adyenpayments.com/pal/servlet" PAL_TEST_URL = "https://pal-test.adyen.com/pal/servlet" ENDPOINT_CHECKOUT_TEST = "https://checkout-test.adyen.com" ENDPOINT_CHECKOUT_LIVE_SUFFIX = "https://{live_prefix}-checkout-live" \ ".adyenpayments.com/checkout" -API_BIN_LOOKUP_VERSION = "v50" +API_BIN_LOOKUP_VERSION = "v52" API_CHECKOUT_VERSION = "v69" API_CHECKOUT_UTILITY_VERSION = "v1" API_MANAGEMENT_VERSION = "v1" @@ -15,5 +16,6 @@ API_PAYMENT_VERSION = "v64" API_PAYOUT_VERSION = "v64" API_TERMINAL_VERSION = "v1" +API_LEGAL_ENTITY_MANAGEMENT_VERSION = "v2" LIB_VERSION = "7.1.1" LIB_NAME = "adyen-python-api-library" diff --git a/Makefile b/Makefile index fffcff48..f32e2a6a 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,8 @@ $(services): build/spec -c ./templates/config.yaml \ -o build \ --global-property apis,apiTests=false,apiDocs=false,supportingFiles=api-single.py\ - --additional-properties serviceName=$@ + --additional-properties serviceName=$@\ + --skip-validate-spec mkdir -p Adyen/services cp -r build/openapi_client/api Adyen/services/$@ cp build/api/api-single.py Adyen/services/$@/__init__.py diff --git a/templates/api.mustache b/templates/api.mustache index 4f0f1b39..050db927 100644 --- a/templates/api.mustache +++ b/templates/api.mustache @@ -15,28 +15,19 @@ class {{classname}}(AdyenServiceBase): {{#operations}} {{#operation}} - {{#bodyParams}} - def {{operationId}}(self, request, {{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/requiredParams}}idempotency_key=None, **kwargs): + def {{#lambda.snakecase}}{{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}{{/lambda.snakecase}}(self, {{#bodyParams}}request, {{/bodyParams}}{{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/requiredParams}}idempotency_key=None, **kwargs): """ {{{summary}}}{{^summary}}{{operationId}}{{/summary}} """ endpoint = f"{{{path}}}" - endpoint = endpoint.replace('/','',1) + endpoint = endpoint.replace('/', '', 1) method = "{{httpMethod}}" + {{#bodyParams}} return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs) {{/bodyParams}} {{^bodyParams}} - def {{operationId}}(self, {{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/requiredParams}}idempotency_key=None, **kwargs): - """ - {{{summary}}}{{^summary}}{{operationId}}{{/summary}} - """ - endpoint = f"{{{path}}}" - endpoint = endpoint.replace('/','',1) - method = "{{httpMethod}}" return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs) {{/bodyParams}} {{/operation}} {{/operations}} - - diff --git a/test/BaseTest.py b/test/BaseTest.py index bf568ea2..08a97bcf 100644 --- a/test/BaseTest.py +++ b/test/BaseTest.py @@ -18,7 +18,7 @@ def create_client_from_file(self, status, request, filename=None): st = open(filename) strjson = st.read() else: - data = "" + data = {} st = "" strjson = "" diff --git a/test/CheckoutTest.py b/test/CheckoutTest.py index 46c31c09..cce3b609 100644 --- a/test/CheckoutTest.py +++ b/test/CheckoutTest.py @@ -1,5 +1,6 @@ import Adyen import unittest +from Adyen import settings try: from BaseTest import BaseTest @@ -14,6 +15,8 @@ class TestCheckout(unittest.TestCase): test = BaseTest(adyen) client.xapikey = "YourXapikey" client.platform = "test" + checkout_version = settings.API_CHECKOUT_VERSION + lib_version = settings.LIB_VERSION def test_payment_methods_success_mocked(self): request = {'merchantAccount': "YourMerchantAccount"} @@ -92,13 +95,13 @@ def test_payments_error_mocked(self): self.adyen.client.http_client.request.assert_called_once_with( 'POST', - 'https://checkout-test.adyen.com/v69/payments', + 'https://checkout-test.adyen.com/{}/payments'.format(self.checkout_version), headers={}, json={ 'returnUrl': 'https://your-company.com/...', u'applicationInfo': { u'adyenLibrary': { - u'version': '7.1.1', + u'version': f"{self.lib_version}", u'name': 'adyen-python-api-library' } }, @@ -136,7 +139,7 @@ def test_payments_details_success_mocked(self): self.adyen.client.http_client.request.assert_called_once_with( 'POST', - u'https://checkout-test.adyen.com/v69/payments/details', + u'https://checkout-test.adyen.com/{}/payments/details'.format(self.checkout_version), headers={}, json={ 'paymentData': 'Hee57361f99....', @@ -538,7 +541,7 @@ def test_payment_link(self): result = self.adyen.checkout.payment_links(request) self.adyen.client.http_client.request.assert_called_once_with( 'POST', - 'https://checkout-test.adyen.com/v69/paymentLinks', + f'https://checkout-test.adyen.com/{self.checkout_version}/paymentLinks', headers={}, xapikey='YourXapikey', json=request @@ -555,7 +558,7 @@ def test_get_payment_link(self): result = self.adyen.checkout.get_payment_link(id) self.adyen.client.http_client.request.assert_called_once_with( 'GET', - f'https://checkout-test.adyen.com/v69/paymentLinks/{id}', + f'https://checkout-test.adyen.com/{self.checkout_version}/paymentLinks/{id}', headers={}, xapikey="YourXapikey", json=None @@ -574,7 +577,7 @@ def test_update_payment_link(self): result = self.adyen.checkout.update_payment_link(request, id) self.adyen.client.http_client.request.assert_called_once_with( 'PATCH', - f'https://checkout-test.adyen.com/v69/paymentLinks/{id}', + f'https://checkout-test.adyen.com/{self.checkout_version}/paymentLinks/{id}', headers={}, xapikey="YourXapikey", json=request diff --git a/test/CheckoutUtilityTest.py b/test/CheckoutUtilityTest.py index 76805f18..99bb39ce 100644 --- a/test/CheckoutUtilityTest.py +++ b/test/CheckoutUtilityTest.py @@ -1,7 +1,7 @@ import unittest import Adyen - +from Adyen import settings try: from BaseTest import BaseTest except ImportError: @@ -15,6 +15,7 @@ class TestCheckoutUtility(unittest.TestCase): test = BaseTest(ady) client.xapikey = "YourXapikey" client.platform = "test" + checkout_version = settings.API_CHECKOUT_VERSION def test_origin_keys_success_mocked(self): request = { @@ -53,7 +54,7 @@ def test_origin_keys_success_mocked(self): def test_checkout_utility_api_url_custom(self): url = self.ady.client._determine_api_url("test", "checkout", "originKeys") - self.assertEqual(url, "https://checkout-test.adyen.com/v69/originKeys") + self.assertEqual(url, "https://checkout-test.adyen.com/{}/originKeys".format(self.checkout_version)) def test_applePay_session(self): request = { diff --git a/test/DetermineEndpointTest.py b/test/DetermineEndpointTest.py index 54fcb9d9..251f7c02 100644 --- a/test/DetermineEndpointTest.py +++ b/test/DetermineEndpointTest.py @@ -1,4 +1,5 @@ import Adyen +from Adyen import settings import unittest try: @@ -15,19 +16,23 @@ class TestDetermineUrl(unittest.TestCase): client = adyen.client test = BaseTest(adyen) client.xapikey = "YourXapikey" + checkout_version = settings.API_CHECKOUT_VERSION + payment_version = settings.API_PAYMENT_VERSION + binLookup_version = settings.API_BIN_LOOKUP_VERSION + management_version = settings.API_MANAGEMENT_VERSION def test_checkout_api_url_custom(self): self.client.live_endpoint_prefix = "1797a841fbb37ca7-AdyenDemo" url = self.adyen.client._determine_api_url("live", "checkout", "payments") self.assertEqual("https://1797a841fbb37ca7-AdyenDemo-checkout-" - "live.adyenpayments.com/checkout/v69/payments", url) + f"live.adyenpayments.com/checkout/{self.checkout_version}/payments", url) def test_checkout_api_url(self): self.client.live_endpoint_prefix = None url = self.adyen.client._determine_api_url("test", "checkout", "payments/details") self.assertEqual(url, "https://checkout-test.adyen.com" - "/v69/payments/details") + f"/{self.checkout_version}/payments/details") def test_payments_invalid_platform(self): @@ -62,7 +67,7 @@ def test_pal_url_live_endpoint_prefix_live_platform(self): self.assertEqual( url, ("https://1797a841fbb37ca7-AdyenDemo-pal-" - "live.adyenpayments.com/pal/servlet/Payment/v64/payments") + f"live.adyenpayments.com/pal/servlet/Payment/{self.payment_version}/payments") ) def test_pal_url_live_endpoint_prefix_test_platform(self): @@ -72,8 +77,7 @@ def test_pal_url_live_endpoint_prefix_test_platform(self): ) self.assertEqual( url, - "https://pal-test.adyen.com/pal/servlet/Payment/v64/payments" - ) + f"https://pal-test.adyen.com/pal/servlet/Payment/{self.payment_version}/payments") def test_pal_url_no_live_endpoint_prefix_test_platform(self): self.client.live_endpoint_prefix = None @@ -82,8 +86,7 @@ def test_pal_url_no_live_endpoint_prefix_test_platform(self): ) self.assertEqual( url, - "https://pal-test.adyen.com/pal/servlet/Payment/v64/payments" - ) + f"https://pal-test.adyen.com/pal/servlet/Payment/{self.payment_version}/payments") def test_binlookup_url_no_live_endpoint_prefix_test_platform(self): self.client.live_endpoint_prefix = None @@ -93,7 +96,7 @@ def test_binlookup_url_no_live_endpoint_prefix_test_platform(self): self.assertEqual( url, ("https://pal-test.adyen.com/pal/servlet/" - "BinLookup/v50/get3dsAvailability") + f"BinLookup/{self.binLookup_version}/get3dsAvailability") ) def test_checkout_api_url_orders(self): @@ -101,31 +104,32 @@ def test_checkout_api_url_orders(self): url = self.adyen.client._determine_api_url("test", "checkout", "orders") self.assertEqual(url, "https://checkout-test.adyen.com" - "/v69/orders") + f"/{self.checkout_version}/orders") def test_checkout_api_url_order_cancel(self): self.client.live_endpoint_prefix = None url = self.adyen.client._determine_api_url("test", "checkout", "orders/cancel") self.assertEqual(url, "https://checkout-test.adyen.com" - "/v69/orders/cancel") + f"/{self.checkout_version}/orders/cancel") def test_checkout_api_url_order_payment_methods_balance(self): self.client.live_endpoint_prefix = None url = self.adyen.client._determine_api_url("test", "checkout", "paymentMethods/" "balance") - self.assertEqual(url, "https://checkout-test.adyen.com""/v69/" + self.assertEqual(url, f"https://checkout-test.adyen.com/{self.checkout_version}/" "paymentMethods/balance") def test_checkout_api_url_sessions(self): self.client.live_endpoint_prefix = None url = self.adyen.client._determine_api_url("test", "checkout", "sessions") - self.assertEqual(url, "https://checkout-test.adyen.com""/v69/" + self.assertEqual(url, f"https://checkout-test.adyen.com/{self.checkout_version}/" "sessions") def test_management_api_url_companies(self): companyId = "YOUR_COMPANY_ID" url = self.adyen.client._determine_api_url("test", "management", f'companies/{companyId}/users') - self.assertEqual(url, "https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ID/users") + self.assertEqual(url, f"https://management-test.adyen.com/{self.management_version}/" + "companies/YOUR_COMPANY_ID/users") diff --git a/test/LegalEntityManagementTest.py b/test/LegalEntityManagementTest.py new file mode 100644 index 00000000..09096920 --- /dev/null +++ b/test/LegalEntityManagementTest.py @@ -0,0 +1,105 @@ +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" + lem_version = settings.API_LEGAL_ENTITY_MANAGEMENT_VERSION + + def test_creating_legal_entity(self): + request = { + "type": "individual", + "individual": { + "residentialAddress": { + "city": "Amsterdam", + "country": "NL", + "postalCode": "1011DJ", + "street": "Simon Carmiggeltstraat 6 - 50" + }, + "name": { + "firstName": "Shelly", + "lastName": "Eller" + }, + "birthData": { + "dateOfBirth": "1990-06-21" + }, + "email": "s.eller@example.com" + } + } + self.adyen.client = self.test.create_client_from_file(200, request, + "test/mocks/legalEntityManagement/" + "individual_legal_entity_created.json") + result = self.adyen.legalEntityManagement.legal_entities_api.create_legal_entity(request) + self.assertEqual('Shelly', result.message['individual']['name']['firstName']) + self.adyen.client.http_client.request.assert_called_once_with( + 'POST', + f'https://kyc-test.adyen.com/lem/{self.lem_version}/legalEntities', + headers={}, + json=request, + xapikey="YourXapikey" + ) + + def test_get_transfer_instrument(self): + instrumentId = "SE322JV223222F5GNXSR89TMW" + self.adyen.client = self.test.create_client_from_file(200, None, "test/mocks/legalEntityManagement/" + "details_of_trainsfer_instrument.json") + result = self.adyen.legalEntityManagement.transfer_instruments_api.get_transfer_instrument(instrumentId) + self.assertEqual(instrumentId, result.message['id']) + self.adyen.client.http_client.request.assert_called_once_with( + 'GET', + f'https://kyc-test.adyen.com/lem/{self.lem_version}/transferInstruments/{instrumentId}', + headers={}, + json=None, + xapikey="YourXapikey" + ) + + def test_update_business_line(self): + businessLineId = "SE322JV223222F5GVGMLNB83F" + request = { + "industryCode": "55", + "webData": [ + { + "webAddress": "https://www.example.com" + } + ] + } + self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/legalEntityManagement/" + "business_line_updated.json") + result = self.adyen.legalEntityManagement.business_lines_api.update_business_line(request, businessLineId) + self.assertEqual(businessLineId, result.message['id']) + self.adyen.client.http_client.request.assert_called_once_with( + 'PATCH', + f'https://kyc-test.adyen.com/lem/{self.lem_version}/businessLines/{businessLineId}', + headers={}, + json=request, + xapikey="YourXapikey" + ) + + def test_accept_terms_of_service(self): + legalEntityId = "legalId" + documentId = "documentId" + request = { + 'acceptedBy': "UserId", + 'ipAddress': "UserIpAddress" + } + self.adyen.client = self.test.create_client_from_file(204, request) + self.adyen.legalEntityManagement.terms_of_service_api.accept_terms_of_service(request, legalEntityId, + documentId) + self.adyen.client.http_client.request.assert_called_once_with( + 'PATCH', + f'https://kyc-test.adyen.com/lem/{self.lem_version}/legalEntities/{legalEntityId}/termsOfService/{documentId}', + headers={}, + json=request, + xapikey="YourXapikey" + ) diff --git a/test/ManagementTest.py b/test/ManagementTest.py index 8180e25d..0d50fd52 100644 --- a/test/ManagementTest.py +++ b/test/ManagementTest.py @@ -1,4 +1,5 @@ import Adyen +from Adyen import settings import unittest try: @@ -14,6 +15,7 @@ class TestManagement(unittest.TestCase): test = BaseTest(adyen) client.xapikey = "YourXapikey" client.platform = "test" + management_version = settings.API_MANAGEMENT_VERSION def test_get_company_account(self): request = None @@ -28,7 +30,7 @@ def test_get_company_account(self): self.assertEqual(id, result.message['id']) self.adyen.client.http_client.request.assert_called_once_with( 'GET', - 'https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT', + f'https://management-test.adyen.com/{self.management_version}/companies/{id}', headers={}, json=None, xapikey="YourXapikey" @@ -51,7 +53,7 @@ def test_my_api_credential_api(self): result = self.adyen.management.my_api_credential_api.delete_me_allowed_origins_origin_id(originId) self.adyen.client.http_client.request.assert_called_once_with( 'DELETE', - f'https://management-test.adyen.com/v1/me/allowedOrigins/{originId}', + f'https://management-test.adyen.com/{self.management_version}/me/allowedOrigins/{originId}', headers={}, json=None, xapikey="YourXapikey" @@ -78,7 +80,7 @@ def test_update_a_store(self): storeId) self.adyen.client.http_client.request.assert_called_once_with( 'PATCH', - f'https://management-test.adyen.com/v1/merchants/{merchantId}/stores/{storeId}', + f'https://management-test.adyen.com/{self.management_version}/merchants/{merchantId}/stores/{storeId}', headers={}, json=request, xapikey="YourXapikey" @@ -113,7 +115,7 @@ def test_create_a_user(self): self.assertEqual(request['name']['firstName'],result.message['name']['firstName']) self.adyen.client.http_client.request.assert_called_once_with( 'POST', - f'https://management-test.adyen.com/v1/companies/{companyId}/users', + f'https://management-test.adyen.com/{self.management_version}/companies/{companyId}/users', json=request, headers={}, xapikey="YourXapikey" @@ -147,7 +149,7 @@ def test_query_paramaters(self): get_companies_company_id_merchants(companyId, query_parameters=query_parameters) self.adyen.client.http_client.request.assert_called_once_with( 'GET', - 'https://management-test.adyen.com/v1/companies/YOUR_COMPANY_ACCOUNT/merchants?pageNumber=1&pageSize=10', + f'https://management-test.adyen.com/{self.management_version}/companies/{companyId}/merchants?pageNumber=1&pageSize=10', headers={}, json=None, xapikey="YourXapikey" diff --git a/test/TerminalTest.py b/test/TerminalTest.py index 0c7b3126..178d58af 100644 --- a/test/TerminalTest.py +++ b/test/TerminalTest.py @@ -1,15 +1,12 @@ -import pkg_resources import unittest - import Adyen +from Adyen import settings try: from BaseTest import BaseTest except ImportError: from .BaseTest import BaseTest -VERSION = pkg_resources.get_distribution("Adyen").version - class TestTerminal(unittest.TestCase): adyen = Adyen.Adyen(username="YourWSUser", @@ -18,6 +15,7 @@ class TestTerminal(unittest.TestCase): xapikey="YourXapikey") test = BaseTest(adyen) client = adyen.client + terminal_version = settings.API_TERMINAL_VERSION def test_assign_terminals(self): request = { @@ -36,7 +34,7 @@ def test_assign_terminals(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/assignTerminals", headers={}, json={ "companyAccount": "YOUR_COMPANY_ACCOUNT", @@ -80,7 +78,7 @@ def test_find_terminal(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/findTerminal", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/findTerminal", headers={}, json={ "terminal": "P400Plus-275479597", @@ -128,7 +126,7 @@ def test_get_stores_under_account(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/getStoresUnderAccount", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/getStoresUnderAccount", headers={}, json={ "companyAccount": "YOUR_COMPANY_ACCOUNT", @@ -153,7 +151,7 @@ def test_get_terminal_details(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/getTerminalDetails", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/getTerminalDetails", headers={}, json={ "terminal": "P400Plus-275479597", @@ -205,7 +203,7 @@ def test_get_terminals_under_account(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/getTerminalsUnderAccount", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/getTerminalsUnderAccount", headers={}, json={ "companyAccount": "YOUR_COMPANY_ACCOUNT", @@ -242,7 +240,7 @@ def test_get_terminals_under_account_store(self): self.client.http_client.request.assert_called_once_with( "POST", - "https://postfmapi-test.adyen.com/postfmapi/terminal/v1/getTerminalsUnderAccount", + f"https://postfmapi-test.adyen.com/postfmapi/terminal/{self.terminal_version}/getTerminalsUnderAccount", headers={}, json={ "companyAccount": "YOUR_COMPANY_ACCOUNT", diff --git a/test/mocks/legalEntityManagement/business_line_updated.json b/test/mocks/legalEntityManagement/business_line_updated.json new file mode 100644 index 00000000..c3eac1b0 --- /dev/null +++ b/test/mocks/legalEntityManagement/business_line_updated.json @@ -0,0 +1,16 @@ +{ + "capability": "issueBankAccount", + "industryCode": "55", + "legalEntityId": "LE322KH223222F5GVGMLF3WBL", + "sourceOfFunds": { + "adyenProcessedFunds": false, + "description": "Funds from my flower shop business", + "type": "business" + }, + "webData": [ + { + "webAddress": "https://www.example.com" + } + ], + "id": "SE322JV223222F5GVGMLNB83F" +} \ No newline at end of file diff --git a/test/mocks/legalEntityManagement/details_of_trainsfer_instrument.json b/test/mocks/legalEntityManagement/details_of_trainsfer_instrument.json new file mode 100644 index 00000000..ee9c772c --- /dev/null +++ b/test/mocks/legalEntityManagement/details_of_trainsfer_instrument.json @@ -0,0 +1,10 @@ +{ + "bankAccount": { + "countryCode": "NL", + "currencyCode": "EUR", + "iban": "NL62ABNA0000000123" + }, + "legalEntityId": "LE322JV223222D5G2SPGL59KT", + "type": "bankAccount", + "id": "SE322JV223222F5GNXSR89TMW" +} \ No newline at end of file diff --git a/test/mocks/legalEntityManagement/individual_legal_entity_created.json b/test/mocks/legalEntityManagement/individual_legal_entity_created.json new file mode 100644 index 00000000..b9031f5d --- /dev/null +++ b/test/mocks/legalEntityManagement/individual_legal_entity_created.json @@ -0,0 +1,20 @@ +{ + "individual": { + "email": "s.eller@example.com", + "birthData": { + "dateOfBirth": "1990-06-21" + }, + "name": { + "firstName": "Shelly", + "lastName": "Eller" + }, + "residentialAddress": { + "city": "Amsterdam", + "country": "NL", + "postalCode": "1011DJ", + "street": "Simon Carmiggeltstraat 6 - 50" + } + }, + "type": "individual", + "id": "LE322JV223222D5GG42KN6869" +} \ No newline at end of file