WxJava icon indicating copy to clipboard operation
WxJava copied to clipboard

发起商家转账API设置公钥后,部分请求失败,提示“应答的微信支付签名验证失败”

Open tcsp opened this issue 1 year ago • 5 comments

简要描述

使用4.7.4.B版本进行v3的支付请求,商户号后台已经开启公钥转换,部分请求报错“应答的微信支付签名验证失败”

模块版本情况

  • WxJava 模块名: weixin-java-pay
  • WxJava 版本号: 4.7.4.B

详细描述

WxPayConfig中已经设置了publicKeyId和publicKeyPath,目前部分请求可以成功,但是部分请求失败。

日志

org.apache.http.HttpException: 应答的微信支付签名验证失败
    at com.github.binarywang.wxpay.v3.SignatureExec.executeWithSignature(SignatureExec.java:86)
    at com.github.binarywang.wxpay.v3.SignatureExec.execute(SignatureExec.java:60)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute$original$CXZdG3oL(InternalHttpClient.java:185)
    at org.apache.http.impl.client.InternalHttpClient.doExecute$original$CXZdG3oL$accessor$QqM84g9U(InternalHttpClient.java)
    at org.apache.http.impl.client.InternalHttpClient$auxiliary$zhNVrxxa.call
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at com.github.binarywang.wxpay.service.impl.WxPayServiceApacheHttpImpl.postV3WithWechatpaySerial(WxPayServiceApacheHttpImpl.java:179)
    at com.github.binarywang.wxpay.service.impl.TransferServiceImpl.transferBatches(TransferServiceImpl.java:36)

tcsp avatar May 28 '25 07:05 tcsp

是否尝试过最新版

binarywang avatar May 28 '25 08:05 binarywang

@binarywang 更新到4.7.5.B尝试过,还是一样的表现。诡异的是部分成功,部分失败。

tcsp avatar May 28 '25 08:05 tcsp

我的意思是首页展示的最新版本,你可以细看下首页版本说明

binarywang avatar May 29 '25 03:05 binarywang

@binarywang 试了4.7.5-20250528.161554这个版本还是不行,只能自己本地加下日志,打包个版本调试下了。光看代码是没什么头绪

tcsp avatar May 29 '25 05:05 tcsp

加了下日志,找到问题所在了。最后是生产环境运维所传的公钥文件是另一个商户号的,导致v3请求验签一直过不去。但是测试环境上的公钥文件又是对的,导致测试环境一直复现不出来。生产环境是通过动态配置项进行公钥配置开关,但是由于该方法底层合并了v2和v3的支付接口,v2部分接口不需要使用公钥验签,所以该部分接口不会报错,但是v3部分接口其实全部报错。没有细查的情况下误认为是同样公钥生效的情况下,一部分成功,一部分失败。

最终结论是代码没有什么问题。

tcsp avatar May 29 '25 08:05 tcsp