// 使用定时更新的签名验证器,不需要传入证书
verifier = new ScheduledUpdateCertificatesVerifier(
new WechatPay2Credentials(merchantId, new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey)),
apiV3Key.getBytes(StandardCharsets.UTF_8));
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
.withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey)
.withValidator(new WechatPay2Validator(verifier))
// ... 接下来,你仍然可以通过builder设置各种参数,来配置你的HttpClient
// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签,并进行证书自动更新
CloseableHttpClient httpClient = builder.build();
// 后面跟使用Apache HttpClient一样
CloseableHttpResponse response = httpClient.execute(...);
按照git上代码示例执行post请求,响应状态码400
EntityUtils.toString(response.getEntity(), "UTF-8")
=
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
如果用HttpClients.createDefault().execute()执行同样请求就是正常的响应。
您好,如果您在接入微信支付的过程中遇到问题,可以通过我们的技术支持进行咨询反馈:https://support.pay.weixin.qq.com/online-service?from=wechatpay
怎么解决了