收藏
回答

v3公钥模式下微信支付,回调签名解析失败

v3公钥模式下微信支付,回调时请求头Wechatpay-Serial返回不是公钥id,已签名字符串估计也是没根据公钥生成的,导致解析签名失败

回答关注问题邀请回答
收藏

1 个回答

  • Memory
    Memory
    03-05

    如果是平台证书向平台公钥切换期间,你需要同时兼容平台证书/平台公钥两种模式进行验签

    03-05
    有用
    回复 12
    • 。。。
      。。。
      03-05
      你好,请问下我在平台证书切换成微信支付公钥,JSAPI 支付下单使用的是 WechatpaySftConfig.rsaPublicKeyConfig =
              new RSAPublicKeyConfig.Builder()
                      .merchantId(properties.getMchId())
                      .privateKeyFromPath(properties.getPrivateKeyPath())// 商户API证书私钥的存放路径
                      .publicKeyFromPath(properties.getPublicKeyPath())//微信支付公钥的存放路径
                      .publicKeyId(properties.getPublicKeyId()) //微信支付公钥ID
                      .merchantSerialNumber(properties.getMerchantSerialNumber())
                      .apiV3Key(properties.getApiV3Key())
                      .build(); 但是返回的时候提示 publicKeyId[PUB_KEY_ID_0116410654612*****] and serialNumber[359A9DEEC3210EAC1C598C*******] are not equal,Validate response failed,the WechatPay signature is incorrect.                                           responseHeader[Keep-Alive=timeout=8,Wechatpay-Timestamp=1741078846,Server=nginx,X-Content-Type-Options=nosniff,Connection=keep-alive,Date=Tue, 04 Mar 2025 09:00:47 GMT,Wechatpay-Signature-Type=WECHATPAY2-SHA256-RSA2048,Wechatpay-Serial=359A9DEEC3210********,Wechatpay-Nonce=da88b22e8a98da61cc1ba858be82d5b8,Wechatpay-Signature=Kr20xPFWxweRGIbE2WifaQNW1PeI9EV8AMJHKRdIV9JELcX4Z0Yz7OY+yLUxPNBBtLAUtz9oSN9LVKHwFQjZdcqgqnWLKqzgzUlvzw3LSzmfgK9P4zQo38mfg3tdwL4aEwVznbtGbOGDlFzKuiOc28F8B6cIlsM6ea8DecMWP4sv60mdg2Z29Q06zArVOMrhUa3t3FF1XKW66a8TkRzOh7ScVg2ITFp5q1eKJ6LnHtO0M9OtW2NPq7Kvl2zi5es1AlGLqoEvq/HJU60T8LDV0It7DSMQgVvfOnIJPtuFCZVkBOgPcw+TCusnwgUbXhZt4jiL4lvQSCeIDSbpvYrPPg==,Cache-Control=no-cache, must-revalidate,Content-Length=52,Request-ID=08BE829BBE0610DD0618BBCCC0552084810528EECC03-0,Content-Language=zh-CN,Content-Type=application/json; charset=utf-8
      ] 我在商户管理是还没有点击开启   开始更换  ,是不是因为这个原因导致验签失败的
      03-05
      回复
    • Memory
      Memory
      03-05回复。。。
      03-05
      回复
    • 。。。
      。。。
      03-05回复Memory
      是下单的时候用RSACombinedNotificationConfig放进去会报错,只能是RSAPublicKeyConfig.Builder()    JsapiServiceExtension jsapiServiceExtension =<br />                new JsapiServiceExtension.Builder().config(WechatpaySftConfig.rsaPublicKeyConfig()).build();<br />        PrepayWithRequestPaymentResponse response;<br />        try {<br />            response = jsapiServiceExtension.prepayWithRequestPayment(request, request.getSpAppid());<br />        } catch (HttpException e) {
      03-05
      回复
    • 。。。
      。。。
      03-05回复Memory
      是下单的时候用RSACombinedNotificationConfig放进去会报错,只能是RSAPublicKeyConfig.Builder()    JsapiServiceExtension jsapiServiceExtension =<br />                new JsapiServiceExtension.Builder().config(WechatpaySftConfig.rsaPublicKeyConfig()).build();<br />        PrepayWithRequestPaymentResponse response;<br />        try {<br />            response = jsapiServiceExtension.prepayWithRequestPayment(request, request.getSpAppid());<br />        } catch (HttpException e) {
      03-05
      回复
    • 。。。
      。。。
      03-05回复Memory
      是下单的时候用RSACombinedNotificationConfig放进去会报错,只能是RSAPublicKeyConfig.Builder() ,   JsapiServiceExtension jsapiServiceExtension =
                      new JsapiServiceExtension.Builder().config(WechatpaySftConfig.rsaPublicKeyConfig()).build();
              PrepayWithRequestPaymentResponse response;
              try {
                  response = jsapiServiceExtension.prepayWithRequestPayment(request, request.getSpAppid());
              } catch (HttpException e) {}
      03-05
      回复
    查看更多(7)
登录 后发表内容