当前位置: 移动技术网 > IT编程>开发语言>Java > 微信现金红包签名失败问题

微信现金红包签名失败问题

2018年11月29日  | 移动技术网IT编程  | 我要评论

这两天做微信现金红包,返回数据总是提示签名错误,我自己生成的签名和微信提供的签名验证接口生产的一模一样 ,api密钥也没有错,就是不知道什么问题,网上查了一圈,发现是微信文档有点坑,参数一定要按照下面的顺序生产签名才可以,对所有待签名参数按照字段名的ascii 码从小到大排序(字典序)

<act_name>act_name</act_name>
<client_ip>client_ip</client_ip>
<mch_billno>mch_billno</mch_billno>
<mch_id>mch_id</mch_id>
<nonce_str>nonce_str</nonce_str>
<re_openid>re_openid</re_openid>
<remark>remark</remark>
<send_name>send_name</send_name>
<total_amount>total_amount</total_amount>
<total_num>total_num</total_num>
<wishing>wishing</wishing>
<wxappid>wxappid</wxappid>
<sign>sign</sign>

 

下面是部分代码

 1  1 map<string,string> map = new linkedhashmap<string,string>();
 2  2 //生成签名
 3  3 map.put("act_name", sendredpack.getact_name());
 4  4 map.put("client_ip", sendredpack.getclient_ip());
 5  5 map.put("mch_billno", sendredpack.getmch_billno());
 6  6 map.put("mch_id", sendredpack.getmch_id());
 7  7 map.put("nonce_str", sendredpack.getnonce_str());
 8  8 map.put("re_openid", sendredpack.getre_openid());
 9  9 map.put("remark", sendredpack.getremark());
10 10 map.put("send_name", sendredpack.getsend_name());
11 11 map.put("total_amount", sendredpack.gettotal_amount());
12 12 map.put("total_num", sendredpack.gettotal_num());
13 13 map.put("wishing", sendredpack.getwishing());
14 14 map.put("wxappid", sendredpack.getwxappid());
15 15 
16 16 string sign = wxpayutil.generatesignature(map, key); //采用md5签名
view code

 

  

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网