GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 商家转账回调报错,版本4.7.4B · Issue #3545 · binarywang/WxJava

商家转账回调报错,版本4.7.4B #3545

New issue
Copy link
New issue
Copy link
Closed
#3547
Closed
商家转账回调报错,版本4.7.4B#3545
#3547
Copy link

Description

@liuyn001
liuyn001
opened on Apr 8, 2025
Issue body actions

简要描述

商家转账回调的接口报错

模块版本情况

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

详细描述

4.7.3B运行正常,升级到v4.7.4B报错,排查原因发现新版本代码调整了WxPayConfig中的getVerifier()方法,其中Verifier:certificatesVerifier的初始化判定逻辑是
“if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {” 这样存在不是通过服务器文件初始化的方式,这两个属性为空,导致Verifier空指针,是否调整为 “if (this.getPrivateCertContent() != null && this.getPrivateKeyContent() != null) {” 更为合适

日志

java.lang.NullPointerException: Cannot invoke "com.github.binarywang.wxpay.v3.auth.Verifier.verify(String, byte[], String)" because the return value of "com.github.binarywang.wxpay.config.WxPayConfig.getVerifier()" is null
at com.github.binarywang.wxpay.service.impl.BaseWxPayServiceImpl.verifyNotifySign(BaseWxPayServiceImpl.java:362)
at com.github.binarywang.wxpay.service.impl.BaseWxPayServiceImpl.baseParseOrderNotifyV3Result(BaseWxPayServiceImpl.java:378)
at com.github.binarywang.wxpay.service.impl.TransferServiceImpl.parseTransferBillsNotifyResult(TransferServiceImpl.java:125)
at com.liduoma.lmp.core.goods.service.WxPayMerchantTransferService.transferBillsNotify(WxPayMerchantTransferService.java:90)

日志请写于此处

Activity

  1. binarywang commented on Apr 8, 2025

    @binarywang
    binarywang
    on Apr 8, 2025
    Owner
    More actions

    @SynchPj 麻烦确认下! 谢谢

  2. SynchPj commented on Apr 10, 2025

    @SynchPj
    SynchPj
    on Apr 10, 2025
    Contributor
    More actions

    是单独使用的公钥吗

  3. binarywang
    linked a pull request that will close this issuefix: 证书使用 String、Content 格式时,验证器未正确初始化;新商户号无平台证书,初始化验证器抛出异常,导致v3请求构造异常 #3547on Apr 10, 2025
  4. binarywang commented on Apr 10, 2025

    @binarywang
    binarywang
    on Apr 10, 2025
    Owner
    More actions

    #3547 @SynchPj 看下这个PR是否解决此问题?

  5. liuyn001 commented on Apr 10, 2025

    @liuyn001
    liuyn001
    on Apr 10, 2025
    Author
    More actions

    是单独使用的公钥吗

    通过解析p12文件 直接设置 PrivateCertContent PrivateKeyContent属性

  6. SynchPj commented on Apr 10, 2025

    @SynchPj
    SynchPj
    on Apr 10, 2025
    Contributor
    More actions

    好的,我看看

  7. TamakoT commented on Apr 11, 2025

    @TamakoT
    TamakoT
    on Apr 11, 2025
    More actions

    我遇到了同样的问题,debug也是找到了WxPayConfig#getVerifier方法,这里应该先判断publicKey是不是空,不为空直接使用publickKey,而不是先尝试去获取平台证书,新开通的商户就没有平台证书,新版商户直接就提示404没有平台证书

    我看4.7.0版本的判断逻辑是这么写的:

    Verifier certificatesVerifier;
          if (publicKey == null) {
            certificatesVerifier =
                new AutoUpdateCertificatesVerifier(
                    new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
                    this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
                    this.getPayBaseUrl(), wxPayHttpProxy);
          } else {
            certificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
          }

    到了4.7.4B新版本变成这样了:

    Verifier certificatesVerifier = null;
        // 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现)
        if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {
          certificatesVerifier = new AutoUpdateCertificatesVerifier(
            new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
            this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
            this.getPayBaseUrl(), wxPayHttpProxy);
        }
        if (publicKey != null) {
          Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
          publicCertificatesVerifier.setOtherVerifier(certificatesVerifier);
          certificatesVerifier = publicCertificatesVerifier;
        }
        return certificatesVerifier;
  8. binarywang commented on Apr 11, 2025

    @binarywang
    binarywang
    on Apr 11, 2025
    Owner
    More actions

    我遇到了同样的问题,debug也是找到了WxPayConfig#getVerifier方法,这里应该先判断publicKey是不是空,不为空直接使用publickKey,而不是先尝试去获取平台证书,新开通的商户就没有平台证书,新版商户直接就提示404没有平台证书

    我看4.7.0版本的判断逻辑是这么写的:

    Verifier certificatesVerifier;
    if (publicKey == null) {
    certificatesVerifier =
    new AutoUpdateCertificatesVerifier(
    new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
    this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
    this.getPayBaseUrl(), wxPayHttpProxy);
    } else {
    certificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
    }
    到了4.7.4B新版本变成这样了:

    Verifier certificatesVerifier = null;
    // 如果配置了平台证书,则初始化验证器以备v2版本接口验签(公钥灰度实现)
    if (this.getPrivateCertPath() != null && this.getPrivateKeyPath() != null) {
    certificatesVerifier = new AutoUpdateCertificatesVerifier(
    new WxPayCredentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
    this.getApiV3Key().getBytes(StandardCharsets.UTF_8), this.getCertAutoUpdateTime(),
    this.getPayBaseUrl(), wxPayHttpProxy);
    }
    if (publicKey != null) {
    Verifier publicCertificatesVerifier = new PublicCertificateVerifier(publicKey, publicKeyId);
    publicCertificatesVerifier.setOtherVerifier(certificatesVerifier);
    certificatesVerifier = publicCertificatesVerifier;
    }
    return certificatesVerifier;

    欢迎基于#3547 提供你的代码,谢谢

  9. binarywang
    closed this as completedin #3547on Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.