包名修改

This commit is contained in:
zzs
2017-04-10 09:22:17 +08:00
parent 174f602dd7
commit 7152f001e4
100 changed files with 564 additions and 515 deletions

View File

@@ -0,0 +1,186 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.MsgType;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* 支付基础配置存储
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/5 20:33
*/
public abstract class BasePayConfigStorage implements PayConfigStorage{
// ali rsa_private 商户私钥pkcs8格式
//wx api_key 商户密钥
private volatile String keyPrivate ;
// 支付公钥
private volatile String keyPublic;
//异步回调地址
private volatile String notifyUrl;
//同步回调地址
private volatile String returnUrl;;
//签名加密类型
private volatile String signType;
//字符类型
private volatile String inputCharset;
//支付类型 aliPay 支付宝, wxPay微信..等等,开发者自定义,唯一
private volatile String payType;
/**
* 消息来源类型
*/
private volatile MsgType msgType;
// 访问令牌 每次请求其他方法都要传入的值
private volatile String accessToken;
// access token 到期时间时间戳
private volatile long expiresTime;
//授权码锁
private Lock accessTokenLock = new ReentrantLock();
private boolean isTest = false;
@Override
public String getKeyPrivate() {
return keyPrivate;
}
public void setKeyPrivate(String keyPrivate) {
this.keyPrivate = keyPrivate;
}
@Override
public String getKeyPublic() {
return keyPublic;
}
public void setKeyPublic(String keyPublic) {
this.keyPublic = keyPublic;
}
@Override
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
@Override
public String getReturnUrl() {
return returnUrl;
}
public void setReturnUrl(String returnUrl) {
this.returnUrl = returnUrl;
}
@Override
public String getSignType() {
return signType;
}
public void setSignType(String signType) {
this.signType = signType;
}
@Override
public String getInputCharset() {
return inputCharset;
}
public void setInputCharset(String inputCharset) {
this.inputCharset = inputCharset;
}
@Override
public String getPayType() {
return payType;
}
public void setPayType(String payType) {
this.payType = payType;
}
@Override
public MsgType getMsgType() {
return msgType;
}
public void setMsgType(MsgType msgType) {
this.msgType = msgType;
}
@Override
public String getAccessToken() {
return this.accessToken;
}
@Override
public Lock getAccessTokenLock() {
return this.accessTokenLock;
}
@Override
public long getExpiresTime() {
return expiresTime;
}
@Override
public boolean isAccessTokenExpired() {
return System.currentTimeMillis() > this.expiresTime;
}
@Override
public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) {
this.accessToken = accessToken;
this.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 600) * 1000L;
}
@Override
public synchronized void updateAccessToken(String accessToken, long expiresTime) {
this.accessToken = accessToken;
this.expiresTime = expiresTime;
}
@Override
public void expireAccessToken() {
this.expiresTime = 0;
}
@Override
public String getToken() {
return null;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public void setExpiresTime(long expiresTime) {
this.expiresTime = expiresTime;
}
public void setAccessTokenLock(Lock accessTokenLock) {
this.accessTokenLock = accessTokenLock;
}
@Override
public boolean isTest() {
return isTest;
}
public void setTest(boolean test) {
isTest = test;
}
}

View File

