Skip to content

Commit 83497f0

Browse files
committed
add new tests and update readme
1 parent ceee545 commit 83497f0

File tree

9 files changed

+179
-19
lines changed

9 files changed

+179
-19
lines changed

Adyen/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
AdyenStoredValueApi,
2727
AdyenBalancePlatformApi,
2828
AdyenDisputesApi,
29+
AdyenSessionAuthenticationApi
2930
)
3031

3132
from .httpclient import HTTPClient
@@ -47,6 +48,7 @@ def __init__(self, **kwargs):
4748
self.storedValue = AdyenStoredValueApi(client=self.client)
4849
self.balancePlatform = AdyenBalancePlatformApi(client=self.client)
4950
self.disputes = AdyenDisputesApi(client=self.client)
51+
self.sessionAuthentication = AdyenSessionAuthenticationApi(client=self.client)
5052

5153

5254
_base_adyen_obj = Adyen()
@@ -63,3 +65,4 @@ def __init__(self, **kwargs):
6365
storedValue = _base_adyen_obj.storedValue
6466
balancePlatform = _base_adyen_obj.balancePlatform
6567
disputes = _base_adyen_obj.disputes
68+
sessionAuthentication = _base_adyen_obj.sessionAuthentication

Adyen/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(
9494
api_stored_value_version=None,
9595
api_balance_platform_version=None,
9696
api_disputes_version=None,
97+
api_session_authentication_version=None,
9798

9899
):
99100
self.username = username
@@ -127,6 +128,7 @@ def __init__(
127128
self.api_stored_value_version = api_stored_value_version
128129
self.api_balance_platform_version = api_balance_platform_version
129130
self.api_disputes_version = api_disputes_version
131+
self.api_session_authentication_version = api_session_authentication_version
130132

131133
def _determine_api_url(self, platform, endpoint):
132134
if platform == "test":
@@ -281,7 +283,8 @@ def _set_url_version(self, service, endpoint):
281283
"transfers": self.api_transfers_version,
282284
"storedValue": self.api_stored_value_version,
283285
"balancePlatform": self.api_balance_platform_version,
284-
"disputes": self.api_disputes_version
286+
"disputes": self.api_disputes_version,
287+
"sessionAuthentication": self.api_session_authentication_version
285288
}
286289

287290
new_version = f"v{version_lookup[service]}"
@@ -337,7 +340,8 @@ def call_adyen_api(
337340
self.api_transfers_version,
338341
self.api_stored_value_version,
339342
self.api_balance_platform_version,
340-
self.api_disputes_version]
343+
self.api_disputes_version,
344+
self.api_session_authentication_version]
341345
if any(versions):
342346
endpoint = self._set_url_version(service, endpoint)
343347

Adyen/services/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
from .storedValue import AdyenStoredValueApi
1313
from .balancePlatform import AdyenBalancePlatformApi
1414
from .disputes import AdyenDisputesApi
15+
from .sessionAuthentication import AdyenSessionAuthenticationApi

README.md

Lines changed: 18 additions & 17 deletions
Large diffs are not rendered by default.

test/BalancePlatformTest.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,71 @@ def test_creating_payment_instrument(self):
8787
xapikey="YourXapikey"
8888
)
8989

