微信支付V2签名生成

2023-07-20 19:54:08 浏览数 (1)

代码语言: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

0 人点赞