好兄弟,问题解决了,同样的问题
商户证书为空,serialNumberCertificatesManager certificatesManager = CertificatesManager.getInstance(); FileInputStream certKeyStream = new FileInputStream(new File(wxPayProperties.getCertKeyPath())); FileInputStream weChatPayStream = new FileInputStream(new File(wxPayProperties.getWeChatPayPath())); x509Certificate = PemUtil.loadCertificate(weChatPayStream); privateKey = PemUtil.loadPrivateKey(certKeyStream); certificatesManager.putMerchant(wxPayProperties.getMchId(), new WechatPay2Credentials(wxPayProperties.getMchId(), new PrivateKeySigner(wxPayProperties.getSerialNumber(), privateKey)), wxPayProperties.getApiV3Key().getBytes(StandardCharsets.UTF_8)); verifier = certificatesManager.getVerifier(wxPayProperties.getMchId()); 使用上述方式获取平台证书,在接受到微信通知后,使用verifier进行验签,报商户证书为空。传的参数 mchid 商户id,secrialnumber 商户序列号 这段代码写在@PostConstruct 注解的方法内,只初始化一次,后面用成员变量使用
2022-05-11