配置中提交的微信支付商户证书号,
回调之后的参数中的微信支付商户证书号与提交的微信支付商户证书号参数不一致,导致验证失败。
RSAConfig configgg =
new RSAConfig.Builder()
.merchantId(merchantId)
// 使用 com.wechat.pay.jav中的函数从本地文件中加载商户私钥a.core.util
// ,商户私钥会用来生成请求的签名
// .privateKey(privateKeyString)
.privateKey(merchantPrivateKey)
// .privateKeyFromPath(privateKeyPath)
.merchantSerialNumber("1E2DDBE63EB76C202A6ADF5FACA2D721A315B6E1")
.wechatPayCertificates(merchantCertificateKey)
// .wechatPayCertificatesFromPath(MERCHANT_CERTIFICATE_STRING)
.build();
提交的
1E2DDBE63EB76C202A6ADF5FACA2D721A315B6E1
回调的
6544DD6CBB9A62064D430FC1958391DDB243B564
2022-08-30 17:03:24.522 12714-12714/com.tunshugongshe.client E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tunshugongshe.client, PID: 12714
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tunshugongshe.client/com.tunshugongshe.client.activity.shoppingCart.OrderSettlementtActivity}: com.tunshugongshe.client.webchat.core.exception.ValidationException: Validate response failed,the WechatPay signature is incorrect.
Request-ID[08DCA4B7980610A906189DE0B74C209FFA0F28FCAE04-0] responseHeader[Keep-Alive=timeout=8,Wechatpay-Timestamp=1661850205,Server=nginx,X-Content-Type-Options=nosniff,Connection=keep-alive,Date=Tue, 30 Aug 2022 09:03:25 GMT,Wechatpay-Signature-Type=WECHATPAY2-SHA256-RSA2048,Wechatpay-Serial=6544DD6CBB9A62064D430FC1958391DDB243B564,Wechatpay-Nonce=b498e4bd510262f44b9de073f53c2ebc,Wechatpay-Signature=vL+BiavViLJbBL29USqkuTmGNhhdBG2hS+TtCtKMqv/GvjwEbQ2fh1xotWvcQsKGXgzWHh//OLmA5jUZBEVlYlkt8HmKCGq8d5M2Q6M4+yPsCJ6kv1zjFKHcoIj8HX43OTLGPGojYoPK+1SoXBeD86KSy47PGRX0B1N2QfDgxLudbA0fE7HXyEBWxgAPDO5V7xiKIc8NO0yuuQbfHuUMp77ecQq4MgAHX3B70G2A2AqxemD+XnXz44miMAWi95klGC0W5un1JbV3xt8lQ1fSiIqNM8e/r5zKVSDmOt+B7nSy1dAUYTdIrjb0R9PDGf/wV9jofnfaDufzvfFlO/NKmQ==,Cache-Control=no-cache, must-revalidate,Content-Length=52,Request-ID=08DCA4B7980610A906189DE0B74C209FFA0F28FCAE04-0,Content-Language=zh-CN,Content-Type=application/json; charset=utf-8
] responseBody[{"prepay_id":"wx301703249909580aa1fc28f7cee87f0000"}]
问题解决了吗?
正确答案: config设置错了,这个配置会用平台证书验证response的签名,就不会报错了 // 示例代码 Config config = new RSAAutoCertificateConfig.Builder() .merchantId(mchid) .privateKeyFromPath(privateKeyPath) .merchantSerialNumber(merchantSerialNumber) .apiV3Key(apiV3key) .build(); JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build(); QueryOrderByOutTradeNoRequest queryRequest = new QueryOrderByOutTradeNoRequest(); queryRequest.setMchid(mchid); queryRequest.setOutTradeNo(outTradeNo);
请问下怎么解决的?
解决了吗兄弟