Skip to content

Commit 47051bd

Browse files
authored
🎨 #3586 【微信支付】修复资源上传接口使用POST请求Content-Type不正确导致签名错误的问题
1 parent f5dd32d commit 47051bd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public byte[] postForBytes(String url, String requestStr, boolean useKey) throws
6565
httpPost.releaseConnection();
6666
}
6767
} catch (Exception e) {
68-
this.logError( url, requestStr, e);
68+
this.logError(url, requestStr, e);
6969
wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage()));
7070
throw new WxPayException(e.getMessage(), e);
7171
}
@@ -170,8 +170,6 @@ public String postV3WithWechatpaySerial(String url, String requestStr) throws Wx
170170

171171
@Override
172172
public String postV3(String url, HttpPost httpPost) throws WxPayException {
173-
String serialNumber = getWechatPaySerial(getConfig());
174-
httpPost.addHeader(WECHAT_PAY_SERIAL, serialNumber);
175173
return this.requestV3(url, httpPost);
176174
}
177175

@@ -264,8 +262,11 @@ public String deleteV3(String url) throws WxPayException {
264262

265263
private void configureRequest(HttpRequestBase request) {
266264
String serialNumber = getWechatPaySerial(getConfig());
265+
String method = request.getMethod();
267266
request.addHeader(ACCEPT, APPLICATION_JSON);
268-
request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
267+
if (!method.equals("POST")) {
268+
request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
269+
}
269270
request.addHeader(WECHAT_PAY_SERIAL, serialNumber);
270271

271272
request.setConfig(RequestConfig.custom()

0 commit comments

Comments
 (0)