收藏
回答

微信小程序嵌套web-view,签名错误

签名使用的是公众号的appId和key,

        //获取access_token

       String AppId="***";

        String secret="***";

        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type="+grant_type+"&appid="+AppId+"&secret="+secret;



//获取jsapi_ticket
 
        String url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="+ access_token +"&type=jsapi";
 
 
//将参数排序并拼接字符串
 
      String str = "jsapi_ticket="+jsapi_ticket+"&noncestr="+noncestr+"&timestamp="+timestamp+"&url="+url;
         
      //将字符串进行sha1加密
 
      String signature =SHA1(str);
 
      System.out.println("参数:"+str+"\n签名:"+signature);
 
      Map<String, Object> map = new HashMap<String, Object>();
 
      map.put("noncestr", noncestr);
 
      map.put("timestamp", timestamp);
 
      map.put("signature", signature);
 
      urltime.put(url, timestamp);
 
      urlSign.put(url, map);
 
      return map;



通过https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign验证的签名正确。

但是在小程序中到用JSSDK 中api包无效签名错误。

请教是什么问题

回答关注问题邀请回答
收藏

1 个回答

  • จุ๊บ
    จุ๊บ
    2019-01-19

    web-view不支持公众号网页的微信支付

    2019-01-19
    有用
    回复
登录 后发表内容