@@ -0,0 +1,75 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.http.HttpConfigStorage;
import com.egzosn.pay.common.http.HttpRequestTemplate;
import com.egzosn.pay.common.util.sign.SignUtils;
import java.util.Map;
/**
* 支付基础服务
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/5 20:36
*/
public abstract class BasePayService implements PayService {
protected PayConfigStorage payConfigStorage;
protected HttpRequestTemplate requestTemplate;
protected int retrySleepMillis = 1000;
protected int maxRetryTimes = 5;
/**
* 设置支付配置
* @param payConfigStorage 支付配置
*/
public BasePayService setPayConfigStorage(PayConfigStorage payConfigStorage) {
this.payConfigStorage = payConfigStorage;
return this;
}
@Override
public PayConfigStorage getPayConfigStorage() {
return payConfigStorage;
}
@Override
public HttpRequestTemplate getHttpRequestTemplate() {
return requestTemplate;
}
/**
* 设置并创建请求模版, 代理请求配置这里是否合理??,
* @param configStorage http请求配置
* @return
*/
@Override
public BasePayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage) {
this.requestTemplate = new HttpRequestTemplate(configStorage);
return this;
}
public BasePayService(PayConfigStorage payConfigStorage) {
this(payConfigStorage, null);
}
public BasePayService(PayConfigStorage payConfigStorage, HttpConfigStorage configStorage) {
setPayConfigStorage(payConfigStorage);
setRequestTemplateConfigStorage(configStorage);
}
@Override
public String createSign(String content, String characterEncoding) {
return SignUtils.valueOf(payConfigStorage.getSignType()).createSign(content, payConfigStorage.getKeyPrivate(),characterEncoding);
}
@Override
public String createSign(Map<String, Object> content, String characterEncoding) {
return SignUtils.valueOf(payConfigStorage.getSignType()).sign(content, payConfigStorage.getKeyPrivate(),characterEncoding);
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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 com.egzosn.pay.common.api;
import java.util.Map;
/**
* 回调,可用于类型转换
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/7 18:55
*/
public interface Callback<T> {
T perform(Map<String, Object> map);
}

View File

@@ -0,0 +1,135 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.MsgType;
import java.util.concurrent.locks.Lock;
/**
* 支付客户端配置存储
* @author egan
* @email egzosn@gmail.com
* @date 2016-5-18 14:09:01
* @source chanjarster/weixin-java-tools
*/
public interface PayConfigStorage {
/*
* 应用id
*/
String getAppid();
/**
* 合作商唯一标识
* @see #getPid() 代替者
*/
@Deprecated
String getPartner();
/**
* 合作商唯一标识
* @see #getPartner() 代替者
*/
String getPid();
/**
* 获取收款账号
*/
String getSeller();
/**
* 授权令牌
*/
String getToken();
/**
* 服务端异步回调Url
*/
String getNotifyUrl();
/**
* 服务端同步回调Url
*/
String getReturnUrl();
/**
* 签名方式
*/
String getSignType();
// 字符编码格式 目前支持 gbk 或 utf-8
String getInputCharset();
/**
* 获取密钥 与 #getKeyPrivate 类似
*/
String getSecretKey();
/**
* 公钥
* @return
*/
String getKeyPublic();
/**
* 私钥
* @return
*/
String getKeyPrivate();
/**
* 支付类型 自定义
* 这里暂定 aliPay 支付宝, wxPay微信支付
* @return
*/
String getPayType();
/**
* 消息类型
* @see #getMsgType
* @see MsgType
* @return "text" 或者 "xml"json
*/
MsgType getMsgType();
/**
* 获取访问令牌
* @return
*/
String getAccessToken();
/**
* 访问令牌是否过期
* @return
*/
boolean isAccessTokenExpired();
/**
* 获取access token锁
* @return
*/
Lock getAccessTokenLock();
/**
* 强制将access token过期掉
*/
void expireAccessToken();
/**
* 强制将access token过期掉
*/
long getExpiresTime();
/**
* 应该是线程安全的
* @param accessToken 新的accessToken值
* @param expiresInSeconds 过期时间,以秒为单位 多少秒
*/
void updateAccessToken(String accessToken, int expiresInSeconds);
/**
* 应该是线程安全的
* @param accessToken 新的accessToken值
* @param expiresTime 过期时间,时间戳
*/
void updateAccessToken(String accessToken, long expiresTime);
/**
* 是否为测试环境, true测试环境
* @return
*/
boolean isTest();
}

View File

@@ -0,0 +1,21 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.exception.PayErrorException;
/**
* PayErrorExceptionHandler处理器
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:33:01
*/
public interface PayErrorExceptionHandler {
/**
* 异常统一处理器
* @param e
*/
void handle(PayErrorException e);
}

View File

@@ -0,0 +1,30 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.exception.PayErrorException;
import java.util.Map;
/**
* 处理支付回调消息的处理器接口
* @source Daniel Qian
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:40:30
*/
public interface PayMessageHandler {
/**
* @param payMessage
* @param context 上下文如果handler或interceptor之间有信息要传递可以用这个
* @param payService
* @return xml,text格式的消息如果在异步规则里处理的话可以返回null
*/
public PayOutMessage handle(PayMessage payMessage,
Map<String, Object> context,
PayService payService
) throws PayErrorException;
}

View File

@@ -0,0 +1,28 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.exception.PayErrorException;
import java.util.Map;
/**
* 支付消息拦截器,可以用来做验证
* @author Daniel Qian
*/
public interface PayMessageInterceptor {
/**
* 拦截微信消息
*
* @param wxMessage
* @param context 上下文如果handler或interceptor之间有信息要传递可以用这个
* @param payService
* @return true代表OKfalse代表不OK
*/
public boolean intercept(PayMessage wxMessage,
Map<String, Object> context,
PayService payService
) throws PayErrorException;
}

View File

@@ -0,0 +1,164 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.util.LogExceptionHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* <pre>
* 支付消息路由器通过代码化的配置把来自支付的消息交给handler处理
*
* 说明:
* 1. 配置路由规则时要按照从细到粗的原则,否则可能消息可能会被提前处理
* 2. 默认情况下消息只会被处理一次,除非使用 {@link PayMessageRouterRule#next()}
* 3. 规则的结束必须用{@link PayMessageRouterRule#end()}或者{@link PayMessageRouterRule#next()},否则不会生效
*
* 使用方法:
* PayMessageRouter router = new PayMessageRouter();
* router
* .rule()
* .msgType("MSG_TYPE").event("EVENT").eventKey("EVENT_KEY").content("CONTENT")
* .interceptor(interceptor, ...).handler(handler, ...)
* .end()
* .rule()
* // 另外一个匹配规则
* .end()
* ;
*
* // 将PayMessage交给消息路由器
* router.route(message);
*
* </pre>
* @source chanjarster/weixin-java-tools
* @source Daniel Qian
* @author egan
*
*/
public class PayMessageRouter {
protected final Log log = LogFactory.getLog(PayMessageRouter.class);
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
private final List<PayMessageRouterRule> rules = new ArrayList<PayMessageRouterRule>();
private final PayService payService;
private ExecutorService executorService;
private PayErrorExceptionHandler exceptionHandler;
public PayMessageRouter(PayService payService) {
this.payService = payService;
this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
this.exceptionHandler = new LogExceptionHandler();
}
/**
* <pre>
* 设置自定义的 {@link ExecutorService}
* 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
* </pre>
* @param executorService
*/
public void setExecutorService(ExecutorService executorService) {
this.executorService = executorService;
}
/**
* <pre>
* 设置自定义的{@link PayErrorExceptionHandler}
* 如果不调用该方法,默认使用 {@link LogExceptionHandler}
* </pre>
* @param exceptionHandler
*/
public void setExceptionHandler(PayErrorExceptionHandler exceptionHandler) {
this.exceptionHandler = exceptionHandler;
}
List<PayMessageRouterRule> getRules() {
return this.rules;
}
/**
* 开始一个新的Route规则
* @return
*/
public PayMessageRouterRule rule() {
return new PayMessageRouterRule(this);
}
/**
* 处理支付消息
* @param payMessage
*/
public PayOutMessage route(final PayMessage payMessage) {
final List<PayMessageRouterRule> matchRules = new ArrayList<PayMessageRouterRule>();
// 收集匹配的规则
for (final PayMessageRouterRule rule : rules) {
if (rule.test(payMessage)) {
matchRules.add(rule);
if(!rule.isReEnter()) {
break;
}
}
}
if (matchRules.size() == 0) {
return null;
}
PayOutMessage res = null;
final List<Future> futures = new ArrayList<Future>();
for (final PayMessageRouterRule rule : matchRules) {
// 返回最后一个非异步的rule的执行结果
if(rule.isAsync()) {
futures.add(
executorService.submit(new Runnable() {
public void run() {
rule.service(payMessage, payService, exceptionHandler);
}
})
);
} else {
res = rule.service(payMessage, payService, exceptionHandler);
// 在同步操作结束session访问结束
log.debug("End session access: async=false, fromPay=" + payMessage.getFromPay());
}
}
if (futures.size() > 0) {
executorService.submit(new Runnable() {
@Override
public void run() {
for (Future future : futures) {
try {
future.get();
log.debug("End session access: async=true, fromPay=" + payMessage.getFromPay());
} catch (InterruptedException e) {
log.error("Error happened when wait task finish", e);
} catch (ExecutionException e) {
log.error("Error happened when wait task finish", e);
}
}
}
});
}
return res;
}
}

View File

@@ -0,0 +1,415 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.exception.PayErrorException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:28:01
* @source chanjarster/weixin-java-tools
*/
public class PayMessageRouterRule {
private final PayMessageRouter routerBuilder;
private boolean async = true;
private String fromPay;
private String msgType;
private String payType;
private String[] transactionType;
private String discount;
private String rDiscount;
private String subject;
private String rSubject;
private boolean reEnter = false;
private List<PayMessageHandler> handlers = new ArrayList<PayMessageHandler>();
private List<PayMessageInterceptor> interceptors = new ArrayList<PayMessageInterceptor>();
public PayMessageRouterRule(PayMessageRouter routerBuilder) {
this.routerBuilder = routerBuilder;
}
/**
* 设置是否异步执行默认是true
*
* @param async
* @return
*/
public PayMessageRouterRule async(boolean async) {
this.async = async;
return this;
}
/**
* 如果msgType等于某值
*
* @param msgType
* @return
*/
public PayMessageRouterRule msgType(String msgType) {
this.msgType = msgType;
return this;
}
/**
* 如果payType等于某值
*
* @param payType
* @return
*/
public PayMessageRouterRule payType(String payType) {
this.payType = payType;
return this;
}
/**
* 如果transactionType等于某值
*
* @param transactionType
* @return
*/
public PayMessageRouterRule transactionType(String ... transactionType) {
this.transactionType = transactionType;
return this;
}
/**
* 如果discount等于某值
*
* @param discount
* @return
*/
public PayMessageRouterRule discount(String discount) {
this.discount = discount;
return this;
}
/**
* 如果discount匹配该正则表达式
*
* @param regex
* @return
*/
public PayMessageRouterRule rDiscount(String regex) {
this.rDiscount = regex;
return this;
}
/**
* 如果discount等于某值
*
* @param subject
* @return
*/
public PayMessageRouterRule subject(String subject) {
this.subject = subject;
return this;
}
/**
* 如果discount匹配该正则表达式
*
* @param regex
* @return
*/
public PayMessageRouterRule rSubject(String regex) {
this.rSubject = regex;
return this;
}
/**
* 如果消息匹配某个matcher用在用户需要自定义更复杂的匹配规则的时候
*
* @param matcher
* @return
*/
/* public PayMessageRouterRule matcher(WxMpMessageMatcher matcher) {
this.matcher = matcher;
return this;
}*/
/**
* 设置微信消息拦截器
*
* @param interceptor
* @return
*/
public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor) {
return interceptor(interceptor, (PayMessageInterceptor[]) null);
}
/**
* 设置微信消息拦截器
*
* @param interceptor
* @param otherInterceptors
* @return
*/
public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor, PayMessageInterceptor... otherInterceptors) {
this.interceptors.add(interceptor);
if (otherInterceptors != null && otherInterceptors.length > 0) {
for (PayMessageInterceptor i : otherInterceptors) {
this.interceptors.add(i);
}
}
return this;
}
/**
* 设置微信消息处理器
*
* @param handler
* @return
*/
public PayMessageRouterRule handler(PayMessageHandler handler) {
return handler(handler, (PayMessageHandler[]) null);
}
/**
* 设置微信消息处理器
*
* @param handler
* @param otherHandlers
* @return
*/
public PayMessageRouterRule handler(PayMessageHandler handler, PayMessageHandler... otherHandlers) {
this.handlers.add(handler);
if (otherHandlers != null && otherHandlers.length > 0) {
for (PayMessageHandler i : otherHandlers) {
this.handlers.add(i);
}
}
return this;
}
/**
* 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则
*
* @return
*/
public PayMessageRouter end() {
this.routerBuilder.getRules().add(this);
return this.routerBuilder;
}
/**
* 规则结束,但是消息还会进入其他规则
*
* @return
*/
public PayMessageRouter next() {
this.reEnter = true;
return end();
}
/**
* 将支付事件修正为不区分大小写,
* 比如框架定义的事件常量为
* @param payMessage
* @return
*/
protected boolean test(PayMessage payMessage) {
return (
(this.fromPay == null || this.fromPay.toLowerCase().equals((payMessage.getFromPay() ==null?null:payMessage.getFromPay().toLowerCase())))
&&
(this.msgType == null || this.msgType.toLowerCase().equals((payMessage.getMsgType() ==null?null:payMessage.getMsgType().toLowerCase())))
&&
(this.payType == null || this.payType.equals((payMessage.getPayType() == null ? null : payMessage.getPayType())))
&&
(this.transactionType == null || equalsTransactionType(payMessage.getTransactionType()))
&&
(this.discount == null || this.discount
.equals(payMessage.getDiscount() == null ? null : payMessage.getDiscount().trim()))
&&
(this.rDiscount == null || Pattern
.matches(this.rDiscount, payMessage.getDiscount() == null ? "" : payMessage.getDiscount().trim()))
&&
(this.subject == null || this.subject
.equals(payMessage.getSubject() == null ? null : payMessage.getSubject().trim()))
&&
(this.rSubject == null || Pattern
.matches(this.rSubject, payMessage.getSubject() == null ? "" : payMessage.getSubject().trim()))
)
;
}
/**
* 匹配交易类型
* @param transactionType 交易类型
* @return
*/
public boolean equalsTransactionType(String transactionType) {
if (null == transactionType){
return false;
}
for (String type :this.getTransactionType()){
if (type.toLowerCase().equals((transactionType.toLowerCase()))){
return true;
}
}
return false;
}
/**
* 处理支付回调过来的消息
*
* @param payService
* @return true 代表继续执行别的routerfalse 代表停止执行别的router
*/
protected PayOutMessage service(PayMessage payMessage,
PayService payService,
PayErrorExceptionHandler exceptionHandler) {
try {
Map<String, Object> context = new HashMap<String, Object>();
// 如果拦截器不通过
for (PayMessageInterceptor interceptor : this.interceptors) {
if (!interceptor.intercept(payMessage, context, payService)) {
return null;
}
}
// 交给handler处理
PayOutMessage res = null;
for (PayMessageHandler handler : this.handlers) {
// 返回最后handler的结果
res = handler.handle(payMessage, context, payService);
}
return res;
} catch (PayErrorException e) {
exceptionHandler.handle(e);
}
return null;
}
public PayMessageRouter getRouterBuilder() {
return routerBuilder;
}
public boolean isAsync() {
return async;
}
public void setAsync(boolean async) {
this.async = async;
}
public String getFromPay() {
return fromPay;
}
public void setFromPay(String fromPay) {
this.fromPay = fromPay;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public String getPayType() {
return payType;
}
public void setPayType(String payType) {
this.payType = payType;
}
public String[] getTransactionType() {
return transactionType;
}
public void setTransactionType(String[] transactionType) {
this.transactionType = transactionType;
}
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public String getrDiscount() {
return rDiscount;
}
public void setrDiscount(String rDiscount) {
this.rDiscount = rDiscount;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getrSubject() {
return rSubject;
}
public void setrSubject(String rSubject) {
this.rSubject = rSubject;
}
public boolean isReEnter() {
return reEnter;
}
public void setReEnter(boolean reEnter) {
this.reEnter = reEnter;
}
public List<PayMessageHandler> getHandlers() {
return handlers;
}
public void setHandlers(List<PayMessageHandler> handlers) {
this.handlers = handlers;
}
public List<PayMessageInterceptor> getInterceptors() {
return interceptors;
}
public void setInterceptors(List<PayMessageInterceptor> interceptors) {
this.interceptors = interceptors;
}
}

View File

@@ -0,0 +1,261 @@
package com.egzosn.pay.common.api;
import com.egzosn.pay.common.bean.MethodType;
import com.egzosn.pay.common.bean.PayOrder;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.bean.TransactionType;
import com.egzosn.pay.common.exception.PayErrorException;
import com.egzosn.pay.common.http.HttpConfigStorage;
import com.egzosn.pay.common.http.HttpRequestTemplate;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
/**
* 支付服务
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-5-18 14:09:01
*/
public interface PayService {
/**
* 设置支付配置
*
* @param payConfigStorage
*/
PayService setPayConfigStorage(PayConfigStorage payConfigStorage);
/**
* 获取支付配置
*
* @return
*/
PayConfigStorage getPayConfigStorage();
/**
* 获取http请求工具
*
* @return
*/
HttpRequestTemplate getHttpRequestTemplate();
/**
* 设置 请求工具配置
* @param configStorage http请求配置
* @return
*/
PayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage);
/**
* 回调校验
*
* @param params 回调回来的参数集
* @return
*/
boolean verify(Map<String, String> params);
/**
* 签名校验
*
* @param params 参数集
* @param sign 签名
* @return
*/
boolean signVerify(Map<String, String> params, String sign);
/**
* 校验数据来源
*
* @param id 业务id, 数据的真实性.
* @return
*/
boolean verifySource(String id);
/**
* 返回创建的订单信息
*
* @param order 支付订单
* @return
* @see PayOrder
*/
Map orderInfo(PayOrder order);
/**
* 创建签名
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return
*/
String createSign(String content, String characterEncoding);
/**
* 创建签名
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return
*/
String createSign(Map<String, Object> content, String characterEncoding);
/**
* 将请求参数或者请求流转化为 Map
*
* @param parameterMap 请求参数
* @param is 请求流
* @return
*/
Map<String, String> getParameter2Map(Map<String, String[]> parameterMap, InputStream is);
/**
* 获取输出消息,用户返回给支付端
*
* @param code
* @param message
* @return
*/
PayOutMessage getPayOutMessage(String code, String message);
/**
* 获取输出消息,用户返回给支付端, 针对于web端
*
* @param orderInfo 发起支付的订单信息
* @param method 请求方式 "post" "get",
* @return
* @see MethodType
*/
String buildRequest(Map<String, Object> orderInfo, MethodType method);
/**
* 获取输出二维码,用户返回给支付端,
*
* @param order 发起支付的订单信息
* @return
*/
BufferedImage genQrPay(PayOrder order);
/**
* 交易查询接口
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
*/
Map<String, Object> query(String tradeNo, String outTradeNo);
/**
* 交易查询接口
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T query(String tradeNo, String outTradeNo, Callback<T> callback);
/**
* 交易关闭接口
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
*/
Map<String, Object> close(String tradeNo, String outTradeNo);
/**
* 交易关闭接口
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T close(String tradeNo, String outTradeNo, Callback<T> callback);
/**
* 申请退款接口
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param refundAmount 退款金额
* @param totalAmount 总金额
* @return
*/
Map<String, Object> refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount);
/**
* 申请退款接口
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param refundAmount 退款金额
* @param totalAmount 总金额
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback<T> callback);
/**
* 查询退款
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
*/
Map<String, Object> refundquery(String tradeNo, String outTradeNo);
/**
* 查询退款
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T refundquery(String tradeNo, String outTradeNo, Callback<T> callback);
/**
* 下载对账单
*
* @param billDate 账单时间日账单格式为yyyy-MM-dd月账单格式为yyyy-MM。
* @param billType 账单类型商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型trade、signcustomertrade指商户基于支付宝交易收单的业务账单signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单
* @return
*/
Object downloadbill(Date billDate, String billType);
/**
* 下载对账单
*
* @param billDate 账单时间:具体请查看对应支付平台
* @param billType 账单类型,具体请查看对应支付平台
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T downloadbill(Date billDate, String billType, Callback<T> callback);
/**
* 通用查询接口
*
* @param tradeNoOrBillDate 支付平台订单号或者账单日期, 具体请 类型为{@link String }或者 {@link Date },类型须强制限制,类型不对应则抛出异常{@link PayErrorException}
*
* @param outTradeNoBillType 商户单号或者 账单类型
* @param transactionType 交易类型
* @param callback 处理器
* @param <T> 返回类型
* @return
*/
<T>T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback<T> callback);
}