Closed pigping88 closed 1 year ago
com.github.binarywang.wxpay.exception.WxPayException: 非法请求,头部信息验证失败 at com.github.binarywang.wxpay.service.impl.BaseWxPayServiceImpl.parseOrderNotifyV3Result(BaseWxPayServiceImpl.java:350)
wx: pay:
mchId: xxxxxx
# 微信支付商户密钥
#mchKey: abcdefghijklmn
# path除了classpath也可以用url
keyPath: classpath:cert/apiclient_cert.p12
privateKeyPath: classpath:cert/apiclient_key.pem
privateCertPath: classpath:cert/apiclient_cert.pem
apiV3Key: xxxxxx
certSerialNo: xxxxxx
sandboxEnabled: false
payNotifyUrl: xxxxxx
refundNotifyUrl: xxxxxx
@Bean @ConditionalOnMissingBean public WxPayService wxPayService() { if (StringUtils.isBlank(properties.getMchId())) { log.error("微信商户号配置无效,请检查!"); return new WxPayServiceImpl(); }
WxPayService wxPayService = new WxPayServiceImpl();
WxPayConfig payConfig = new WxPayConfig();
payConfig.setMchId(StringUtils.trimToNull(properties.getMchId()));
payConfig.setMchKey(StringUtils.trimToNull(properties.getMchKey()));
payConfig.setSubAppId(StringUtils.trimToNull(properties.getSubAppId()));
payConfig.setSubMchId(StringUtils.trimToNull(properties.getSubMchId()));
payConfig.setKeyPath(StringUtils.trimToNull(properties.getKeyPath()));
payConfig.setApiV3Key(StringUtils.trimToNull(properties.getApiV3Key()));
payConfig.setCertSerialNo(StringUtils.trimToNull(properties.getCertSerialNo()));
payConfig.setPrivateKeyPath(StringUtils.trimToNull(properties.getPrivateKeyPath()));
payConfig.setPrivateCertPath(StringUtils.trimToNull(properties.getPrivateCertPath()));
// 可以指定是否使用沙箱环境
payConfig.setUseSandboxEnv(BooleanUtils.toBoolean(properties.getSandboxEnabled()));
wxPayService.setConfig(payConfig);
return wxPayService;
}
certSerialNo给的apiv3证书的序列号,平台证书,看了下实现代码,都是自动获取的,怎么就验证支付回调签名失败呢,支付回调又不怎么好调试,需要https,本地用内网穿透,还差点https,线上源码包,没法给日志,不太好追踪具体啥导致的签名失败
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
同样的问题
我也是,而且是偶尔会报一下,哎 头都麻了
可以看一下signature是否为WECHATPAY/SIGNTEST
开头,可能是微信在探测流量
https://pay.weixin.qq.com/docs/partner/development/interface-rules/signature-verification.html
发现头部序列号和商户的证书的序列号不一致,代码扫了下,没看到平台证书获取,配置的地方,导致签名验证失败了