Skip to content

Commit

Permalink
项目声明
Browse files Browse the repository at this point in the history
  • Loading branch information
zzs committed Feb 20, 2017
1 parent 5d33d12 commit 198cc0c
Show file tree
Hide file tree
Showing 27 changed files with 64 additions and 109 deletions.
60 changes: 13 additions & 47 deletions pay-java-ali/src/main/java/in/egan/pay/ali/api/AliPayService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import in.egan.pay.ali.bean.AliTransactionType;
import in.egan.pay.ali.util.SimpleGetRequestExecutor;
import in.egan.pay.common.api.BasePayService;
import in.egan.pay.common.api.PayConfigStorage;
import in.egan.pay.common.api.PayService;
import in.egan.pay.common.api.RequestExecutor;
Expand Down Expand Up @@ -39,18 +40,9 @@
* @email [email protected]
* @date 2016-5-18 14:09:01
*/
public class AliPayService implements PayService {
public class AliPayService extends BasePayService {
protected final Log log = LogFactory.getLog(AliPayService.class);

protected PayConfigStorage payConfigStorage;

protected CloseableHttpClient httpClient;

protected HttpHost httpProxy;

private int retrySleepMillis = 1000;

private int maxRetryTimes = 5;

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

Expand Down Expand Up @@ -104,6 +96,7 @@ public String verifyUrl(String notify_id) throws PayErrorException {
* @param data
* @return
* @throws PayErrorException
* @source chanjarster/weixin-java-tools
*/
@Override
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {
Expand Down Expand Up @@ -365,7 +358,16 @@ public BufferedImage genQrPay(Map<String, Object> orderInfo) {
throw new UnsupportedOperationException();
}


/**
*
* @param executor
* @param uri
* @param data
* @param <T>
* @param <E>
* @return
* @throws PayErrorException
*/
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {

try {
Expand All @@ -375,43 +377,7 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
}
}

public HttpHost getHttpProxy() {
return httpProxy;
}

public CloseableHttpClient getHttpClient() {
return httpClient;
}

public void setPayConfigStorage(PayConfigStorage payConfigStorage) {
this.payConfigStorage = payConfigStorage;

String http_proxy_host = payConfigStorage.getHttpProxyHost();
int http_proxy_port = payConfigStorage.getHttpProxyPort();
String http_proxy_username = payConfigStorage.getHttpProxyUsername();
String http_proxy_password = payConfigStorage.getHttpProxyPassword();

if (StringUtils.isNotBlank(http_proxy_host)) {
// 使用代理服务器
if (StringUtils.isNotBlank(http_proxy_username)) {
// 需要用户认证的代理服务器
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(http_proxy_host, http_proxy_port),
new UsernamePasswordCredentials(http_proxy_username, http_proxy_password));
httpClient = HttpClients
.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
} else {
// 无需用户认证的代理服务器
httpClient = HttpClients.createDefault();
}
httpProxy = new HttpHost(http_proxy_host, http_proxy_port);
} else {
httpClient = HttpClients.createDefault();
}
}

@Override
public PayConfigStorage getPayConfigStorage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* 简单的GET请求执行器,请求的参数是String, 返回的结果也是String
* @author Daniel Qian
* @source chanjarster/weixin-java-tools
*
*/
public class SimpleGetRequestExecutor implements RequestExecutor<String, String> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright 2002-2017 the original huodull or egan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package in.egan.pay.common.api;

import in.egan.pay.common.exception.PayErrorException;
Expand All @@ -33,6 +16,7 @@
* @author: egan
* @email [email protected]
* @date 2017/1/12 20:09
* @source chanjarster/weixin-java-tools
*/
public abstract class BasePayService implements PayService {

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

protected int maxRetryTimes = 5;

/**
*
* @param executor
* @param uri
* @param data
* @param <T>
* @param <E>
* @return
* @throws PayErrorException
*/
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException {

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @author egan
* @email [email protected]
* @date 2016-5-18 14:09:01
* @source chanjarster/weixin-java-tools
*/
public interface PayConfigStorage {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* 支付宝支付通知
* @source chanjarster/weixin-java-tools
* @author egan
* @email [email protected]
* @date 2016-6-1 11:45:31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* PayErrorExceptionHandler处理器
*
* @author egan
* @email [email protected]
* @date 2016-6-1 11:33:01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* 处理支付回调消息的处理器接口
* @source Daniel Qian
* @author egan
* @email [email protected]
* @date 2016-6-1 11:40:30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* 支付消息拦截器,可以用来做验证
*
* @author Daniel Qian
*/
public interface PayMessageInterceptor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* router.route(message);
*
* </pre>
* @source chanjarster/weixin-java-tools
* @source Daniel Qian
* @author egan
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @author egan
* @email [email protected]
* @date 2016-6-1 11:28:01
* @source chanjarster/weixin-java-tools
*/
public class PayMessageRouterRule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public interface PayService {
* @param <E> 请求数据类型
* @return
* @throws PayErrorException
* @source
*/
<T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws PayErrorException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @param <T> 返回值类型
* @param <E> 请求参数类型
* @source chanjarster/weixin-java-tools
*/
public interface RequestExecutor<T, E> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public interface BasePayType {
* @param transactionType 类型值
* @return
*/
public abstract TransactionType getTransactionType(String transactionType);
TransactionType getTransactionType(String transactionType);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @author egan
* @email [email protected]
* @date 2016-6-1 14:2:3
* @source chanjarster/weixin-java-tools
*/
public class PayMessage implements Serializable {
private Map<String, String> payMessage = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author egan
* @email [email protected]
* @date 2016-6-1 11:40:30
* @source chanjarster/weixin-java-tools
*/
public abstract class PayOutMessage implements Serializable {
protected String content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import in.egan.pay.common.bean.PayOutMessage;

/**
*
* @source chanjarster/weixin-java-tools
* @author egan
* @email [email protected]
* @date 2016-6-1 11:40:30
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
* Copyright 2002-2017 the original huodull or egan.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package in.egan.pay.common.bean.outbuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import in.egan.pay.common.bean.PayOutMessage;

/**
* @source chanjarster/weixin-java-tools
* @author egan
* @email [email protected]
* @date 2016-6-1 11:40:30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import in.egan.pay.common.bean.PayOutMessage;
/**
* @source chanjarster/weixin-java-tools
* @author egan
* @email [email protected]
* @date 2016-6-1 11:40:30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author Daniel Qian
* @dete 2017/1/12 9:57
* @author: egan
* @source chanjarster/weixin-java-tools
*/

public class PayError implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @author egan
* @email [email protected]
* @date 2016-5-18 14:09:01
* @source chanjarster/weixin-java-tools
*/
public class PayErrorException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author egan
* @email [email protected]
* @date 2016-6-1 11:28:01
* @source chanjarster/weixin-java-tools
*/
public class LogExceptionHandler implements PayErrorExceptionHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @author egan
* @email [email protected]
* @date 2016-5-24
* @source chanjarster/weixin-java-tools
*/

import in.egan.pay.common.api.RequestExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @author egan
* @email [email protected]
* @date 2016-5-18 14:09:01
* @author Daniel Qian
* @source chanjarster/weixin-java-tools
*/
public class SimplePostRequestExecutor implements RequestExecutor<String, Object> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.io.IOException;

/**
* @source chanjarster/weixin-java-tools
* @author Daniel Qian
* @author egan
* @email [email protected]
* @date 2016-5-24
Expand Down
Loading

0 comments on commit 198cc0c

Please sign in to comment.