代码语言:javascript复制
参数
sign_data = {
"appid": APP_ID,
"mch_id": MCAH_ID,
"out_trade_no": order.order_num,
"transaction_id": order.pay_order,
"customs": "xxxxx",
"mch_customs_no": "xxxxx"
}
sign_ret = generate_sign(sign_data)
代码语言:javascript复制生成签名
def generate_sign(param):
stringA = ''
ks = sorted(param.keys())
for k in ks:
stringA = (k '=' param[k] '&')
stringSignTemp = stringA "key=" "v2key"
hash_md5 = hashlib.md5(stringSignTemp.encode('utf8'))
sign = hash_md5.hexdigest().upper()
return sign