diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 7c863d50..a9a1cec0 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - python-version: ['3.7', '3.8'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - name: Checkout diff --git a/Adyen/__init__.py b/Adyen/__init__.py index de38e81d..a6c2771c 100644 --- a/Adyen/__init__.py +++ b/Adyen/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, unicode_literals - from . import util from .exceptions import ( AdyenAPICommunicationError, diff --git a/Adyen/client.py b/Adyen/client.py index 5c8964b2..3396f51f 100644 --- a/Adyen/client.py +++ b/Adyen/client.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, division, unicode_literals +from __future__ import annotations import json as json_lib @@ -15,9 +15,10 @@ AdyenEndpointInvalidFormat) from . import settings import re +from typing import Any -class AdyenResult(object): +class AdyenResult: """ Args: message (dict, optional): Parsed message returned from API client. @@ -29,20 +30,26 @@ class AdyenResult(object): """ - def __init__(self, message=None, status_code=200, - psp="", raw_request="", raw_response=""): + def __init__( + self, + message: dict[str, Any] | None = None, + status_code: int = 200, + psp: str = "", + raw_request: str = "", + raw_response: str = "" + ) -> None: self.message = message self.status_code = status_code self.psp = psp self.raw_request = raw_request self.raw_response = raw_response - self.details = {} + self.details: dict[str, Any] = {} - def __str__(self): + def __str__(self) -> str: return repr(self.message) -class AdyenClient(object): +class AdyenClient: IDEMPOTENCY_HEADER_NAME = 'Idempotency-Key' APPLICATION_INFO_HEADER_NAME = 'adyen-library-name' APPLICATION_VERSION_HEADER_NAME = 'adyen-library-version' @@ -68,37 +75,38 @@ class AdyenClient(object): """ def __init__( - self, - username=None, - password=None, - xapikey=None, - application_name=None, - review_payout_username=None, - review_payout_password=None, - store_payout_username=None, store_payout_password=None, - platform="test", merchant_account=None, - merchant_specific_url=None, - hmac=None, - http_force=None, - live_endpoint_prefix=None, - http_timeout=30, - api_bin_lookup_version=None, - api_checkout_version=None, - api_management_version=None, - api_payment_version=None, - api_payout_version=None, - api_recurring_version=None, - api_terminal_version=None, - api_legal_entity_management_version=None, - api_data_protection_version=None, - api_transfers_version=None, - api_stored_value_version=None, - api_balance_platform_version=None, - api_disputes_version=None, - api_session_authentication_version=None, - api_capital_version=None - - ): + self, + username: str | None = None, + password: str | None = None, + xapikey: str | None = None, + application_name: str | None = None, + review_payout_username: str | None = None, + review_payout_password: str | None = None, + store_payout_username: str | None = None, + store_payout_password: str | None = None, + platform: str = "test", + merchant_account: str | None = None, + merchant_specific_url: str | None = None, + hmac: str | None = None, + http_force: str | None = None, + live_endpoint_prefix: str | None = None, + http_timeout: int = 30, + api_bin_lookup_version: str | int | None = None, + api_checkout_version: str | int | None = None, + api_management_version: str | int | None = None, + api_payment_version: str | int | None = None, + api_payout_version: str | int | None = None, + api_recurring_version: str | int | None = None, + api_terminal_version: str | int | None = None, + api_legal_entity_management_version: str | int | None = None, + api_data_protection_version: str | int | None = None, + api_transfers_version: str | int | None = None, + api_stored_value_version: str | int | None = None, + api_balance_platform_version: str | int | None = None, + api_disputes_version: str | int | None = None, + api_session_authentication_version: str | int | None = None, + api_capital_version: str | int | None = None + ) -> None: self.username = username self.password = password self.xapikey = xapikey @@ -111,7 +119,7 @@ def __init__( self.merchant_specific_url = merchant_specific_url self.hmac = hmac self.merchant_account = merchant_account - self.psp_list = [] + self.psp_list: list[str] = [] self.LIB_VERSION = settings.LIB_VERSION self.USER_AGENT_SUFFIX = settings.LIB_NAME + "/" self.http_init = False diff --git a/Adyen/exceptions.py b/Adyen/exceptions.py index 6e40e0e1..fe9d4a23 100644 --- a/Adyen/exceptions.py +++ b/Adyen/exceptions.py @@ -40,7 +40,7 @@ def __init__(self, message, *args, **kwargs): - super(AdyenAPIResponseError, self).__init__(message, *args, **kwargs) + super().__init__(message, *args, **kwargs) class AdyenAPIAuthenticationError(AdyenAPIResponseError): diff --git a/Adyen/httpclient.py b/Adyen/httpclient.py index 4b8d310a..13342f79 100644 --- a/Adyen/httpclient.py +++ b/Adyen/httpclient.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, unicode_literals - try: import requests except ImportError: @@ -20,7 +18,7 @@ import base64 -class HTTPClient(object): +class HTTPClient: def __init__( self, user_agent_suffix, diff --git a/Adyen/services/base.py b/Adyen/services/base.py index bbebebfd..f6455ab6 100644 --- a/Adyen/services/base.py +++ b/Adyen/services/base.py @@ -1,14 +1,14 @@ from Adyen import AdyenClient -class AdyenBase(object): +class AdyenBase: def __setattr__(self, attr, value): client_attr = ["username", "password", "platform"] if attr in client_attr: if value: self.client[attr] = value else: - super(AdyenBase, self).__setattr__(attr, value) + super().__setattr__(attr, value) def __getattr__(self, attr): client_attr = ["username", "password", "platform"] diff --git a/Adyen/util.py b/Adyen/util.py index 1fe3cf88..5f65bbb9 100644 --- a/Adyen/util.py +++ b/Adyen/util.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, unicode_literals - import base64 import hmac import hashlib diff --git a/setup.py b/setup.py index f566ba61..5c5a09e3 100644 --- a/setup.py +++ b/setup.py @@ -12,12 +12,30 @@ author_email='support@adyen.com', url='https://github.com/Adyen/adyen-python-api-library', keywords=['payments', 'adyen', 'fintech'], + python_requires='>=3.8', + install_requires=[], # Core is standard library only, plus optional clients below + extras_require={ + "requests": ["requests>=2.25.0"], + "pycurl": ["pycurl>=7.43.0"], + "test": [ + "pytest>=7.0.0", + "pytest-cov>=4.0.0", + "mock>=4.0.0", + "requests>=2.25.0", + ], + }, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.6' + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', ] ) diff --git a/tox.ini b/tox.ini index a20f227f..302db17f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{36,37,38}-{pycurl,requests,urlib} +envlist = py{38,39,310,311,312,313,314}-{pycurl,requests,urllib} skip_missing_interpreters=true [testenv]