浏览代码

Merge branch 'develop' into develop

master
crskyp 8 年前
committed by GitHub
父节点
当前提交
44cbf65f81
共有 28 个文件被更改,包括 111 次插入24 次删除
  1. +1
    -1
      pom.xml
  2. +1
    -1
      readme.md
  3. +6
    -1
      weixin-java-common/pom.xml
  4. +19
    -3
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java
  5. +1
    -0
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaUploadRequestExecutor.java
  6. +1
    -1
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java
  7. +3
    -1
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimpleGetRequestExecutor.java
  8. +2
    -0
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java
  9. +1
    -1
      weixin-java-cp/pom.xml
  10. +3
    -1
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/apache/WxCpServiceImpl.java
  11. +3
    -0
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/jodd/WxCpServiceImpl.java
  12. +4
    -0
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java
  13. +1
    -1
      weixin-java-mp/pom.xml
  14. +1
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
  15. +4
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/apache/WxMpServiceImpl.java
  16. +4
    -2
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/jodd/WxMpServiceImpl.java
  17. +3
    -1
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialDeleteRequestExecutor.java
  18. +4
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialNewsInfoRequestExecutor.java
  19. +2
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialUploadRequestExecutor.java
  20. +2
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVideoInfoRequestExecutor.java
  21. +2
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java
  22. +5
    -1
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MediaImgUploadRequestExecutor.java
  23. +3
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java
  24. +2
    -0
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java
  25. +2
    -0
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
  26. +2
    -0
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java
  27. +1
    -1
      weixin-java-pay/pom.xml
  28. +28
    -8
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java

+ 1
- 1
pom.xml 查看文件

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.6.0</version>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description>


+ 1
- 1
readme.md 查看文件

@@ -52,7 +52,7 @@
---------------------------------
## Maven & Gradle 最新正式版本

* 微信支付(暂时为测试版本)
* 微信支付:

