コード例 #1
0
    def __init__(self, mch_id, appid, nick_name, send_name, openid,
                 total_amount, min_value, max_value, total_num, wishing,
                 client_ip, act_name, remark, api_key):
        self.mch_billno = "%s%s%s" % (
            mch_id, time.strftime("%Y%m%d%H%M%S", time.localtime()), ''.join(
                random.sample(string.ascii_letters + string.digits, 4)))
        self.nonce_str = ''.join(
            random.sample(string.ascii_letters + string.digits, 32))

        package_list = {
            'nonce_str': self.nonce_str,
            'mch_billno': self.mch_billno,
            'mch_id': mch_id,
            'wxappid': appid,
            'nick_name': nick_name,
            'send_name': send_name,
            're_openid': openid,
            'total_amount': total_amount,
            'min_value': min_value,
            'max_value': max_value,
            'total_num': total_num,
            'wishing': wishing,
            'client_ip': client_ip,
            'act_name': act_name,
            'remark': remark
        }
        key_list = sorted(package_list.keys())
        sign_str = u''
        for key in key_list:
            sign_str += u"%s=%s&" % (key, package_list[key])
        sign_str += 'key=' + api_key
        print sign_str
        self.sign = md5_sign(sign_str)
        package_list['sign'] = self.sign
        self.package_list = package_list
コード例 #2
0
    def __init__(self,
                 app_id,
                 app_key,
                 partner_id,
                 partner_key,
                 out_trade_no,
                 sign_method='md5'):
        QueryOrderMessage.__init__(self, app_id, partner_id, partner_key,
                                   out_trade_no)

        if app_key == None or app_key == '':
            raise ValueError(u'app_key con not be none or ""')

        self.app_key = app_key
        self.sign_method = sign_method
        self.timestamp = str(int(time.time()))

        sign = md5_sign(
            "out_trade_no=%s&partner=%s" %
            (self.out_trade_no, self.partner_id), self.partner_key)
        self.package = "out_trade_no=%s&partner=%s&sign=%s" % (
            self.out_trade_no, self.partner_id, sign)
        self.app_signature = sha1_sign(
            "appid=%s&appkey=%s&package=%s&timestamp=%s" %
            (self.app_id, self.app_key, self.package, self.timestamp))
コード例 #3
0
ファイル: alipay_submit.py プロジェクト: chengdg/weizoom
	def _build_request_sign(self, params):
		assert_param(params)

		link_str = create_link_str(params, self.alipay_config)
		if self.alipay_config.sign_type != 'MD5':
			raise ValueError('Only surpport md5 sign right now')

		return md5_sign(link_str, self.alipay_config.key)
コード例 #4
0
ファイル: alipay_core.py プロジェクト: chengdg/weizoom
def build_request_sign(params):
    assert_param(params)

    link_str = create_link_str(params,
                               params[AlipayRequestParams.INPUT_CHARSET])
    if params[AlipayRequestParams.SEC_ID] != 'MD5':
        raise ValueError('Only surpport md5 sign right now')

    return md5_sign(link_str, params['key'])
コード例 #5
0
    def __init__(self, app_id, partner_id, partner_key, out_trade_no):
        QueryOrderMessage.__init__(self, app_id, partner_id, partner_key,
                                   out_trade_no)

        self.nonce_str = ''.join(
            random.sample(string.ascii_letters + string.digits, 32))
        self.sign = md5_sign(
            "appid=%s&mch_id=%s&nonce_str=%s&out_trade_no=%s" %
            (self.app_id, self.partner_id, self.nonce_str, self.out_trade_no),
            self.partner_key)
コード例 #6
0
    def __init__(self,
                 appid,
                 mch_id,
                 partner_key,
                 out_trade_no,
                 total_fee,
                 spbill_create_ip,
                 notify_url,
                 openid,
                 body=''):
        if appid == None or appid == '':
            raise ValueError(u'appid con not be none or ""')

        if mch_id == None or mch_id == '':
            raise ValueError(u'mch_id con not be none or ""')

        if partner_key == None or partner_key == '':
            raise ValueError(u'partner_key con not be none or ""')

        if out_trade_no == None or out_trade_no == '':
            raise ValueError(u'out_trade_no con not be none or ""')

        if total_fee == None or total_fee == '':
            raise ValueError(u'total_ffee con not be none or ""')

        if spbill_create_ip == None or spbill_create_ip == '':
            raise ValueError(u'spbill_create_ip con not be none or ""')

        if notify_url == None or notify_url == '':
            raise ValueError(u'notify_url con not be none or ""')

        if openid == None or openid == '':
            raise ValueError(u'openid con not be none or ""')

        self.appid = appid
        self.mch_id = mch_id
        self.partner_key = partner_key
        self.out_trade_no = out_trade_no
        self.total_fee = total_fee
        self.spbill_create_ip = spbill_create_ip
        self.notify_url = notify_url
        self.openid = openid
        self.body = body

        self.nonce_str = ''.join(
            random.sample(string.ascii_letters + string.digits, 32))

        package_list = {
            'trade_type': 'JSAPI',
            'appid': appid,
            'body': body.encode('utf8'),
            'mch_id': mch_id,
            'nonce_str': self.nonce_str,
            'notify_url': notify_url,
            'openid': openid,
            'out_trade_no': out_trade_no,
            'spbill_create_ip': spbill_create_ip,
            'total_fee': total_fee
        }
        key_list = sorted(package_list.keys())
        sign_str = u''
        for key in key_list:
            sign_str += u"%s=%s&" % (key, package_list[key])
        sign_str += 'key=' + partner_key
        self.sign = md5_sign(sign_str)