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


    这两天做微信现金红包,返回数据总是提示签名错误,我自己生成的签名和微信提供的签名验证接口生产的一模一样 ,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

      

  • 相关阅读:
    Air Raid HDU
    Strategic Game HDU
    Antenna Placement POJ
    Load Testing CodeForces
    Packmen CodeForces
    Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
    Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
    Dog Show CodeForces
    Sum of Nestings CodeForces
    Preparing for Merge Sort CodeForces
  • 原文地址:https://www.cnblogs.com/maoyvwang/p/10033450.html
Copyright © 2020-2023  润新知