예제 #1
0
    def request_from_json(self, json_request, encoded=True):
        """
        Method produces HppRequest object from JSON.
        Carries out the following actions:
            * Deserialize JSON to request object
            * Decodes Base64 inputs
            * Validates inputs
        :param json_request: string
        :param encoded: bool
        :return: HppRequest
        """
        logger.info("Converting JSON to HppRequest.")

        logger.debug("Decoding object.")
        try:
            hpp_request = JsonUtils.from_json_hpp_request(
                json_request, self.encoding_charset, encoded)
        except Exception as e:
            error_msg = "Exception decoding json HPP request"
            logger.error("{}: {}".format(error_msg, e))
            raise SdkError(error_msg, e)

        # validate request
        attr.validate(hpp_request)

        return hpp_request
예제 #2
0
def json_hpp_card_storage_request_encoded():
    path = get_sample_path('samples/hpp_card_storage_request_encoded.json')
    with codecs.open(path, 'r', encoding='utf-8') as data_file:
        yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', True)
예제 #3
0
def json_hpp_payment_request_supplementary_data():
    path = get_sample_path(
        'samples/hpp_payment_request_supplementary_data.json')
    with codecs.open(path, 'r', encoding='utf-8') as data_file:
        yield JsonUtils.from_json_hpp_request(data_file.read(), 'utf-8', False)