请教支付验证签名失败怎么处理?

微信支付 文章 2020-08-29 20:41 0 98 全屏看文

请教支付验证签名失败怎么处理?How to deal with payment verification signature failure?

请教支付验证签名失败怎么处理?

问题描述:统一下单之后,生成二次签名,传入 wx.requestPayment拉起支付,扫码提示:支付验证签名失败。

后端java代码:

Long timeStamp = System.currentTimeMillis() / 1000;r.put("timeStamp", timeStamp.toString());r.put("nonceStr",WXPayUtil.generateNonceStr());String prepay_id = result.get("prepay_id");r.put("package","prepay_id="+prepay_id);r.put("signType", WXPayConstants.MD5);r.put("appId",DefaultConsts.WX_APPID);;String sign = WXPayUtil.generateSignature(r,DefaultConsts.WX_KEY);System.out.println("生成的签名paySign : "+ sign);r.put("paySign",sign);return r;


小程序代码:

 wx.requestPayment({    timeStamp: prepay.timeStamp,    nonceStr:  prepay.nonceStr,    package:  prepay.package,    signType: prepay.signType,    paySign: prepay.paySign,    success (res) {       console.log(res)       },    fail (res) {       console.log(res)        }  })


排查过程:

1.参数名称、大小写排查 -- 通过;

2.微信支付接口签名校验工具: 连接商户key之后的字符串与后端比对一致;md5之后的字符串比较:一致。

3.重置key 。

统一下单和二次签名都使用的是md5、两个方法没有数据关联。

请问还有其他需要排查的地方吗?

Problem Description: after a unified order is placed, a secondary signature is generated and passed in wx.requestPayment Pull up payment, scan code prompt: payment verification signature failed. Back end java code: long timestamp= System.currentTimeMillis () / 1000;r.put("timeStamp", timeStamp.toString ());r.put("nonceStr", WXPayUtil.generateNonceStr ());String prepay_ id = result.get ("prepay_ id");r.put("package","prepay_ id="+prepay_ id);r.put("signType", WXPayConstants.MD5 );r.put("appId", DefaultConsts.WX_ APPID);;String sign = WXPayUtil.generateSignature (R, DefaultConsts.WX_ KEY); System.out.println (generated signature: paysign) + sign; r.put ("paysign", sign); return R; applet code: wx.requestPayment ({    timeStamp: prepay.timeStamp ,    nonceStr:  prepay.nonceStr ,    package:  prepay.package ,    signType: prepay.signType ,    paySign: prepay.paySign ,    success (res) {        console.log (res)       },    fail (res) {        console.log (RES)}}) troubleshooting process: 1. Parameter name, case check -- pass; 2. Wechat payment interface signature verification tool: string after connecting merchant key is consistent with backend; string comparison after MD5: consistent. 3. Reset the key. MD5 is used for unified single and secondary signature, and there is no data association between the two methods. Is there anything else that needs to be investigated?

回答:

北望沣渭:

感觉问题出在 timeStamp.toString() 应该用 String.valueOf(timeStamp)

张磊:

补充:统一下单的回调url是一个未配置的地址,同时在本地测试。

和这个有关吗?

奎:
你用的什么支付模式?二次签名的appId是支付小程序的appId


张磊:统一下单用的:JSAPI,appId是小程序的。

-EOF-