This commit is contained in:
egzosn
2017-05-05 22:46:04 +08:00
12 changed files with 345 additions and 251 deletions

View File

@@ -96,7 +96,7 @@ public class PayController {
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();
}

View File

@@ -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);

View File

@@ -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.api.WxYouDianPayService;
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 enum PayType implements BasePayType {
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 enum PayType implements BasePayType {
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);

View File

@@ -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;
@@ -100,6 +101,12 @@ public class PayResponse {
.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()
;
}

View File

@@ -12,8 +12,8 @@ import java.util.Map;
/**
* 支付宝回调信息拦截器
* @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 {