Skip to content

Commit 99c7bf3

Browse files
authored
Merge pull request #149 from vrialland/feat/terminal-api
feat: add support for Terminal API support
2 parents 9361510 + 16ab0d4 commit 99c7bf3

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
@@ -410,3 +410,40 @@ def get_cost_estimate(self, request="", **kwargs):
410410
action = "getCostEstimate"
411411

412412
return self.client.call_api(request, self.service, action, **kwargs)
413+
414+
415+
class AdyenTerminal(AdyenServiceBase):
416+
"""This represents the Adyen API Terminal service.
417+
418+
API call currently implemented:
419+
- assignTerminals
420+
- findTerminal
421+
- getStoreUnderAccount
422+
- getTerminalDetails
423+
- getTerminalsUnderAccount
424+
Please refer to the Terminal Manual for specifics around the API.
425+
https://docs.adyen.com/api-explorer/#/postfmapi/
426+
427+
Args:
428+
client (AdyenAPIClient, optional): An API client for the service to
429+
use. If not provided, a new API client will be created.
430+
"""
431+
432+
def __init__(self, client=None):
433+
super(AdyenTerminal, self).__init__(client=client)
434+
self.service = "terminal"
435+
436+
def assign_terminals(self, request="", **kwargs):
437+
return self.client.call_api(request, self.service, "assignTerminals", **kwargs)
438+
439+
def find_terminal(self, request="", **kwargs):
440+
return self.client.call_api(request, self.service, "findTerminal", **kwargs)
441+
442+
def get_stores_under_account(self, request="", **kwargs):
443+
return self.client.call_api(request, self.service, "getStoresUnderAccount", **kwargs)
444+
445+
def get_terminal_details(self, request="", **kwargs):
446+
return self.client.call_api(request, self.service, "getTerminalDetails", **kwargs)
447+
448+
def get_terminals_under_account(self, request="", **kwargs):
449+
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 = "7.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
@@ -13,6 +13,7 @@ The library supports all APIs under the following services:
1313
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
1414
* [Orders API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/post/orders): Endpoints for creating and canceling orders. Current supported version: **v67**
1515
* [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**
16+
* [Terminal API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Endpoints for interacting with POS terminals. **v1**
1617

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

0 commit comments

Comments
 (0)