- 微信支付java调用sdk生成httpclient,执行post请求报400badrequest
// 使用定时更新的签名验证器,不需要传入证书 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()执行同样请求就是正常的响应。
2021-12-15 - java app支付 用微信的sdk问题
//这样创建的client执行就成功 CloseableHttpClient client = HttpClients.createDefault(); //用微信的sdk里提供的自动更新证书的验签器生成的client执行报400 bad request nginx ScheduledUpdateCertificatesVerifier verifier = new ScheduledUpdateCertificatesVerifier( new WechatPay2Credentials(mchId, new PrivateKeySigner(serialNo, merchantPrivateKey)), key.getBytes(StandardCharsets.UTF_8)); WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create() .withMerchant(mchId, serialNo, merchantPrivateKey) .withValidator(new WechatPay2Validator(verifier)); return builder.build();
2021-12-15 - 微信支付v3接口的文档看不懂,有没有完整示例的能参考下?
实在看不懂,支付宝的接入用了半天,微信这个看了两天,越看越看不懂。
2021-12-13