@@ -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
@@ -353,17 +355,14 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
353355
354356 def hpp_payment (self , request_data , action , hmac_key = "" , ** kwargs ):
355357
356- from . import platform
357-
358358 if not self .http_init :
359359 self .http_client = HTTPClient (self .app_name ,
360360 self .USER_AGENT_SUFFIX ,
361361 self .LIB_VERSION ,
362362 self .http_force )
363363 self .http_init = True
364364
365- if self .platform :
366- platform = self .platform
365+ platform = self .platform
367366 if platform .lower () not in ['live' , 'test' ]:
368367 errorstring = " 'platform' must be the value of 'live' or 'test' "
369368 raise ValueError (errorstring )
@@ -476,8 +475,7 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
476475 """
477476
478477 if status_code == 404 :
479- from . import merchant_specific_url
480- if url == merchant_specific_url :
478+ if url == self .merchant_specific_url :
481479 erstr = "Received a 404 for url:'{}'. Please ensure that" \
482480 " the custom merchant specific url is correct" \
483481 .format (url )
@@ -509,7 +507,6 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
509507 " if the problem persists"
510508 raise AdyenAPIAuthenticationError (erstr )
511509 elif status_code == 403 :
512- from . import username
513510
514511 if response_obj .get ("message" ) == "Invalid Merchant Account" :
515512 erstr = ("You provided the merchant account:'%s' that"
@@ -527,7 +524,7 @@ def _handle_http_error(self, url, response_obj, status_code, psp_ref,
527524 " the PSP reference: %s" % (
528525 response_obj ["message" ], self .username , psp_ref )
529526
530- raise AdyenAPIInvalidPermission (erstr , username , psp_ref ,
527+ raise AdyenAPIInvalidPermission (erstr , self . username , psp_ref ,
531528 raw_request = raw_request ,
532529 raw_response = raw_response , url = url ,
533530 psp = psp_ref , headers = headers )
0 commit comments