Skip to content

Commit 4fcd02a

Browse files
author
Vincent Rialland
committed
feat: add Terminal API support
1 parent 26c0cf2 commit 4fcd02a

15 files changed

+440
-1
lines changed

Adyen/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
AdyenPayment,
2121
AdyenThirdPartyPayout,
2222
AdyenHPP,
23-
AdyenCheckoutApi
23+
AdyenCheckoutApi,
24+
AdyenTerminal
2425
)
2526

2627
from .httpclient import HTTPClient
@@ -35,6 +36,7 @@ def __init__(self, **kwargs):
3536
self.hpp = AdyenHPP(client=self.client)
3637
self.recurring = AdyenRecurring(client=self.client)
3738
self.checkout = AdyenCheckoutApi(client=self.client)
39+
self.terminal = AdyenTerminal(client=self.client)
3840

3941

4042
_base_adyen_obj = Adyen()
@@ -44,3 +46,4 @@ def __init__(self, **kwargs):
4446
payout = _base_adyen_obj.payout
4547
checkout = _base_adyen_obj.checkout
4648
binlookup = _base_adyen_obj.binlookup
49+
terminal = _base_adyen_obj.terminal

Adyen/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __init__(
8989
api_payment_version=None,
9090
api_payout_version=None,
9191
api_recurring_version=None,
92+
api_terminal_version=None,
9293
):
9394
self.username = username
9495
self.password = password
@@ -115,6 +116,7 @@ def __init__(
115116
self.api_payment_version = api_payment_version or settings.API_PAYMENT_VERSION
116117
self.api_payout_version = api_payout_version or settings.API_PAYOUT_VERSION
117118
self.api_recurring_version = api_recurring_version or settings.API_RECURRING_VERSION
119+
self.api_terminal_version = api_terminal_version or settings.API_TERMINAL_VERSION
118120

119121
def _determine_api_url(self, platform, service, action):
120122
"""This returns the Adyen API endpoint based on the provided platform,
@@ -138,6 +140,9 @@ def _determine_api_url(self, platform, service, action):
138140
api_version = self.api_payout_version
139141
elif service == "BinLookup":
140142
api_version = self.api_bin_lookup_version
143+
elif service == "terminal":
144+
base_uri = settings.BASE_TERMINAL_URL.format(platform)
145+
api_version = self.api_terminal_version
141146
else:
142147
api_version = self.api_payment_version
143148
return '/'.join([base_uri, service, api_version, action])

Adyen/services.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,40 @@ def get_cost_estimate(self, request="", **kwargs):
367367
action = "getCostEstimate"
368368

369369
return self.client.call_api(request, self.service, action, **kwargs)
370+
371+
372+
class AdyenTerminal(AdyenServiceBase):
373+
"""This represents the Adyen API Terminal service.
374+
375+
API call currently implemented:
376+
- assignTerminals
377+
- findTerminal
378+
- getStoreUnderAccount
379+
- getTerminalDetails
380+
- getTerminalsUnderAccount
381+
Please refer to the Terminal Manual for specifics around the API.
382+
https://docs.adyen.com/api-explorer/#/postfmapi/
383+
384+
Args:
385+
client (AdyenAPIClient, optional): An API client for the service to
386+
use. If not provided, a new API client will be created.
387+
"""
388+
389+
def __init__(self, client=None):
390+
super(AdyenTerminal, self).__init__(client=client)
391+
self.service = "terminal"
392+
393+
def assign_terminals(self, request="", **kwargs):
394+
return self.client.call_api(request, self.service, "assignTerminals", **kwargs)
395+
396+
def find_terminal(self, request="", **kwargs):
397+
return self.client.call_api(request, self.service, "findTerminal", **kwargs)
398+
399+
def get_stores_under_account(self, request="", **kwargs):
400+
return self.client.call_api(request, self.service, "getStoresUnderAccount", **kwargs)
401+
402+
def get_terminal_details(self, request="", **kwargs):
403+
return self.client.call_api(request, self.service, "getTerminalDetails", **kwargs)
404+
405+
def get_terminals_under_account(self, request="", **kwargs):
406+
return self.client.call_api(request, self.service, "getTerminalsUnderAccount", **kwargs)

Adyen/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Those constants are used from the library only
22
BASE_PAL_URL = "https://pal-{}.adyen.com/pal/servlet"
3+
BASE_TERMINAL_URL = "https://postfmapi-{}.adyen.com/postfmapi"
34
PAL_LIVE_ENDPOINT_URL_TEMPLATE = "https://{}-pal-live" \
45
".adyenpayments.com/pal/servlet"
56
BASE_HPP_URL = "https://{}.adyen.com/hpp"
@@ -12,5 +13,6 @@
1213
API_RECURRING_VERSION = "v49"
1314
API_PAYMENT_VERSION = "v64"
1415
API_PAYOUT_VERSION = "v64"
16+
API_TERMINAL_VERSION = "v1"
1517
LIB_VERSION = "6.0.0"
1618
LIB_NAME = "adyen-python-api-library"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The library supports all APIs under the following services:
1111
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
1212
* [Orders API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/post/orders): Endpoints for creating and canceling orders. Current supported version: **v67**
1313
* [Utility API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/post/originKeys): This operation takes the origin domains and returns a JSON object containing the corresponding origin keys for the domains. Current supported version: **v67**
14+
* [Terminal API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Endpoints for interacting with POS terminals. **v1**
1415

1516
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
1617

0 commit comments

Comments
 (0)