Skip to content

Commit eee954b

Browse files
committed
微信支付相关代码独立成一个子模块
1 parent 8a270c8 commit eee954b

File tree

49 files changed

+1596
-1308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1596
-1308
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<module>weixin-java-common</module>
8787
<module>weixin-java-cp</module>
8888
<module>weixin-java-mp</module>
89+
<module>weixin-java-pay</module>
8990
<module>weixin-java-osgi</module>
9091
</modules>
9192

weixin-java-mp/pom.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,11 @@
1818
<artifactId>weixin-java-common</artifactId>
1919
<version>${project.version}</version>
2020
</dependency>
21-
<dependency>
22-
<groupId>junit</groupId>
23-
<artifactId>junit</artifactId>
24-
<scope>test</scope>
25-
</dependency>
2621
<dependency>
2722
<groupId>org.testng</groupId>
2823
<artifactId>testng</artifactId>
2924
<scope>test</scope>
3025
</dependency>
31-
<dependency>
32-
<groupId>org.mockito</groupId>
33-
<artifactId>mockito-all</artifactId>
34-
<scope>test</scope>
35-
</dependency>
3626
<dependency>
3727
<groupId>com.google.inject</groupId>
3828
<artifactId>guice</artifactId>
@@ -54,16 +44,6 @@
5444
<version>2.9.4</version>
5545
<scope>test</scope>
5646
</dependency>
57-
<dependency>
58-
<groupId>io.rest-assured</groupId>
59-
<artifactId>xml-path</artifactId>
60-
<version>3.0.1</version>
61-
</dependency>
62-
<dependency>
63-
<groupId>com.github.binarywang</groupId>
64-
<artifactId>qrcode-utils</artifactId>
65-
<version>1.0</version>
66-
</dependency>
6747
</dependencies>
6848

6949
<build>

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpConfigStorage.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import me.chanjar.weixin.common.bean.WxAccessToken;
44
import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
55

6-
import javax.net.ssl.SSLContext;
76
import java.io.File;
87
import java.util.concurrent.locks.Lock;
98

