Skip to content

Commit 236cd10

Browse files
committed
add custom endpoint
1 parent 8c257eb commit 236cd10

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

Adyen/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ def _determine_hpp_url(self, platform, action):
122122
result = '/'.join([base_uri, service])
123123
return result
124124

125-
def _determine_checkout_url(self, platform, service, action):
125+
def _determine_checkout_url(self, platform, service, action,
126+
live_endpoint_prefix=None):
126127
"""This returns the Adyen API endpoint based on the provided platform,
127128
service and action.
128129
@@ -133,14 +134,18 @@ def _determine_checkout_url(self, platform, service, action):
133134
"""
134135
if action == "paymentDetails":
135136
action = "payment/details"
136-
if action == "paymentResult":
137+
if action == "paymentsResult":
137138
action = "payment/result"
138139
if action == "originKey":
139140
action = "v1/originKeys"
140141

141142
base_uri = settings.BASE_CHECKOUT_URL.format(platform)
142-
api_version = settings.CHECKOUT_API_VERSION
143143

144+
if live_endpoint_prefix is not None:
145+
base_uri = settings.ENDPOINT_PROTOCOL + live_endpoint_prefix \
146+
+ settings.CHECKOUT_URL_LIVE_SUFFIX
147+
148+
api_version = settings.CHECKOUT_API_VERSION
144149
return '/'.join([base_uri, api_version, action])
145150

146151
def _review_payout_username(self, **kwargs):

Adyen/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def payment_session(self, request="", **kwargs):
334334
action, **kwargs)
335335

336336
def payment_result(self, request="", **kwargs):
337-
action = "paymentResult"
337+
action = "paymentsResult"
338338
if validation.check_in(request, action):
339339
return self.client.call_checkout_api(request, self.service, action,
340340
**kwargs)

Adyen/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
BASE_PAL_URL = "https://pal-{}.adyen.com/pal/servlet"
44
BASE_HPP_URL = "https://{}.adyen.com/hpp"
5+
ENDPOINT_LIVE_SUFFIX = "-pal-live.adyenpayments.com"
6+
ENDPOINT_PROTOCOL = "https://"
57
BASE_CHECKOUT_URL = "https://checkout-{}.adyen.com/"
8+
CHECKOUT_URL_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout"
69
CHECKOUT_API_VERSION = "v40"
710
API_VERSION = "v30"
811
API_RECURRING_VERSION = "v25"

Adyen/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"channel", "returnUrl", "countryCode",
2626
"shopperLocale", "sessionValidity",
2727
"merchantAccount"]
28-
actions['paymentResult'] = ["payload"]
28+
actions['paymentsResult'] = ["payload"]
2929
actions['originKeys'] = ["originDomains"]
3030

3131
payout_required_fields = {

test/CheckoutTest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,18 @@ def test_payments_result_error_mocked(self):
193193
self.assertEqual("14_018", result.message['errorCode'])
194194
self.assertEqual("Invalid payload provided", result.message['message'])
195195
self.assertEqual("validation", result.message['errorType'])
196+
197+
def test_checkout_api_url(self):
198+
url = self.ady.client._determine_checkout_url("live", ""
199+
, "paymentDetails")
200+
self.assertEqual(url, "https://checkout-live.adyen.com"
201+
"//v40/payment/details")
202+
203+
def test_checkout_api_url_custom(self):
204+
url = self.ady.client._determine_checkout_url("live", ""
205+
, "payments",
206+
"1797a841fbb37ca7"
207+
"-AdyenDemo")
208+
209+
self.assertEqual(url, "https://1797a841fbb37ca7-AdyenDemo-checkout-"
210+
"live.adyenpayments.com/checkout/v40/payments")

0 commit comments

Comments
 (0)