Skip to content

Commit 198cc0c

Browse files
author
zzs
committed
项目声明
1 parent 5d33d12 commit 198cc0c

27 files changed

+64
-109
lines changed

pay-java-ali/src/main/java/in/egan/pay/ali/api/AliPayService.java

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import in.egan.pay.ali.bean.AliTransactionType;
44
import in.egan.pay.ali.util.SimpleGetRequestExecutor;
5+
import in.egan.pay.common.api.BasePayService;
56
import in.egan.pay.common.api.PayConfigStorage;
67
import in.egan.pay.common.api.PayService;
78
import in.egan.pay.common.api.RequestExecutor;
@@ -39,18 +40,9 @@
3940
4041
* @date 2016-5-18 14:09:01
4142
*/
42-
public class AliPayService implements PayService {
43+
public class AliPayService extends BasePayService {
4344
protected final Log log = LogFactory.getLog(AliPayService.class);
4445

45-
protected PayConfigStorage payConfigStorage;
46-
47-
protected CloseableHttpClient httpClient;
48-
49-
protected HttpHost httpProxy;
50-
51-
private int retrySleepMillis = 1000;
52-
53-
private int maxRetryTimes = 5;
5446

5547
private String httpsReqUrl = "https://mapi.alipay.com/gateway.do";
5648

@@ -104,6 +96,7 @@ public String verifyUrl(String notify_id) throws PayErrorException {
10496
* @param data
10597
* @return
10698
* @throws PayErrorException
99+
* @source chanjarster/weixin-java-tools
107100
*/
108101
@Override
109102
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {
@@ -365,7 +358,16 @@ public BufferedImage genQrPay(Map<String, Object> orderInfo) {
365358
throw new UnsupportedOperationException();
366359
}
367360

368-
361+
/**
362+
*
363+
* @param executor
364+
* @param uri
365+
* @param data
366+
* @param <T>
367+
* @param <E>
368+
* @return
369+
* @throws PayErrorException
370+
*/
369371
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {
370372

371373
try {
@@ -375,43 +377,7 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
375377
}
376378
}
377379

378-
public HttpHost getHttpProxy() {
379-
return httpProxy;
380-
}
381380

382-
public CloseableHttpClient getHttpClient() {
383-
return httpClient;
384-
}
385-
386-
public void setPayConfigStorage(PayConfigStorage payConfigStorage) {
387-
this.payConfigStorage = payConfigStorage;
388-
389-
String http_proxy_host = payConfigStorage.getHttpProxyHost();
390-
int http_proxy_port = payConfigStorage.getHttpProxyPort();
391-
String http_proxy_username = payConfigStorage.getHttpProxyUsername();
392-
String http_proxy_password = payConfigStorage.getHttpProxyPassword();
393-
394-
if (StringUtils.isNotBlank(http_proxy_host)) {
395-
// 使用代理服务器
396-
if (StringUtils.isNotBlank(http_proxy_username)) {
397-
// 需要用户认证的代理服务器
398-
CredentialsProvider credsProvider = new BasicCredentialsProvider();
399-
credsProvider.setCredentials(
400-
new AuthScope(http_proxy_host, http_proxy_port),
401-
new UsernamePasswordCredentials(http_proxy_username, http_proxy_password));
402-
httpClient = HttpClients
403-
.custom()
404-
.setDefaultCredentialsProvider(credsProvider)
405-
.build();
406-
} else {
407-
// 无需用户认证的代理服务器
408-
httpClient = HttpClients.createDefault();
409-
}
410-
httpProxy = new HttpHost(http_proxy_host, http_proxy_port);
411-
} else {
412-
httpClient = HttpClients.createDefault();
413-
}
414-
}
415381

416382
@Override
417383
public PayConfigStorage getPayConfigStorage() {

pay-java-ali/src/main/java/in/egan/pay/ali/util/SimpleGetRequestExecutor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/**
2222
* 简单的GET请求执行器,请求的参数是String, 返回的结果也是String
2323
* @author Daniel Qian
24+
* @source chanjarster/weixin-java-tools
2425
*
2526
*/
2627
public class SimpleGetRequestExecutor implements RequestExecutor<String, String> {

pay-java-common/src/main/java/in/egan/pay/common/api/BasePayService.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
/*
2-
* Copyright 2002-2017 the original huodull or egan.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
181
package in.egan.pay.common.api;
192

203
import in.egan.pay.common.exception.PayErrorException;
@@ -33,6 +16,7 @@
3316
* @author: egan
3417
3518
* @date 2017/1/12 20:09
19+
* @source chanjarster/weixin-java-tools
3620
*/
3721
public abstract class BasePayService implements PayService {
3822

@@ -46,6 +30,16 @@ public abstract class BasePayService implements PayService {
4630

4731
protected int maxRetryTimes = 5;
4832

33+
/**
34+
*
35+
* @param executor
36+
* @param uri
37+
* @param data
38+
* @param <T>
39+
* @param <E>
40+
* @return
41+
* @throws PayErrorException
42+
*/
4943
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {
5044

5145
try {

pay-java-common/src/main/java/in/egan/pay/common/api/PayConfigStorage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @author egan
1010
1111
* @date 2016-5-18 14:09:01
12+
* @source chanjarster/weixin-java-tools
1213
*/
1314
public interface PayConfigStorage {
1415

pay-java-common/src/main/java/in/egan/pay/common/api/PayConsts.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* 支付宝支付通知
5+
* @source chanjarster/weixin-java-tools
56
* @author egan
67
78
* @date 2016-6-1 11:45:31

pay-java-common/src/main/java/in/egan/pay/common/api/PayErrorExceptionHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* PayErrorExceptionHandler处理器
10+
*
1011
* @author egan
1112
1213
* @date 2016-6-1 11:33:01

pay-java-common/src/main/java/in/egan/pay/common/api/PayMessageHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* 处理支付回调消息的处理器接口
11+
* @source Daniel Qian
1112
* @author egan
1213
1314
* @date 2016-6-1 11:40:30

pay-java-common/src/main/java/in/egan/pay/common/api/PayMessageInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/**
1010
* 支付消息拦截器,可以用来做验证
11-
*
11+
* @author Daniel Qian
1212
*/
1313
public interface PayMessageInterceptor {
1414

pay-java-common/src/main/java/in/egan/pay/common/api/PayMessageRouter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* router.route(message);
3939
*
4040
* </pre>
41+
* @source chanjarster/weixin-java-tools
4142
* @source Daniel Qian
4243
* @author egan
4344
*

pay-java-common/src/main/java/in/egan/pay/common/api/PayMessageRouterRule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @author egan
1818
1919
* @date 2016-6-1 11:28:01
20+
* @source chanjarster/weixin-java-tools
2021
*/
2122
public class PayMessageRouterRule {
2223

0 commit comments

Comments
 (0)