예제 #1
0
 def jwt_url_connection(self, mconfig, logger=None):
     self.merchantconfig = mconfig
     self.jwt_method = mconfig.request_type_method
     self.date_time = mconfig.get_time()
     self.jwt_connection()
     self.logger = LogFactory.setup_logger(self.__class__.__name__,
                                           mconfig.log_config)
 def get_method_headers(self):
     logger = LogFactory.setup_logger(self.__class__.__name__, self.merchant_config.log_config)
     try:
         auth = Authorization()
         authentication_type = self.merchant_config.authentication_type
         
         print("Request Type         :" + self.request_type)
         print(GlobalLabelParameters.CONTENT_TYPE + "         :" + GlobalLabelParameters.APPLICATION_JSON)
         
         if authentication_type.upper() == GlobalLabelParameters.HTTP.upper():
             print(" " + GlobalLabelParameters.USER_AGENT + "          : " + GlobalLabelParameters.USER_AGENT_VALUE)
             print(" MerchantID          : " + self.merchant_config.merchant_id)
             print(" Date                : " + self.merchant_config.get_time())
             
             temp_sig = auth.get_token(self.merchant_config, self.date)
             print("Signature Header      :" + str(temp_sig))
             print("Host                  :" + self.merchant_config.request_host)
         else:
             temp_sig = auth.get_token(self.merchant_config, self.date)
             print("Authorization Bearer:         " + str(temp_sig.encode("utf-8").decode("utf-8")))
         if self.merchant_config.log_config.enable_log is True:
             logger.info("END> ======================================= ")
             logger.info("\n")
     except ApiException as e:
         authenticationsdk.util.ExceptionAuth.log_exception(logger, e, self.merchant_config)
     except Exception as e:
         authenticationsdk.util.ExceptionAuth.log_exception(logger, repr(e), self.merchant_config)
 def payment_get(self, mconfig):
     self.logger = LogFactory.setup_logger(self.__class__.__name__, mconfig.log_config)
     try:
         authorization = Authorization()
         authorization.validate_request_type_method(mconfig)
         # Calls PaymentRequestService class of service of sampleapiclient
         payment_req_obj = PaymentRequestService()
         payment_req_obj.payment_request_service(mconfig)
     except ApiException as e:
         authenticationsdk.util.ExceptionAuth.log_exception(self.logger, e, mconfig.log_config)
     except Exception as e:
         authenticationsdk.util.ExceptionAuth.log_exception(self.logger, repr(e), mconfig.log_config)
def json_file_data(path, mconfig):
    logger = LogFactory.setup_logger("RequestData", mconfig.log_config)
    try:
        if path == "" or path is None:
            raise ApiException(0, GlobalLabelParameters.REQUEST_JSON_EMPTY)

        else:
            digest_obj = DigestAndPayload()
            return digest_obj.string_payload_generation(path)
    except IOError as e:

        authenticationsdk.util.ExceptionAuth.log_exception(logger,
                                                           GlobalLabelParameters.REQUEST_JSON_ERROR + str(e.filename),
                                                           mconfig)
    def http_connection(self, mconfig, logger=None):
        self.logger = LogFactory.setup_logger(self.__class__.__name__,
                                              mconfig.log_config)
        try:

            self.http_merchant_config = mconfig
            self.request_type = mconfig.request_type_method
            self.merchant_id = mconfig.merchant_id
            self.merchant_key_id = mconfig.merchant_keyid
            self.merchant_secret_key = mconfig.merchant_secretkey

            self.http_connection_request()
        except Exception as e:
            authenticationsdk.util.ExceptionAuth.log_exception(
                self.logger, repr(e), mconfig)
 def __init__(self):
     self.logger = LogFactory.setup_logger(self.__class__.__name__)