weixin-java-pay-demo icon indicating copy to clipboard operation
weixin-java-pay-demo copied to clipboard

微信商户红包 一直签名失败。

Open Being789 opened this issue 2 years ago • 1 comments

问题(提问前,请确保阅读过项目首页说明以及SDK wiki文档相关内容)

简要描述

最近这两天使用微信的商家红包,然后使用了该方法

public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack"; if (request.getAmtType() != null) { //裂变红包 url = this.payService.getPayBaseUrl() + "/mmpaymkttransfers/sendgroupredpack"; } String responseContent = this.payService.post(url, request.toXML(), true); final WxPaySendRedpackResult result = BaseWxPayResult.fromXML(responseContent, WxPaySendRedpackResult.class); result.checkResult(this.payService, request.getSignType(), true); return result; }

问题出现在了,商家红包的签名必须使用V2 的KEY ,但是里面的方法使用的是MchKey。 目前微信的商家红包好像只停留在了V2版本,V3都不支持。必须使用V2的key。

就是以下这段代码出现了问题。 //设置签名字段的值 this.setSign(SignUtils.createSign(this, this.getSignType(), config.getMchKey(), this.getIgnoredParamsForSign()));

我看没有其他人提这个问题。我把V2的key替换掉之后就成功了。 WxPayConfig 里面可能需要新增apiV2Key。然后在红包签名的地方使用该key。

版本情况

  • WxJava 版本号: weixin-java-pay-4.5.0

期待结果

尽量详细描述

实际情况

尽量详细描述

重现步骤

日志

日志内容如果过多,请将日志放在 pastebin 或者其他地方,并将url地址贴在这里

Being789 avatar Nov 01 '23 03:11 Being789