@@ -72,7 +72,7 @@ def __init__(self, username=None, password=None, xapikey=None,
7272 platform = "test" , merchant_account = None ,
7373 merchant_specific_url = None , skin_code = None ,
7474 hmac = None , app_name = None ,
75- http_force = None ):
75+ http_force = None , live_endpoint_prefix = None ):
7676 self .username = username
7777 self .password = password
7878 self .xapikey = xapikey
@@ -91,6 +91,7 @@ def __init__(self, username=None, password=None, xapikey=None,
9191 self .USER_AGENT_SUFFIX = "adyen-python-api-library/"
9292 self .http_init = False
9393 self .http_force = http_force
94+ self .live_endpoint_prefix = live_endpoint_prefix
9495
9596 def _determine_api_url (self , platform , service , action ):
9697 """This returns the Adyen API endpoint based on the provided platform,
@@ -105,7 +106,7 @@ def _determine_api_url(self, platform, service, action):
105106 if service == "Recurring" :
106107 api_version = settings .API_RECURRING_VERSION
107108 else :
108- api_version = settings .API_VERSION
109+ api_version = settings .API_PAYOUT_VERSION
109110 return '/' .join ([base_uri , service , api_version , action ])
110111
111112 def _determine_hpp_url (self , platform , action ):
@@ -122,8 +123,7 @@ def _determine_hpp_url(self, platform, action):
122123 result = '/' .join ([base_uri , service ])
123124 return result
124125
125- def _determine_checkout_url (self , platform , service , action ,
126- live_endpoint_prefix = None ):
126+ def _determine_checkout_url (self , platform , service , action ):
127127 """This returns the Adyen API endpoint based on the provided platform,
128128 service and action.
129129
@@ -132,18 +132,18 @@ def _determine_checkout_url(self, platform, service, action,
132132 service (str): API service to place request through.
133133 action (str): the API action to perform.
134134 """
135- base_uri = settings .BASE_CHECKOUT_URL .format (platform )
136- api_version = settings .CHECKOUT_API_VERSION
137- if live_endpoint_prefix is not None :
138- base_uri = settings .ENDPOINT_PROTOCOL + live_endpoint_prefix \
139- + settings .CHECKOUT_URL_LIVE_SUFFIX
135+ base_uri = settings .ENDPOINT_CHECKOUT_URL .format (platform )
136+ api_version = settings .API_CHECKOUT_VERSION
137+ if self . live_endpoint_prefix is not None :
138+ base_uri = settings .ENDPOINT_PROTOCOL + self . live_endpoint_prefix \
139+ + settings .ENDPOINT_CHECKOUT_LIVE_SUFFIX
140140
141141 if action == "paymentsDetails" :
142142 action = "payments/details"
143143 if action == "paymentsResult" :
144144 action = "payment/result"
145145 if action == "originKeys" :
146- api_version = settings .CHECKOUT_UTILITY_API_VERSION
146+ api_version = settings .API_CHECKOUT_UTILITY_VERSION
147147
148148 return '/' .join ([base_uri , api_version , action ])
149149
@@ -216,47 +216,47 @@ def call_api(self, request_data, service, action, idempotency=False,
216216
217217 # username at self object has highest priority. fallback to root module
218218 # and ensure that it is set.
219+ if self .xapikey :
220+ xapikey = self .xapikey
221+ elif 'xapikey' in kwargs :
222+ xapikey = kwargs .pop ("xapikey" )
223+
219224 if self .username :
220225 username = self .username
221226 elif 'username' in kwargs :
222227 username = kwargs .pop ("username" )
223228 elif service == "Payout" :
224- if any (substring in action for substring in ["store" , "submit" ]):
229+ if any (substring in action for substring in
230+ ["store" , "submit" ]):
225231 username = self ._store_payout_username (** kwargs )
226232 else :
227233 username = self ._review_payout_username (** kwargs )
228234 if not username :
229235 errorstring = """Please set your webservice username.
230- You can do this by running 'Adyen.username = 'Your username'"""
236+ You can do this by running
237+ 'Adyen.username = 'Your username'"""
231238 raise AdyenInvalidRequestError (errorstring )
232-
233- # password at self object has highest priority. fallback to root module
234- # and ensure that it is set.
239+ # password at self object has highest priority.
240+ # fallback to root module
241+ # and ensure that it is set.
235242 if self .password :
236243 password = self .password
237244 elif 'password' in kwargs :
238245 password = kwargs .pop ("password" )
239246 elif service == "Payout" :
240- if any (substring in action for substring in ["store" , "submit" ]):
247+ if any (substring in action for substring in
248+ ["store" , "submit" ]):
241249 password = self ._store_payout_pass (** kwargs )
242250 else :
243251 password = self ._review_payout_pass (** kwargs )
244252 if not password :
245253 errorstring = """Please set your webservice password.
246- You can do this by running 'Adyen.password = 'Your password'"""
254+ You can do this by running
255+ 'Adyen.password = 'Your password'"""
247256 raise AdyenInvalidRequestError (errorstring )
248257 # xapikey at self object has highest priority.
249258 # fallback to root module
250259 # and ensure that it is set.
251- if self .xapikey :
252- xapikey = self .xapikey
253- elif 'xapikey' in kwargs :
254- xapikey = kwargs .pop ("xapikey" )
255- if not xapikey :
256- errorstring = """Please set your webservice xapikey.
257- You can do this by running
258- 'Adyen.xapikey = 'Your xapikey'"""
259- raise AdyenInvalidRequestError (errorstring )
260260
261261 # platform at self object has highest priority. fallback to root module
262262 # and ensure that it is set to either 'live' or 'test'.
0 commit comments