@@ -261,13 +261,7 @@ def call_api(
261261 successful.
262262 """
263263 if not self .http_init :
264- self .http_client = HTTPClient (
265- user_agent_suffix = self .USER_AGENT_SUFFIX ,
266- lib_version = self .LIB_VERSION ,
267- force_request = self .http_force ,
268- timeout = self .http_timeout ,
269- )
270- self .http_init = True
264+ self ._init_http_client ()
271265
272266 # username at self object has highest priority. fallback to root module
273267 # and ensure that it is set.
@@ -380,6 +374,15 @@ def call_api(
380374
381375 return adyen_result
382376
377+ def _init_http_client (self ):
378+ self .http_client = HTTPClient (
379+ user_agent_suffix = self .USER_AGENT_SUFFIX ,
380+ lib_version = self .LIB_VERSION ,
381+ force_request = self .http_force ,
382+ timeout = self .http_timeout ,
383+ )
384+ self .http_init = True
385+
383386 def call_hpp (self , message , action , hmac_key = "" , ** kwargs ):
384387 """This will call the adyen hpp. hmac_key and platform are pulled from
385388 root module level and or self object.
@@ -399,10 +402,7 @@ def call_hpp(self, message, action, hmac_key="", **kwargs):
399402 :param hmac_key:
400403 """
401404 if not self .http_init :
402- self .http_client = HTTPClient (self .USER_AGENT_SUFFIX ,
403- self .LIB_VERSION ,
404- self .http_force )
405- self .http_init = True
405+ self ._init_http_client ()
406406
407407 # hmac provided in function has highest priority. fallback to self then
408408 # root module and ensure that it is set.
@@ -466,10 +466,7 @@ def call_checkout_api(self, request_data, action, idempotency_key=None,
466466 action (str): The specific action of the API service to be called
467467 """
468468 if not self .http_init :
469- self .http_client = HTTPClient (self .USER_AGENT_SUFFIX ,
470- self .LIB_VERSION ,
471- self .http_force )
472- self .http_init = True
469+ self ._init_http_client ()
473470
474471 # xapi at self object has highest priority. fallback to root module
475472 # and ensure that it is set.
@@ -548,12 +545,8 @@ def call_checkout_api(self, request_data, action, idempotency_key=None,
548545 return adyen_result
549546
550547 def hpp_payment (self , request_data , action , hmac_key = "" , ** kwargs ):
551-
552548 if not self .http_init :
553- self .http_client = HTTPClient (self .USER_AGENT_SUFFIX ,
554- self .LIB_VERSION ,
555- self .http_force )
556- self .http_init = True
549+ self ._init_http_client ()
557550
558551 platform = self .platform
559552 if not isinstance (platform , str ):
0 commit comments