新注册商户没有证书,请问下这个开发指引中的httpClient能用公钥吗?如果可以的话怎么改,如果不可以的话有什么解决办法?谢谢
private CloseableHttpClient httpClient;
private CertificatesManager certificatesManager;
private Verifier verifier;
@Before
public void setup() throws GeneralSecurityException, IOException, HttpCodeException, NotFoundException {
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(privateKey);
certificatesManager = CertificatesManager.getInstance();
certificatesManager.putMerchant(merchantId, new WechatPay2Credentials(merchantId,
new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey)),
apiV3Key.getBytes(StandardCharsets.UTF_8));
verifier = certificatesManager.getVerifier(merchantId);
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
.withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey)
.withValidator(new WechatPay2Validator(verifier));
httpClient = builder.build();
}
你需要用这个sdkhttps://github.com/wechatpay-apiv3/wechatpay-java