Skip to content

Commit 1454090

Browse files
authored
[PW-7629] - Generate classic payments endpoints (#204)
* Changed the templates to support small service generation * add service argument to the template * fixed templates * Generate classic payments endpoints * make file alphabetical order * update makefile * update names * update names
1 parent f88a307 commit 1454090

File tree

13 files changed

+193
-141
lines changed

13 files changed

+193
-141
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ venv/
99
.vagrant/
1010
.env
1111
test.py
12+
build/

Adyen/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from .client import AdyenClient
1616
from .services import (
1717
AdyenBase,
18+
AdyenPaymentsApi,
1819
AdyenBinlookupApi,
1920
AdyenRecurringApi,
20-
AdyenPayment,
2121
AdyenPayoutsApi,
2222
AdyenManagementApi,
2323
AdyenCheckoutApi,
@@ -34,7 +34,7 @@
3434
class Adyen(AdyenBase):
3535
def __init__(self, **kwargs):
3636
self.client = AdyenClient(**kwargs)
37-
self.payment = AdyenPayment(client=self.client)
37+
self.payment = AdyenPaymentsApi(client=self.client)
3838
self.binlookup = AdyenBinlookupApi(client=self.client)
3939
self.payout = AdyenPayoutsApi(client=self.client)
4040
self.recurring = AdyenRecurringApi(client=self.client)

Adyen/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _determine_base_url_and_version(self, platform, service):
163163
'test': settings.BASE_TERMINAL_URL.format(platform)
164164
}
165165
},
166-
'Payment': {
166+
'payments': {
167167
'version': self.api_payment_version,
168168
'base_url': {
169169
'live': live_pal_url + '/Payment',

Adyen/services/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .base import AdyenBase
22
from .binLookup import AdyenBinlookupApi
33
from .checkout import AdyenCheckoutApi
4-
from .payments import AdyenPayment
4+
from .payments import AdyenPaymentsApi
55
from .payouts import AdyenPayoutsApi
66
from .recurring import AdyenRecurringApi
77
from .terminal import AdyenTerminal

Adyen/services/payments.py

Lines changed: 0 additions & 110 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from ..base import AdyenServiceBase
2+
from .general_api import GeneralApi
3+
from .modifications_api import ModificationsApi
4+
5+
6+
class AdyenPaymentsApi(AdyenServiceBase):
7+
"""NOTE: This class is auto generated by OpenAPI Generator
8+
Ref: https://openapi-generator.tech
9+
10+
Do not edit the class manually.
11+
"""
12+
13+
def __init__(self, client=None):
14+
super(AdyenPaymentsApi, self).__init__(client=client)
15+
self.general_api = GeneralApi(client=client)
16+
self.modifications_api = ModificationsApi(client=client)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from ..base import AdyenServiceBase
2+
3+
4+
class GeneralApi(AdyenServiceBase):
5+
"""NOTE: This class is auto generated by OpenAPI Generator
6+
Ref: https://openapi-generator.tech
7+
8+
Do not edit the class manually.
9+
"""
10+
11+
def __init__(self, client=None):
12+
super(GeneralApi, self).__init__(client=client)
13+
self.service = "payments"
14+
15+
def authorise(self, request, idempotency_key=None, **kwargs):
16+
"""
17+
Create an authorisation
18+
"""
19+
endpoint = f"/authorise"
20+
endpoint = endpoint.replace('/', '', 1)
21+
method = "POST"
22+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
23+
24+
def authorise3d(self, request, idempotency_key=None, **kwargs):
25+
"""
26+
Complete a 3DS authorisation
27+
"""
28+
endpoint = f"/authorise3d"
29+
endpoint = endpoint.replace('/', '', 1)
30+
method = "POST"
31+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
32+
33+
def authorise3ds2(self, request, idempotency_key=None, **kwargs):
34+
"""
35+
Complete a 3DS2 authorisation
36+
"""
37+
endpoint = f"/authorise3ds2"
38+
endpoint = endpoint.replace('/', '', 1)
39+
method = "POST"
40+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
41+
42+
def get_authentication_result(self, request, idempotency_key=None, **kwargs):
43+
"""
44+
Get the 3DS authentication result
45+
"""
46+
endpoint = f"/getAuthenticationResult"
47+
endpoint = endpoint.replace('/', '', 1)
48+
method = "POST"
49+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
50+
51+
def retrieve3ds2_result(self, request, idempotency_key=None, **kwargs):
52+
"""
53+
Get the 3DS2 authentication result
54+
"""
55+
endpoint = f"/retrieve3ds2Result"
56+
endpoint = endpoint.replace('/', '', 1)
57+
method = "POST"
58+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
59+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
from ..base import AdyenServiceBase
2+
3+
4+
class ModificationsApi(AdyenServiceBase):
5+
"""NOTE: This class is auto generated by OpenAPI Generator
6+
Ref: https://openapi-generator.tech
7+
8+
Do not edit the class manually.
9+
"""
10+
11+
def __init__(self, client=None):
12+
super(ModificationsApi, self).__init__(client=client)
13+
self.service = "payments"
14+
15+
def adjust_authorisation(self, request, idempotency_key=None, **kwargs):
16+
"""
17+
Change the authorised amount
18+
"""
19+
endpoint = f"/adjustAuthorisation"
20+
endpoint = endpoint.replace('/', '', 1)
21+
method = "POST"
22+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
23+
24+
def cancel(self, request, idempotency_key=None, **kwargs):
25+
"""
26+
Cancel an authorisation
27+
"""
28+
endpoint = f"/cancel"
29+
endpoint = endpoint.replace('/', '', 1)
30+
method = "POST"
31+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
32+
33+
def cancel_or_refund(self, request, idempotency_key=None, **kwargs):
34+
"""
35+
Cancel or refund a payment
36+
"""
37+
endpoint = f"/cancelOrRefund"
38+
endpoint = endpoint.replace('/', '', 1)
39+
method = "POST"
40+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
41+
42+
def capture(self, request, idempotency_key=None, **kwargs):
43+
"""
44+
Capture an authorisation
45+
"""
46+
endpoint = f"/capture"
47+
endpoint = endpoint.replace('/', '', 1)
48+
method = "POST"
49+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
50+
51+
def donate(self, request, idempotency_key=None, **kwargs):
52+
"""
53+
Create a donation
54+
"""
55+
endpoint = f"/donate"
56+
endpoint = endpoint.replace('/', '', 1)
57+
method = "POST"
58+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
59+
60+
def refund(self, request, idempotency_key=None, **kwargs):
61+
"""
62+
Refund a captured payment
63+
"""
64+
endpoint = f"/refund"
65+
endpoint = endpoint.replace('/', '', 1)
66+
method = "POST"
67+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
68+
69+
def technical_cancel(self, request, idempotency_key=None, **kwargs):
70+
"""
71+
Cancel an authorisation using your reference
72+
"""
73+
endpoint = f"/technicalCancel"
74+
endpoint = endpoint.replace('/', '', 1)
75+
method = "POST"
76+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
77+
78+
def void_pending_refund(self, request, idempotency_key=None, **kwargs):
79+
"""
80+
Cancel an in-person refund
81+
"""
82+
endpoint = f"/voidPendingRefund"
83+
endpoint = endpoint.replace('/', '', 1)
84+
method = "POST"
85+
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)
86+

Adyen/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
API_DATA_PROTECION_VERSION = "v1"
1818
API_MANAGEMENT_VERSION = "v1"
1919
API_RECURRING_VERSION = "v68"
20-
API_PAYMENT_VERSION = "v64"
20+
API_PAYMENT_VERSION = "v68"
2121
API_PAYOUT_VERSION = "v68"
2222
API_TERMINAL_VERSION = "v1"
2323
API_TRANSFERS_VERSION = "v3"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ $(smallServices): build/spec
6666

6767
build/spec:
6868
git clone https://github.com/Adyen/adyen-openapi.git build/spec
69-
sed -i 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
69+
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json

0 commit comments

Comments
 (0)