Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.6','3.7', '3.8']
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ venv/
.idea/
.coverage
.vagrant/
.env
test.py
24 changes: 8 additions & 16 deletions Adyen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
review_payout_password=None,
store_payout_username=None, store_payout_password=None,
platform="test", merchant_account=None,
merchant_specific_url=None, skin_code=None,
merchant_specific_url=None,
hmac=None,
http_force=None,
live_endpoint_prefix=None,
Expand Down Expand Up @@ -214,6 +214,7 @@ def call_api(
self,
request_data,
service,
method,
endpoint,
idempotency_key=None,
**kwargs
Expand All @@ -230,6 +231,7 @@ def call_api(
should be in the structure of the Adyen API.
https://docs.adyen.com/api-explorer
service (str): This is the API service to be called.
method (str): This is the method used to send the request to an endpoint.
endpoint (str): The specific endpoint of the API service to be called
idempotency (bool, optional): Whether the transaction should be
processed idempotently.
Expand Down Expand Up @@ -308,9 +310,6 @@ def call_api(

message = request_data

if not message.get('merchantAccount'):
message['merchantAccount'] = self.merchant_account

# Add application info
if 'applicationInfo' in request_data:
request_data['applicationInfo'].update({
Expand All @@ -336,12 +335,12 @@ def call_api(

if xapikey:
raw_response, raw_request, status_code, headers = \
self.http_client.request(url, json=request_data,
self.http_client.request(method, url, json=request_data,
xapikey=xapikey, headers=headers,
**kwargs)
else:
raw_response, raw_request, status_code, headers = \
self.http_client.request(url, json=message, username=username,
self.http_client.request(method, url, json=message, username=username,
password=password,
headers=headers,
**kwargs)
Expand All @@ -361,7 +360,7 @@ def _init_http_client(self):
)
self.http_init = True

def call_checkout_api(self, request_data, endpoint, idempotency_key=None,
def call_checkout_api(self, request_data, method, endpoint, idempotency_key=None,
**kwargs):
"""This will call the checkout adyen api. xapi key merchant_account,
and platform are pulled from root module level and or self object.
Expand All @@ -374,6 +373,7 @@ def call_checkout_api(self, request_data, endpoint, idempotency_key=None,
request_data (dict): The dictionary of the request to place. This
should be in the structure of the Adyen API.
https://docs.adyen.com/api-explorer/#/CheckoutService
method (str): This is the method used to send the request to an endpoint.
endpoint (str): The specific endpoint of the API service to be called
"""
if not self.http_init:
Expand Down Expand Up @@ -407,14 +407,6 @@ def call_checkout_api(self, request_data, endpoint, idempotency_key=None,
errorstring = "'platform' must be the value of 'live' or 'test'"
raise ValueError(errorstring)

merchant_account_not_required = [
'applePay/sessions'
]

if request_data.get('merchantAccount') is None:
if endpoint not in merchant_account_not_required:
request_data['merchantAccount'] = self.merchant_account

with_app_info = [
"authorise",
"authorise3d",
Expand Down Expand Up @@ -449,7 +441,7 @@ def call_checkout_api(self, request_data, endpoint, idempotency_key=None,
url = self._determine_checkout_url(platform, endpoint)

raw_response, raw_request, status_code, headers = \
self.http_client.request(url, json=request_data,
self.http_client.request(method, url, json=request_data,
xapikey=xapikey, headers=headers,
**kwargs)

Expand Down
Loading