1- # wechatpay-apache-httpclient
1+ # wechatpay-apache-httpclient
22
33## 概览
44
@@ -54,7 +54,7 @@ import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
5454// ...
5555WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder . create()
5656 .withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey)
57- .withWechatpay (wechatpayCertificates);
57+ .withWechatPay (wechatpayCertificates);
5858// ... 接下来,你仍然可以通过builder设置各种参数,来配置你的HttpClient
5959
6060// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签
@@ -113,7 +113,7 @@ rootNode.putObject("payer")
113113 .put(" openid" , " oUpF8uMuAJO_M2pxb1Q9zNjWeS6o" );
114114
115115objectMapper. writeValue(bos, rootNode);
116-
116+
117117httpPost. setEntity(new StringEntity (bos. toString(" UTF-8" ), " UTF-8" ));
118118CloseableHttpResponse response = httpClient. execute(httpPost);
119119
@@ -148,7 +148,7 @@ ObjectNode rootNode = objectMapper.createObjectNode();
148148rootNode. put(" mchid" ," 1900009191" );
149149
150150objectMapper. writeValue(bos, rootNode);
151-
151+
152152httpPost. setEntity(new StringEntity (bos. toString(" UTF-8" ), " UTF-8" ));
153153CloseableHttpResponse response = httpClient. execute(httpPost);
154154
@@ -173,7 +173,7 @@ Credentials credentials = new WechatPay2Credentials(merchantId, new Signer() {
173173});
174174WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder . create()
175175 .withCredentials(credentials)
176- .withWechatpay (wechatpayCertificates);
176+ .withWechatPay (wechatpayCertificates);
177177```
178178
179179## 自动更新证书功能
@@ -250,7 +250,7 @@ String filePath = "/your/home/hellokitty.png";
250250URI uri = new URI (" https://api.mch.weixin.qq.com/v3/merchant/media/upload" );
251251File file = new File (filePath);
252252
253- try (FileInputStream ins1 = new FileInputStream (file)) {
253+ try (FileInputStream ins1 = new FileInputStream (file)) {
254254 String sha256 = DigestUtils . sha256Hex(ins1);
255255 try (InputStream ins2 = new FileInputStream (file)) {
256256 HttpPost request = new WechatPayUploadHttpPost .Builder (uri)
@@ -261,7 +261,7 @@ try (FileInputStream ins1 = new FileInputStream(file)) {
261261}
262262```
263263
264- [ AutoUpdateVerifierTest.uploadImageTest] ( /src/test/java/com/wechat/pay/contrib/apache/httpclient/AutoUpdateVerifierTest.java#L86 ) 是一个更完整的示例。
264+ [ AutoUpdateVerifierTest.uploadImageTest] ( /src/test/java/com/wechat/pay/contrib/apache/httpclient/AutoUpdateVerifierTest.java#90 ) 是一个更完整的示例。
265265
266266## 常见问题
267267
@@ -281,7 +281,7 @@ PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(
281281
282282### 如何下载平台证书?
283283
284- 使用` WechatPayHttpClientBuilder ` 需要调用` withWechatpay ` 设置[ 微信支付平台证书] ( https://wechatpay-api.gitbook.io/wechatpay-api-v3/ren-zheng/zheng-shu#ping-tai-zheng-shu ) ,而平台证书又只能通过调用[ 获取平台证书接口] ( https://wechatpay-api.gitbook.io/wechatpay-api-v3/jie-kou-wen-dang/ping-tai-zheng-shu#huo-qu-ping-tai-zheng-shu-lie-biao ) 下载。为了解开"死循环",你可以在第一次下载平台证书时,按照下述方法临时"跳过”应答签名的验证。
284+ 使用` WechatPayHttpClientBuilder ` 需要调用` withWechatPay ` 设置[ 微信支付平台证书] ( https://wechatpay-api.gitbook.io/wechatpay-api-v3/ren-zheng/zheng-shu#ping-tai-zheng-shu ) ,而平台证书又只能通过调用[ 获取平台证书接口] ( https://wechatpay-api.gitbook.io/wechatpay-api-v3/jie-kou-wen-dang/ping-tai-zheng-shu#huo-qu-ping-tai-zheng-shu-lie-biao ) 下载。为了解开"死循环",你可以在第一次下载平台证书时,按照下述方法临时"跳过”应答签名的验证。
285285
286286``` java
287287CloseableHttpClient httpClient = WechatPayHttpClientBuilder . create()
0 commit comments