@@ -79,6 +79,8 @@ def __init__(self, username=None, password=None,
7979 self .store_payout_username = store_payout_username
8080 self .store_payout_password = store_payout_password
8181 self .platform = platform
82+ if not self .platform :
83+ self .platform = 'test'
8284 self .merchant_specific_url = merchant_specific_url
8385 self .hmac = hmac
8486 self .merchant_account = merchant_account
@@ -308,9 +310,8 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
308310
309311 # hmac provided in function has highest priority. fallback to self then
310312 # root module and ensure that it is set.
311- if hmac_key :
312- hmac = hmac_key
313- elif self .hmac :
313+ hmac = hmac_key
314+ if self .hmac :
314315 hmac = self .hmac
315316 elif not hmac :
316317 errorstring = """Please set an hmac with your Adyen.Adyen class instance.
@@ -354,17 +355,14 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
354355
355356 def hpp_payment (self , request_data , action , hmac_key = "" , ** kwargs ):
356357
357- from . import platform
358-
359358 if not self .http_init :
360359 self .http_client = HTTPClient (self .app_name ,
361360 self .USER_AGENT_SUFFIX ,
362361 self .LIB_VERSION ,
363362 self .http_force )
364363 self .http_init = True
365364
366- if self .platform :
367- platform = self .platform
365+ platform = self .platform
368366 if platform .lower () not in ['live' , 'test' ]:
369367 errorstring = " 'platform' must be the value of 'live' or 'test' "
370368 raise ValueError (errorstring )
@@ -477,8 +475,7 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
477475 """
478476
479477 if status_code == 404 :
480- from . import merchant_specific_url
481- if url == merchant_specific_url :
478+ if url == self .merchant_specific_url :
482479 erstr = "Received a 404 for url:'{}'. Please ensure that" \
483480 " the custom merchant specific url is correct" \
484481 .format (url )
@@ -510,7 +507,6 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
510507 " if the problem persists"
511508 raise AdyenAPIAuthenticationError (erstr )
512509 elif status_code == 403 :
513- from . import username
514510
515511 if response_obj .get ("message" ) == "Invalid Merchant Account" :
516512 erstr = ("You provided the merchant account:'%s' that"
@@ -528,7 +524,7 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
528524 " the PSP reference: %s" % (
529525 response_obj ["message" ], self .username , psp_ref )
530526
531- raise AdyenAPIInvalidPermission (erstr , username , psp_ref ,
527+ raise AdyenAPIInvalidPermission (erstr , self . username , psp_ref ,
532528 raw_request = raw_request ,
533529 raw_response = raw_response , url = url ,
534530 psp = psp_ref , headers = headers )
0 commit comments