maven:
```xml


+ 6
- 1
weixin-java-common/pom.xml 查看文件

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.6.0</version>
<version>2.7.0-SNAPSHOT</version>
</parent>

<artifactId>weixin-java-common</artifactId>
@@ -39,6 +39,11 @@
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-http</artifactId>
<version>3.7</version>
</dependency>
</dependencies>

<build>


+ 19
- 3
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java 查看文件

@@ -10,6 +10,7 @@ import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
import okhttp3.*;

@@ -111,7 +112,7 @@ public class MediaDownloadRequestExecutor extends AbstractRequestExecutor<File,
}
}

String fileName = getFileName(response);
String fileName = getFileNameApache(response);
if (StringUtils.isBlank(fileName)) {
return null;
}
@@ -128,7 +129,6 @@ public class MediaDownloadRequestExecutor extends AbstractRequestExecutor<File,

/**
* jodd-http实现方式
*
* @param provider
* @param proxyInfo
* @param uri
@@ -237,7 +237,23 @@ public class MediaDownloadRequestExecutor extends AbstractRequestExecutor<File,
if (m.matches()) {
return m.group(1);
}
throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
request.withConnectionProvider(provider);
HttpResponse response = request.send();
String contentType = response.header("Content-Type");
if (contentType != null && contentType.startsWith("application/json")) {
// application/json; encoding=utf-8 下载媒体文件出错
throw new WxErrorException(WxError.fromJson(response.bodyText()));
}

String fileName = getFileNameJodd(response);
if (StringUtils.isBlank(fileName)) {
return null;
}

InputStream inputStream = new ByteArrayInputStream(response.bodyBytes());
String[] nameAndExt = fileName.split("\\.");
return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], this.tmpDirFile);
}


}

+ 1
- 0
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaUploadRequestExecutor.java 查看文件

@@ -8,6 +8,7 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
import okhttp3.*;



+ 1
- 1
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java 查看文件

@@ -3,6 +3,7 @@ package me.chanjar.weixin.common.util.http;
import jodd.http.HttpConnectionProvider;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.exception.WxErrorException;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
import okhttp3.ConnectionPool;

@@ -63,5 +64,4 @@ public interface RequestExecutor<T, E> {
*/
T executeOkhttp(ConnectionPool pool, final OkhttpProxyInfo proxyInfo, String uri, E data) throws WxErrorException, IOException;


}

+ 3
- 1
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimpleGetRequestExecutor.java 查看文件

@@ -7,6 +7,7 @@ import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
import okhttp3.*;

@@ -28,6 +29,7 @@ import java.util.concurrent.TimeUnit;
*/
public class SimpleGetRequestExecutor extends AbstractRequestExecutor<String, String> {


/**
* apache-http实现方式
*
@@ -98,6 +100,7 @@ public class SimpleGetRequestExecutor extends AbstractRequestExecutor<String, St
return responseContent;
}


/**
* okHttp实现方式
*
@@ -146,5 +149,4 @@ public class SimpleGetRequestExecutor extends AbstractRequestExecutor<String, St
return responseContent;
}


}

+ 2
- 0
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java 查看文件

@@ -7,6 +7,7 @@ import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
import okhttp3.*;

@@ -40,6 +41,7 @@ public class SimplePostRequestExecutor extends AbstractRequestExecutor<String, S
* @throws IOException
*/
public String executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, IOException {

HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();


+ 1
- 1
weixin-java-cp/pom.xml 查看文件

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.6.0</version>
<version>2.7.0-SNAPSHOT</version>
</parent>

<artifactId>weixin-java-cp</artifactId>


+ 3
- 1
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/apache/WxCpServiceImpl.java 查看文件

@@ -1,6 +1,5 @@
package me.chanjar.weixin.cp.api.impl.apache;


import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
@@ -8,6 +7,7 @@ import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.cp.api.impl.AbstractWxCpService;


import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -73,6 +73,7 @@ public class WxCpServiceImpl extends AbstractWxCpService<CloseableHttpClient, Ht
}

@Override

public void initHttp() {
ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage
.getApacheHttpClientBuilder();
@@ -91,4 +92,5 @@ public class WxCpServiceImpl extends AbstractWxCpService<CloseableHttpClient, Ht

this.httpClient = apacheHttpClientBuilder.build();
}

}

+ 3
- 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/jodd/WxCpServiceImpl.java 查看文件

@@ -19,6 +19,7 @@ public class WxCpServiceImpl extends AbstractWxCpService<HttpConnectionProvider,
@Override
public ProxyInfo getRequestHttpProxy() {
return httpProxy;

}

@Override
@@ -56,10 +57,12 @@ public class WxCpServiceImpl extends AbstractWxCpService<HttpConnectionProvider,

@Override
public void initHttp() {

if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) {
httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
}

httpClient = JoddHttp.httpConnectionProvider;
}

}

+ 4
- 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java 查看文件

@@ -61,6 +61,10 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> {
messageJson.add("voice", voice);
}

if (StringUtils.isNotBlank(message.getSafe())) {
messageJson.addProperty("safe", message.getSafe());
}

if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
JsonObject video = new JsonObject();
video.addProperty("media_id", message.getMediaId());


+ 1
- 1
weixin-java-mp/pom.xml 查看文件

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.6.0</version>
<version>2.7.0-SNAPSHOT</version>
</parent>
<artifactId>weixin-java-mp</artifactId>
<name>WeiXin Java Tools - MP</name>


+ 1
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java 查看文件

@@ -350,4 +350,5 @@ public interface WxMpService {
*/
void initHttp();


}

+ 4
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/apache/WxMpServiceImpl.java 查看文件

@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.api.impl.apache;


import java.io.IOException;
import java.util.concurrent.locks.Lock;

@@ -71,11 +72,13 @@ public class WxMpServiceImpl extends AbstractWxMpService<CloseableHttpClient,Htt
+ this.getWxMpConfigStorage().getSecret();
try {
HttpGet httpGet = new HttpGet(url);

if (this.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) {

String resultContent = new BasicResponseHandler().handleResponse(response);
WxError error = WxError.fromJson(resultContent);
if (error.getErrorCode() != 0) {
@@ -96,4 +99,5 @@ public class WxMpServiceImpl extends AbstractWxMpService<CloseableHttpClient,Htt
}
return this.getWxMpConfigStorage().getAccessToken();
}

}

+ 4
- 2
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/jodd/WxMpServiceImpl.java 查看文件

@@ -1,6 +1,5 @@
package me.chanjar.weixin.mp.api.impl.jodd;


import jodd.http.*;
import jodd.http.net.SocketHttpConnectionProvider;
import me.chanjar.weixin.common.bean.WxAccessToken;
@@ -30,6 +29,7 @@ public class WxMpServiceImpl extends AbstractWxMpService<HttpConnectionProvider,

@Override
public void initHttp() {

WxMpConfigStorage configStorage = this.getWxMpConfigStorage();

if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
@@ -40,7 +40,6 @@ public class WxMpServiceImpl extends AbstractWxMpService<HttpConnectionProvider,
}



@Override
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
Lock lock = this.getWxMpConfigStorage().getAccessTokenLock();
@@ -57,9 +56,11 @@ public class WxMpServiceImpl extends AbstractWxMpService<HttpConnectionProvider,
+ this.getWxMpConfigStorage().getSecret();

HttpRequest request = HttpRequest.get(url);

if (this.getRequestHttpProxy() != null) {
SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider();
provider.useProxy(getRequestHttpProxy());

request.withConnectionProvider(provider);
}
HttpResponse response = request.send();
@@ -77,4 +78,5 @@ public class WxMpServiceImpl extends AbstractWxMpService<HttpConnectionProvider,
}
return this.getWxMpConfigStorage().getAccessToken();
}

}

+ 3
- 1
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialDeleteRequestExecutor.java 查看文件

@@ -10,7 +10,9 @@ import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import okhttp3.*;

@@ -57,6 +59,7 @@ public class MaterialDeleteRequestExecutor extends AbstractRequestExecutor<Boole
}
}


@Override
public Boolean executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String materialId) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
@@ -108,5 +111,4 @@ public class MaterialDeleteRequestExecutor extends AbstractRequestExecutor<Boole
}
}


}

+ 4
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialNewsInfoRequestExecutor.java 查看文件

@@ -10,7 +10,9 @@ import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
@@ -57,6 +59,7 @@ public class MaterialNewsInfoRequestExecutor extends AbstractRequestExecutor<WxM
}
}


@Override
public WxMpMaterialNews executeJodd(HttpConnectionProvider httpclient, ProxyInfo httpProxy, String uri, String materialId) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
@@ -102,6 +105,7 @@ public class MaterialNewsInfoRequestExecutor extends AbstractRequestExecutor<WxM

Response response = client.newCall(request).execute();
String responseContent = response.body().toString();

WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);


+ 2
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialUploadRequestExecutor.java 查看文件

@@ -10,7 +10,9 @@ import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMpMaterial;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;


+ 2
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVideoInfoRequestExecutor.java 查看文件

@@ -10,7 +10,9 @@ import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;


+ 2
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java 查看文件

@@ -6,6 +6,7 @@ import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;

import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
@@ -95,6 +96,7 @@ public class MaterialVoiceAndImageDownloadRequestExecutor extends AbstractReques
Response response = client.newCall(request).execute();

try (InputStream inputStream = new ByteArrayInputStream(response.body().bytes())) {

// 下载媒体文件出错
byte[] responseContent = IOUtils.toByteArray(inputStream);
String responseContentString = new String(responseContent, "UTF-8");


+ 5
- 1
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MediaImgUploadRequestExecutor.java 查看文件

@@ -4,7 +4,9 @@ import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.http.ProxyInfo;

import jodd.util.MimeTypes;

import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
@@ -13,7 +15,9 @@ import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;

import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
import okhttp3.*;

@@ -38,7 +42,6 @@ import java.util.UUID;
*/
public class MediaImgUploadRequestExecutor extends AbstractRequestExecutor<WxMediaImgUploadResult, File> {


@Override
public WxMediaImgUploadResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, File data) throws WxErrorException, IOException {
if (data == null) {
@@ -99,6 +102,7 @@ public class MediaImgUploadRequestExecutor extends AbstractRequestExecutor<WxMed
@Override
public WxMediaImgUploadResult executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri,
File data) throws WxErrorException, IOException {

if (data == null) {
throw new WxErrorException(WxError.newBuilder().setErrorMsg("文件对象为空").build());
}


+ 3
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java 查看文件

@@ -8,11 +8,13 @@ import jodd.util.MimeTypes;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;

import me.chanjar.weixin.common.util.http.AbstractRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;

import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import okhttp3.*;

@@ -101,6 +103,7 @@ public class QrCodeRequestExecutor extends AbstractRequestExecutor<File, WxMpQrC
@Override
public File executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri,
WxMpQrCodeTicket ticket) throws WxErrorException, IOException {

if (ticket != null) {
if (uri.indexOf('?') == -1) {
uri += '?';


+ 2
- 0
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java 查看文件

@@ -4,6 +4,8 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;

import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;



+ 2
- 0
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java 查看文件

@@ -7,6 +7,8 @@ import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;

import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;


+ 2
- 0
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java 查看文件

@@ -6,6 +6,8 @@ import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;

import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;


+ 1
- 1
weixin-java-pay/pom.xml 查看文件

@@ -5,7 +5,7 @@
<parent>
<artifactId>weixin-java-parent</artifactId>
<groupId>com.github.binarywang</groupId>
<version>2.6.0</version>
<version>2.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>



+ 28
- 8
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java 查看文件

@@ -188,17 +188,37 @@ public class WxPayServiceImpl implements WxPayService {
}

Map<String, String> payInfo = new HashMap<>();
payInfo.put("appId", getConfig().getAppId());
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。
// 但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000));
payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis()));
payInfo.put("package", "prepay_id=" + prepayId);
payInfo.put("signType", "MD5");
if ("NATIVE".equals(request.getTradeType())) {
payInfo.put("codeUrl", unifiedOrderResult.getCodeURL());
} else if ("APP".equals(request.getTradeType())) {
// APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数
String appId = getConfig().getAppId();
Map<String, String> configMap = new HashMap<>();
// 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改
String partnerid = getConfig().getMchId();
configMap.put("prepayid", prepayId);
configMap.put("partnerid", partnerid);
configMap.put("package", "Sign=WXPay");
configMap.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
configMap.put("noncestr", String.valueOf(System.currentTimeMillis()));
configMap.put("appid", appId);
// 此map用于客户端与微信服务器交互
payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey()));
payInfo.put("prepayId", prepayId);
payInfo.put("partnerId", partnerid);
payInfo.put("appId", appId);
payInfo.put("packageValue", "Sign=WXPay");
payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000));
payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis()));
} else if ("JSAPI".equals(request.getTradeType())) {
payInfo.put("appId", unifiedOrderResult.getAppid());
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000));
payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis()));
payInfo.put("package", "prepay_id=" + prepayId);
payInfo.put("signType", "MD5");
payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey()));
}
payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey()));
return payInfo;
}



正在加载...
取消
保存