|
1 | 1 | package com.github.binarywang.wxpay.service.impl; |
2 | 2 |
|
3 | | -import com.github.binarywang.wxpay.bean.WxPayApiData; |
4 | | -import com.github.binarywang.wxpay.exception.WxPayException; |
5 | | -import jodd.util.Base64; |
| 3 | +import java.io.UnsupportedEncodingException; |
| 4 | +import java.nio.charset.StandardCharsets; |
| 5 | +import javax.net.ssl.SSLContext; |
| 6 | + |
6 | 7 | import org.apache.commons.lang3.StringUtils; |
7 | 8 | import org.apache.http.HttpHost; |
8 | 9 | import org.apache.http.auth.AuthScope; |
|
20 | 21 | import org.apache.http.impl.client.HttpClients; |
21 | 22 | import org.apache.http.util.EntityUtils; |
22 | 23 |
|
23 | | -import javax.net.ssl.SSLContext; |
24 | | -import java.io.UnsupportedEncodingException; |
25 | | -import java.nio.charset.StandardCharsets; |
| 24 | +import com.github.binarywang.wxpay.bean.WxPayApiData; |
| 25 | +import com.github.binarywang.wxpay.exception.WxPayException; |
| 26 | +import jodd.util.Base64; |
26 | 27 |
|
27 | 28 | /** |
28 | 29 | * <pre> |
@@ -65,15 +66,19 @@ public String post(String url, String requestStr, boolean useKey) throws WxPayEx |
65 | 66 | try (CloseableHttpResponse response = httpClient.execute(httpPost)) { |
66 | 67 | String responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); |
67 | 68 | this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString); |
68 | | - wxApiData.set(new WxPayApiData(url, requestStr, responseString, null)); |
| 69 | + if (this.getConfig().isIfSaveApiData()) { |
| 70 | + wxApiData.set(new WxPayApiData(url, requestStr, responseString, null)); |
| 71 | + } |
69 | 72 | return responseString; |
70 | 73 | } |
71 | 74 | } finally { |
72 | 75 | httpPost.releaseConnection(); |
73 | 76 | } |
74 | 77 | } catch (Exception e) { |
75 | 78 | this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); |
76 | | - wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage())); |
| 79 | + if (this.getConfig().isIfSaveApiData()) { |
| 80 | + wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage())); |
| 81 | + } |
77 | 82 | throw new WxPayException(e.getMessage(), e); |
78 | 83 | } |
79 | 84 | } |
|
0 commit comments