@@ -80,39 +79,8 @@ public interface WxMpConfigStorage {
8079

8180
String getAppId();
8281

83-
/**
84-
* 服务商模式下的子商户公众账号ID
85-
*/
86-
String getSubAppId();
87-
88-
/**
89-
* 服务商模式下的子商户号
90-
*/
91-
String getSubMchId();
92-
9382
String getSecret();
9483

95-
String getPartnerId();
96-
97-
String getPartnerKey();
98-
99-
/**
100-
* 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数。
101-
*
102-
* @since 2.5.0
103-
*/
104-
String getNotifyURL();
105-
106-
/**
107-
* 交易类型
108-
* <pre>
109-
* JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付
110-
* </pre>
111-
*
112-
* @since 2.5.0
113-
*/
114-
String getTradeType();
115-
11684
String getToken();
11785

11886
String getAesKey();
@@ -131,17 +99,6 @@ public interface WxMpConfigStorage {
13199

132100
File getTmpDirFile();
133101

134-
SSLContext getSslContext();
135-
136-
void setSslContext(SSLContext sslContext);
137-
138-
/**
139-
* 在此之前,必须将partnerId进行赋值
140-
*
141-
* @param filePath apiclient_cert.p12的文件的绝对路径
142-
*/
143-
void setSslContextFilePath(String filePath) throws Exception;
144-
145102
/**
146103
* http client builder
147104
*
@@ -154,8 +111,4 @@ public interface WxMpConfigStorage {
154111
*/
155112
boolean autoRefreshToken();
156113

157-
/**
158-
* 微信支付是否使用仿真测试环境
159-
*/
160-
boolean useSandboxForWxPay();
161114
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
import me.chanjar.weixin.common.bean.WxAccessToken;
44
import me.chanjar.weixin.common.util.ToStringUtils;
55
import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
6-
import org.apache.http.ssl.SSLContexts;
76

8-
import javax.net.ssl.SSLContext;
97
import java.io.File;
10-
import java.io.FileInputStream;
11-
import java.security.KeyStore;
128
import java.util.concurrent.locks.Lock;
139
import java.util.concurrent.locks.ReentrantLock;
1410

@@ -20,13 +16,7 @@
2016
public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
2117

2218
protected volatile String appId;
23-
protected volatile String subAppId;
24-
protected volatile String subMchId;
2519
protected volatile String secret;
26-
protected volatile String partnerId;
27-
protected volatile String partnerKey;
28-
protected volatile String notifyURL;
29-
protected volatile String tradeType;
3020
protected volatile String token;
3121
protected volatile String accessToken;
3222
protected volatile String aesKey;
@@ -54,8 +44,6 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
5444
*/
5545
protected volatile File tmpDirFile;
5646

57-
protected volatile SSLContext sslContext;
58-
5947
protected volatile ApacheHttpClientBuilder apacheHttpClientBuilder;
6048

6149
@Override
@@ -257,41 +245,6 @@ public String toString() {
257245
return ToStringUtils.toSimpleString(this);
258246
}
259247

260-
@Override
261-
public String getPartnerId() {
262-
return this.partnerId;
263-
}
264-
265-
public void setPartnerId(String partnerId) {
266-
this.partnerId = partnerId;
267-
}
268-
269-
@Override
270-
public String getPartnerKey() {
271-
return this.partnerKey;
272-
}
273-
274-
public void setPartnerKey(String partnerKey) {
275-
this.partnerKey = partnerKey;
276-
}
277-
278-
279-
public String getNotifyURL() {
280-
return notifyURL;
281-
}
282-
283-
public void setNotifyURL(String notifyURL) {
284-
this.notifyURL = notifyURL;
285-
}
286-
287-
public String getTradeType() {
288-
return tradeType;
289-
}
290-
291-
public void setTradeType(String tradeType) {
292-
this.tradeType = tradeType;
293-
}
294-
295248
@Override
296249
public File getTmpDirFile() {
297250
return this.tmpDirFile;
@@ -301,38 +254,6 @@ public void setTmpDirFile(File tmpDirFile) {
301254
this.tmpDirFile = tmpDirFile;
302255
}
303256

304-
@Override
305-
public SSLContext getSslContext() {
306-
return this.sslContext;
307-
}
308-
309-
@Override
310-
public void setSslContext(SSLContext context) {
311-
this.sslContext = context;
312-
}
313-
314-
@Override
315-
public void setSslContextFilePath(String filePath) {
316-
if (null == partnerId) {
317-
throw new IllegalArgumentException("请设置partnerId的值");
318-
}
319-
320-
File file = new File(filePath);
321-
if (!file.exists()) {
322-
throw new RuntimeException("证书文件:【" + file.getPath() + "】不存在!");
323-
}
324-
325-
try {
326-
FileInputStream inputStream = new FileInputStream(file);
327-
KeyStore keystore = KeyStore.getInstance("PKCS12");
328-
char[] partnerId2charArray = partnerId.toCharArray();
329-
keystore.load(inputStream, partnerId2charArray);
330-
this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build();
331-
} catch (Exception e) {
332-
throw new RuntimeException("证书文件有问题,请核实!", e);
333-
}
334-
}
335-
336257
@Override
337258
public ApacheHttpClientBuilder getApacheHttpClientBuilder() {
338259
return this.apacheHttpClientBuilder;
@@ -347,26 +268,4 @@ public boolean autoRefreshToken() {
347268
return true;
348269
}
349270

350-
@Override
351-
public boolean useSandboxForWxPay() {
352-
return false;
353-
}
354-
355-
@Override
356-
public String getSubAppId() {
357-
return subAppId;
358-
}
359-
360-
public void setSubAppId(String subAppId) {
361-
this.subAppId = subAppId;
362-
}
363-
364-
@Override
365-
public String getSubMchId() {
366-
return subMchId;
367-
}
368-
369-
public void setSubMchId(String subMchId) {
370-
this.subMchId = subMchId;
371-
}
372271
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ public interface WxMpService {
311311
*/
312312
WxMpCardService getCardService();
313313

314-
/**
315-
* 返回微信支付相关接口方法的实现类对象,以方便调用其各个接口
316-
*
317-
* @return WxMpPayService
318-
*/
319-
WxMpPayService getPayService();
320-
321314
/**
322315
* 返回数据分析统计相关接口方法的实现类对象,以方便调用其各个接口
323316
*

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public class WxMpServiceImpl implements WxMpService {
4545
private WxMpUserTagService tagService = new WxMpUserTagServiceImpl(this);
4646
private WxMpQrcodeService qrCodeService = new WxMpQrcodeServiceImpl(this);
4747
private WxMpCardService cardService = new WxMpCardServiceImpl(this);
48-
private WxMpPayService payService = new WxMpPayServiceImpl(this);
4948
private WxMpStoreService storeService = new WxMpStoreServiceImpl(this);
5049
private WxMpDataCubeService dataCubeService = new WxMpDataCubeServiceImpl(this);
5150
private WxMpUserBlacklistService blackListService = new WxMpUserBlacklistServiceImpl(this);
@@ -505,11 +504,6 @@ public WxMpCardService getCardService() {
505504
return this.cardService;
506505
}
507506

508-
@Override
509-
public WxMpPayService getPayService() {
510-
return this.payService;
511-
}
512-
513507
@Override
514508
public WxMpDataCubeService getDataCubeService() {
515509
return this.dataCubeService;

0 commit comments

Comments
 (0)