-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zzs
committed
Feb 20, 2017
1 parent
5d33d12
commit 198cc0c
Showing
27 changed files
with
64 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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"; | ||
|
||
|
@@ -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 { | ||
|
@@ -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 { | ||
|
@@ -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() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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 { | ||
|
||
|
@@ -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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
* @author egan | ||
* @email [email protected] | ||
* @date 2016-5-18 14:09:01 | ||
* @source chanjarster/weixin-java-tools | ||
*/ | ||
public interface PayConfigStorage { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
/** | ||
* 支付宝支付通知 | ||
* @source chanjarster/weixin-java-tools | ||
* @author egan | ||
* @email [email protected] | ||
* @date 2016-6-1 11:45:31 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
/** | ||
* PayErrorExceptionHandler处理器 | ||
* | ||
* @author egan | ||
* @email [email protected] | ||
* @date 2016-6-1 11:33:01 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
/** | ||
* 处理支付回调消息的处理器接口 | ||
* @source Daniel Qian | ||
* @author egan | ||
* @email [email protected] | ||
* @date 2016-6-1 11:40:30 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* 支付消息拦截器,可以用来做验证 | ||
* | ||
* @author Daniel Qian | ||
*/ | ||
public interface PayMessageInterceptor { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
* @author egan | ||
* @email [email protected] | ||
* @date 2016-6-1 11:28:01 | ||
* @source chanjarster/weixin-java-tools | ||
*/ | ||
public class PayMessageRouterRule { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
16 changes: 0 additions & 16 deletions
16
pay-java-common/src/main/java/in/egan/pay/common/bean/outbuilder/JsonBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
Oops, something went wrong.