Beispiel #1
0
        self.query_params[Constants.PAYZIPPY_TRANSACTION_ID] = payzippy_transaction_id

    def set_hash_method(self, hash_method):
        self.query_params[Constants.HASH_METHOD] = hash_method

    def set_hash(self, hashval):
        self.query_params[Constants.HASH] = hashval

    def set_merchant_transaction_id(self, merchant_transaction_id):
        self.query_params[Constants.MERCHANT_TRANSACTION_ID] = merchant_transaction_id

    def set_transaction_type(self, transaction_type):
        self.query_params[Constants.TRANSACTION_TYPE] = transaction_type

    def query(self):
        try:
            ValidityCheck.validate_query_params(self.query_params)
        except Exception, e:
            raise Exception("Invalid parameter : " + str(e))
        else:
            hash_util = HashUtil(self.query_params, self.query_params.get(Constants.HASH_METHOD))
            self.query_params[Constants.HASH] = hash_util.generate_hash()

            params = urllib.urlencode(self.query_params)
            conn = httplib.HTTPSConnection(self.query_api_host)
            conn.request(Constants.POST_METHOD, self.query_api_path, params, Constants.HEADERS)
            response = conn.getresponse()
            data = response.read()
            conn.close()
        return QueryResponse(data)
 def is_valid_response(self):
     hash_util = HashUtil(self.params,
                          self.params.get(Constants.HASH_METHOD))
     return self.params.get(Constants.HASH) == hash_util.generate_hash()
Beispiel #3
0
 def is_valid_response(self):
     hash_util = HashUtil(self.response_params, self.response_params.get(Constants.HASH_METHOD))
     return self.response_params.get(Constants.HASH) == hash_util.generate_hash()
Beispiel #4
0
        self.query_params[Constants.HASH_METHOD] = hash_method

    def set_hash(self, hashval):
        self.query_params[Constants.HASH] = hashval

    def set_merchant_transaction_id(self, merchant_transaction_id):
        self.query_params[
            Constants.MERCHANT_TRANSACTION_ID] = merchant_transaction_id

    def set_transaction_type(self, transaction_type):
        self.query_params[Constants.TRANSACTION_TYPE] = transaction_type

    def query(self):
        try:
            ValidityCheck.validate_query_params(self.query_params)
        except Exception, e:
            raise Exception("Invalid parameter : " + str(e))
        else:
            hash_util = HashUtil(self.query_params,
                                 self.query_params.get(Constants.HASH_METHOD))
            self.query_params[Constants.HASH] = hash_util.generate_hash()

            params = urllib.urlencode(self.query_params)
            conn = httplib.HTTPSConnection(self.query_api_host)
            conn.request(Constants.POST_METHOD, self.query_api_path, params,
                         Constants.HEADERS)
            response = conn.getresponse()
            data = response.read()
            conn.close()
        return QueryResponse(data)
Beispiel #5
0
    # ======================================
    # Charge method, and its helping methods
    # ======================================

    def charge(self):
        try:
            ValidityCheck.validate_charge_params(self.request_params)
        except Exception, e:
            self.response[Constants.STATUS] = Constants.ERROR
            self.response[
                Constants.ERROR_MESSAGE] = "Invalid parameter : " + str(e)
        else:
            self.set_timegmt()

            hash_util = HashUtil(
                self.request_params,
                self.request_params.get(Constants.HASH_METHOD))
            self.request_params[Constants.HASH] = hash_util.generate_hash()

            if self.request_params[Constants.UI_MODE] == Constants.IFRAME:
                url = Config.charging_url + "?" + urllib.urlencode(
                    self.request_params)
            else:
                url = Config.charging_url

            self.response[Constants.PARAMS] = self.request_params
            self.response[Constants.URL] = url
            self.response[Constants.STATUS] = Constants.OK
        return self.response
Beispiel #6
0
        self.request_params[Constants.HASH] = hashval

    def get_charging_api_url(self):
        return self.charging_api_url

    # ======================================
    # Charge method, and its helping methods
    # ======================================

    def charge(self):
        try:
            ValidityCheck.validate_charge_params(self.request_params)
        except Exception, e:
            self.response[Constants.STATUS] = Constants.ERROR
            self.response[Constants.ERROR_MESSAGE] = "Invalid parameter : " + str(e)
        else:
            self.set_timegmt()

            hash_util = HashUtil(self.request_params, self.request_params.get(Constants.HASH_METHOD))
            self.request_params[Constants.HASH] = hash_util.generate_hash()

            if self.request_params[Constants.UI_MODE] == Constants.IFRAME:
                url = Config.charging_url + "?" + urllib.urlencode(self.request_params)
            else:
                url = Config.charging_url

            self.response[Constants.PARAMS] = self.request_params
            self.response[Constants.URL] = url
            self.response[Constants.STATUS] = Constants.OK
        return self.response