生成支付秘钥和签名秘钥的算法如下
//支付密钥算法
public static String calcPaySig(String uri, String postBody, String appKey) {
String needSign = uri + "&" + postBody;
HMac paySignMac = new HMac(HmacAlgorithm.HmacSHA256, appKey.getBytes(StandardCharsets.UTF_8));
return paySignMac.digestHex(needSign);
}
// 签名密钥算法
public static String calcSignature(String postBody, String sessionKey) {
HMac signatureMac = new HMac(HmacAlgorithm.HmacSHA256, sessionKey.getBytes(StandardCharsets.UTF_8));
return signatureMac.digestHex(postBody);
}
可以收集下参数用验签工具验下签https://pay.weixin.qq.com/docs/merchant/development/verify-signature/verify-signature-tool.html