Skip to content

Commit 09b1e67

Browse files
Merge pull request #153 from Adyen/develop
Release 6.0.0
2 parents be78ec7 + 26c0cf2 commit 09b1e67

File tree

11 files changed

+194
-97
lines changed

11 files changed

+194
-97
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
releaseguide.md
66
venv/
77
.idea/
8-
.coverage
8+
.coverage
9+
.vagrant/

Adyen/client.py

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def __init__(
8383
http_force=None,
8484
live_endpoint_prefix=None,
8585
http_timeout=30,
86+
api_bin_lookup_version=None,
87+
api_checkout_utility_version=None,
88+
api_checkout_version=None,
89+
api_payment_version=None,
90+
api_payout_version=None,
91+
api_recurring_version=None,
8692
):
8793
self.username = username
8894
self.password = password
@@ -103,6 +109,12 @@ def __init__(
103109
self.http_force = http_force
104110
self.live_endpoint_prefix = live_endpoint_prefix
105111
self.http_timeout = http_timeout
112+
self.api_bin_lookup_version = api_bin_lookup_version or settings.API_BIN_LOOKUP_VERSION
113+
self.api_checkout_utility_version = api_checkout_utility_version or settings.API_CHECKOUT_UTILITY_VERSION
114+
self.api_checkout_version = api_checkout_version or settings.API_CHECKOUT_VERSION
115+
self.api_payment_version = api_payment_version or settings.API_PAYMENT_VERSION
116+
self.api_payout_version = api_payout_version or settings.API_PAYOUT_VERSION
117+
self.api_recurring_version = api_recurring_version or settings.API_RECURRING_VERSION
106118

107119
def _determine_api_url(self, platform, service, action):
108120
"""This returns the Adyen API endpoint based on the provided platform,
@@ -121,13 +133,13 @@ def _determine_api_url(self, platform, service, action):
121133
base_uri = settings.BASE_PAL_URL.format(platform)
122134

123135
if service == "Recurring":
124-
api_version = settings.API_RECURRING_VERSION
136+
api_version = self.api_recurring_version
125137
elif service == "Payout":
126-
api_version = settings.API_PAYOUT_VERSION
138+
api_version = self.api_payout_version
127139
elif service == "BinLookup":
128-
api_version = settings.API_BIN_LOOKUP_VERSION
140+
api_version = self.api_bin_lookup_version
129141
else:
130-
api_version = settings.API_PAYMENT_VERSION
142+
api_version = self.api_payment_version
131143
return '/'.join([base_uri, service, api_version, action])
132144

133145
@staticmethod
@@ -153,7 +165,7 @@ def _determine_checkout_url(self, platform, action):
153165
platform (str): Adyen platform, ie 'live' or 'test'.
154166
action (str): the API action to perform.
155167
"""
156-
api_version = settings.API_CHECKOUT_VERSION
168+
api_version = self.api_checkout_version
157169
if platform == "test":
158170
base_uri = settings.ENDPOINT_CHECKOUT_TEST
159171
elif self.live_endpoint_prefix is not None and platform == "live":
@@ -172,7 +184,7 @@ def _determine_checkout_url(self, platform, action):
172184
if action == "paymentsResult":
173185
action = "payments/result"
174186
if action == "originKeys":
175-
api_version = settings.API_CHECKOUT_UTILITY_VERSION
187+
api_version = self.api_checkout_utility_version
176188
if action == "paymentMethodsBalance":
177189
action = "paymentMethods/balance"
178190
if action == "ordersCancel":
@@ -238,24 +250,18 @@ def call_api(
238250
/api-idempotency
239251
request_data (dict): The dictionary of the request to place. This
240252
should be in the structure of the Adyen API.
241-
https://docs.adyen.com/manuals/api-manual
253+
https://docs.adyen.com/api-explorer
242254
service (str): This is the API service to be called.
243255
action (str): The specific action of the API service to be called
244256
idempotency (bool, optional): Whether the transaction should be
245257
processed idempotently.
246-
https://docs.adyen.com/manuals/api-manual#apiidempotency
258+
https://docs.adyen.com/development-resources/api-idempotency
247259
Returns:
248260
AdyenResult: The AdyenResult is returned when a request was
249261
successful.
250262
"""
251263
if not self.http_init:
252-
self.http_client = HTTPClient(
253-
user_agent_suffix=self.USER_AGENT_SUFFIX,
254-
lib_version=self.LIB_VERSION,
255-
force_request=self.http_force,
256-
timeout=self.http_timeout,
257-
)
258-
self.http_init = True
264+
self._init_http_client()
259265

260266
# username at self object has highest priority. fallback to root module
261267
# and ensure that it is set.
@@ -368,6 +374,15 @@ def call_api(
368374

369375
return adyen_result
370376

377+
def _init_http_client(self):
378+
self.http_client = HTTPClient(
379+
user_agent_suffix=self.USER_AGENT_SUFFIX,
380+
lib_version=self.LIB_VERSION,
381+
force_request=self.http_force,
382+
timeout=self.http_timeout,
383+
)
384+
self.http_init = True
385+
371386
def call_hpp(self, message, action, hmac_key="", **kwargs):
372387
"""This will call the adyen hpp. hmac_key and platform are pulled from
373388
root module level and or self object.
@@ -377,7 +392,7 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
377392
Args:
378393
request_data (dict): The dictionary of the request to place. This
379394
should be in the structure of the Adyen API.
380-
https://docs.adyen.com/manuals/api-manual
395+
https://docs.adyen.com/online-payments/classic-integrations/hosted-payment-pages/hosted-payment-pages-api
381396
service (str): This is the API service to be called.
382397
action (str): The specific action of the API service to be called
383398
Returns:
@@ -387,10 +402,7 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
387402
:param hmac_key:
388403
"""
389404
if not self.http_init:
390-
self.http_client = HTTPClient(self.USER_AGENT_SUFFIX,
391-
self.LIB_VERSION,
392-
self.http_force)
393-
self.http_init = True
405+
self._init_http_client()
394406

395407
# hmac provided in function has highest priority. fallback to self then
396408
# root module and ensure that it is set.
@@ -449,15 +461,12 @@ def call_checkout_api(self, request_data, action, idempotency_key=None,
449461
/api-idempotency
450462
request_data (dict): The dictionary of the request to place. This
451463
should be in the structure of the Adyen API.
452-
https://docs.adyen.com/developers/checkout/api-integration
464+
https://docs.adyen.com/api-explorer/#/CheckoutService
453465
service (str): This is the API service to be called.
454466
action (str): The specific action of the API service to be called
455467
"""
456468
if not self.http_init:
457-
self.http_client = HTTPClient(self.USER_AGENT_SUFFIX,
458-
self.LIB_VERSION,
459-
self.http_force)
460-
self.http_init = True
469+
self._init_http_client()
461470

462471
# xapi at self object has highest priority. fallback to root module
463472
# and ensure that it is set.
@@ -497,7 +506,8 @@ def call_checkout_api(self, request_data, action, idempotency_key=None,
497506
"payments",
498507
"paymentSession",
499508
"paymentLinks",
500-
"paymentMethodsBalance"
509+
"paymentMethodsBalance",
510+
"sessions"
501511
]
502512

503513
if action in with_app_info:
@@ -535,12 +545,8 @@ def call_checkout_api(self, request_data, action, idempotency_key=None,
535545
return adyen_result
536546

537547
def hpp_payment(self, request_data, action, hmac_key="", **kwargs):
538-
539548
if not self.http_init:
540-
self.http_client = HTTPClient(self.USER_AGENT_SUFFIX,
541-
self.LIB_VERSION,
542-
self.http_force)
543-
self.http_init = True
549+
self._init_http_client()
544550

545551
platform = self.platform
546552
if not isinstance(platform, str):
@@ -588,7 +594,7 @@ def _handle_response(self, url, raw_response, raw_request,
588594
Returns:
589595
AdyenResult: Result object if successful.
590596
"""
591-
if status_code != 200:
597+
if (status_code != 200 and status_code != 201):
592598
response = {}
593599
# If the result can't be parsed into json, most likely is raw html.
594600
# Some response are neither json or raw html, handle them here:

Adyen/services.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AdyenRecurring(AdyenServiceBase):
3333
3434
API calls currently implemented: listRecurringDetails and disable. Please
3535
refer to the Recurring Manual for specifics around the API.
36-
https://docs.adyen.com/developers/recurring-manual
36+
https://docs.adyen.com/online-payments/tokenization
3737
3838
Args:
3939
client (AdyenAPIClient, optional): An API client for the service to
@@ -69,7 +69,7 @@ class AdyenHPP(AdyenServiceBase):
6969
This currently only implements the directory_lookup request which will
7070
return the list of payment methods available for given shopper. Please
7171
refer to the HPP manual and the directory lookup section for the specifics.
72-
https://docs.adyen.com/developers/hpp-manual#directorylookup
72+
https://docs.adyen.com/online-payments/classic-integrations/hosted-payment-pages/directory-lookup
7373
7474
Args:
7575
client (AdyenAPIClient, optional): An API client for the service to
@@ -133,8 +133,8 @@ class AdyenPayment(AdyenServiceBase):
133133
capture
134134
refund
135135
cancelOrRefund
136-
Please refer to the Recurring Manual for specifics around the API.
137-
https://docs.adyen.com/developers/recurring-manual
136+
Please refer to our API Explorer for specifics around these APIs.
137+
https://docs.adyen.com/api-explorer/
138138
139139
The AdyenPayment class, is accessible as adyen.payment.method(args)
140140
@@ -225,9 +225,8 @@ def cancel_or_refund(self, request, idempotency_key=None, **kwargs):
225225

226226

227227
class AdyenThirdPartyPayout(AdyenServiceBase):
228-
"""This represents the Adyen API Third Party Payouts Service.
229-
230-
https://docs.adyen.com/developers/api-reference/third-party-payouts-api
228+
"""This represents the Adyen Payouts Service.
229+
https://docs.adyen.com/api-explorer/#/Payout/overview
231230
232231
The AdyenThirdPartyPayout class is accessible as adyen.payout.method(args)
233232
@@ -281,7 +280,7 @@ class AdyenCheckoutApi(AdyenServiceBase):
281280
originKeys
282281
283282
Please refer to the checkout documentation for specifics around the API.
284-
https://docs.adyen.com/developers/checkout
283+
https://docs.adyen.com/online-payments
285284
286285
The AdyenPayment class, is accessible as adyen.payment.method(args)
287286
@@ -326,6 +325,9 @@ def origin_keys(self, request=None, **kwargs):
326325
action = "originKeys"
327326
return self.client.call_checkout_api(request, action, **kwargs)
328327

328+
def sessions(self, request=None, **kwargs):
329+
action = "sessions"
330+
return self.client.call_checkout_api(request, action, **kwargs)
329331
# Orders endpoints
330332

331333
# /paymentMethods/balance
@@ -349,7 +351,7 @@ class AdyenBinLookup(AdyenServiceBase):
349351
350352
API call currently implemented: getCostEstimate.
351353
Please refer to the Bin Lookup Manual for specifics around the API.
352-
https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview
354+
https://docs.adyen.com/api-explorer/#/BinLookup/
353355
354356
Args:
355357
client (AdyenAPIClient, optional): An API client for the service to

Adyen/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
ENDPOINT_CHECKOUT_LIVE_SUFFIX = "https://{}-checkout-live" \
88
".adyenpayments.com/checkout"
99
API_BIN_LOOKUP_VERSION = "v50"
10-
API_CHECKOUT_VERSION = "v67"
10+
API_CHECKOUT_VERSION = "v68"
1111
API_CHECKOUT_UTILITY_VERSION = "v1"
1212
API_RECURRING_VERSION = "v49"
1313
API_PAYMENT_VERSION = "v64"
1414
API_PAYOUT_VERSION = "v64"
15-
LIB_VERSION = "5.1.0"
15+
LIB_VERSION = "6.0.0"
1616
LIB_NAME = "adyen-python-api-library"

README.md

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,85 @@
11
[![Build Status](https://travis-ci.org/Adyen/adyen-python-api-library.svg?branch=master)](https://travis-ci.org/Adyen/adyen-python-api-library)
22
[![Coverage Status](https://coveralls.io/repos/github/Adyen/adyen-python-api-library/badge.svg?branch=master)](https://coveralls.io/github/Adyen/adyen-python-api-library?branch=master)
33

4-
# Adyen APIs Library for Python
5-
6-
This library simplifies working with Adyen APIs and allows you to integrate Adyen
7-
payments within any Python application.
8-
9-
## Integration
10-
The Library supports all APIs under the following services:
11-
12-
* checkout
13-
* checkout utility
14-
* payments
15-
* modifications
16-
* payouts
17-
* recurring
18-
19-
## Requirements
20-
4+
This is the officially supported Python library for using Adyen's APIs.
5+
## Integration
6+
The library supports all APIs under the following services:
7+
8+
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v68/overview): Our latest integration for accepting online payments. Current supported version: **v68**
9+
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
10+
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
11+
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
12+
* [Orders API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/post/orders): Endpoints for creating and canceling orders. Current supported version: **v67**
13+
* [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+
15+
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
16+
17+
18+
## Prerequisites
19+
20+
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
21+
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
2122
- Python 2.7 or 3.6
2223
- Packages: requests or pycurl ( optional )
23-
- Adyen account. If you don't have this you can request it here: https://www.adyen.com/home/discover/test-account-signup#form
24+
2425

25-
## Installation
26+
## Installation
2627

2728
### For development propose
2829

29-
Clone this repository and run ```make install```
30+
Clone this repository and run
31+
~~~~ bash
32+
make install
33+
~~~~
3034

3135
### For usage propose
3236

33-
Use pip command: ```pip install Adyen```
34-
35-
## Usage
36-
37-
Create a class instance of the 'Adyen' class.
38-
39-
```python
37+
Use pip command:
38+
~~~~ bash
39+
pip install Adyen
40+
~~~~
41+
42+
## Using the library
43+
44+
45+
### General use with API key
46+
47+
~~~~ python
4048
import Adyen
4149

4250
ady = Adyen.Adyen()
4351

44-
ady.payment.client.username = "webservice user name"
52+
ady.payment.client.xapikey = "YourXapikey"
4553
ady.payment.client.skin_code = "skin code for Hosted Payment pages"
4654
ady.payment.client.hmac = "HMAC key for skin code"
4755
ady.payment.client.platform = "test" # Environment to use the library in.
4856
ady.payment.client.merchant_account = "merchant account name from CA"
49-
ady.payment.client.password = "webservice user password"
50-
```
51-
52-
## Documentation
53-
* https://docs.adyen.com/developers/development-resources/libraries
54-
* https://docs.adyen.com/developers/checkout
57+
~~~~
58+
59+
### Example integration
60+
61+
For a closer look at how our Python library works, clone our [example integration](https://github.com/adyen-examples/adyen-python-online-payments). This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
5562

56-
## Support
57-
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://support.adyen.com/hc/en-us/requests/new?ticket_form_id=360000705420).
5863

5964
## Contributing
60-
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
61-
* New features and functionality
62-
* Resolved bug fixes and issues
63-
* Any general improvements
64-
65-
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how.
66-
65+
66+
We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
67+
68+
69+
Have a look at our [contributing guidelines](https://github.com/Adyen/adyen-python-api-library/blob/develop/CONTRIBUTING.md) to find out how to raise a pull request.
70+
71+
72+
## Support
73+
If you have a feature request, or spotted a bug or a technical problem, [create an issue here](https://github.com/Adyen/adyen-web/issues/new/choose).
74+
75+
For other questions, [contact our Support Team](https://www.adyen.help/hc/en-us/requests/new?ticket_form_id=360000705420).
76+
77+
6778
## Licence
68-
MIT license see LICENSE
79+
This repository is available under the [MIT license](https://github.com/Adyen/adyen-python-api-library/blob/master/LICENSE.md).
80+
81+
82+
## See also
83+
* [Example integration](https://github.com/adyen-examples/adyen-python-online-payments)
84+
* [Adyen docs](https://docs.adyen.com/)
85+
* [API Explorer](https://docs.adyen.com/api-explorer/)

0 commit comments

Comments
 (0)