diff --git a/README.md b/README.md index 68f7265d..867c3618 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,30 @@ 1. pay-java-common 公共lib,支付核心与规范定义 2. pay-java-demo 具体的支付demo 3. pay-java-* 具体的支付实现库 +###Maven配置 +支付核心模块 +```xml + + + com.egzosn + pay-java-common + 2.0.1 + + +``` + +具体支付模块 "{module-name}" 为具体的支付渠道的模块名 pay-java-ali,pay-java-wx等 + +```xml + + + com.egzosn + {module-name} + 2.0.1 + + +``` + ###使用 @@ -33,13 +57,13 @@ 服务端+网页端详细使用与简单教程请看 [pay-java-demo](pay-java-demo?dir=1&filepath=pay-java-demo) -android 例子 [pay-java-android](https://github.com/egzosn/pay-java-android) +android 例子 [pay-java-android](http://git.oschina.net/egzosn/pay-java-android) ##交流 很希望更多志同道合友友一起扩展新的的支付接口。 -这里感谢[ouyangxiangshao](https://github.com/ouyangxiangshao) 与[Actinian](https://github.com/Actinian) 所提交的安卓例子或者分支 +这里感谢[ouyangxiangshao](https://github.com/ouyangxiangshao) 与[Actinian](http://git.oschina.net/Actinia517) 所提交的安卓例子或者分支 非常欢迎和感谢对本项目发起Pull Request的同学,不过本项目基于git flow开发流程,因此在发起Pull Request的时候请选择develop分支。 diff --git a/pay-java-ali/pom.xml b/pay-java-ali/pom.xml index 8fc22996..1c1ab585 100644 --- a/pay-java-ali/pom.xml +++ b/pay-java-ali/pom.xml @@ -5,7 +5,7 @@ pay-java-parent com.egzosn - 2.0.SNAPSHOT + 2.0.1 4.0.0 pay-java-ali diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayConfigStorage.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayConfigStorage.java index 10c54b6f..7198174d 100644 --- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayConfigStorage.java +++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayConfigStorage.java @@ -4,9 +4,10 @@ /** * 支付客户端配置存储 - * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + * author egan + * + * email egzosn@gmail.com + * date 2016-5-18 14:09:01 */ public class AliPayConfigStorage extends BasePayConfigStorage { @@ -57,9 +58,11 @@ public String getPartner() { return pid; } + /** + * 设置合作者id * @see #setPid(String) - * @return 合作者id + * @param partner 合作者id */ @Deprecated public void setPartner(String partner) { diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java index 2c2da216..e7e9bdc2 100644 --- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java +++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java @@ -28,8 +28,9 @@ /** * 支付宝支付通知 * @author egan - * @email egzosn@gmail.com - * @date 2017-2-22 20:09 + * + * email egzosn@gmail.com + * date 2017-2-22 20:09 */ public class AliPayService extends BasePayService { protected final Log log = LogFactory.getLog(AliPayService.class); @@ -44,7 +45,7 @@ public class AliPayService extends BasePayService { /** * 获取对应的请求地址 - * @return + * @return 请求地址 */ public String getReqUrl(){ return payConfigStorage.isTest() ? devReqUrl : httpsReqUrl; @@ -64,6 +65,12 @@ public String getHttpsVerifyUrl() { return getReqUrl() + "?service=notify_verify"; } + /** + * 回调校验 + * + * @param params 回调回来的参数集 + * @return 签名校验 true通过 + */ @Override public boolean verify(Map params) { @@ -95,9 +102,10 @@ public boolean signVerify(Map params, String sign) { /** + * 校验数据来源 * * @param id 业务id, 数据的真实性. - * @return + * @return true通过 */ @Override public boolean verifySource(String id) { @@ -110,7 +118,7 @@ public boolean verifySource(String id) { /** * 生成并设置签名 * @param parameters 请求参数 - * @return + * @return 请求参数 */ private Map setSign(Map parameters){ parameters.put("sign_type", payConfigStorage.getSignType()); @@ -120,12 +128,13 @@ private Map setSign(Map parameters){ return parameters; } + /** * 返回创建的订单信息 * * @param order 支付订单 - * @return - * @see PayOrder + * @return 订单信息 + * @see PayOrder 支付订单信息 */ @Override public Map orderInfo(PayOrder order) { @@ -139,8 +148,8 @@ public Map orderInfo(PayOrder order) { * create the order info * * @param order 支付订单 - * @return - * @see PayOrder + * @return 返回支付宝预下单信息 + * @see PayOrder 支付订单信息 */ private Map getOrder(PayOrder order) { @@ -179,7 +188,7 @@ private Map getOrder(PayOrder order) { /** * 获取公共请求参数 * @param transactionType 交易类型 - * @return + * @return 放回公共请求参数 */ private Map getPublicParameters(TransactionType transactionType ){ Map orderInfo = new TreeMap<>(); @@ -199,8 +208,8 @@ private Map getPublicParameters(TransactionType transactionType * create the order info * * @param order 支付订单 - * @return - * @see PayOrder + * @return 返回过时的交易订单,兼容即时收款 + * @see PayOrder 支付订单信息 */ private Map getOrderBefore(PayOrder order) { Map orderInfo = new TreeMap<>(); @@ -254,8 +263,12 @@ private Map getOrderBefore(PayOrder order) { } - - + /** + * 将请求参数或者请求流转化为 Map + * @param parameterMap 请求参数 + * @param is 请求流 + * @return 获得回调的请求参数 + */ @Override public Map getParameter2Map(Map parameterMap, InputStream is) { @@ -273,11 +286,23 @@ public Map getParameter2Map(Map parameterMap, return params; } + /** + * 获取输出消息,用户返回给支付端 + * @param code 状态 + * @param message 消息 + * @return 返回输出消息 + */ @Override public PayOutMessage getPayOutMessage(String code, String message) { return PayOutMessage.TEXT().content(code.toLowerCase()).build(); } + /** + * + * @param orderInfo 发起支付的订单信息 + * @param method 请求方式 "post" "get", + * @return 获取输出消息,用户返回给支付端, 针对于web端 + */ @Override public String buildRequest(Map orderInfo, MethodType method) { @@ -322,7 +347,7 @@ public String buildRequest(Map orderInfo, MethodType method) { * 生成二维码支付 * 暂未实现或无此功能 * @param order 发起支付的订单信息 - * @return + * @return 返回图片信息,支付时需要的 */ @Override public BufferedImage genQrPay(PayOrder order) { @@ -344,7 +369,7 @@ public BufferedImage genQrPay(PayOrder order) { * 交易查询接口 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回查询回来的结果集,支付方原值返回 */ @Override public Map query(String tradeNo, String outTradeNo) { @@ -357,13 +382,14 @@ public Map perform(Map map) { }); } + /** - * + * 交易查询接口,带处理器 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回查询回来的结果集 */ @Override public T query(String tradeNo, String outTradeNo, Callback callback) { @@ -371,7 +397,13 @@ public T query(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.QUERY, callback); } - + /** + * 交易关闭接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方交易关闭后的结果 + */ @Override public Map close(String tradeNo, String outTradeNo) { @@ -382,12 +414,28 @@ public Map perform(Map map) { } }); } - + /** + * 交易关闭接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方交易关闭后的结果 + */ @Override public T close(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.CLOSE, callback); } - + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @return 返回支付方申请退款后的结果 + */ @Override public Map refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount) { @@ -398,7 +446,17 @@ public Map perform(Map map) { } }); } - + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方申请退款后的结果 + */ @Override public T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback callback) { //获取公共参数 @@ -412,7 +470,13 @@ public T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, setSign(parameters); return callback.perform(requestTemplate.getForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(parameters), JSONObject.class)); } - + /** + * 查询退款 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方查询退款后的结果 + */ @Override public Map refundquery(String tradeNo, String outTradeNo) { return refundquery(tradeNo, outTradeNo, new Callback>() { @@ -422,7 +486,15 @@ public Map perform(Map map) { } }); } - + /** + * 查询退款 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方查询退款后的结果 + */ @Override public T refundquery(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.REFUNDQUERY, callback); @@ -432,7 +504,7 @@ public T refundquery(String tradeNo, String outTradeNo, Callback callback * 目前只支持日账单 * @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单; * @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。 - * @return + * @return 返回支付方下载对账单的结果 */ @Override public Map downloadbill(Date billDate, String billType) { @@ -449,8 +521,8 @@ public Map perform(Map map) { * @param billDate 账单时间:具体请查看对应支付平台 * @param billType 账单类型,具体请查看对应支付平台 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回支付方下载对账单的结果 */ @Override public T downloadbill(Date billDate, String billType, Callback callback) { @@ -478,8 +550,8 @@ public T downloadbill(Date billDate, String billType, Callback callback) * @param outTradeNoBillType 商户单号或者 账单类型 * @param transactionType 交易类型 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回支付方对应接口的结果 */ @Override public T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback callback) { @@ -514,7 +586,7 @@ public T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillT * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 * @param bizContent 请求参数的集合 - * @return + * @return 请求参数的集合 不包含下载账单 */ private Map getBizContent(String tradeNo, String outTradeNo, Map bizContent){ if (null == bizContent){ @@ -533,7 +605,7 @@ private Map getBizContent(String tradeNo, String outTradeNo, M * 获取biz_content。不包含下载账单 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 获取biz_content。不包含下载账单 */ private String getContentToJson(String tradeNo, String outTradeNo){ diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliTransactionType.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliTransactionType.java index bc2d1ebc..c678e0e0 100644 --- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliTransactionType.java +++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliTransactionType.java @@ -14,8 +14,9 @@ * * * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:58 + * + * email egzosn@gmail.com + * date 2016/10/19 22:58 */ public enum AliTransactionType implements TransactionType { //app支付 //手机网站支付 @@ -45,7 +46,7 @@ public String getType() { /** * 获取接口名称 - * @return + * @return 接口名称 */ @Override public String getMethod() { diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/api/AliPayService.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/api/AliPayService.java index ed29276c..41a8b17e 100644 --- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/api/AliPayService.java +++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/api/AliPayService.java @@ -29,8 +29,10 @@ /** * 支付宝支付通知 * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + * + * email egzosn@gmail.com + * date 2016-5-18 14:09:01 + * * @see com.egzosn.pay.ali.api.AliPayService */ public class AliPayService extends BasePayService { @@ -53,6 +55,12 @@ public String getHttpsVerifyUrl() { return httpsReqUrl + "?service=notify_verify"; } + /** + * 回调校验 + * + * @param params 回调回来的参数集 + * @return 签名校验 true通过 + */ @Override public boolean verify(Map params) { @@ -69,7 +77,12 @@ public boolean verify(Map params) { return false; } - + /** + * 校验数据来源 + * + * @param id 业务id, 数据的真实性. + * @return true通过 + */ @Override public boolean verifySource(String id) { return "true".equals(requestTemplate.getForObject( getHttpsVerifyUrl() + "partner=" + payConfigStorage.getPid() + "¬ify_id=" + id, String.class)); @@ -91,16 +104,11 @@ public boolean signVerify(Map params, String sign) { /** * 生成并设置签名 * @param parameters 请求参数 - * @return + * @return 订单信息 */ private Map setSign(Map parameters){ parameters.put("sign_type", payConfigStorage.getSignType()); String sign = createSign(SignUtils.parameterText(parameters, "&", "sign", "appId"), payConfigStorage.getInputCharset()); - /* try { - sign = URLEncoder.encode(sign, payConfigStorage.getInputCharset()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - }*/ parameters.put("sign", sign); return parameters; @@ -109,7 +117,7 @@ private Map setSign(Map parameters){ /** * 获取公共请求参数 * @param transactionType 交易类型 - * @return + * @return 公共请求参数 */ private Map getPublicParameters(TransactionType transactionType ){ Map orderInfo = new TreeMap<>(); @@ -127,12 +135,13 @@ private Map getPublicParameters(TransactionType transactionType } + /** * 返回创建的订单信息 * * @param order 支付订单 - * @return - * @see PayOrder + * @return 订单信息 + * @see PayOrder 支付订单信息 */ @Override public Map orderInfo(PayOrder order) { @@ -156,7 +165,7 @@ public Map orderInfo(PayOrder order) { * create the order info * * @param order 支付订单 - * @return + * @return 订单信息 * @see PayOrder */ private Map getOrder(PayOrder order) { @@ -198,7 +207,13 @@ private Map getOrder(PayOrder order) { } - + /** + * 将请求参数或者请求流转化为 Map + * + * @param parameterMap 请求参数 + * @param is 请求流 + * @return 获得回调的请求参数 + */ @Override public Map getParameter2Map(Map parameterMap, InputStream is) { @@ -218,12 +233,25 @@ public Map getParameter2Map(Map parameterMap, return params; } - + /** + * 获取输出消息,用户返回给支付端 + * + * @param code 状态 + * @param message 消息 + * @return 返回输出消息 + */ @Override public PayOutMessage getPayOutMessage(String code, String message) { return PayOutMessage.TEXT().content(code.toLowerCase()).build(); } - + /** + * 获取输出消息,用户返回给支付端, 针对于web端 + * + * @param orderInfo 发起支付的订单信息 + * @param method 请求方式 "post" "get", + * @return 获取输出消息,用户返回给支付端, 针对于web端 + * @see MethodType 请求类型 + */ @Override public String buildRequest(Map orderInfo, MethodType method) { @@ -258,7 +286,7 @@ public String buildRequest(Map orderInfo, MethodType method) { * 生成二维码支付 * 暂未实现或无此功能 * @param orderInfo 发起支付的订单信息 - * @return + * @return 返回图片信息,支付时需要的 */ @Override public BufferedImage genQrPay(PayOrder orderInfo) { @@ -270,7 +298,7 @@ public BufferedImage genQrPay(PayOrder orderInfo) { * 交易查询接口 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回查询回来的结果集,支付方原值返回 */ @Override public Map query(String tradeNo, String outTradeNo) { @@ -284,12 +312,12 @@ public Map perform(Map map) { } /** - * + * 交易查询接口,带处理器 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回查询回来的结果集 */ @Override public T query(String tradeNo, String outTradeNo, Callback callback) { @@ -297,7 +325,13 @@ public T query(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.QUERY, callback); } - + /** + * 交易关闭接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方交易关闭后的结果 + */ @Override public Map close(String tradeNo, String outTradeNo) { @@ -308,12 +342,28 @@ public Map perform(Map map) { } }); } - + /** + * 交易关闭接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方交易关闭后的结果 + */ @Override public T close(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.CLOSE, callback); } - + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @return 返回支付方申请退款后的结果 + */ @Override public Map refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount) { @@ -324,7 +374,17 @@ public Map perform(Map map) { } }); } - + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方申请退款后的结果 + */ @Override public T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback callback) { //获取公共参数 @@ -338,6 +398,14 @@ public T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, setSign(parameters); return callback.perform(requestTemplate.getForObject(queryReqUrl + "?" + UriVariables.getMapToParameters(parameters), JSONObject.class)); } + + /** + * 查询退款 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方查询退款后的结果 + */ @Override public Map refundquery(String tradeNo, String outTradeNo) { return refundquery(tradeNo, outTradeNo, new Callback>() { @@ -348,6 +416,15 @@ public Map perform(Map map) { }); } + /** + * 查询退款 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 返回支付方查询退款后的结果 + */ @Override public T refundquery(String tradeNo, String outTradeNo, Callback callback) { return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.REFUNDQUERY, callback); @@ -357,7 +434,7 @@ public T refundquery(String tradeNo, String outTradeNo, Callback callback * 目前只支持日账单 * @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单; * @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。 - * @return + * @return 返回支付方下载对账单的结果 */ @Override public Map downloadbill(Date billDate, String billType) { @@ -374,8 +451,8 @@ public Map perform(Map map) { * @param billDate 账单时间:具体请查看对应支付平台 * @param billType 账单类型,具体请查看对应支付平台 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回支付方下载对账单的结果 */ @Override public T downloadbill(Date billDate, String billType, Callback callback) { @@ -403,8 +480,8 @@ public T downloadbill(Date billDate, String billType, Callback callback) * @param outTradeNoBillType 商户单号或者 账单类型 * @param transactionType 交易类型 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回支付方对应接口的结果 */ @Override public T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback callback) { @@ -435,7 +512,7 @@ public T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillT * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 * @param bizContent 请求参数的集合 - * @return + * @return 请求参数的集合 不包含下载账单 */ private Map getBizContent(String tradeNo, String outTradeNo, Map bizContent){ if (null == bizContent){ @@ -454,7 +531,7 @@ private Map getBizContent(String tradeNo, String outTradeNo, M * 获取biz_content。不包含下载账单 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 请求参数的集合 不包含下载账单 */ private String getContentToJson(String tradeNo, String outTradeNo){ diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/bean/AliTransactionType.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/bean/AliTransactionType.java index 9fea37b1..d3e2963a 100644 --- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/bean/AliTransactionType.java +++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/before/bean/AliTransactionType.java @@ -14,8 +14,10 @@ * * * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:58 + * + * email egzosn@gmail.com + * date 2016/10/19 22:58 + * * @see com.egzosn.pay.ali.bean.AliTransactionType */ @Deprecated @@ -42,7 +44,7 @@ public String getType() { /** * 获取接口名称 - * @return + * @return 接口名称 */ @Override public String getMethod() { diff --git a/pay-java-common/pom.xml b/pay-java-common/pom.xml index 90dbcc7c..6998d364 100644 --- a/pay-java-common/pom.xml +++ b/pay-java-common/pom.xml @@ -5,7 +5,7 @@ pay-java-parent com.egzosn - 2.0.SNAPSHOT + 2.0.1 4.0.0 jar diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java index 808e9ace..9e31da89 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java @@ -8,8 +8,10 @@ /** * 支付基础配置存储 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/5 20:33 + *
+ *     email egzosn@gmail.com
+ *     date 2017/3/5 20:33
+ *  
*/ public abstract class BasePayConfigStorage implements PayConfigStorage{ diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java index 4b281366..fbe4c2f7 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java @@ -9,8 +9,10 @@ /** * 支付基础服务 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/5 20:36 + *
+ *      email egzosn@gmail.com
+ *      date 2017/3/5 20:36
+ *   
*/ public abstract class BasePayService implements PayService { @@ -42,7 +44,7 @@ public HttpRequestTemplate getHttpRequestTemplate() { /** * 设置并创建请求模版, 代理请求配置这里是否合理??, * @param configStorage http请求配置 - * @return + * @return 支付服务 */ @Override public BasePayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage) { @@ -59,12 +61,25 @@ public BasePayService(PayConfigStorage payConfigStorage, HttpConfigStorage confi setPayConfigStorage(payConfigStorage); setRequestTemplateConfigStorage(configStorage); } + /** + * 创建签名 + * + * @param content 需要签名的内容 + * @param characterEncoding 字符编码 + * @return 签名 + */ @Override public String createSign(String content, String characterEncoding) { return SignUtils.valueOf(payConfigStorage.getSignType()).createSign(content, payConfigStorage.getKeyPrivate(),characterEncoding); } - + /** + * 创建签名 + * + * @param content 需要签名的内容 + * @param characterEncoding 字符编码 + * @return 签名 + */ @Override public String createSign(Map content, String characterEncoding) { return SignUtils.valueOf(payConfigStorage.getSignType()).sign(content, payConfigStorage.getKeyPrivate(),characterEncoding); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/Callback.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/Callback.java index b9850247..fb519aed 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/Callback.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/Callback.java @@ -22,11 +22,17 @@ /** * 回调,可用于类型转换 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/7 18:55 + *
+ *     email egzosn@gmail.com
+ *     date 2017/3/7 18:55
+ *  
*/ public interface Callback { - + /** + * 执行者 + * @param map 需要转化的map + * @return 处理过后的类型对象 + */ T perform(Map map); } diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java index e9bffdd5..cecc27e8 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java @@ -7,74 +7,88 @@ /** * 支付客户端配置存储 * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 - * @source chanjarster/weixin-java-tools + *
+ *     email egzosn@gmail.com
+ *     date 2016-5-18 14:09:01
+ * 
*/ public interface PayConfigStorage { /* * 应用id + * @return 应用id */ String getAppid(); /** * 合作商唯一标识 * @see #getPid() 代替者 + * @return 合作商唯一标识 */ @Deprecated String getPartner(); /** * 合作商唯一标识 * @see #getPartner() 代替者 + * @return 合作商唯一标识 */ String getPid(); /** * 获取收款账号 + * @return 收款账号 */ String getSeller(); /** * 授权令牌 + * @return 授权令牌 */ String getToken(); /** * 服务端异步回调Url + * @return 异步回调Url */ String getNotifyUrl(); /** * 服务端同步回调Url + * @return 同步回调Url */ String getReturnUrl(); /** * 签名方式 + * @return 签名方式 */ String getSignType(); - // 字符编码格式 目前支持 gbk 或 utf-8 + + /** + * 字符编码格式 + * @return 字符编码 + */ String getInputCharset(); /** * 获取密钥 与 #getKeyPrivate 类似 + * @return 获取密钥 */ String getSecretKey(); /** * 公钥 - * @return + * @return 公钥 */ String getKeyPublic(); /** * 私钥 - * @return + * @return 私钥 */ String getKeyPrivate(); /** * 支付类型 自定义 * 这里暂定 aliPay 支付宝, wxPay微信支付 - * @return + * @return 支付类型 */ String getPayType(); @@ -89,18 +103,18 @@ public interface PayConfigStorage { /** * 获取访问令牌 - * @return + * @return 访问令牌 */ String getAccessToken(); /** * 访问令牌是否过期 - * @return + * @return true过期 */ boolean isAccessTokenExpired(); /** * 获取access token锁 - * @return + * @return access token锁 */ Lock getAccessTokenLock(); @@ -110,6 +124,7 @@ public interface PayConfigStorage { void expireAccessToken(); /** * 强制将access token过期掉 + * @return 过期时间 */ long getExpiresTime(); @@ -129,7 +144,7 @@ public interface PayConfigStorage { /** * 是否为测试环境, true测试环境 - * @return + * @return true测试环境 */ boolean isTest(); } diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayErrorExceptionHandler.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayErrorExceptionHandler.java index 29815401..3f1a2d78 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayErrorExceptionHandler.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayErrorExceptionHandler.java @@ -7,14 +7,16 @@ * PayErrorExceptionHandler处理器 * * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:33:01 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:33:01
+ *  
*/ public interface PayErrorExceptionHandler { /** * 异常统一处理器 - * @param e + * @param e 支付异常 */ void handle(PayErrorException e); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageHandler.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageHandler.java index c8a738ba..c0bab6a0 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageHandler.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageHandler.java @@ -9,20 +9,25 @@ /** * 处理支付回调消息的处理器接口 - * @source Daniel Qian + * * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ *
+ *
+ *     source Daniel Qian
+ *  
*/ public interface PayMessageHandler { /** - * @param payMessage + * @param payMessage 支付消息 * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 - * @param payService + * @param payService 支付服务 * @return xml,text格式的消息,如果在异步规则里处理的话,可以返回null */ - public PayOutMessage handle(PayMessage payMessage, + PayOutMessage handle(PayMessage payMessage, Map context, PayService payService ) throws PayErrorException; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageInterceptor.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageInterceptor.java index 56458f95..23a55d7d 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageInterceptor.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageInterceptor.java @@ -8,19 +8,26 @@ /** * 支付消息拦截器,可以用来做验证 - * @author Daniel Qian + * @author egan + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ *
+ *
+ *     source Daniel Qian
+ *  
*/ public interface PayMessageInterceptor { /** * 拦截微信消息 * - * @param wxMessage + * @param payMessage 支付消息 * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 - * @param payService + * @param payService 支付服务 * @return true代表OK,false代表不OK */ - public boolean intercept(PayMessage wxMessage, + boolean intercept(PayMessage payMessage, Map context, PayService payService ) throws PayErrorException; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouter.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouter.java index 074d089c..0ed37f94 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouter.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouter.java @@ -36,16 +36,14 @@ * * // 将PayMessage交给消息路由器 * router.route(message); - * + * source chanjarster/weixin-java-tools Daniel Qian * - * @source chanjarster/weixin-java-tools - * @source Daniel Qian * @author egan * */ public class PayMessageRouter { - protected final Log log = LogFactory.getLog(PayMessageRouter.class); + protected final Log log = LogFactory.getLog(PayMessageRouter.class); private static final int DEFAULT_THREAD_POOL_SIZE = 100; @@ -66,9 +64,9 @@ public PayMessageRouter(PayService payService) { /** *
    * 设置自定义的 {@link ExecutorService}
-   * 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
+   * 如果不调用用该方法,默认使 Executors.newFixedThreadPool(100)
    * 
- * @param executorService + * @param executorService 异步线程处理器 */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; @@ -81,19 +79,23 @@ public void setExecutorService(ExecutorService executorService) { * 设置自定义的{@link PayErrorExceptionHandler} * 如果不调用该方法,默认使用 {@link LogExceptionHandler} * - * @param exceptionHandler + * @param exceptionHandler 异常处理器 */ public void setExceptionHandler(PayErrorExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } + /** + * 获取所有的规则 + * @return 规则 + */ List getRules() { return this.rules; } /** * 开始一个新的Route规则 - * @return + * @return 新的Route规则 */ public PayMessageRouterRule rule() { return new PayMessageRouterRule(this); @@ -101,7 +103,8 @@ public PayMessageRouterRule rule() { /** * 处理支付消息 - * @param payMessage + * @param payMessage 支付消息 + * @return 支付输出结果 */ public PayOutMessage route(final PayMessage payMessage) { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouterRule.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouterRule.java index c1055823..d97a9638 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouterRule.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayMessageRouterRule.java @@ -13,11 +13,15 @@ /** - * + * Route规则 路由 * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:28:01 - * @source chanjarster/weixin-java-tools + *
+ *  email egzosn@gmail.com
+ *  date 2016-6-1 11:28:01
+ *
+ *
+ *  source chanjarster/weixin-java-tools
+ *  
*/ public class PayMessageRouterRule { @@ -56,8 +60,8 @@ public PayMessageRouterRule(PayMessageRouter routerBuilder) { /** * 设置是否异步执行,默认是true * - * @param async - * @return + * @param async 是否异步执行,默认是true + * @return Route规则 */ public PayMessageRouterRule async(boolean async) { this.async = async; @@ -67,8 +71,8 @@ public PayMessageRouterRule async(boolean async) { /** * 如果msgType等于某值 * - * @param msgType - * @return + * @param msgType 消息类型 + * @return Route规则 */ public PayMessageRouterRule msgType(String msgType) { this.msgType = msgType; @@ -78,8 +82,8 @@ public PayMessageRouterRule msgType(String msgType) { /** * 如果payType等于某值 * - * @param payType - * @return + * @param payType 支付类型 + * @return Route规则 */ public PayMessageRouterRule payType(String payType) { this.payType = payType; @@ -89,8 +93,8 @@ public PayMessageRouterRule payType(String payType) { /** * 如果transactionType等于某值 * - * @param transactionType - * @return + * @param transactionType 交易类型 + * @return Route规则 */ public PayMessageRouterRule transactionType(String ... transactionType) { this.transactionType = transactionType; @@ -100,8 +104,8 @@ public PayMessageRouterRule transactionType(String ... transactionType) { /** * 如果discount等于某值 * - * @param discount - * @return + * @param discount discount等于某值 + * @return Route规则 */ public PayMessageRouterRule discount(String discount) { this.discount = discount; @@ -111,8 +115,8 @@ public PayMessageRouterRule discount(String discount) { /** * 如果discount匹配该正则表达式 * - * @param regex - * @return + * @param regex discount匹配该正则表达式 + * @return Route规则 */ public PayMessageRouterRule rDiscount(String regex) { this.rDiscount = regex; @@ -120,10 +124,10 @@ public PayMessageRouterRule rDiscount(String regex) { } /** - * 如果discount等于某值 + * 如果subject等于某值 * - * @param subject - * @return + * @param subject 简介 + * @return Route规则 */ public PayMessageRouterRule subject(String subject) { this.subject = subject; @@ -131,10 +135,10 @@ public PayMessageRouterRule subject(String subject) { } /** - * 如果discount匹配该正则表达式 + * 如果subject匹配该正则表达式 * - * @param regex - * @return + * @param regex 简介正则 + * @return Route规则 */ public PayMessageRouterRule rSubject(String regex) { this.rSubject = regex; @@ -143,32 +147,21 @@ public PayMessageRouterRule rSubject(String regex) { /** - * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 + * 设置消息拦截器 * - * @param matcher - * @return - */ - /* public PayMessageRouterRule matcher(WxMpMessageMatcher matcher) { - this.matcher = matcher; - return this; - }*/ - - /** - * 设置微信消息拦截器 - * - * @param interceptor - * @return + * @param interceptor 消息拦截器 + * @return Route规则 */ public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor) { return interceptor(interceptor, (PayMessageInterceptor[]) null); } /** - * 设置微信消息拦截器 + * 设置消息拦截器 * - * @param interceptor - * @param otherInterceptors - * @return + * @param interceptor 消息拦截器 + * @param otherInterceptors 其他消息拦截器 + * @return Route规则 */ public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor, PayMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); @@ -181,21 +174,21 @@ public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor, PayMe } /** - * 设置微信消息处理器 + * 设置消息处理器 * - * @param handler - * @return + * @param handler 消息处理器 + * @return Route规则 */ public PayMessageRouterRule handler(PayMessageHandler handler) { return handler(handler, (PayMessageHandler[]) null); } /** - * 设置微信消息处理器 + * 设置消息处理器 * - * @param handler - * @param otherHandlers - * @return + * @param handler 消息处理器 + * @param otherHandlers 其他消息处理器 + * @return Route规则 */ public PayMessageRouterRule handler(PayMessageHandler handler, PayMessageHandler... otherHandlers) { this.handlers.add(handler); @@ -210,7 +203,7 @@ public PayMessageRouterRule handler(PayMessageHandler handler, PayMessageHandler /** * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 * - * @return + * @return Route规则 */ public PayMessageRouter end() { this.routerBuilder.getRules().add(this); @@ -220,7 +213,7 @@ public PayMessageRouter end() { /** * 规则结束,但是消息还会进入其他规则 * - * @return + * @return Route规则 */ public PayMessageRouter next() { this.reEnter = true; @@ -230,8 +223,8 @@ public PayMessageRouter next() { /** * 将支付事件修正为不区分大小写, * 比如框架定义的事件常量为 - * @param payMessage - * @return + * @param payMessage 支付消息 + * @return 是否匹配通过 */ protected boolean test(PayMessage payMessage) { return ( @@ -261,7 +254,7 @@ protected boolean test(PayMessage payMessage) { /** * 匹配交易类型 * @param transactionType 交易类型 - * @return + * @return 匹配交易类型 */ public boolean equalsTransactionType(String transactionType) { if (null == transactionType){ @@ -278,12 +271,12 @@ public boolean equalsTransactionType(String transactionType) { } - /** - * 处理支付回调过来的消息 - * - * @param payService - * @return true 代表继续执行别的router,false 代表停止执行别的router + * 返回支付响应消息 + * @param payMessage 支付消息 + * @param payService 支付服务 + * @param exceptionHandler 异常处理器 + * @return 支付响应消息 */ protected PayOutMessage service(PayMessage payMessage, PayService payService, diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java index c297165e..35dfed3d 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java @@ -18,36 +18,39 @@ * 支付服务 * * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + *
+ * email egzosn@gmail.com
+ * date 2016-5-18 14:09:01
+ *
*/ public interface PayService { + /** * 设置支付配置 - * - * @param payConfigStorage + * @param payConfigStorage 支付配置 + * @return 支付服务 */ PayService setPayConfigStorage(PayConfigStorage payConfigStorage); /** * 获取支付配置 * - * @return + * @return 支付配置 */ PayConfigStorage getPayConfigStorage(); /** * 获取http请求工具 * - * @return + * @return http请求工具 */ HttpRequestTemplate getHttpRequestTemplate(); /** - * 设置 请求工具配置 + * 设置 请求工具配置 设置并创建请求模版, 代理请求配置这里是否合理??, * @param configStorage http请求配置 - * @return + * @return 支付服务 */ PayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage); @@ -55,7 +58,7 @@ public interface PayService { * 回调校验 * * @param params 回调回来的参数集 - * @return + * @return 签名校验 true通过 */ boolean verify(Map params); @@ -64,16 +67,16 @@ public interface PayService { * * @param params 参数集 * @param sign 签名 - * @return + * @return 签名校验 true通过 */ boolean signVerify(Map params, String sign); /** + * 支付宝需要,微信是否也需要再次校验来源,进行订单查询 * 校验数据来源 - * * @param id 业务id, 数据的真实性. - * @return + * @return true通过 */ boolean verifySource(String id); @@ -82,8 +85,8 @@ public interface PayService { * 返回创建的订单信息 * * @param order 支付订单 - * @return - * @see PayOrder + * @return 订单信息 + * @see PayOrder 支付订单信息 */ Map orderInfo(PayOrder order); @@ -92,7 +95,7 @@ public interface PayService { * * @param content 需要签名的内容 * @param characterEncoding 字符编码 - * @return + * @return 签名 */ String createSign(String content, String characterEncoding); @@ -101,7 +104,7 @@ public interface PayService { * * @param content 需要签名的内容 * @param characterEncoding 字符编码 - * @return + * @return 签名 */ String createSign(Map content, String characterEncoding); @@ -110,16 +113,16 @@ public interface PayService { * * @param parameterMap 请求参数 * @param is 请求流 - * @return + * @return 获得回调的请求参数 */ Map getParameter2Map(Map parameterMap, InputStream is); /** * 获取输出消息,用户返回给支付端 * - * @param code - * @param message - * @return + * @param code 状态 + * @param message 消息 + * @return 返回输出消息 */ PayOutMessage getPayOutMessage(String code, String message); @@ -128,8 +131,8 @@ public interface PayService { * * @param orderInfo 发起支付的订单信息 * @param method 请求方式 "post" "get", - * @return - * @see MethodType + * @return 获取输出消息,用户返回给支付端, 针对于web端 + * @see MethodType 请求类型 */ String buildRequest(Map orderInfo, MethodType method); @@ -137,7 +140,7 @@ public interface PayService { * 获取输出二维码,用户返回给支付端, * * @param order 发起支付的订单信息 - * @return + * @return 返回图片信息,支付时需要的 */ BufferedImage genQrPay(PayOrder order); @@ -146,17 +149,17 @@ public interface PayService { * * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回查询回来的结果集,支付方原值返回 */ Map query(String tradeNo, String outTradeNo); /** - * 交易查询接口 + * 交易查询接口,带处理器 * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回查询回来的结果集 */ T query(String tradeNo, String outTradeNo, Callback callback); @@ -165,7 +168,7 @@ public interface PayService { * * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回支付方交易关闭后的结果 */ Map close(String tradeNo, String outTradeNo); @@ -176,7 +179,7 @@ public interface PayService { * @param outTradeNo 商户单号 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回支付方交易关闭后的结果 */ T close(String tradeNo, String outTradeNo, Callback callback); @@ -187,7 +190,7 @@ public interface PayService { * @param outTradeNo 商户单号 * @param refundAmount 退款金额 * @param totalAmount 总金额 - * @return + * @return 返回支付方申请退款后的结果 */ Map refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount); /** @@ -199,7 +202,7 @@ public interface PayService { * @param totalAmount 总金额 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回支付方申请退款后的结果 */ T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback callback); @@ -208,7 +211,7 @@ public interface PayService { * * @param tradeNo 支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回支付方查询退款后的结果 */ Map refundquery(String tradeNo, String outTradeNo); /** @@ -218,7 +221,7 @@ public interface PayService { * @param outTradeNo 商户单号 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回支付方查询退款后的结果 */ T refundquery(String tradeNo, String outTradeNo, Callback callback); @@ -227,7 +230,7 @@ public interface PayService { * * @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。 * @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单; - * @return + * @return 返回支付方下载对账单的结果 */ Object downloadbill(Date billDate, String billType); @@ -238,7 +241,7 @@ public interface PayService { * @param billType 账单类型,具体请查看对应支付平台 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回支付方下载对账单的结果 */ T downloadbill(Date billDate, String billType, Callback callback); @@ -251,7 +254,7 @@ public interface PayService { * @param transactionType 交易类型 * @param callback 处理器 * @param 返回类型 - * @return + * @return 返回支付方对应接口的结果 */ T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback callback); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/BasePayType.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/BasePayType.java index 88f4b6b8..fcfe7e7c 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/BasePayType.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/BasePayType.java @@ -3,8 +3,10 @@ /** * 基础的支付类型 * @author egan - * @email egzosn@gmail.com - * @date 2016/11/20 0:47 + *
+ *     email egzosn@gmail.com
+ *     date 2016/11/20 0:47
+ *  
*/ public interface BasePayType { @@ -12,7 +14,7 @@ public interface BasePayType { /** * 根据支付类型获取交易类型 * @param transactionType 类型值 - * @return + * @return 交易类型 */ TransactionType getTransactionType(String transactionType); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/CurType.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/CurType.java index 0d91cea3..e58f8cf4 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/CurType.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/CurType.java @@ -4,9 +4,13 @@ /** * @author Fuzx 货币类型 - * @create 2017 2017/1/24 0024 + * create 2017 2017/1/24 0024 */ public interface CurType { + /** + * 货币类型 + * @return 货币类型 + */ String getCurType(); } diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MethodType.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MethodType.java index 02149103..387bd635 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MethodType.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MethodType.java @@ -19,8 +19,10 @@ /** * @author: egan - * @email egzosn@gmail.com - * @date 2017/2/7 9:52 + *
+ *     email egzosn@gmail.com
+ *     date 2017/2/7 9:52
+ * 
*/ public enum MethodType { GET, POST diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MsgType.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MsgType.java index f79aa3a5..c0030409 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MsgType.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/MsgType.java @@ -20,8 +20,10 @@ /** * 消息类型 * @author: egan - * @email egzosn@gmail.com - * @date 2016/11/18 0:59 + *
+ *     email egzosn@gmail.com
+ *     date 2016/11/18 0:59
+ *  
*/ public enum MsgType { text, xml,json diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayMessage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayMessage.java index 3cf6e160..c6eceb18 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayMessage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayMessage.java @@ -12,8 +12,10 @@ * 支付回调消息 * 基础实现,具体可根据具体支付回调的消息去实现 * @author egan - * @email egzosn@gmail.com - * @date 2017/3/7 16:37 + *
+ *     email egzosn@gmail.com
+ *     date 2017/3/7 16:37
+ *  
*/ public class PayMessage implements Serializable { private Map payMessage = null; @@ -87,161 +89,6 @@ public String getDiscount(){ public String getSubject(){ return payMessage.get("subject"); } - //////////////////支付宝 -/* public Date getNotifyTime(){ - return parseDate(payMessage.get("notify_time")); - } - - public String getNotifyType(){ - return payMessage.get("notify_type"); - } - public String getNotifyId(){ - return payMessage.get("notify_id"); - } - - public String getSignType(){ - return payMessage.get("sign_type"); - } - - - - - - public String getPaymentType(){ - return payMessage.get("payment_type"); - } - - public String getTradeNo(){ - return payMessage.get("trade_no"); - } - - public String getTradeStatus(){ - return payMessage.get("trade_status"); - } - public String getSellerId(){ - return payMessage.get("seller_id"); - } - public String getSellerEmail(){ - return payMessage.get("seller_email"); - } - public String getBuyerId(){ - return payMessage.get("buyer_id"); - } - - public String getBuyerEmail(){ - return payMessage.get("buyer_email"); - } - - - public Number getQuantity(){ - String quantity = payMessage.get("quantity"); - if (null == quantity || "".equals(quantity)){ return 1; } - if (isNumber(quantity)){ - return Integer.parseInt(quantity); - } - return 1; - } - - public Number getPrice(){ - String price = payMessage.get("price"); - if (null == price || "".equals(price)){ return 1; } - if (isNumber(price)){ - return new BigDecimal(price); - } - return 1; - } - - public String getBody(){ - return payMessage.get("body"); - } - - public Date getGmtCreate(){ - - return parseDate(payMessage.get("gmt_create")); - } - - public Date getGmtPayment(){ - - return parseDate(payMessage.get("gmt_payment")); - } - public String getIsTotalFeeAdjust (){ - return payMessage.get("is_total_fee_adjust"); - - } - - - public String getUseCoupon(){ - return payMessage.get("use_coupon"); - - } - - public String getRefundStatus(){ - return payMessage.get("refund_status"); - - } - public Date getGmtRefund(){ - return parseDate(payMessage.get("gmt_refund")); - - }*/ - /////////////////支付宝 - - - - //////////////////微信 - /* public String getIsSubscribe(){ - return payMessage.get("is_subscribe"); - } - public String getAppid(){ - return payMessage.get("appid"); - } - - public String getFeeType(){ - return payMessage.get("fee_type"); - } - public String getNonceStr(){ - return payMessage.get("nonce_str"); - } - public String getTransactionId(){ - return payMessage.get("transaction_id"); - } - - public String getTradeType(){ - return payMessage.get("trade_type"); - } - - public String getResultCode(){ - return payMessage.get("result_code"); - } - - public String getMchId(){ - return payMessage.get("mch_id"); - } - - public String getAttach(){ - return payMessage.get("attach"); - } - - public String getTimeEnd(){ - return payMessage.get("time_end"); - } - public String getBankType(){ - return payMessage.get("bank_type"); - } - public String getOpenid(){ - return payMessage.get("openid"); - } - public String getReturnCode(){ - return payMessage.get("return_code"); - } - public Number getCashFee(){ - String cashFee = payMessage.get("cash_fee"); - if (null == cashFee || "".equals(cashFee)){ return 0; } - if (isNumber(cashFee)){ - return new BigDecimal(cashFee).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); - } - return 0; - }*/ - //////////////////微信 diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOrder.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOrder.java index 0ee1b60d..6e1cb0a7 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOrder.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOrder.java @@ -6,8 +6,10 @@ * 支付订单信息 * * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:34 + *
+ *      email egzosn@gmail.com
+ *      date 2016/10/19 22:34
+ *  
*/ public class PayOrder { //商品名称 @@ -64,7 +66,7 @@ public void setPrice(BigDecimal price) { /** * 获取商户订单号 - * @return + * @return 商户订单号 * @see #getOutTradeNo() */ @Deprecated @@ -72,8 +74,10 @@ public String getTradeNo() { return outTradeNo; } + /** - * 设置商户订单号 + * + * @param tradeNo 商户订单号 * @see #setOutTradeNo(String) */ @Deprecated @@ -83,14 +87,15 @@ public void setTradeNo(String tradeNo) { /** * 获取商户订单号 - * @return + * @return 商户订单号 */ public String getOutTradeNo() { return outTradeNo; } + /** - * 设置商户订单号 - * @return + * 设置商户订单号 + * @param outTradeNo 商户订单号 */ public void setOutTradeNo(String outTradeNo) { this.outTradeNo = outTradeNo; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOutMessage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOutMessage.java index f4e52ae0..97f686fe 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOutMessage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/PayOutMessage.java @@ -10,9 +10,10 @@ /** * 支付回调通知返回消息 * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 - * @source chanjarster/weixin-java-tools + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ * 
*/ public abstract class PayOutMessage implements Serializable { protected String content; @@ -37,21 +38,21 @@ public void setMsgType(String msgType) { /** * 获得文本消息builder - * @return + * @return 文本消息builder */ public static TextBuilder TEXT() { return new TextBuilder(); } /** * 获得XML消息builder - * @return + * @return XML消息builder */ public static XmlBuilder XML() { return new XmlBuilder(); } /** * 获得Json消息builder - * @return + * @return Json消息builder */ public static JsonBuilder JSON() { return new JsonBuilder(new JSONObject()); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/TransactionType.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/TransactionType.java index 49df677d..a17258a5 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/TransactionType.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/TransactionType.java @@ -3,19 +3,21 @@ /** * 交易类型 * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:30 + *
+ *     email egzosn@gmail.com
+ *     date 2016/10/19 22:30
+ * 
*/ public interface TransactionType { /** * 获取交易类型 - * @return + * @return 交易类型 */ String getType(); /** * 获取接口 - * @return + * @return 接口 */ String getMethod(); } diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/BaseBuilder.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/BaseBuilder.java index 274886e6..5206146e 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/BaseBuilder.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/BaseBuilder.java @@ -3,10 +3,13 @@ import com.egzosn.pay.common.bean.PayOutMessage; /** - * @source chanjarster/weixin-java-tools + * source chanjarster/weixin-java-tools + * * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ *  
*/ public abstract class BaseBuilder { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/JsonBuilder.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/JsonBuilder.java index 9deca90c..726a2ed3 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/JsonBuilder.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/JsonBuilder.java @@ -6,8 +6,10 @@ /** * @author: egan - * @email egzosn@gmail.com - * @date 2017/1/13 14:30 + *
+ *      email egzosn@gmail.com
+ *      date 2017/1/13 14:30
+ *   
*/ public class JsonBuilder extends BaseBuilder{ JSONObject json = null; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayJsonOutMessage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayJsonOutMessage.java index ff554c0b..576134b2 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayJsonOutMessage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayJsonOutMessage.java @@ -5,8 +5,10 @@ /** * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *      email egzosn@gmail.com
+ *      date 2016-6-1 11:40:30
+ *   
*/ public class PayJsonOutMessage extends PayOutMessage{ diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayTextOutMessage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayTextOutMessage.java index 20af4602..7d311962 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayTextOutMessage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayTextOutMessage.java @@ -5,8 +5,10 @@ /** * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *      email egzosn@gmail.com
+ *      date 2016-6-1 11:40:30
+ *  
*/ public class PayTextOutMessage extends PayOutMessage{ diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayXmlOutMessage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayXmlOutMessage.java index 5f196f8a..c4b96bda 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayXmlOutMessage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/PayXmlOutMessage.java @@ -5,8 +5,10 @@ /** * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 13:53:3 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 13:53:3
+ *  
*/ public class PayXmlOutMessage extends PayOutMessage{ diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/TextBuilder.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/TextBuilder.java index 59b5ef51..16895baf 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/TextBuilder.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/TextBuilder.java @@ -3,10 +3,12 @@ import com.egzosn.pay.common.bean.PayOutMessage; /** - * @source chanjarster/weixin-java-tools + *

source chanjarster/weixin-java-tools

* @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ *  
*/ public class TextBuilder extends BaseBuilder { private String content; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/XmlBuilder.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/XmlBuilder.java index c0f67b62..3314b756 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/XmlBuilder.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/outbuilder/XmlBuilder.java @@ -2,10 +2,12 @@ import com.egzosn.pay.common.bean.PayOutMessage; /** - * @source chanjarster/weixin-java-tools + *

source chanjarster/weixin-java-tools

* @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:40:30 + *
+ *     email egzosn@gmail.com
+ *     date 2016-6-1 11:40:30
+ *  
*/ public class XmlBuilder extends BaseBuilder { private String content; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayError.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayError.java index 5166e34e..d392d587 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayError.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayError.java @@ -4,28 +4,30 @@ * 支付错误码说明 * * @author egan - * @email egzosn@gmail.com - * @date 2017-03-02 22:28:01 + *
+ *     email egzosn@gmail.com
+ *     date 2017-03-02 22:28:01
+ *  
*/ public interface PayError { /** * 获取错误码 * - * @return + * @return 错误码 */ String getErrorCode(); /** * 获取错误消息 * - * @return + * @return 错误消息 */ String getErrorMsg(); /** * 获取异常信息 - * @return + * @return 异常信息 */ String getString(); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayException.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayException.java index 887bada0..db26fba2 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayException.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/result/PayException.java @@ -18,9 +18,12 @@ package com.egzosn.pay.common.bean.result; /** + * 支付异常 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/7 12:32 + *
+ *      email egzosn@gmail.com
+ *      date 2017/3/7 12:32
+ *  
*/ public class PayException implements PayError { private String errorCode; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/exception/PayErrorException.java b/pay-java-common/src/main/java/com/egzosn/pay/common/exception/PayErrorException.java index 0eac659b..3b077b4b 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/exception/PayErrorException.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/exception/PayErrorException.java @@ -4,8 +4,10 @@ /** * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + *
+ * email egzosn@gmail.com
+ * date 2016-5-18 14:09:01
+ *  
*/ public class PayErrorException extends RuntimeException { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/http/ClientHttpRequest.java b/pay-java-common/src/main/java/com/egzosn/pay/common/http/ClientHttpRequest.java index 30a5b88a..29b7eae7 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/http/ClientHttpRequest.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/http/ClientHttpRequest.java @@ -26,8 +26,10 @@ /** * 一个HTTP请求的客户端 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/4 17:56 + *
+ * email egzosn@gmail.com
+ * date 2017/3/4 17:56
+ *  
*/ public class ClientHttpRequest extends HttpEntityEnclosingRequestBase implements org.apache.http.client.ResponseHandler{ //http请求 @@ -83,7 +85,7 @@ public String getMethod() { /** * 设置代理 * @param httpProxy http代理配置信息 - * @return + * @return 当前HTTP请求的客户端 */ public ClientHttpRequest setProxy(HttpHost httpProxy){ if (httpProxy != null) { @@ -98,7 +100,7 @@ public ClientHttpRequest setProxy(HttpHost httpProxy){ * 设置请求参数 * * @param request 请求参数 - * @return + * @return 当前HTTP请求的客户端 */ public ClientHttpRequest setParameters(Object request) { if (null == request){ diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpConfigStorage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpConfigStorage.java index 1e8f9161..8bc93f00 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpConfigStorage.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpConfigStorage.java @@ -4,8 +4,10 @@ /** * HTTP 配置 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/3 20:48 + *
+ * email egzosn@gmail.com
+ * date 2017/3/3 20:48
+ *  
*/ public class HttpConfigStorage { //http代理地址 @@ -20,7 +22,7 @@ public class HttpConfigStorage { /** * http代理地址 - * @return + * @return http代理地址 */ public String getHttpProxyHost() { return httpProxyHost; @@ -33,7 +35,7 @@ public void setHttpProxyHost(String httpProxyHost) { /** * 代理端口 - * @return + * @return 代理端口 */ public int getHttpProxyPort() { return httpProxyPort; @@ -44,7 +46,7 @@ public void setHttpProxyPort(int httpProxyPort) { } /** * 代理用户名 - * @return + * @return 代理用户名 */ public String getHttpProxyUsername() { return httpProxyUsername; @@ -56,7 +58,7 @@ public void setHttpProxyUsername(String httpProxyUsername) { /** * 代理密码 - * @return + * @return 代理密码 */ public String getHttpProxyPassword() { return httpProxyPassword; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpRequestTemplate.java b/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpRequestTemplate.java index ff3831c4..1043fb1c 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpRequestTemplate.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/http/HttpRequestTemplate.java @@ -18,8 +18,10 @@ /** * http请求工具 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/3 21:33 + *
+ * email egzosn@gmail.com
+ * date 2017/3/3 21:33
+ *  
*/ public class HttpRequestTemplate { @@ -43,6 +45,11 @@ public HttpRequestTemplate() { setHttpConfigStorage(null); } + /** + * 设置HTTP请求的配置 + * @param configStorage 请求配置 + * @return 当前HTTP请求的客户端模板 + */ public HttpRequestTemplate setHttpConfigStorage(HttpConfigStorage configStorage){ if (null == configStorage){ @@ -79,11 +86,11 @@ public HttpRequestTemplate setHttpConfigStorage(HttpConfigStorage configStorage) * * post * @param uri 请求地址 - * @param request + * @param request 请求参数 * @param responseType 为响应类(需要自己依据响应格式来确定) - * @param - * @return - * @throws IOException + * @param uriVariables 地址通配符对应的值 + * @param 响应类型 + * @return 类型对象 */ public T postForObject(String uri, Object request, Class responseType, Object... uriVariables){ return doExecute(URI.create(UriVariables.getUri(uri, uriVariables)), request, responseType, MethodType.POST); @@ -105,10 +112,10 @@ public T postForObject(URI uri, Object request, Class responseType){ * @param responseType 响应类型 * @param uriVariables 用于匹配表达式 * @param 响应类型 - * @return + * @return 类型对象 * * - * getForObject("http://egan.in/pay/{id}/f/{type}", String.class, "1", "APP") + * getForObject("http://egan.in/pay/{id}/f/{type}", String.class, "1", "APP") * */ public T getForObject(String uri, Class responseType, Object... uriVariables){ @@ -123,12 +130,12 @@ public T getForObject(String uri, Class responseType, Object... uriVariab * @param responseType 响应类型 * @param uriVariables 用于匹配表达式 * @param 响应类型 - * @return + * @return 类型对象 * - * Map uriVariables = new HashMap(); - * uriVariables.put("id", "1"); - * uriVariables.put("type", "APP"); - * getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables) + * Map<String, String> uriVariables = new HashMap<String, String>(); + * uriVariables.put("id", "1"); + * uriVariables.put("type", "APP"); + * getForObject("http://egan.in/pay/{id}/f/{type}", String.class, uriVariables) * */ public T getForObject(String uri, Class responseType, Map uriVariables){ @@ -142,9 +149,8 @@ public T getForObject(String uri, Class responseType, Map uriV * @param request 请求数据 * @param responseType 响应类型 * @param method 请求方法 - * @param - * @return - * @throws IOException + * @param 响应类型 + * @return 类型对象 */ public T doExecute(URI uri, Object request, Class responseType, MethodType method){ ClientHttpRequest httpRequest = new ClientHttpRequest(uri ,method, request); @@ -165,9 +171,8 @@ public T doExecute(URI uri, Object request, Class responseType, MethodType * @param request 请求数据 * @param responseType 响应类型 * @param method 请求方法 - * @param - * @return - * @throws IOException + * @param 响应类型 + * @return 类型对象 */ public T doExecute(String uri, Object request, Class responseType, MethodType method){ return doExecute(URI.create(uri), request, responseType, method); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/http/UriVariables.java b/pay-java-common/src/main/java/com/egzosn/pay/common/http/UriVariables.java index e3cd8af9..68aa6535 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/http/UriVariables.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/http/UriVariables.java @@ -17,18 +17,20 @@ * URL表达式处理器 * * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/5 10:07 + *
+ * email egzosn@gmail.com
+ * date 2017/3/5 10:07
+ * 
*/ public class UriVariables { /** * 依次匹配 - * @param uri - * @param uriVariables - * @return + * @param uri 匹配的uri,带代表式 + * @param uriVariables 匹配表达式的值 + * @return 匹配完的url * - * System.out.println(getUri("http://egan.in/{a}/ba/{a1}?{bb}={a1}", "no1", "no2", "no3", "no4")); + * System.out.println(getUri("http://egan.in/{a}/ba/{a1}?{bb}={a1}", "no1", "no2", "no3", "no4")); * 结果 http://egan.in/no1/ba/no2?no3=no4 * * @@ -51,15 +53,15 @@ public static String getUri(String uri, Object... uriVariables) { /** * 匹配Map.key - * @param uri - * @param uriVariables - * @return + * @param uri 匹配的uri,带代表式 + * @param uriVariables 匹配表达式的值 + * @return 匹配完的url * - * Map uriVariable = new HashMap<>(); - * uriVariable.put("a", "no1"); - * uriVariable.put("a1", "no2"); - * uriVariable.put("bb", "no3"); - * System.out.println(getUri("http://egan.in/{a}/ba/{a1}?{bb}={a1}", uriVariable)); + * Map<String, Object> uriVariable = new HashMap<String, Object>(); + * uriVariable.put("a", "no1"); + * uriVariable.put("a1", "no2"); + * uriVariable.put("bb", "no3"); + * System.out.println(getUri("http://egan.in/{a}/ba/{a1}?{bb}={a1}", uriVariable)); * 结果 http://egan.in/no1/ba/no2?no3=no2 * */ @@ -83,8 +85,8 @@ public static String getUri(String uri, Map uriVariables) { /** * Map转化为对应得参数字符串 - * @param pe - * @return + * @param pe 参数 + * @return 参数字符串 */ public static String getMapToParameters(Map pe){ StringBuilder builder = new StringBuilder(); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/LogExceptionHandler.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/LogExceptionHandler.java index 297d05b3..35550c5f 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/LogExceptionHandler.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/LogExceptionHandler.java @@ -10,9 +10,13 @@ /** * LogExceptionHandler 日志处理器 * @author egan - * @email egzosn@gmail.com - * @date 2016-6-1 11:28:01 - * @source chanjarster/weixin-java-tools + *
+ * email egzosn@gmail.com
+ * date 2016-6-1 11:28:01
+ *
+ *
+ * source chanjarster/weixin-java-tools
+ * 
*/ public class LogExceptionHandler implements PayErrorExceptionHandler { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/MatrixToImageWriter.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/MatrixToImageWriter.java index d72c10d2..fc320497 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/MatrixToImageWriter.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/MatrixToImageWriter.java @@ -17,8 +17,10 @@ /** * 二维码生成工具 * @author egan - * @email egzosn@gmail.com - * @date 2017/2/7 10:35 + *
+ * email egzosn@gmail.com
+ * date  2017/2/7 10:35
+ * 
*/ public class MatrixToImageWriter { @@ -32,7 +34,7 @@ private MatrixToImageWriter() {} * 根据二维矩阵的碎片 生成对应的二维码图像缓冲 * @param matrix 二维矩阵的碎片 包含 宽高 行,字节 * @see com.google.zxing.common.BitMatrix - * @return + * @return 二维码图像缓冲 */ public static BufferedImage toBufferedImage(BitMatrix matrix) { int width = matrix.getWidth(); @@ -49,10 +51,10 @@ public static BufferedImage toBufferedImage(BitMatrix matrix) { /** * 二维码生成文件 - * @param matrix - * @param format - * @param file - * @throws IOException + * @param matrix 二维矩阵的碎片 包含 宽高 行,字节 + * @param format 格式 + * @param file 保持的文件地址 + * @throws IOException 文件保存异常 */ public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException { @@ -65,10 +67,10 @@ public static void writeToFile(BitMatrix matrix, String format, File file) /** * 二维码生成流 - * @param matrix - * @param format - * @param stream - * @throws IOException + * @param matrix 二维矩阵的碎片 包含 宽高 行,字节 + * @param format 格式 + * @param stream 保持的文件输出流 + * @throws IOException 文件保存异常 */ public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException { @@ -81,8 +83,8 @@ public static void writeToStream(BitMatrix matrix, String format, OutputStream s /** * 二维码信息写成JPG文件 - * @param content - * @param fileUrl + * @param content 二维码信息 + * @param fileUrl 文件地址 */ public static void writeInfoToJpgFile(String content, String fileUrl){ MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); @@ -101,8 +103,8 @@ public static void writeInfoToJpgFile(String content, String fileUrl){ /** * 二维码信息写成JPG BufferedImage - * @param content - * @return + * @param content 二维码信息 + * @return JPG BufferedImage */ public static BufferedImage writeInfoToJpgBuff(String content){ BufferedImage re=null; diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/XML.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/XML.java index 1dfa49db..214610bc 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/XML.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/XML.java @@ -18,14 +18,16 @@ /** * XML工具 * @author egan - * @email egzosn@gmail.com - * @date 2016-6-2 19:45:06 + *
+ * email egzosn@gmail.com
+ * date 2016-6-2 19:45:06
+ * 
*/ public class XML { /** * 解析xml并转化为Json值 * @param content json字符串 - * @return + * @return Json值 */ public static JSONObject toJSONObject(String content){ @@ -45,7 +47,7 @@ public static JSONObject toJSONObject(String content){ /** * 解析xml并转化为json值 * @param in 输入流 - * @return + * @return Json值 */ public static JSONObject toJSONObject(InputStream in) { @@ -63,7 +65,13 @@ public static JSONObject toJSONObject(InputStream in) { } - + /** + * + * @param in xml输入流 + * @param m 参数集 + * @return 整理完成的参数集 + * @throws IOException xml io转化异常 + */ public static Map inputStream2Map(InputStream in, Map m) throws IOException { if (null == m){ m = new JSONObject(); @@ -97,8 +105,8 @@ public static Map inputStream2Map(InputStream in, Map m) throws IOException { /** * 获取子结点的xml * - * @param children - * @return String + * @param children 集合 + * @return String 子结点的xml */ public static String getChildrenText(List children) { StringBuffer sb = new StringBuffer(); @@ -122,9 +130,9 @@ public static String getChildrenText(List children) { } /** - * @Description:将请求参数转换为xml格式的string + * 将请求参数转换为xml格式的string * @param parameters 请求参数 - * @return + * @return xml */ public static String getMap2Xml(Map parameters) { StringBuffer sb = new StringBuffer(); diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java index 2b224b07..ef8ed829 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java @@ -10,8 +10,10 @@ * 签名 工具 * * @author: egan - * @email egzosn@gmail.com - * @date 2016/11/9 17:45 + *
+ * email egzosn@gmail.com
+ * date 2016/11/9 17:45
+ * 
*/ public enum SignUtils { @@ -21,7 +23,7 @@ public enum SignUtils { * @param content 需要签名的内容 * @param key 密钥 * @param characterEncoding 字符编码 - * @return + * @return 签名值 */ @Override public String createSign(String content, String key, String characterEncoding) { @@ -76,64 +78,6 @@ public static String parameterText(Map parameters) { return parameterText(parameters, "&"); } - /** - * - * 把数组所有元素排序,并按照“参数=参数值”的模式用“@param separator”字符拼接成字符串 - * @param parameters 参数 - * @param separator 分隔符 - * @return 去掉空值与签名参数后的新签名,拼接后字符串 - */ - /* public static String parameterText(Map parameters, String separator) { - if(parameters == null){ - return ""; - } - StringBuffer sb = new StringBuffer(); - - // TODO 2016/11/11 10:14 author: egan 已经排序好处理 - if (parameters instanceof SortedMap) { - for (String k : ((Set) parameters.keySet())) { - Object v = parameters.get(k); - if (null == v || "".equals(v.toString().trim()) || "sign".equals(k) || "key".equals(k) || "appId".equals(k) || "sign_type".equalsIgnoreCase(k)) { - continue; - } - sb.append(k ).append("=").append( v.toString().trim()).append(separator); - } - if (sb.length() > 0 && !"".equals(separator)) { - sb.deleteCharAt(sb.length() - 1); - } - return sb.toString(); - - } - - - // TODO 2016/11/11 10:14 author: egan 未排序须处理 - List keys = new ArrayList(parameters.keySet()); - //排序 - Collections.sort(keys); - for (String k : keys) { - String valueStr = ""; - Object o = parameters.get(k); - if (o instanceof String[]) { - String[] values = (String[]) o; - if (null == values){continue;} - for (int i = 0; i < values.length; i++) { - String value = values[i].trim(); - if ("".equals(value)){ continue;} - valueStr += (i == values.length - 1) ? value : value + ","; - } - } else if (o != null) { - valueStr = o.toString(); - } - if (null == valueStr || "".equals(valueStr.toString().trim()) || "sign".equals(k) || "key".equals(k) || "appId".equals(k) || "sign_type".equalsIgnoreCase(k)) { - continue; - } - sb.append(k ).append("=").append( valueStr).append(separator); - } - if (sb.length() > 0) { - sb.deleteCharAt(sb.length() - 1); - } - return sb.toString(); - }*/ /** * @@ -211,9 +155,9 @@ public static String parameterText(Map parameters, String separator, String... i /** * 将参数集合(事前做好排序)按分割符号拼凑字符串并加密为MD5 * example: mchnt_cd+"|" +order_id+"|"+order_amt+"|"+order_pay_type+"|"+page_notify_url+"|"+back_notify_url+"|"+order_valid_time+"|"+iss_ins_cd+"|"+goods_name+"|"+"+goods_display_url+"|"+rem+"|"+ver+"|"+mchnt_key - * @param parameters - * @param separator - * @return + * @param parameters 参数集合 + * @param separator 分隔符 + * @return 参数排序好的值 */ public static String parameters2MD5Str(Object parameters, String separator){ StringBuffer sb = new StringBuffer(); @@ -240,7 +184,7 @@ public static String parameters2MD5Str(Object parameters, String separator){ /** * 获取随机字符串 - * @return + * @return 随机字符串 */ public static String randomStr(){ return UUID.randomUUID().toString().replace("-", ""); @@ -252,7 +196,7 @@ public static String randomStr(){ * @param parameters 需要进行排序签名的参数 * @param key 密钥 * @param characterEncoding 编码格式 - * @return + * @return 签名值 */ public String sign(Map parameters, String key, String characterEncoding) { @@ -262,9 +206,9 @@ public String sign(Map parameters, String key, String characterEncoding) { * 签名 * @param parameters 需要进行排序签名的参数 * @param key 密钥 - * @param separator 分隔符 默认 & + * @param separator 分隔符 默认 & * @param characterEncoding 编码格式 - * @return + * @return 签名值 */ public String sign(Map parameters, String key, String separator, String characterEncoding) { @@ -278,7 +222,7 @@ public String sign(Map parameters, String key, String separator, String charact * @param content 需要签名的内容 * @param key 密钥 * @param characterEncoding 字符编码 - * @return + * @return 签名值 */ public abstract String createSign(String content, String key, String characterEncoding); @@ -293,7 +237,6 @@ public String sign(Map parameters, String key, String separator, String charact */ public boolean verify(Map params, String sign, String key, String characterEncoding){ //判断是否一样 -// return StringUtils.equals(sign(params, key, characterEncoding), sign); return this.verify(parameterText(params), sign, key, characterEncoding); } @@ -309,8 +252,4 @@ public boolean verify(Map params, String sign, String key, String characterEnco */ public abstract boolean verify(String text, String sign, String key, String characterEncoding); - - - //签名错误代码 - public static final int SIGN_ERROR = 91; } diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/MD5.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/MD5.java index 848b91ff..5db35acc 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/MD5.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/MD5.java @@ -45,9 +45,7 @@ public static boolean verify(String text, String sign, String key, String input_ /** * @param content 需要加密串 * @param charset 字符集 - * @return - * @throws SignatureException - * @throws UnsupportedEncodingException + * @return 加密后的字节数组 */ public static byte[] getContentBytes(String content, String charset) { if (StringUtils.isEmpty(charset)) { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA.java index 98190a57..32a50c0d 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA.java @@ -101,6 +101,7 @@ public static boolean verify(String content, String sign, String publicKey, Stri * @param privateKey 商户私钥 * @param characterEncoding 编码格式 * @return 解密后的字符串 + * @throws Exception 解密异常 */ public static String decrypt(String content, String privateKey, String characterEncoding) throws Exception { PrivateKey prikey = getPrivateKey(privateKey); @@ -132,7 +133,8 @@ public static String decrypt(String content, String privateKey, String character /** * 得到私钥 * @param key 密钥字符串(经过base64编码) - * @throws Exception + * @throws Exception 加密异常 + * @return 私钥 */ public static PrivateKey getPrivateKey(String key) throws Exception { diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA2.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA2.java index b5b93a89..3caac65c 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA2.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/encrypt/RSA2.java @@ -36,6 +36,7 @@ public static boolean verify(String content, String sign, String publicKey, Stri * @param privateKey 商户私钥 * @param characterEncoding 编码格式 * @return 解密后的字符串 + * @throws Exception 解密异常 */ public static String decrypt(String content, String privateKey, String characterEncoding) throws Exception { return RSA.decrypt(content, privateKey, characterEncoding); @@ -45,7 +46,8 @@ public static String decrypt(String content, String privateKey, String character /** * 得到私钥 * @param key 密钥字符串(经过base64编码) - * @throws Exception + * @throws Exception 加密异常 + * @return 私钥 */ public static PrivateKey getPrivateKey(String key) throws Exception { return RSA.getPrivateKey(key); diff --git a/pay-java-demo/pom.xml b/pay-java-demo/pom.xml index 299e1235..50342177 100644 --- a/pay-java-demo/pom.xml +++ b/pay-java-demo/pom.xml @@ -118,6 +118,15 @@ pay-java-demo + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + UTF-8 + + org.apache.tomcat.maven tomcat7-maven-plugin diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java index 9ec0f6c9..d53562c6 100644 --- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java +++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java @@ -46,7 +46,7 @@ public class PayController { * 这里模拟账户信息增加 * * @param account - * @return + * @return 支付账户信息 */ @RequestMapping("add") public Map add(ApyAccount account) { @@ -66,7 +66,7 @@ public Map add(ApyAccount account) { * @param payId 账户id * @param transactionType 交易类型, 这个针对于每一个 支付类型的对应的几种交易方式 * @param bankType 针对刷卡支付,卡的类型,类型值 - * @return + * @return 跳到支付页面 */ @RequestMapping(value = "toPay.html", produces = "text/html;charset=UTF-8") public String toPay(Integer payId, String transactionType, String bankType, BigDecimal price) { @@ -88,7 +88,7 @@ public String toPay(Integer payId, String transactionType, String bankType, BigD * 获取二维码图像 * 二维码支付 * - * @return + * @return 二维码图像 */ @RequestMapping(value = "toQrPay.jpg", produces = "image/jpeg;charset=UTF-8") public byte[] toWxQrPay(Integer payId, String transactionType, BigDecimal price) throws IOException { @@ -96,7 +96,7 @@ public byte[] toWxQrPay(Integer payId, String transactionType, BigDecimal price) PayResponse payResponse = service.getPayResponse(payId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageIO.write(payResponse.getService().genQrPay(new PayOrder("订单title", "摘要", null == price ? new BigDecimal(0.01) : price, "9d1c43152c304ed2b9d2db320ef0a742", PayType.valueOf(payResponse.getStorage().getPayType()).getTransactionType(transactionType))), "JPEG", baos); + ImageIO.write(payResponse.getService().genQrPay(new PayOrder("订单title", "摘要", null == price ? new BigDecimal(0.01) : price, UUID.randomUUID().toString().replace("-", ""), PayType.valueOf(payResponse.getStorage().getPayType()).getTransactionType(transactionType))), "JPEG", baos); return baos.toByteArray(); } @@ -106,7 +106,7 @@ public byte[] toWxQrPay(Integer payId, String transactionType, BigDecimal price) * * @param payId 支付账户id * @param transactionType 交易类型 - * @return + * @return 支付预订单信息 */ @RequestMapping("getOrderInfo") public Map getOrderInfo(Integer payId, String transactionType, BigDecimal price) { @@ -121,10 +121,10 @@ public Map getOrderInfo(Integer payId, String transactionType, B /** - * 微信或者支付宝回调地址 + * 支付回调地址 * * @param request - * @return + * @return 支付是否成功 */ @RequestMapping(value = "payBack{payId}.json") public String payBack(HttpServletRequest request, @PathVariable Integer payId) throws IOException { @@ -151,7 +151,7 @@ public String payBack(HttpServletRequest request, @PathVariable Integer payId) t * 查询 * * @param order 订单的请求体 - * @return + * @return 返回查询回来的结果集,支付方原值返回 */ @RequestMapping("query") public Map query(QueryOrder order) { @@ -163,7 +163,7 @@ public Map query(QueryOrder order) { * 交易关闭接口 * * @param order 订单的请求体 - * @return + * @return 返回支付方交易关闭后的结果 */ @RequestMapping("close") public Map close(QueryOrder order) { @@ -175,7 +175,7 @@ public Map close(QueryOrder order) { * 申请退款接口 * * @param order 订单的请求体 - * @return + * @return 返回支付方申请退款后的结果 */ @RequestMapping("refund") public Map refund(QueryOrder order) { @@ -189,7 +189,7 @@ public Map refund(QueryOrder order) { * 查询退款 * * @param order 订单的请求体 - * @return + * @return 返回支付方查询退款后的结果 */ @RequestMapping("refundquery") public Map refundquery(QueryOrder order) { @@ -201,7 +201,7 @@ public Map refundquery(QueryOrder order) { * 下载对账单 * * @param order 订单的请求体 - * @return + * @return 返回支付方下载对账单的结果 */ @RequestMapping("downloadbill") public Object downloadbill(QueryOrder order) { @@ -215,7 +215,7 @@ public Object downloadbill(QueryOrder order) { * 通用查询接口,根据 TransactionType 类型进行实现,此接口不包括退款 * * @param order 订单的请求体 - * @return + * @return 返回支付方对应接口的结果 */ @RequestMapping("secondaryInterface") public Map secondaryInterface(QueryOrder order) { diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/dao/ApyAccountRepository.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/dao/ApyAccountRepository.java index 56b60aea..c470817a 100644 --- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/dao/ApyAccountRepository.java +++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/dao/ApyAccountRepository.java @@ -42,6 +42,7 @@ public class ApyAccountRepository { apyAccount1.setSignType(SignUtils.RSA.name()); apyAccount1.setPayType(PayType.aliPay); apyAccount1.setMsgType(MsgType.text); + //设置测试环境 apyAccount1.setTest(true); apyAccounts.put(apyAccount1.getPayId(), apyAccount1); diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java index 5872929b..23bbd9af 100644 --- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java +++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java @@ -1,10 +1,17 @@ package com.egzosn.pay.demo.entity; import com.egzosn.pay.ali.api.AliPayConfigStorage; +import com.egzosn.pay.ali.api.AliPayService; import com.egzosn.pay.ali.bean.AliTransactionType; import com.egzosn.pay.common.api.PayService; import com.egzosn.pay.common.bean.BasePayType; import com.egzosn.pay.common.bean.TransactionType; +import com.egzosn.pay.demo.service.handler.FuiouPayMessageHandler; +import com.egzosn.pay.fuiou.api.FuiouPayConfigStorage; +import com.egzosn.pay.fuiou.api.FuiouPayService; +import com.egzosn.pay.fuiou.bean.FuiouTransactionType; +import com.egzosn.pay.fuiou.api.FuiouPayConfigStorage; +import com.egzosn.pay.fuiou.api.FuiouPayService; import com.egzosn.pay.wx.api.WxPayConfigStorage; import com.egzosn.pay.wx.api.WxPayService; import com.egzosn.pay.wx.bean.WxTransactionType; @@ -13,18 +20,20 @@ import com.egzosn.pay.wx.youdian.bean.YoudianTransactionType; + /** * 支付类型 + * * @author egan - * @email egzosn@gmail.com - * @date 2016/11/20 0:30 + * email egzosn@gmail.com + * date 2016/11/20 0:30 */ public enum PayType implements BasePayType { aliPay{ /** - * @see AliPayService 17年更新的版本,旧版本请自行切换 + * @see com.egzosn.pay.ali.api.AliPayService 17年更新的版本,旧版本请自行切换 * @param apyAccount * @return */ @@ -43,11 +52,13 @@ public PayService getPayService(ApyAccount apyAccount) { aliPayConfigStorage.setMsgType(apyAccount.getMsgType()); aliPayConfigStorage.setInputCharset(apyAccount.getInputCharset()); aliPayConfigStorage.setTest(apyAccount.isTest()); - return new com.egzosn.pay.ali.api.AliPayService(aliPayConfigStorage); + return new AliPayService(aliPayConfigStorage); } @Override public TransactionType getTransactionType(String transactionType) { + // com.egzosn.pay.ali.before.bean.AliTransactionType 17年更新的版本,旧版本请自行切换 + // AliTransactionType 17年更新的版本,旧版本请自行切换 return AliTransactionType.valueOf(transactionType); } @@ -111,6 +122,29 @@ public TransactionType getTransactionType(String transactionType) { return YoudianTransactionType.valueOf(transactionType); } + },fuiou{ + + @Override + public PayService getPayService(ApyAccount apyAccount) { + FuiouPayConfigStorage fuiouPayConfigStorage = new FuiouPayConfigStorage(); + fuiouPayConfigStorage.setKeyPrivate(apyAccount.getPrivateKey()); + fuiouPayConfigStorage.setNotifyUrl(apyAccount.getNotifyUrl()); + fuiouPayConfigStorage.setReturnUrl(apyAccount.getReturnUrl()); + fuiouPayConfigStorage.setSignType(apyAccount.getSignType()); + fuiouPayConfigStorage.setPayType(apyAccount.getPayType().toString()); + fuiouPayConfigStorage.setMsgType(apyAccount.getMsgType()); + fuiouPayConfigStorage.setInputCharset(apyAccount.getInputCharset()); + fuiouPayConfigStorage.setTest(apyAccount.isTest()); + return new FuiouPayService(fuiouPayConfigStorage); + } + + @Override + public TransactionType getTransactionType(String transactionType) { + // in.egan.pay.ali.before.bean.AliTransactionType 17年更新的版本,旧版本请自行切换 + return FuiouTransactionType.valueOf(transactionType); + } + + }; public abstract PayService getPayService(ApyAccount apyAccount); diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java index a84c7e18..738e5b9f 100644 --- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java +++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java @@ -1,18 +1,19 @@ - - package com.egzosn.pay.demo.service; -import com.egzosn.pay.ali.bean.AliTransactionType; +import com.egzosn.pay.common.api.PayMessageRouter; import com.egzosn.pay.common.http.HttpConfigStorage; +import com.egzosn.pay.demo.service.handler.FuiouPayMessageHandler; import com.egzosn.pay.demo.service.handler.YouDianPayMessageHandler; import com.egzosn.pay.demo.service.interceptor.AliPayMessageInterceptor; import com.egzosn.pay.demo.entity.ApyAccount; import com.egzosn.pay.demo.entity.PayType; import com.egzosn.pay.demo.service.handler.AliPayMessageHandler; +import com.egzosn.pay.demo.service.handler.FuiouPayMessageHandler; import com.egzosn.pay.demo.service.handler.WxPayMessageHandler; +import com.egzosn.pay.demo.service.handler.YouDianPayMessageHandler; +import com.egzosn.pay.demo.service.interceptor.AliPayMessageInterceptor; import com.egzosn.pay.common.api.PayConfigStorage; import com.egzosn.pay.common.api.PayMessageHandler; -import com.egzosn.pay.common.api.PayMessageRouter; import com.egzosn.pay.common.api.PayService; import com.egzosn.pay.common.bean.MsgType; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; @@ -84,7 +85,7 @@ private void buildRouter(Integer payId) { .async(false) .msgType(MsgType.text.name()) //消息类型 .payType(PayType.aliPay.name()) //支付账户事件类型 - .transactionType(AliTransactionType.UNAWARE.name())//交易类型,有关回调的可在这处理 +// .transactionType(AliTransactionType.UNAWARE.name())//交易类型,有关回调的可在这处理 .interceptor(new AliPayMessageInterceptor(payId)) //拦截器 .handler(autowire(new AliPayMessageHandler(payId))) //处理器 .end() @@ -100,6 +101,12 @@ private void buildRouter(Integer payId) { .payType(PayType.youdianPay.name()) .handler(autowire(new YouDianPayMessageHandler(payId))) .end() + .rule() + .async(false) + .msgType(MsgType.xml.name()) + .payType(PayType.fuiou.name()) + .handler(autowire(new FuiouPayMessageHandler(payId))) + .end() ; } diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/interceptor/AliPayMessageInterceptor.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/interceptor/AliPayMessageInterceptor.java index b5258d1c..7f27f51b 100644 --- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/interceptor/AliPayMessageInterceptor.java +++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/interceptor/AliPayMessageInterceptor.java @@ -12,8 +12,8 @@ /** * 支付宝回调信息拦截器 * @author: egan - * @email egzosn@gmail.com - * @date 2017/1/18 19:28 + * email egzosn@gmail.com + * date 2017/1/18 19:28 */ public class AliPayMessageInterceptor implements PayMessageInterceptor { diff --git a/pay-java-fuiou/pom.xml b/pay-java-fuiou/pom.xml index dad1c72d..ee437eab 100644 --- a/pay-java-fuiou/pom.xml +++ b/pay-java-fuiou/pom.xml @@ -5,7 +5,7 @@ pay-java-parent com.egzosn - 2.0.SNAPSHOT + 2.0.1 4.0.0 pay-java-fuiou diff --git a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayConfigStorage.java b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayConfigStorage.java index b24d6f36..c09f5602 100644 --- a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayConfigStorage.java +++ b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayConfigStorage.java @@ -1,31 +1,52 @@ -package com.egzosn.pay.fuiou.api;/** - * Created by Fuzx on 2017/1/16 0016. - */ - -import com.egzosn.pay.common.before.api.BasePayConfigStorage; +package com.egzosn.pay.fuiou.api; +import com.egzosn.pay.common.api.BasePayConfigStorage; /** * @author Fuzx - * @create 2017 2017/1/16 0016 + *
+ * create 2017 2017/1/16 0016
+ * 
*/ public class FuiouPayConfigStorage extends BasePayConfigStorage { public String mchntCd;//商户代码 public String mchntKey;//商户密钥 - + /** + * 应用id + * @return 空 + */ @Override public String getAppid() { return null; } + /** + * 合作商唯一标识 + * + * @see #getPid() 代替者 + */ + @Override + public String getPartner () { + return mchntCd; + } + + /** + * 合作商唯一标识 + * + * @see #getPartner() 代替者 + */ @Override - public String getPartner() { + public String getPid () { + return mchntCd; + } + + public String getMchntCd () { return mchntCd; } - public void setPartner(String partner) { - this.mchntCd = partner; + public void setMchntCd (String mchntCd) { + this.mchntCd = mchntCd; } @Override @@ -35,7 +56,7 @@ public String getSeller() { @Override public String getSecretKey() { - return mchntKey; + return super.getKeyPrivate(); } public void setSecretKey(String mchntKey){ diff --git a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayService.java b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayService.java index 6538ef2c..6403930a 100644 --- a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayService.java +++ b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/api/FuiouPayService.java @@ -1,59 +1,73 @@ -package com.egzosn.pay.fuiou.api;/** - * Created by Fuzx on 2017/1/16 0016. - */ - -import com.egzosn.pay.common.before.api.BasePayService; -import com.egzosn.pay.common.before.api.PayConfigStorage; -import com.egzosn.pay.common.before.api.RequestExecutor; +package com.egzosn.pay.fuiou.api; +import com.alibaba.fastjson.JSONObject; +import com.egzosn.pay.common.api.BasePayService; +import com.egzosn.pay.common.api.Callback; +import com.egzosn.pay.common.api.PayConfigStorage; 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.before.bean.result.PayError; +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.util.sign.SignUtils; import com.egzosn.pay.common.util.str.StringUtils; -import com.egzosn.pay.fuiou.utils.SimplePostRequestExecutor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.message.BasicNameValuePair; import java.awt.image.BufferedImage; import java.io.InputStream; +import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.*; /** * @author Fuzx - * @create 2017 2017/1/16 0016 + *
+ * create 2017 2017/1/16 0016
+ * 
*/ public class FuiouPayService extends BasePayService { - + //日志 protected final Log log = LogFactory.getLog(FuiouPayService.class); + //正式域名 + public final static String URL_FuiouBaseDomain = "https://pay.fuiou.com/"; + //测试域名 +// public final static String URL_FuiouBaseDomain = "http://www-1.fuiou.com:8888/wg1_run/"; + //B2C/B2B支付 + public final static String URL_FuiouSmpGate = URL_FuiouBaseDomain + "smpGate.do"; + //B2C/B2B支付(跨境支付) + public final static String URL_FuiouNewSmpGate = URL_FuiouBaseDomain + "newSmpGate.do"; + //订单退款 + public final static String URL_FuiouSmpRefundGate = URL_FuiouBaseDomain + "newSmpRefundGate.do"; + //3.2 支付结果查询 + public final static String URL_FuiouSmpQueryGate = URL_FuiouBaseDomain + "smpQueryGate.do"; + //3.3 支付结果查询(直接返回) + public final static String URL_FuiouSmpAQueryGate = URL_FuiouBaseDomain + "smpAQueryGate.do"; + //3.4订单退款 + public final static String URL_NewSmpRefundGate = URL_FuiouBaseDomain + "newSmpRefundGate.do"; - public final static String fuiouBaseDomain = "https://pay.fuiou.com/";//正式域名 -// public final static String fuiouBaseDomain = "http://www-1.fuiou.com:8888/wg1_run/";//测试域名 - - public final static String fuiouSmpGate = fuiouBaseDomain + "smpGate.do";//B2C/B2B支付 - - public final static String fuiouNewSmpGate = fuiouBaseDomain + "newSmpGate.do";//B2C/B2B支付(跨境支付) - public final static String fuiouSmpRefundGate = fuiouBaseDomain + "newSmpRefundGate.do";//订单退款 - - public final static String fuiouSmpQueryGate = fuiouBaseDomain + "smpQueryGate.do";//3.2 支付结果查询 - public final static String fuiouSmpAQueryGate = fuiouBaseDomain + "smpAQueryGate.do";//3.3 支付结果查询(直接返回) - - public FuiouPayService(PayConfigStorage payConfigStorage) { - setPayConfigStorage(payConfigStorage); + /** + * 构造函数,初始化时候使用 + * @param payConfigStorage 支付账户配置信息 + * @param configStorage 网络代理配置 + */ + public FuiouPayService (PayConfigStorage payConfigStorage, HttpConfigStorage configStorage) { + super(payConfigStorage, configStorage); } - - - @Override - public String getHttpsVerifyUrl() { - return null; + /** + * 构造函数,初始化时候使用 + * @param payConfigStorage 支付账户配置信息 + */ + public FuiouPayService (PayConfigStorage payConfigStorage) { + super(payConfigStorage); } + /** * 回调校验 * @param params 回调回来的参数集 - * @return + * @return 返回检验结果 0000 成功 其他失败 */ @Override public boolean verify(Map params) { @@ -62,7 +76,8 @@ public boolean verify(Map params) { return false; } try { - return getSignVerify(params, params.get("md5")) && "0000".equals(verifyUrl(params.get("order_id")));//返回参数校验 和 重新请求订单检查数据是否合法 + //返回参数校验 和 重新请求订单检查数据是否合法 + return (signVerify(params, params.get("md5")) && verifySource(params.get("order_id"))); } catch (PayErrorException e) { e.printStackTrace(); } @@ -70,13 +85,14 @@ public boolean verify(Map params) { } /** - * 校验回调参数是否合法 + * 回调签名校验 + * * @param params 参数集 - * @param returnSign - * @return + * @param responseSign 响应的签名串 + * @return 校验结果 */ @Override - public boolean getSignVerify(Map params, String returnSign) { + public boolean signVerify (Map params, String responseSign ) { LinkedHashSet keySet = new LinkedHashSet<>(); keySet.add("mchnt_cd");//商户代码 keySet.add("order_id");//商户订单号 @@ -97,63 +113,29 @@ public boolean getSignVerify(Map params, String returnSign) { } String sign = createSign(verifyMD5Str.deleteCharAt(verifyMD5Str.length() -1).toString(),payConfigStorage.getInputCharset()); // System.out.println("加密串"+verifyMD5Str+",,返回参数生成MD5="+sign+",,返回MD5摘要值"+returnSign); - if(returnSign.equals(sign)){ - return true; - } - return false; + return responseSign.equals(sign); } /** - * 发起请求校验订单是否支付成功 - * @param order_id - * @return - * @throws PayErrorException + * 校验回调数据来源是否合法 + * + * @param order_id 业务id, 数据的真实性. + * @return 返回校验结果 */ @Override - public String verifyUrl(String order_id) throws PayErrorException { -// LinkedHashMap param = new LinkedHashMap(); -// param.put("mchnt_cd",payConfigStorage.getPartner()); -// param.put("order_id",order_id); -// param.put("md5",createSign(SignUtils.parameters2MD5Str(param,"|"),payConfigStorage.getInputCharset())); - List pairList = new ArrayList(); - pairList.add(new BasicNameValuePair("mchnt_cd",payConfigStorage.getPartner())); - pairList.add(new BasicNameValuePair("order_id",order_id)); - pairList.add(new BasicNameValuePair("md5",createSign(SignUtils.parameters2MD5Str(pairList,"|"),payConfigStorage.getInputCharset()))); - return execute(new SimplePostRequestExecutor(), fuiouSmpAQueryGate,pairList); -// JSONObject jsonObject = XML.toJSONObject(responseContent); - -// return getFormString(param,MethodType.POST,fuiouSmpAQueryGate); - } - - @Override - public T execute(RequestExecutor executor, String uri, E data) throws PayErrorException { - int retryTimes = 0; - do { - try { - return executeInternal(executor, uri, data); - } catch (PayErrorException e) { - PayError error = (PayError) e.getPayError(); - if ("404".equals(error.getErrorCode()) ) { - int sleepMillis = retrySleepMillis * (1 << retryTimes); - try { - log.debug(String.format("富友支付系统错误,错误信息:<%s>,(%s)ms 后重试(第%s次)",e.getMessage(),sleepMillis, retryTimes + 1)); - Thread.sleep(sleepMillis); - } catch (InterruptedException e1) { - throw new RuntimeException(e1); - } - } else { - throw e; - } - } - } while (++retryTimes < maxRetryTimes); - - throw new RuntimeException("富友支付服务端异常,超出重试次数"); + public boolean verifySource (String order_id) { + LinkedHashMap params = new LinkedHashMap<>(); + params.put("mchnt_cd",payConfigStorage.getPid()); + params.put("order_id",order_id); + params.put("md5",createSign(SignUtils.parameters2MD5Str(params,"|"),payConfigStorage.getInputCharset())); + JSONObject resultJson = getHttpRequestTemplate().postForObject(URL_FuiouSmpAQueryGate,params,JSONObject.class); + return resultJson.getString("order_pay_code").equals("0000"); } /** - * 对支付请求参数进行加密,排序 + * 将支付请求参数加密成md5 * @param order 支付订单 - * @return + * @return 返回支付请求参数集合 */ @Override public Map orderInfo(PayOrder order) { @@ -163,6 +145,11 @@ public Map orderInfo(PayOrder order) { return parameters; } + /** + * 按序添加请求参数 + * @param order 支付订单 + * @return 返回支付请求参数集合 + */ private LinkedHashMap getOrderInfo(PayOrder order) { LinkedHashMap parameters = new LinkedHashMap(); parameters.put("mchnt_cd", payConfigStorage.getPartner());//商户代码 @@ -183,9 +170,9 @@ private LinkedHashMap getOrderInfo(PayOrder order) { /** * 对内容进行加密 - * @param content 需要签名的内容 + * @param content 需要加密的内容 * @param characterEncoding 字符编码 - * @return + * @return 加密后的字符串 */ @Override public String createSign(String content, String characterEncoding) { @@ -193,45 +180,57 @@ public String createSign(String content, String characterEncoding) { } /** - * 将参数拼凑成String + * 将请求参数或者请求流转化为 Map * @param parameterMap 请求参数 * @param is 请求流 - * @return + * @return 返回参数集合 */ @Override public Map getParameter2Map(Map parameterMap, InputStream is) { - Map params = new TreeMap(); - for (Iterator iter = parameterMap.keySet().iterator(); iter.hasNext(); ) { - String name = (String) iter.next(); - String[] values = parameterMap.get(name); - String valueStr = ""; - for (int i = 0; i < values.length; i++) { - valueStr = (i == values.length - 1) ? valueStr + values[i] - : valueStr + values[i] + ","; - } - //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 - //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk"); - params.put(name, valueStr); - } - return params; + return null; } + /** + * 获取输出消息,用户返回给支付端 + * @param code 返回代码 + * @param message 返回信息 + * @return 消息实体 + */ + @Override public PayOutMessage getPayOutMessage(String code, String message) { return PayOutMessage.TEXT().content(code.toLowerCase()).build(); } + /** + * 发送支付请求(form表单) + * @param orderInfo 发起支付的订单信息 + * @param method 请求方式 "post" "get", + * @return form表单提交的html字符串 + */ + @Override public String buildRequest(Map orderInfo, MethodType method) { - return getFormString(orderInfo, method,fuiouSmpGate); + return getFormString(orderInfo, method,URL_FuiouSmpGate ); } /** - * 根据参数行程form表单 + * 获取输出二维码,用户返回给支付端, + * + * @param order 发起支付的订单信息 + * @return 空 + */ + @Override + public BufferedImage genQrPay (PayOrder order) { + return null; + } + + /** + * 根据参数形成form表单 * @param param 参数 * @param method 请求方式 get_post - * @param url - * @return + * @param url 支付请求url地址 + * @return form表单html代码 */ private String getFormString(Map param, MethodType method,String url) { StringBuffer formHtml = new StringBuffer(); @@ -261,41 +260,158 @@ private String getFormString(Map param, MethodType method,String } /** - * 生成二维码支付 - * 暂未实现或无此功能 - * - * @param orderInfo 发起支付的订单信息 - * @return + * 交易查询接口 + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 空 */ @Override - public BufferedImage genQrPay(Map orderInfo) { - throw new UnsupportedOperationException(); + public Map query(String tradeNo, String outTradeNo) { + return null; } + /** + * 交易查询接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @return 空 + */ @Override - public Map query(String tradeNo, String outTradeNo) { + public T query (String tradeNo, String outTradeNo, Callback callback) { return null; } + /** + * 交易关闭接口 + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 空 + */ @Override public Map close(String tradeNo, String outTradeNo) { return null; } + /** + * 交易关闭接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @return 空 + */ @Override - public Map refund(String tradeNo, String outTradeNo) { + public T close (String tradeNo, String outTradeNo, Callback callback) { return null; } + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @return 退款返回结果集 + */ + @Override + public Map refund (String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount) { + Map params = new HashMap<>(); + params.put("mchnt_cd",payConfigStorage.getSecretKey());//商户代码 + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + df.setTimeZone(TimeZone.getTimeZone("GMT+8")); + params.put("origin_order_date",df.format(new Date()));//原交易日期 + params.put("origin_order_id",tradeNo);//原订单号 + params.put("refund_amt",refundAmount);//退款金额 + params.put("rem","");//备注 + params.put("md5",createSign(SignUtils.parameters2MD5Str(params,"|"),payConfigStorage.getInputCharset())); + JSONObject resultJson = getHttpRequestTemplate().postForObject(URL_FuiouSmpRefundGate,params,JSONObject.class); + //5341标识退款成功 + return resultJson; + + } + + /** + * 申请退款接口 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param refundAmount 退款金额 + * @param totalAmount 总金额 + * @param callback 处理器 + * @return 空 + */ + @Override + public T refund (String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback callback) { + return null; + } + + /** + * 查询退款 + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 空 + * + */ + @Override public Map refundquery(String tradeNo, String outTradeNo) { return null; } + /** + * 查询退款 + * + * @param tradeNo 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @return 空 + */ + @Override + public T refundquery (String tradeNo, String outTradeNo, Callback callback) { + return null; + } + + /** + * 下载对账单 + * @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。 + * @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单; + * @return 空 + */ @Override public Object downloadbill(Date billDate, String billType) { return null; } + /** + * 下载对账单 + * + * @param billDate 账单时间:具体请查看对应支付平台 + * @param billType 账单类型,具体请查看对应支付平台 + * @param callback 处理器 + * @return 空 + */ + @Override + public T downloadbill (Date billDate, String billType, Callback callback) { + return null; + } + + + /** + * 通用查询接口 + * + * @param tradeNoOrBillDate 支付平台订单号或者账单日期, 具体请 类型为{@link String }或者 {@link Date },类型须强制限制,类型不对应则抛出异常{@link PayErrorException} + * @param outTradeNoBillType 商户单号或者 账单类型 + * @param transactionType 交易类型 + * @param callback 处理器 + * @return 空 + */ + @Override + public T secondaryInterface (Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback callback) { + return null; + } + } diff --git a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouCurType.java b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouCurType.java index aa2a3758..9fea7a10 100644 --- a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouCurType.java +++ b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouCurType.java @@ -1,35 +1,46 @@ -package com.egzosn.pay.fuiou.bean;/** - * Created by Fuzx on 2017/1/24 0024. - */ +package com.egzosn.pay.fuiou.bean; import com.egzosn.pay.common.bean.CurType; /** + * 货币类型 * @author Fuzx - * @create 2017 2017/1/24 0024 + * create 2017 2017/1/24 0024 */ public enum FuiouCurType implements CurType { - CNY("人民币"), - USD("美元"), - HKD("港币"), - MOP("澳门元"), - EUR("欧元"), - TWD("新台币"), - KRW("韩元"), - JPY("日元"), - SGD("新加坡元"), - AUD("澳大利亚元"); - + CNY("人民币"), + USD("美元"), + HKD("港币"), + MOP("澳门元"), + EUR("欧元"), + TWD("新台币"), + KRW("韩元"), + JPY("日元"), + SGD("新加坡元"), + AUD("澳大利亚元"); + /** + * 币种名称 + */ private String name; + //索引 private int index; - private FuiouCurType(String name) { + /** + * 构造函数 + * @param name + */ + FuiouCurType(String name) { this.name = name; } + + /** + * 获取币种名称 + * @return 币种名称 + */ @Override public String getCurType(){ return this.name(); } - } +} diff --git a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouTransactionType.java b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouTransactionType.java index 55302489..273b3836 100644 --- a/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouTransactionType.java +++ b/pay-java-fuiou/src/main/java/com/egzosn/pay/fuiou/bean/FuiouTransactionType.java @@ -3,19 +3,18 @@ import com.egzosn.pay.common.bean.TransactionType; /** - * 微信交易类型 - * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:58 + * 支付类型 + * @author Fuzx + * create 2017 2017/1/24 0024 */ public enum FuiouTransactionType implements TransactionType { - B2B(""), - B2C("") + B2B("B2B"), + B2C("B2C") ; private String method; - private FuiouTransactionType(String method) { + FuiouTransactionType(String method) { this.method = method; } @@ -26,7 +25,7 @@ public String getType() { /** * 获取接口名称 - * @return + * @return 接口名称 */ @Override public String getMethod() { diff --git a/pay-java-wx-youdian/pom.xml b/pay-java-wx-youdian/pom.xml index 4fbe5969..b850ea74 100644 --- a/pay-java-wx-youdian/pom.xml +++ b/pay-java-wx-youdian/pom.xml @@ -5,7 +5,7 @@ pay-java-parent com.egzosn - 2.0.SNAPSHOT + 2.0.1 4.0.0 pay-java-wx-youdian diff --git a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayConfigStorage.java b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayConfigStorage.java index 78c7aec7..a5bd59c9 100644 --- a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayConfigStorage.java +++ b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayConfigStorage.java @@ -5,8 +5,9 @@ /** * 支付客户端配置存储 * @author egan - * @email egzosn@gmail.com - * @date 2017/01/12 22:58 + * + * email egzosn@gmail.com + * date 2017/01/12 22:58 */ public class WxYouDianPayConfigStorage extends BasePayConfigStorage { diff --git a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayService.java b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayService.java index 004e8e9d..fc7167a5 100644 --- a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayService.java +++ b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/api/WxYouDianPayService.java @@ -29,8 +29,9 @@ /** * 友店支付服务 * @author egan - * @email egzosn@gmail.com - * @date 2017/01/12 22:58 + * + * email egzosn@gmail.com + * date 2017/01/12 22:58 */ public class WxYouDianPayService extends BasePayService { protected final Log log = LogFactory.getLog(WxYouDianPayService.class); @@ -44,7 +45,10 @@ public class WxYouDianPayService extends BasePayService { public final static String unifiedOrderUrl = "http://life.51youdian.com/Api/CheckoutCounter/unifiedorder"; - + /** + * 获取请求token + * @return 授权令牌 + */ public String getAccessToken() { try { return getAccessToken(false); @@ -56,9 +60,9 @@ public String getAccessToken() { /** * 获取授权令牌 - * @param forceRefresh - * @return - * @throws PayErrorException + * @param forceRefresh 是否重新获取, true重新获取 + * @return 新的授权令牌 + * @throws PayErrorException 支付异常 */ public String getAccessToken(boolean forceRefresh) throws PayErrorException { Lock lock = payConfigStorage.getAccessTokenLock(); @@ -85,40 +89,6 @@ public String getAccessToken(boolean forceRefresh) throws PayErrorException { }else { throw new PayErrorException(new YdPayError(errorcode, json.getString("msg"), json.toJSONString())); } - - /* try { - HttpGet httpGet = new HttpGet(resetLoginUrl+ "?" + param.toString()); - if (this.httpProxy != null) { - RequestConfig config = RequestConfig.custom().setProxy(this.httpProxy).build(); - httpGet.setConfig(config); - } - try (CloseableHttpResponse response = getHttpClient().execute(httpGet)) { - String responseObj = new BasicResponseHandler().handleResponse(response); - JSONObject json = JSON.parseObject(responseObj); - int errorcode = json.getIntValue("errorcode"); - - switch (errorcode){ - //成功 - case 0: - //刷新 - payConfigStorage.updateAccessToken(payConfigStorage.getAccessToken(), 7200); - break; - //登录已过期 - case 401: - //进行重新登陆 - JSONObject login = login(); - payConfigStorage.updateAccessToken(login.getString("access_token"), login.getLongValue("viptime")); - break; - default: - throw new PayErrorException(new PayError(errorcode, json.getString("msg"), responseObj)); - - } - }finally { - httpGet.releaseConnection(); - } - } catch (IOException e) { - throw new RuntimeException(e); - }*/ } } finally { lock.unlock(); @@ -128,9 +98,9 @@ public String getAccessToken(boolean forceRefresh) throws PayErrorException { /** - * 登录 获取授权码 - * @return - * @throws PayErrorException + * 登录 并获取登陆信息(授权码) + * @return 登陆信息 + * @throws PayErrorException 支付异常 */ public JSONObject login() throws PayErrorException { TreeMap data = new TreeMap<>(); @@ -153,12 +123,17 @@ public JSONObject login() throws PayErrorException { /** * 微信友店2支付状态校验 - * @return + * @return 请求地址 */ public String getHttpsVerifyUrl() { return unifiedorderStatusUrl; } - + /** + * 回调校验 + * + * @param params 回调回来的参数集 + * @return 签名校验 true通过 + */ @Override public boolean verify(Map params) { if (!"SUCCESS".equals(params.get("return_code"))){ @@ -188,11 +163,12 @@ public boolean signVerify(Map params, String sign) { } + /** * 验证链接来源是否有效 - * @param id 商户订单号(扫码收款返回的order_sn) - * @return - * @throws PayErrorException + * 校验数据来源 + * @param id id 商户订单号(扫码收款返回的order_sn) + * @return true通过 */ @Override public boolean verifySource(String id) { @@ -219,8 +195,8 @@ public boolean verifySource(String id) { * @see MethodType#GET * @see MethodType#POST * @param request 请求内容,GET无需 - * @return - * @throws PayErrorException + * @return 请求成功后的结果 + * @throws PayErrorException 支付异常 */ public JSONObject execute(String uri, MethodType method, Object request) throws PayErrorException { int retryTimes = 0; @@ -230,7 +206,7 @@ public JSONObject execute(String uri, MethodType method, Object request) throws if ( 0 != result.getIntValue("errorcode")){ throw new PayErrorException(new YdPayError(result.getIntValue("errorcode"), result.getString("msg"), result.toJSONString())); } - + return result; }catch (PayErrorException e){ PayError error = e.getPayError(); if ("401".equals(error.getErrorCode()) ) { @@ -256,12 +232,13 @@ public JSONObject execute(String uri, MethodType method, Object request) throws } + /** * 获取支付平台所需的订单信息 * * @param order 支付订单 - * @return - * @see PayOrder + * @return 订单信息 + * @see PayOrder 支付订单信息 */ @Override public JSONObject orderInfo(PayOrder order) { @@ -275,7 +252,7 @@ public JSONObject orderInfo(PayOrder order) { try { JSONObject json = execute(unifiedOrderUrl+ "?" + params, MethodType.GET, null); //友店比较特殊,需要在下完预订单后,自己存储 order_sn 对应 微信官方文档 out_trade_no - order.setTradeNo(json.getString("order_sn")); + order.setOutTradeNo(json.getString("order_sn")); return json; } catch (PayErrorException e) { e.printStackTrace(); @@ -294,7 +271,7 @@ public JSONObject orderInfo(PayOrder order) { * 2、将所有的参数集进行key排序 * 3、将排序后的数组从起始位置拼接成字符串如:password=XXXXXXXusername=XXXXX * 4、将拼接出来的字符串连接上apb_nonce的值即AAAAAAAAAA。再连接 password=XXXXXXXusername=XXXXXAAAAAAAAAA - * @return + * @return 签名结果 */ @Override public String createSign(String content, String characterEncoding) { @@ -302,10 +279,11 @@ public String createSign(String content, String characterEncoding) { } /** + * 将请求参数或者请求流转化为 Map * * @param parameterMap 请求参数 * @param is 请求流 - * @return + * @return 获得回调的请求参数 */ @Override public Map getParameter2Map(Map parameterMap, InputStream is) { @@ -332,12 +310,12 @@ public Map getParameter2Map(Map parameterMap, *return_code 返回码只有SUCCESS和FAIL *return_msg 返回具体信息 *nonce_str 您的服务器新生成随机生成32位字符串 - *sign 为签名,签名规则是您需要发送的所有数据(除了sign)按照字典升序排列后加上&key=xxxxxxxx您的密钥后md5加密,最后转成小写 + *sign 为签名,签名规则是您需要发送的所有数据(除了sign)按照字典升序排列后加上&key=xxxxxxxx您的密钥后md5加密,最后转成小写 *最后把得到的所有需要返回的数据用json格式化成json对象格式如下 - *{‘return_code’:’SUCCESS’,’return_msg’:’ok’,’nonce_str’:’dddddddddddddddddddd’,’sign’:’sdddddddddddddddddd’} + *{"return_code":"SUCCESS","return_msg":"ok","nonce_str":"dddddddddddddddddddd’,’sign’:’sdddddddddddddddddd"} * @param code return_code * @param message return_msg - * @return + * @return 返回输出消息 */ @Override public PayOutMessage getPayOutMessage(String code, String message) { @@ -353,8 +331,9 @@ public PayOutMessage getPayOutMessage(String code, String message) { * 针对web端的即时付款 * 暂未实现或无此功能 * @param orderInfo 发起支付的订单信息 - * @param method 请求方式 "post" "get", - * @return + * @param method 请求方式 "post" "get", + * @return 获取输出消息,用户返回给支付端, 针对于web端 + * @see MethodType 请求类型 */ @Override public String buildRequest(Map orderInfo, MethodType method) { diff --git a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YdPayError.java b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YdPayError.java index 4b860e7f..49cd9cf3 100644 --- a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YdPayError.java +++ b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YdPayError.java @@ -21,8 +21,9 @@ /** * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/6 19:41 + * + * email egzosn@gmail.com + * date 2017/3/6 19:41 */ public class YdPayError implements PayError { diff --git a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YoudianTransactionType.java b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YoudianTransactionType.java index 9e7f4cf9..a25008d0 100644 --- a/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YoudianTransactionType.java +++ b/pay-java-wx-youdian/src/main/java/com/egzosn/pay/wx/youdian/bean/YoudianTransactionType.java @@ -5,8 +5,9 @@ /** * 友店交易类型 * @author egan - * @email egzosn@gmail.com - * @date 2017/01/12 22:58 + * + * email egzosn@gmail.com + * date 2017/01/12 22:58 */ public enum YoudianTransactionType implements TransactionType { @@ -17,7 +18,7 @@ public enum YoudianTransactionType implements TransactionType { private String method; - private YoudianTransactionType(String method) { + YoudianTransactionType(String method) { this.method = method; } @@ -28,7 +29,7 @@ public String getType() { /** * 获取接口名称 - * @return + * @return 接口名称 */ @Override public String getMethod() { diff --git a/pay-java-wx/pom.xml b/pay-java-wx/pom.xml index b9fb2944..a779de56 100644 --- a/pay-java-wx/pom.xml +++ b/pay-java-wx/pom.xml @@ -5,7 +5,7 @@ pay-java-parent com.egzosn - 2.0.SNAPSHOT + 2.0.1 4.0.0 pay-java-wx diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayConfigStorage.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayConfigStorage.java index 9ce9d5a7..1eaf01a1 100644 --- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayConfigStorage.java +++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayConfigStorage.java @@ -5,8 +5,11 @@ /** * 支付客户端配置存储 * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + * + *
+ * email egzosn@gmail.com
+ * date 2016-5-18 14:09:01
+ * 
*/ public class WxPayConfigStorage extends BasePayConfigStorage { @@ -36,16 +39,17 @@ public void setAppid(String appid) { } /** - * - * @return - * + * 合作商唯一标识 + * @see #getPid() 代替者 */ - @Deprecated - @Override public String getPartner() { return mchId; } + /** + * 合作商唯一标识 + * @see #getPartner() 代替者 + */ @Override public String getPid() { return mchId; diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java index 8f116b0a..df059d97 100644 --- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java +++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java @@ -29,8 +29,10 @@ /** * 支付宝支付通知 * @author egan - * @email egzosn@gmail.com - * @date 2016-5-18 14:09:01 + *
+ * email egzosn@gmail.com
+ * date 2016-5-18 14:09:01
+ * 
*/ public class WxPayService extends BasePayService { protected final Log log = LogFactory.getLog(WxPayService.class); @@ -38,7 +40,6 @@ public class WxPayService extends BasePayService { - public final static String httpsVerifyUrl = "https://gw.tenpay.com/gateway"; public final static String uri = "https://api.mch.weixin.qq.com/"; // public final static String unifiedOrderUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder"; // public final static String orderqueryUrl = "https://api.mch.weixin.qq.com/pay/orderquery"; @@ -54,19 +55,21 @@ public WxPayService(PayConfigStorage payConfigStorage, HttpConfigStorage configS } /** - * 微信支付V2版本所需 - * 当前版本不需要 ? - * @return + * 根据交易类型获取url + * @param transactionType 交易类型 + * @return 请求url */ - public String getHttpsVerifyUrl() { - return httpsVerifyUrl + "/verifynotifyid.xml"; - } - private String getUrl(TransactionType transactionType){ return uri + transactionType.getMethod(); } + /** + * 回调校验 + * + * @param params 回调回来的参数集 + * @return 签名校验 true通过 + */ @Override public boolean verify(Map params) { if (!"SUCCESS".equals(params.get("return_code"))){ @@ -89,9 +92,9 @@ public boolean verify(Map params) { /** - * 支付宝需要,微信是否也需要再次校验来源,进行订单查询 + * 微信是否也需要再次校验来源,进行订单查询 * @param id 商户单号 - * @return + * @return true通过 */ @Override public boolean verifySource(String id) { @@ -111,7 +114,7 @@ public boolean signVerify(Map params, String sign) { /** * 获取公共参数 - * @return + * @return 公共参数 */ private Map getPublicParameters() { @@ -127,11 +130,11 @@ private Map getPublicParameters() { /** - * 获取支付平台所需的订单信息 + * 返回创建的订单信息 * * @param order 支付订单 - * @return - * @see PayOrder + * @return 订单信息 + * @see PayOrder 支付订单信息 */ @Override public Map orderInfo(PayOrder order) { @@ -190,7 +193,7 @@ public Map orderInfo(PayOrder order) { /** * 生成并设置签名 * @param parameters 请求参数 - * @return + * @return 请求参数 */ private Map setSign(Map parameters){ parameters.put("sign_type", payConfigStorage.getSignType()); @@ -203,13 +206,20 @@ private Map setSign(Map parameters){ * 签名 * @param content 需要签名的内容 不包含key * @param characterEncoding 字符编码 - * @return + * @return 签名结果 */ @Override public String createSign(String content, String characterEncoding) { return SignUtils.valueOf(payConfigStorage.getSignType().toUpperCase()).createSign(content, "&key=" + payConfigStorage.getKeyPrivate(), characterEncoding).toUpperCase(); } + /** + * 将请求参数或者请求流转化为 Map + * + * @param parameterMap 请求参数 + * @param is 请求流 + * @return 获得回调的请求参数 + */ @Override public Map getParameter2Map(Map parameterMap, InputStream is) { TreeMap map = new TreeMap(); @@ -221,24 +231,38 @@ public Map getParameter2Map(Map parameterMap, return map; } - + /** + * 获取输出消息,用户返回给支付端 + * + * @param code 状态 + * @param message 消息 + * @return 返回输出消息 + */ @Override public PayOutMessage getPayOutMessage(String code, String message) { return PayOutMessage.XML().code(code.toUpperCase()).content(message).build(); } + /** - * 针对web端的即时付款 - * 暂未实现或无此功能 + * 获取输出消息,用户返回给支付端, 针对于web端 + * * @param orderInfo 发起支付的订单信息 - * @param method 请求方式 "post" "get", - * @return + * @param method 请求方式 "post" "get", + * @return 获取输出消息,用户返回给支付端, 针对于web端 + * @see MethodType 请求类型 */ @Override public String buildRequest(Map orderInfo, MethodType method) { throw new UnsupportedOperationException(); } + /** + * 获取输出二维码,用户返回给支付端, + * + * @param order 发起支付的订单信息 + * @return 返回图片信息,支付时需要的 + */ @Override public BufferedImage genQrPay(PayOrder order) { Map orderInfo = orderInfo(order); @@ -252,10 +276,11 @@ public BufferedImage genQrPay(PayOrder order) { } /** - * 交易查询接口 - * @param transactionId 支付平台订单号 + * 交易查询接口 + * + * @param transactionId 微信支付平台订单号 * @param outTradeNo 商户单号 - * @return + * @return 返回查询回来的结果集,支付方原值返回 */ @Override public Map query(String transactionId, String outTradeNo) { @@ -273,8 +298,8 @@ public Map perform(Map map) { * @param transactionId 支付平台订单号 * @param outTradeNo 商户单号 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 处理过后的类型对象,返回查询回来的结果集,支付方原值返回 */ @Override public T query(String transactionId, String outTradeNo, Callback callback) { @@ -282,7 +307,13 @@ public T query(String transactionId, String outTradeNo, Callback callback return secondaryInterface(transactionId, outTradeNo, WxTransactionType.QUERY, callback); } - + /** + * 交易关闭接口 + * + * @param transactionId 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方交易关闭后的结果 + */ @Override public Map close(String transactionId, String outTradeNo) { @@ -293,7 +324,15 @@ public Map perform(Map map) { } }); } - + /** + * 交易关闭接口 + * + * @param transactionId 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 处理过后的类型对象,返回支付方交易关闭后的结果 + */ @Override public T close(String transactionId, String outTradeNo, Callback callback) { return secondaryInterface(transactionId, outTradeNo, WxTransactionType.CLOSE, callback); @@ -305,7 +344,7 @@ public T close(String transactionId, String outTradeNo, Callback callback * @param outTradeNo 商户单号 * @param refundAmount 退款金额 * @param totalAmount 总金额 - * @return + * @return 返回支付方申请退款后的结果 */ @Override public Map refund(String transactionId, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount) { @@ -326,8 +365,8 @@ public Map perform(Map map) { * @param refundAmount 退款金额 * @param totalAmount 总金额 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 处理过后的类型对象, 返回支付方申请退款后的结果 */ @Override public T refund(String transactionId, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback callback) { @@ -350,6 +389,13 @@ public T refund(String transactionId, String outTradeNo, BigDecimal refundAm return callback.perform(requestTemplate.postForObject(getUrl(WxTransactionType.REFUND), XML.getMap2Xml(parameters), JSONObject.class)); } + /** + * 查询退款 + * + * @param transactionId 支付平台订单号 + * @param outTradeNo 商户单号 + * @return 返回支付方查询退款后的结果 + */ @Override public Map refundquery(String transactionId, String outTradeNo) { return refundquery(transactionId, outTradeNo, new Callback>() { @@ -360,6 +406,15 @@ public Map perform(Map map) { }); } + /** + * 查询退款 + * + * @param transactionId 支付平台订单号 + * @param outTradeNo 商户单号 + * @param callback 处理器 + * @param 返回类型 + * @return 处理过后的类型对象,返回支付方查询退款后的结果 + */ @Override public T refundquery(String transactionId, String outTradeNo, Callback callback) { return secondaryInterface(transactionId, outTradeNo, WxTransactionType.REFUNDQUERY, callback); @@ -369,7 +424,7 @@ public T refundquery(String transactionId, String outTradeNo, Callback ca * 目前只支持日账单 * @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单; * @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。 - * @return + * @return 返回支付方下载对账单的结果 */ @Override public Map downloadbill(Date billDate, String billType) { @@ -386,8 +441,8 @@ public Map perform(Map map) { * @param billDate 账单时间:具体请查看对应支付平台 * @param billType 账单类型,具体请查看对应支付平台 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 处理过后的类型对象,返回支付方下载对账单的结果 */ @Override public T downloadbill(Date billDate, String billType, Callback callback) { @@ -413,8 +468,8 @@ public T downloadbill(Date billDate, String billType, Callback callback) * @param outTradeNoBillType 商户单号或者 账单类型 * @param transactionType 交易类型 * @param callback 处理器 - * @param - * @return + * @param 返回类型 + * @return 返回支付方对应接口的结果 */ @Override public T secondaryInterface(Object transactionIdOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback callback) { diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxPayError.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxPayError.java index 1d24de28..b3655d4b 100644 --- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxPayError.java +++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxPayError.java @@ -20,9 +20,13 @@ import com.egzosn.pay.common.bean.result.PayError; /** + * 微信支付异常 * @author: egan - * @email egzosn@gmail.com - * @date 2017/3/6 17:31 + *
+ *
+ * email egzosn@gmail.com
+ * date 2017/3/6 17:31
+ * 
*/ public class WxPayError implements PayError { diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxTransactionType.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxTransactionType.java index e5166c99..21ce55d5 100644 --- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxTransactionType.java +++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/bean/WxTransactionType.java @@ -5,8 +5,9 @@ /** * 微信交易类型 * @author egan - * @email egzosn@gmail.com - * @date 2016/10/19 22:58 + * + * email egzosn@gmail.com + * date 2016/10/19 22:58 */ public enum WxTransactionType implements TransactionType { //公众号支付 diff --git a/pom.xml b/pom.xml index 2267aa9b..9cb1fce5 100644 --- a/pom.xml +++ b/pom.xml @@ -2,14 +2,16 @@ + 4.0.0 com.egzosn pay-java-parent pom - 2.0.SNAPSHOT + 2.0.1 Pay Java - Parent - 支付整合父级 + Pay Java Parent + https://github.com/egzosn/pay-java-parent The Apache License, Version 2.0 @@ -34,32 +36,21 @@ https://github.com/egzosn/pay-java-parent - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - Maven Central Staging Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - pay-java-common pay-java-ali pay-java-wx - pay-java-demo pay-java-wx-youdian pay-java-fuiou + pay-java-demo 4.5.2 1.2.17 - 2.0.SNAPSHOT + 2.0.1 @@ -103,31 +94,83 @@ + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + - + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + UTF-8 + zh_CN + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + org.apache.maven.plugins maven-surefire-plugin 2.17 - - true - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - org.sonatype.plugins nexus-staging-maven-plugin @@ -153,8 +196,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.0 + 2.3.2 + 1.7 + 1.7 UTF-8