Skip to content

Commit 22fb285

Browse files
committed
Fixes with e2e test
1 parent a2bfc2c commit 22fb285

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

Adyen/client.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ def _determine_checkout_url(self, platform, service, action):
135135
action = "payment/details"
136136
if action == "paymentResult":
137137
action = "payment/result"
138+
if action == "originKey":
139+
action = "v1/originKeys"
140+
138141
base_uri = settings.BASE_CHECKOUT_URL.format(platform)
139142
api_version = settings.CHECKOUT_API_VERSION
140143

@@ -239,6 +242,17 @@ def call_api(self, request_data, service, action, idempotency=False,
239242
You can do this by running 'Adyen.password = 'Your password'"""
240243
raise AdyenInvalidRequestError(errorstring)
241244

245+
# xapikey at self object has highest priority. fallback to root module
246+
# and ensure that it is set.
247+
if self.xapikey:
248+
xapikey = self.xapikey
249+
elif 'xapikey' in kwargs:
250+
xapikey = kwargs.pop("xapikey")
251+
if not xapikey:
252+
errorstring = """Please set your webservice xapikey.
253+
You can do this by running 'Adyen.xapikey = 'Your xapikey'"""
254+
raise AdyenInvalidRequestError(errorstring)
255+
242256
# platform at self object has highest priority. fallback to root module
243257
# and ensure that it is set to either 'live' or 'test'.
244258
if self.platform:
@@ -473,7 +487,6 @@ def _handle_response(self, url, raw_response, raw_request,
473487
Returns:
474488
AdyenResult: Result object if successful.
475489
"""
476-
477490
if status_code != 200:
478491
response = {}
479492
# If the result can't be parsed into json, most likely is raw html.

Adyen/httpclient.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ def _requests_post(self, url,
142142
data=None,
143143
username="",
144144
password="",
145+
xapikey="",
145146
headers=None,
146147
timeout=30):
148+
self.pr = """pr"""
147149
"""This function will POST to the url endpoint using requests.
148150
Returning an AdyenResult object on 200 HTTP response.
149-
Either json or data has to be provided.
151+
Either json or data has to be %sovided.
150152
If username and password are provided, basic auth will be used.
151153
152154
@@ -167,14 +169,16 @@ def _requests_post(self, url,
167169
str: Raw request placed
168170
int: HTTP status code, eg 200,404,401
169171
dict: Key/Value pairs of the headers received.
170-
"""
172+
""" % self.pr
171173
if headers is None:
172174
headers = {}
173175

174176
# Adding basic auth if username and password provided.
175177
auth = None
176178
if username and password:
177179
auth = requests.auth.HTTPBasicAuth(username, password)
180+
elif xapikey:
181+
headers['x-api-key'] = xapikey
178182

179183
# Add User-Agent header to request so that the request
180184
# can be identified as coming from the Adyen Python library.
@@ -246,12 +250,12 @@ def _urllib_post(self, url,
246250
if username and password:
247251
if sys.version_info[0] >= 3:
248252
basic_authstring = base64.encodebytes(('%s:%s' %
249-
(username, password))
250-
.encode()).decode().\
253+
(username, password))
254+
.encode()).decode(). \
251255
replace('\n', '')
252256
else:
253257
basic_authstring = base64.encodestring('%s:%s' % (username,
254-
password)).\
258+
password)). \
255259
replace('\n', '')
256260
url_request.add_header("Authorization",
257261
"Basic %s" % basic_authstring)

Adyen/services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def payments_details(self, request="", **kwargs):
328328
action, **kwargs)
329329

330330
def payment_session(self, request="", **kwargs):
331-
action = "paymentsSession"
331+
action = "paymentSession"
332332
if validation.check_in(request, action):
333333
return self.client.call_checkout_api(request, self.service,
334334
action, **kwargs)
@@ -339,7 +339,7 @@ def payment_result(self, request="", **kwargs):
339339
return self.client.call_checkout_api(request, self.service, action,
340340
**kwargs)
341341

342-
def origin_key(self, request="", **kwargs):
342+
def origin_keys(self, request="", **kwargs):
343343
action = "originKeys"
344344
if validation.check_in(request, action):
345345
return self.client.call_checkout_api(request, self.service,

Adyen/validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
actions['payments'] = ["amount", "reference", "paymentMethod",
2222
"merchantAccount", "returnUrl"]
2323
actions['paymentsDetails'] = ["paymentData", "details"]
24-
actions['paymentsSession'] = ["amount", "reference", "shopperReference",
25-
"channel", "token", "returnUrl", "countryCode",
26-
"shopperLocale", "sessionValidity",
27-
"merchantAccount"]
24+
actions['paymentSession'] = ["amount", "reference", "shopperReference",
25+
"channel", "returnUrl", "countryCode",
26+
"shopperLocale", "sessionValidity",
27+
"merchantAccount"]
2828
actions['paymentResult'] = ["payload"]
2929
actions['originKeys'] = ["originDomains"]
3030

0 commit comments

Comments
 (0)