Browse Source

字符编码字符串用常量替换

master
Binary Wang 8 years ago
parent
commit
bf2b4eed55
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java

+ 4
- 4
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java View File

@@ -385,7 +385,7 @@ public class WxPayServiceImpl implements WxPayService {
String content = createScanPayQrcodeMode1(productId);
return createQrcode(content, logoFile, sideLength);
}
@Override
public String createScanPayQrcodeMode1(String productId){
//weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
@@ -400,7 +400,7 @@ public class WxPayServiceImpl implements WxPayService {
String sign = this.createSign(params);
params.put("sign", sign);

for (String key : params.keySet()) {
codeUrl.append(key + "=" + params.get(key) + "&");
}
@@ -414,7 +414,7 @@ public class WxPayServiceImpl implements WxPayService {
public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) {
return createQrcode(codeUrl, logoFile, sideLength);
}
private byte[] createQrcode(String content, File logoFile, Integer sideLength) {
if (sideLength == null || sideLength < 1) {
return QrcodeUtils.createQrcode(content, logoFile);
@@ -491,7 +491,7 @@ public class WxPayServiceImpl implements WxPayService {
HttpPost httpPost = new HttpPost(url);

try (CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build()) {
httpPost.setEntity(new StringEntity(new String(requestStr.getBytes("UTF-8"), "ISO-8859-1")));
httpPost.setEntity(new StringEntity(new String(requestStr.getBytes(CharEncoding.UTF_8), CharEncoding.ISO_8859_1)));
try (CloseableHttpResponse response = httpclient.execute(httpPost)) {
String result = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", url, requestStr, result);


Loading…
Cancel
Save