90+
def test_creating_transfer_limit(self):
91+
request = {
92+
"amount": {
93+
"currency": "EUR",
94+
"value": 10000
95+
},
96+
"reference": "Your reference for the transfer limit",
97+
"scaInformation": {
98+
"scaOnApproval": True
99+
},
100+
"scope": "perTransaction",
101+
"startsAt": "2025-08-15T06:36:20+01:00",
102+
"endsAt": "2026-08-14T00:00:00+01:00",
103+
"transferType": "all"
104+
}
105+
106+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
107+
108+
self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/configuration/"
109+
"transfer-limit-created.json")
110+
result = self.adyen.balancePlatform.transfer_limits_balance_platform_level_api.create_transfer_limit(request,
111+
balance_platform_id)
112+
self.assertEqual("TRLI00000000000000000000000001", result.message['id'])
113+
self.adyen.client.http_client.request.assert_called_once_with(
114+
'POST',
115+
f'{self.balance_platform_url}/balancePlatforms/{balance_platform_id}/transferLimits',
116+
headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION},
117+
json=request,
118+
xapikey="YourXapikey"
119+
)
120+
121+
def test_creating_webhook(self):
122+
request = {
123+
"type": "balance",
124+
"target": {
125+
"type": "balanceAccount",
126+
"id": "BA00000000000000000LIABLE"
127+
},
128+
"currency": "USD",
129+
"status": "active",
130+
"conditions": [
131+
{
132+
"balanceType": "available",
133+
"conditionType": "lessThan",
134+
"value": 500000
135+
}
136+
]
137+
}
138+
139+
balance_platform_id = 'YOUR_BALANCE_PLATFORM_ID'
140+
webhook_id = 'YOUR_WEBHOOK_ID'
141+
142+
self.adyen.client = self.test.create_client_from_file(200, request, "test/mocks/configuration/"
143+
"webhook-setting-created.json")
144+
result = self.adyen.balancePlatform.balances_api.create_webhook_setting(request, balance_platform_id, webhook_id)
145+
self.assertEqual("active", result.message['status'])
146+
self.assertEqual("BWHS00000000000000000000000001", result.message['id'])
147+
self.adyen.client.http_client.request.assert_called_once_with(
148+
'POST',
149+
f'{self.balance_platform_url}/balancePlatforms/{balance_platform_id}/webhooks/{webhook_id}/settings',
150+
headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION},
151+
json=request,
152+
xapikey="YourXapikey"
153+
)
154+
90155
def test_creating_payment_instrument_group(self):
91156
request = {
92157
"balancePlatform": "YOUR_BALANCE_PLATFORM",

test/SessionAuthenticationTest.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import Adyen
2+
import unittest
3+
from Adyen import settings
4+
5+
try:
6+
from BaseTest import BaseTest
7+
except ImportError:
8+
from .BaseTest import BaseTest
9+
10+
11+
class TestSessionAuthentication(unittest.TestCase):
12+
adyen = Adyen.Adyen()
13+
14+
client = adyen.client
15+
test = BaseTest(adyen)
16+
client.xapikey = "YourXapikey"
17+
client.platform = "test"
18+
session_url = adyen.sessionAuthentication.session_authentication_api.baseUrl
19+
20+
def test_create_session_token(self):
21+
request = {
22+
"allowOrigin": 'https://www.your-website.com',
23+
"product": "platform",
24+
"policy": {
25+
"resources": [
26+
{
27+
"type": "accountHolder",
28+
"accountHolderId": "AH00000000000000000000001"
29+
}
30+
],
31+
"roles": [
32+
"Transactions Overview Component: View",
33+
"Payouts Overview Component: View"
34+
]
35+
}
36+
}
37+
self.adyen.client = self.test.create_client_from_file(200, request,
38+
"test/mocks/sessionAuthentication/"
39+
"authentication-session-created.json")
40+
41+
result = self.adyen.sessionAuthentication.session_authentication_api.create_authentication_session(request)
42+
self.assertEqual("long_session_token_string", result.message["sessionToken"])
43+
self.adyen.client.http_client.request.assert_called_once_with(
44+
'POST',
45+
f'{self.session_url}/sessions',
46+
headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION},
47+
json=request,
48+
xapikey="YourXapikey"
49+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"amount": {
3+
"value": 10000,
4+
"currency": "EUR"
5+
},
6+
"id": "TRLI00000000000000000000000001",
7+
"scope": "perTransaction",
8+
"reference": "Your reference for the transfer limit",
9+
"scaInformation": {
10+
"status": "pending"
11+
},
12+
"startsAt": "2025-08-15T06:36:20+01:00",
13+
"endsAt": "2026-08-13T23:00:00+01:00",
14+
"limitStatus": "pendingSCA",
15+
"transferType": "all"
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "BWHS00000000000000000000000001",
3+
"type": "balance",
4+
"target": {
5+
"type": "balanceAccount",
6+
"id": "BA00000000000000000LIABLE"
7+
},
8+
"currency": "USD",
9+
"status": "active",
10+
"conditions": [
11+
{
12+
"balanceType": "available",
13+
"conditionType": "lessThan",
14+
"value": 500000
15+
}
16+
]
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"sessionToken": "long_session_token_string",
3+
"expiresAt": "2025-10-07T12:00:00Z"
4+
}

0 commit comments

Comments
 (0)