Visitar URL original
修复POST请求签名错误问题 by SynchPj · Pull Request #3586 · binarywang/WxJava · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
🎨 修复POST请求签名错误问题
  • Loading branch information
SynchPj
SynchPj committed May 14, 2025
commit b10eef61e2f57e6322efae874d8e032e15e8f7b6
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public byte[] postForBytes(String url, String requestStr, boolean useKey) throws
httpPost.releaseConnection();
}
} catch (Exception e) {
this.logError( url, requestStr, e);
this.logError(url, requestStr, e);
wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage()));
throw new WxPayException(e.getMessage(), e);
}
Expand Down Expand Up @@ -170,8 +170,6 @@ public String postV3WithWechatpaySerial(String url, String requestStr) throws Wx

@Override
public String postV3(String url, HttpPost httpPost) throws WxPayException {
String serialNumber = getWechatPaySerial(getConfig());
httpPost.addHeader(WECHAT_PAY_SERIAL, serialNumber);
return this.requestV3(url, httpPost);
}

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

private void configureRequest(HttpRequestBase request) {
String serialNumber = getWechatPaySerial(getConfig());
String method = request.getMethod();
request.addHeader(ACCEPT, APPLICATION_JSON);
request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
if (!method.equals("POST")) {
request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
}
request.addHeader(WECHAT_PAY_SERIAL, serialNumber);

request.setConfig(RequestConfig.custom()
Expand Down