jsapi 微信底层就不过多形容了,次要记录一下,查了很多材料,发现微信返回参数不能间接返给前端应用,还须要进行一次签名,不然前台就会提醒签名谬误
// dic 微信返回的
Map<String, String> reqData = new HashMap<>();
String timeStamp = String.valueOf(WXPayUtil.getCurrentTimestamp());
String prepay_id = "prepay_id=" + dic.get("prepay_id");
reqData.put("appId", dic.get("appid"));
reqData.put("timeStamp", timeStamp);
reqData.put("nonceStr", dic.get("nonce_str"));
reqData.put("package", prepay_id);
reqData.put("signType", WXPayConstants.MD5);
应用 MD5 进行签名
String paySign = WXPayUtil.generateSignature(reqData, "微信商户号的 key", WXPayConstants.SignType.MD5);
返回前端参数
Map<String, String> data = new HashMap<>();
data.put("appId", dic.get("appid"));
data.put("timeStamp", timeStamp);
data.put("nonceStr", dic.get("nonce_str"));
data.put("package", prepay_id);
data.put("paySign", paySign);
data.put("signType", WXPayConstants.MD5);
data.put("mch_id", dic.get("mch_id"));
data.put("nvcOrderNumber", dic.get("out_trade_no"));
前端调起领取
形容比较简单,只是记录,仅供参考