支付网关支持商户应用配置项的下单操作;
This commit is contained in:
parent
bc3a2fa5cd
commit
252369f962
|
|
@ -53,10 +53,11 @@ public class CS {
|
|||
}
|
||||
|
||||
/**
|
||||
* 账号类型:1-服务商 2-商户
|
||||
* 账号类型:1-服务商 2-商户 3-商户应用
|
||||
*/
|
||||
public static final byte INFO_TYPE_ISV = 1;
|
||||
public static final byte INFO_TYPE_MCH = 2;
|
||||
public static final byte INFO_TYPE_MCH_APP = 3;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -132,6 +133,9 @@ public class CS {
|
|||
/** 更新商户配置信息 **/
|
||||
String TOPIC_MODIFY_MCH_INFO = "topic.modify.mch.info";
|
||||
|
||||
/** 更新商户应用配置信息 **/
|
||||
String TOPIC_MODIFY_MCH_APP = "topic.modify.mch.app";
|
||||
|
||||
/** 更新服务商配置信息 **/
|
||||
String TOPIC_MODIFY_ISV_INFO = "topic.modify.isv.info";
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
package com.jeequan.jeepay.pay.channel;
|
||||
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
@ -48,7 +48,7 @@ public interface IChannelNoticeService {
|
|||
|
||||
/** 返回需要更新的订单状态 和响应数据 **/
|
||||
ChannelRetMsg doNotice(HttpServletRequest request,
|
||||
Object params, PayOrder payOrder, MchConfigContext mchConfigContext, NoticeTypeEnum noticeTypeEnum);
|
||||
Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum);
|
||||
|
||||
/** 数据库订单 状态更新异常 (仅异步通知使用) **/
|
||||
ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest request);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
package com.jeequan.jeepay.pay.channel;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
|
||||
/*
|
||||
* @Description: 301方式获取渠道侧用户ID, 如微信openId 支付宝的userId等
|
||||
|
|
@ -29,9 +29,9 @@ public interface IChannelUserService {
|
|||
String getIfCode();
|
||||
|
||||
/** 获取重定向地址 **/
|
||||
String buildUserRedirectUrl(String callbackUrlEncode, MchConfigContext mchConfigContext);
|
||||
String buildUserRedirectUrl(String callbackUrlEncode, MchAppConfigContext mchAppConfigContext);
|
||||
|
||||
/** 获取渠道用户ID **/
|
||||
String getChannelUserId(JSONObject reqParams, MchConfigContext mchConfigContext);
|
||||
String getChannelUserId(JSONObject reqParams, MchAppConfigContext mchAppConfigContext);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package com.jeequan.jeepay.pay.channel;
|
|||
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
|
||||
/*
|
||||
* 查单(渠道侧)接口定义
|
||||
|
|
@ -32,6 +32,6 @@ public interface IPayOrderQueryService {
|
|||
String getIfCode();
|
||||
|
||||
/** 查询订单 **/
|
||||
ChannelRetMsg query(PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception;
|
||||
ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ package com.jeequan.jeepay.pay.channel;
|
|||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
|
||||
/*
|
||||
* 调起上游渠道侧支付接口
|
||||
*
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/5/8 15:13
|
||||
|
|
@ -39,6 +39,6 @@ public interface IPaymentService {
|
|||
String preCheck(UnifiedOrderRQ bizRQ, PayOrder payOrder);
|
||||
|
||||
/** 调起支付接口,并响应数据; 内部处理普通商户和服务商模式 **/
|
||||
AbstractRS pay(UnifiedOrderRQ bizRQ, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception;
|
||||
AbstractRS pay(UnifiedOrderRQ bizRQ, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.model.params.alipay.AlipayConfig;
|
|||
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
|
@ -69,16 +69,16 @@ public class AlipayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchConfigContext mchConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
|
||||
//配置参数获取
|
||||
Byte useCert = null;
|
||||
String alipaySignType, alipayPublicCert, alipayPublicKey = null;
|
||||
if(mchConfigContext.isIsvsubMch()){
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
|
||||
// 获取支付参数
|
||||
AlipayIsvParams alipayParams = mchConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
|
||||
AlipayIsvParams alipayParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
|
||||
useCert = alipayParams.getUseCert();
|
||||
alipaySignType = alipayParams.getSignType();
|
||||
alipayPublicCert = alipayParams.getAlipayPublicCert();
|
||||
|
|
@ -87,7 +87,7 @@ public class AlipayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
}else{
|
||||
|
||||
// 获取支付参数
|
||||
AlipayNormalMchParams alipayParams = mchConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
|
||||
AlipayNormalMchParams alipayParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
|
||||
useCert = alipayParams.getUseCert();
|
||||
alipaySignType = alipayParams.getSignType();
|
||||
alipayPublicCert = alipayParams.getAlipayPublicCert();
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
|
|||
import com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.IChannelUserService;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 支付宝: 获取用户ID实现类
|
||||
*
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:21
|
||||
|
|
@ -45,17 +45,17 @@ public class AlipayChannelUserService implements IChannelUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String buildUserRedirectUrl(String callbackUrlEncode, MchConfigContext mchConfigContext) {
|
||||
public String buildUserRedirectUrl(String callbackUrlEncode, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
String oauthUrl = AlipayConfig.PROD_OAUTH_URL;
|
||||
String appId = null;
|
||||
|
||||
if(mchConfigContext.isIsvsubMch()){
|
||||
AlipayIsvParams isvParams = mchConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
AlipayIsvParams isvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
|
||||
appId = isvParams.getAppId();
|
||||
}else{
|
||||
//获取商户配置信息
|
||||
AlipayNormalMchParams normalMchParams = mchConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
|
||||
AlipayNormalMchParams normalMchParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
|
||||
appId = normalMchParams.getAppId();
|
||||
if(normalMchParams.getSandbox() != null && normalMchParams.getSandbox() == CS.YES){
|
||||
oauthUrl = AlipayConfig.SANDBOX_OAUTH_URL;
|
||||
|
|
@ -66,7 +66,7 @@ public class AlipayChannelUserService implements IChannelUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUserId(JSONObject reqParams, MchConfigContext mchConfigContext) {
|
||||
public String getChannelUserId(JSONObject reqParams, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
String authCode = reqParams.getString("auth_code");
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class AlipayChannelUserService implements IChannelUserService {
|
|||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
request.setCode(authCode); request.setGrantType("authorization_code");
|
||||
try {
|
||||
return mchConfigContext.getAlipayClientWrapper().execute(request).getUserId();
|
||||
return mchAppConfigContext.getAlipayClientWrapper().execute(request).getUserId();
|
||||
} catch (ChannelException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import com.alipay.api.request.*;
|
|||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvsubMchParams;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/*
|
||||
|
|
@ -36,16 +36,16 @@ public class AlipayKit {
|
|||
|
||||
|
||||
/** 放置 isv特殊信息 **/
|
||||
public static void putApiIsvInfo(MchConfigContext mchConfigContext, AlipayRequest req, AlipayObject model){
|
||||
public static void putApiIsvInfo(MchAppConfigContext mchAppConfigContext, AlipayRequest req, AlipayObject model){
|
||||
|
||||
//不是特约商户, 无需放置此值
|
||||
if(!mchConfigContext.isIsvsubMch()){
|
||||
if(!mchAppConfigContext.isIsvsubMch()){
|
||||
return ;
|
||||
}
|
||||
|
||||
// 获取支付参数
|
||||
AlipayIsvParams isvParams = mchConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvParams.class);
|
||||
AlipayIsvsubMchParams isvsubMchParams = mchConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvsubMchParams.class);
|
||||
AlipayIsvParams isvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvParams.class);
|
||||
AlipayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvsubMchParams.class);
|
||||
|
||||
// 子商户信息
|
||||
if(req instanceof AlipayTradePayRequest) ((AlipayTradePayRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.alipay.api.response.AlipayTradeQueryResponse;
|
|||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public class AlipayPayOrderQueryService implements IPayOrderQueryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AlipayTradeQueryRequest req = new AlipayTradeQueryRequest();
|
||||
|
||||
|
|
@ -51,9 +51,9 @@ public class AlipayPayOrderQueryService implements IPayOrderQueryService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//通用字段
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
AlipayTradeQueryResponse resp = mchConfigContext.getAlipayClientWrapper().execute(req);
|
||||
AlipayTradeQueryResponse resp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
|
||||
String result = resp.getTradeStatus();
|
||||
|
||||
if("TRADE_SUCCESS".equals(result)) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package com.jeequan.jeepay.pay.channel.alipay;
|
|||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractPaymentService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.util.PaywayUtil;
|
||||
|
|
@ -51,8 +51,8 @@ public class AlipayPaymentService extends AbstractPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchConfigContext);
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliAppOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -47,7 +47,7 @@ public class AliApp extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AlipayTradeAppPayRequest req = new AlipayTradeAppPayRequest();
|
||||
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
||||
|
|
@ -59,14 +59,14 @@ public class AliApp extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
|
||||
String payData = null;
|
||||
|
||||
// sdk方式需自行拦截接口异常信息
|
||||
try {
|
||||
payData = mchConfigContext.getAlipayClientWrapper().getAlipayClient().sdkExecute(req).getBody();
|
||||
payData = mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().sdkExecute(req).getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
throw ChannelException.sysError(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliBarOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public class AliBar extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AliBarOrderRQ bizRQ = (AliBarOrderRQ) rq;
|
||||
|
||||
|
|
@ -71,10 +71,10 @@ public class AliBar extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
|
||||
AlipayTradePayResponse alipayResp = mchConfigContext.getAlipayClientWrapper().execute(req);
|
||||
AlipayTradePayResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
|
||||
|
||||
// 构造函数响应数据
|
||||
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public class AliJsapi extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
AliJsapiOrderRQ bizRQ = (AliJsapiOrderRQ) rq;
|
||||
|
||||
|
|
@ -70,10 +70,10 @@ public class AliJsapi extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
|
||||
AlipayTradeCreateResponse alipayResp = mchConfigContext.getAlipayClientWrapper().execute(req);
|
||||
AlipayTradeCreateResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
|
||||
|
||||
// 构造函数响应数据
|
||||
AliJsapiOrderRS res = ApiResBuilder.buildSuccess(AliJsapiOrderRS.class);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.utils.AmountUtil;
|
|||
import com.jeequan.jeepay.pay.channel.alipay.AlipayKit;
|
||||
import com.jeequan.jeepay.pay.channel.alipay.AlipayPaymentService;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -49,7 +49,7 @@ public class AliPc extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AliPcOrderRQ bizRQ = (AliPcOrderRQ) rq;
|
||||
|
||||
|
|
@ -66,16 +66,16 @@ public class AliPc extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
// 构造函数响应数据
|
||||
AliPcOrderRS res = ApiResBuilder.buildSuccess(AliPcOrderRS.class);
|
||||
|
||||
try {
|
||||
if(CS.PAY_DATA_TYPE.FORM.equals(bizRQ.getPayDataType())){
|
||||
res.setFormContent(mchConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
|
||||
res.setFormContent(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
|
||||
}else{
|
||||
res.setPayUrl(mchConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
|
||||
res.setPayUrl(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
|
||||
}
|
||||
}catch (AlipayApiException e) {
|
||||
throw ChannelException.sysError(e.getMessage());
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.core.utils.AmountUtil;
|
||||
import com.jeequan.jeepay.pay.channel.alipay.AlipayKit;
|
||||
import com.jeequan.jeepay.pay.channel.alipay.AlipayPaymentService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -48,7 +48,7 @@ public class AliQr extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AliQrOrderRQ aliQrOrderRQ = (AliQrOrderRQ)rq;
|
||||
|
||||
|
|
@ -62,10 +62,10 @@ public class AliQr extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
|
||||
AlipayTradePrecreateResponse alipayResp = mchConfigContext.getAlipayClientWrapper().execute(req);
|
||||
AlipayTradePrecreateResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
|
||||
|
||||
// 构造函数响应数据
|
||||
AliQrOrderRS res = ApiResBuilder.buildSuccess(AliQrOrderRS.class);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.utils.AmountUtil;
|
|||
import com.jeequan.jeepay.pay.channel.alipay.AlipayKit;
|
||||
import com.jeequan.jeepay.pay.channel.alipay.AlipayPaymentService;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -49,7 +49,7 @@ public class AliWap extends AlipayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext){
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
AliWapOrderRQ bizRQ = (AliWapOrderRQ)rq;
|
||||
|
||||
|
|
@ -65,22 +65,22 @@ public class AliWap extends AlipayPaymentService {
|
|||
req.setBizModel(model);
|
||||
|
||||
//统一放置 isv接口必传信息
|
||||
AlipayKit.putApiIsvInfo(mchConfigContext, req, model);
|
||||
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
|
||||
|
||||
// 构造函数响应数据
|
||||
AliWapOrderRS res = ApiResBuilder.buildSuccess(AliWapOrderRS.class);
|
||||
|
||||
try {
|
||||
if(CS.PAY_DATA_TYPE.FORM.equals(bizRQ.getPayDataType())){ //表单方式
|
||||
res.setFormContent(mchConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
|
||||
res.setFormContent(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
|
||||
|
||||
}else if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(bizRQ.getPayDataType())){ //二维码图片地址
|
||||
|
||||
String payUrl = mchConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody();
|
||||
String payUrl = mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody();
|
||||
res.setCodeImgUrl(sysConfigService.getDBApplicationConfig().genScanImgUrl(payUrl));
|
||||
}else{ // 默认都为 payUrl方式
|
||||
|
||||
res.setPayUrl(mchConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
|
||||
res.setPayUrl(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
|
||||
}
|
||||
}catch (AlipayApiException e) {
|
||||
throw ChannelException.sysError(e.getMessage());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import com.jeequan.jeepay.core.exception.ResponseException;
|
|||
import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
|
@ -82,13 +82,13 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
}
|
||||
|
||||
//获取支付参数 (缓存数据) 和 商户信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(payOrder.getMchNo());
|
||||
if(mchConfigContext == null){
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户信息失败");
|
||||
}
|
||||
|
||||
// 验签
|
||||
if (!verifyNotifySign(request, mchConfigContext)) {
|
||||
if (!verifyNotifySign(request, mchAppConfigContext)) {
|
||||
throw new BizException("验签失败");
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
String nonce = resource.getString("nonce");
|
||||
|
||||
// 解密
|
||||
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, mchConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getApiV3Key());
|
||||
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getApiV3Key());
|
||||
JSONObject decryptJSON = JSONObject.parseObject(result);
|
||||
return MutablePair.of(decryptJSON.getString("out_trade_no"), decryptJSON);
|
||||
|
||||
|
|
@ -121,16 +121,16 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchConfigContext mchConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
ChannelRetMsg channelResult = new ChannelRetMsg();
|
||||
channelResult.setChannelState(ChannelRetMsg.ChannelState.WAITING); // 默认支付中
|
||||
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(mchConfigContext.getWxServiceWrapper().getApiVersion())) { // V2
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { // V2
|
||||
// 获取回调参数
|
||||
WxPayOrderNotifyResult result = (WxPayOrderNotifyResult) params;
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 验证参数
|
||||
verifyWxPayParams(wxPayService, result, payOrder);
|
||||
|
|
@ -139,7 +139,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
channelResult.setChannelUserId(result.getOpenid()); //支付用户ID
|
||||
channelResult.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
|
||||
|
||||
}else if (CS.PAY_IF_VERSION.WX_V3.equals(mchConfigContext.getWxServiceWrapper().getApiVersion())) { // V3
|
||||
}else if (CS.PAY_IF_VERSION.WX_V3.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { // V3
|
||||
// 获取回调参数
|
||||
JSONObject resultJSON = (JSONObject) params;
|
||||
|
||||
|
|
@ -200,10 +200,10 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
/**
|
||||
* V3校验通知签名
|
||||
* @param request 请求信息
|
||||
* @param mchConfigContext 商户配置
|
||||
* @param mchAppConfigContext 商户配置
|
||||
* @return true:校验通过 false:校验不通过
|
||||
*/
|
||||
private boolean verifyNotifySign(HttpServletRequest request, MchConfigContext mchConfigContext) throws Exception {
|
||||
private boolean verifyNotifySign(HttpServletRequest request, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
SignatureHeader header = new SignatureHeader();
|
||||
header.setTimeStamp(request.getHeader("Wechatpay-Timestamp"));
|
||||
header.setNonce(request.getHeader("Wechatpay-Nonce"));
|
||||
|
|
@ -215,7 +215,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
header.getNonce(),
|
||||
getReqParamJSON().toJSONString());
|
||||
|
||||
WxPayConfig wxPayConfig = mchConfigContext.getWxServiceWrapper().getWxPayService().getConfig();
|
||||
WxPayConfig wxPayConfig = mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig();
|
||||
// 自动获取微信平台证书
|
||||
PrivateKey privateKey = PemUtils.loadPrivateKey(new FileInputStream(wxPayConfig.getPrivateKeyPath()));
|
||||
AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import com.jeequan.jeepay.core.constants.CS;
|
|||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.IChannelUserService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -46,17 +46,17 @@ public class WxpayChannelUserService implements IChannelUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String buildUserRedirectUrl(String callbackUrlEncode, MchConfigContext mchConfigContext) {
|
||||
public String buildUserRedirectUrl(String callbackUrlEncode, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
String appId = null;
|
||||
String oauth2Url = "";
|
||||
if(mchConfigContext.isIsvsubMch()){
|
||||
WxpayIsvParams wxpayIsvParams = mchConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvParams.class);
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
WxpayIsvParams wxpayIsvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvParams.class);
|
||||
appId = wxpayIsvParams.getAppId();
|
||||
oauth2Url = wxpayIsvParams.getOauth2Url();
|
||||
}else{
|
||||
//获取商户配置信息
|
||||
WxpayNormalMchParams normalMchParams = mchConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
WxpayNormalMchParams normalMchParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
appId = normalMchParams.getAppId();
|
||||
oauth2Url = normalMchParams.getOauth2Url();
|
||||
}
|
||||
|
|
@ -69,10 +69,10 @@ public class WxpayChannelUserService implements IChannelUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUserId(JSONObject reqParams, MchConfigContext mchConfigContext) {
|
||||
public String getChannelUserId(JSONObject reqParams, MchAppConfigContext mchAppConfigContext) {
|
||||
String code = reqParams.getString("code");
|
||||
try {
|
||||
return mchConfigContext.getWxServiceWrapper().getWxMpService().getOAuth2Service().getAccessToken(code).getOpenId();
|
||||
return mchAppConfigContext.getWxServiceWrapper().getWxMpService().getOAuth2Service().getAccessToken(code).getOpenId();
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -45,20 +45,20 @@ public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
try {
|
||||
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(mchConfigContext.getWxServiceWrapper().getApiVersion())) { //V2
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { //V2
|
||||
|
||||
WxPayOrderQueryRequest req = new WxPayOrderQueryRequest();
|
||||
|
||||
//放置isv信息
|
||||
WxpayKit.putApiIsvInfo(mchConfigContext, req);
|
||||
WxpayKit.putApiIsvInfo(mchAppConfigContext, req);
|
||||
|
||||
req.setOutTradeNo(payOrder.getPayOrderId());
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
WxPayOrderQueryResult result = wxPayService.queryOrder(req);
|
||||
|
||||
|
|
@ -74,9 +74,9 @@ public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
return ChannelRetMsg.unknown();
|
||||
}
|
||||
|
||||
}else if (CS.PAY_IF_VERSION.WX_V3.equals(mchConfigContext.getWxServiceWrapper().getApiVersion())) { //V3
|
||||
}else if (CS.PAY_IF_VERSION.WX_V3.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { //V3
|
||||
|
||||
JSONObject resultJSON = WxpayV3Util.queryOrderV3(payOrder.getPayOrderId(), mchConfigContext.getWxServiceWrapper().getWxPayService().getConfig());
|
||||
JSONObject resultJSON = WxpayV3Util.queryOrderV3(payOrder.getPayOrderId(), mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig());
|
||||
|
||||
String channelState = resultJSON.getString("trade_state");
|
||||
if ("SUCCESS".equals(channelState)) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import com.jeequan.jeepay.pay.channel.AbstractPaymentService;
|
|||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.util.PaywayUtil;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -56,14 +56,14 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
// 微信API版本
|
||||
String apiVersion = mchConfigContext.getWxServiceWrapper().getApiVersion();
|
||||
String apiVersion = mchAppConfigContext.getWxServiceWrapper().getApiVersion();
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(apiVersion)) {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchConfigContext);
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
|
||||
} else if (CS.PAY_IF_VERSION.WX_V3.equals(apiVersion)) {
|
||||
return PaywayUtil.getRealPaywayV3Service(this, payOrder.getWayCode()).pay(rq, payOrder, mchConfigContext);
|
||||
return PaywayUtil.getRealPaywayV3Service(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
|
||||
} else {
|
||||
throw new BizException("不支持的微信支付API版本");
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
* @param payOrder
|
||||
* @return
|
||||
*/
|
||||
public WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public WxPayUnifiedOrderRequest buildUnifiedOrderRequest(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
String payOrderId = payOrder.getPayOrderId();
|
||||
|
||||
// 微信统一下单请求对象
|
||||
|
|
@ -90,8 +90,8 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
request.setProductId(System.currentTimeMillis()+"");
|
||||
|
||||
// 特约商户
|
||||
if(mchConfigContext.isIsvsubMch()){
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
request.setSubMchId(isvsubMchParams.getSubMchId());
|
||||
request.setSubAppId(isvsubMchParams.getSubMchAppId());
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
* @param payOrder
|
||||
* @return
|
||||
*/
|
||||
public JSONObject buildV3OrderRequest(PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public JSONObject buildV3OrderRequest(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
String payOrderId = payOrder.getPayOrderId();
|
||||
|
||||
// 微信统一下单请求对象
|
||||
|
|
@ -122,9 +122,9 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
sceneInfo.put("payer_client_ip", payOrder.getClientIp());
|
||||
reqJSON.put("scene_info", sceneInfo);
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
reqJSON.put("sp_appid", wxPayService.getConfig().getAppId());
|
||||
reqJSON.put("sp_mchid", wxPayService.getConfig().getMchId());
|
||||
reqJSON.put("sub_mchid", isvsubMchParams.getSubMchId());
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvsubMchParams;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/*
|
||||
|
|
@ -33,14 +33,14 @@ import org.apache.commons.lang3.StringUtils;
|
|||
public class WxpayKit {
|
||||
|
||||
/** 放置 isv特殊信息 **/
|
||||
public static void putApiIsvInfo(MchConfigContext mchConfigContext, BaseWxPayRequest req){
|
||||
public static void putApiIsvInfo(MchAppConfigContext mchAppConfigContext, BaseWxPayRequest req){
|
||||
|
||||
//不是特约商户, 无需放置此值
|
||||
if(!mchConfigContext.isIsvsubMch()){
|
||||
if(!mchAppConfigContext.isIsvsubMch()){
|
||||
return ;
|
||||
}
|
||||
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvsubMchParams.class);
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvsubMchParams.class);
|
||||
req.setSubMchId(isvsubMchParams.getSubMchId());
|
||||
req.setSubAppId(isvsubMchParams.getSubMchAppId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxAppOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -49,9 +49,9 @@ public class WxApp extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchConfigContext);
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchAppConfigContext);
|
||||
req.setTradeType(WxPayConstants.TradeType.APP);
|
||||
|
||||
// 构造函数响应数据
|
||||
|
|
@ -62,7 +62,7 @@ public class WxApp extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayAppOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class WxBar extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxBarOrderRQ bizRQ = (WxBarOrderRQ) rq;
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public class WxBar extends WxpayPaymentService {
|
|||
request.setAuthCode(bizRQ.getAuthCode());
|
||||
|
||||
//放置isv信息
|
||||
WxpayKit.putApiIsvInfo(mchConfigContext, request);
|
||||
WxpayKit.putApiIsvInfo(mchAppConfigContext, request);
|
||||
|
||||
// 构造函数响应数据
|
||||
WxBarOrderRS res = ApiResBuilder.buildSuccess(WxBarOrderRS.class);
|
||||
|
|
@ -81,7 +81,7 @@ public class WxBar extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayMicropayResult wxPayMicropayResult = wxPayService.micropay(request);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxH5OrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxH5OrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -49,11 +49,11 @@ public class WxH5 extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
WxH5OrderRQ bizRQ = (WxH5OrderRQ) rq;
|
||||
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchConfigContext);
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchAppConfigContext);
|
||||
req.setTradeType(WxPayConstants.TradeType.MWEB);
|
||||
|
||||
// 构造函数响应数据
|
||||
|
|
@ -64,7 +64,7 @@ public class WxH5 extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayMwebOrderResult wxPayMwebOrderResult = wxPayService.createOrder(req);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -60,11 +60,11 @@ public class WxJsapi extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchConfigContext);
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchAppConfigContext);
|
||||
req.setTradeType(WxPayConstants.TradeType.JSAPI);
|
||||
req.setOpenid(bizRQ.getOpenid());
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class WxJsapi extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayMpOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ public class WxLite extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchConfigContext);
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchAppConfigContext);
|
||||
req.setTradeType(WxPayConstants.TradeType.JSAPI);
|
||||
req.setOpenid(bizRQ.getOpenid());
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class WxLite extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayMpOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxNativeOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxNativeOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -50,11 +50,11 @@ public class WxNative extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxNativeOrderRQ bizRQ = (WxNativeOrderRQ) rq;
|
||||
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchConfigContext);
|
||||
WxPayUnifiedOrderRequest req = buildUnifiedOrderRequest(payOrder, mchAppConfigContext);
|
||||
req.setTradeType(WxPayConstants.TradeType.NATIVE);
|
||||
|
||||
// 构造函数响应数据
|
||||
|
|
@ -65,7 +65,7 @@ public class WxNative extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
try {
|
||||
WxPayNativeOrderResult wxPayNativeOrderResult = wxPayService.createOrder(req);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxAppOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -47,15 +47,15 @@ public class WxApp extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchConfigContext);
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
String reqUrl; // 请求地址
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
reqUrl = WxpayV3Util.ISV_URL_MAP.get(WxPayConstants.TradeType.APP);
|
||||
}else {
|
||||
reqUrl = WxpayV3Util.NORMALMCH_URL_MAP.get(WxPayConstants.TradeType.APP);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package com.jeequan.jeepay.pay.channel.wxpay.paywayV3;
|
|||
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -43,7 +43,7 @@ public class WxBar extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
return wxBar.pay(rq, payOrder, mchConfigContext);
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
return wxBar.pay(rq, payOrder, mchAppConfigContext);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxH5OrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxH5OrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -49,14 +49,14 @@ public class WxH5 extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
WxH5OrderRQ bizRQ = (WxH5OrderRQ) rq;
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchConfigContext);
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
JSONObject sceneInfo = reqJSON.getJSONObject("scene_info");
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class WxH5 extends WxpayPaymentService {
|
|||
reqJSON.put("scene_info", sceneInfo);
|
||||
|
||||
String reqUrl; // 请求地址
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
reqUrl = WxpayV3Util.ISV_URL_MAP.get(WxPayConstants.TradeType.MWEB);
|
||||
}else {
|
||||
reqUrl = WxpayV3Util.NORMALMCH_URL_MAP.get(WxPayConstants.TradeType.MWEB);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -49,16 +49,16 @@ public class WxJsapi extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchConfigContext);
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
String reqUrl; // 请求地址
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
reqUrl = WxpayV3Util.ISV_URL_MAP.get(WxPayConstants.TradeType.JSAPI);
|
||||
|
||||
JSONObject payer = new JSONObject();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -49,16 +49,16 @@ public class WxLite extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception{
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchConfigContext);
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
String reqUrl; // 请求地址
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
reqUrl = WxpayV3Util.ISV_URL_MAP.get(WxPayConstants.TradeType.JSAPI);
|
||||
|
||||
JSONObject payer = new JSONObject();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -49,17 +49,17 @@ public class WxNative extends WxpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
WxNativeOrderRQ bizRQ = (WxNativeOrderRQ) rq;
|
||||
|
||||
WxPayService wxPayService = mchConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchConfigContext);
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
String reqUrl; // 请求地址
|
||||
if(mchConfigContext.isIsvsubMch()){ // 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
reqUrl = WxpayV3Util.ISV_URL_MAP.get(WxPayConstants.TradeType.NATIVE);
|
||||
}else {
|
||||
reqUrl = WxpayV3Util.NORMALMCH_URL_MAP.get(WxPayConstants.TradeType.NATIVE);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
|
|||
import com.jeequan.jeepay.pay.channel.ysfpay.utils.YsfSignUtils;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
|
@ -65,7 +65,7 @@ public class YsfpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchConfigContext mchConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
|
||||
ChannelRetMsg result = ChannelRetMsg.confirmSuccess(null);
|
||||
|
|
@ -77,7 +77,7 @@ public class YsfpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
log.info("{} 回调参数, jsonParams:{}", logPrefix, jsonParams);
|
||||
|
||||
// 校验支付回调
|
||||
boolean verifyResult = verifyParams(jsonParams, payOrder, mchConfigContext.getIsvConfigContext());
|
||||
boolean verifyResult = verifyParams(jsonParams, payOrder, mchAppConfigContext.getIsvConfigContext());
|
||||
// 验证参数失败
|
||||
if(!verifyResult){
|
||||
throw ResponseException.buildText("ERROR");
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
||||
import com.jeequan.jeepay.pay.channel.ysfpay.utils.YsfHttpUtil;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -46,7 +46,7 @@ public class YsfpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
private YsfpayPaymentService ysfpayPaymentService;
|
||||
|
||||
@Override
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
JSONObject reqParams = new JSONObject();
|
||||
String orderType = YsfHttpUtil.getOrderTypeByCommon(payOrder.getWayCode());
|
||||
String logPrefix = "【云闪付("+orderType+")查单】";
|
||||
|
|
@ -56,7 +56,7 @@ public class YsfpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
reqParams.put("orderType", orderType); //订单类型
|
||||
|
||||
//封装公共参数 & 签名 & 调起http请求 & 返回响应数据并包装为json格式。
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/queryOrder", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/queryOrder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
log.info("查询订单 payorderId:{}, 返回结果:{}", payOrder.getPayOrderId(), resJSON);
|
||||
if(resJSON == null){
|
||||
return ChannelRetMsg.waiting(); //支付中
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.jeequan.jeepay.pay.channel.ysfpay.utils.YsfHttpUtil;
|
|||
import com.jeequan.jeepay.pay.channel.ysfpay.utils.YsfSignUtils;
|
||||
import com.jeequan.jeepay.pay.config.SystemYmlConfig;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.util.PaywayUtil;
|
||||
|
|
@ -38,7 +38,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -70,13 +69,13 @@ public class YsfpayPaymentService extends AbstractPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchConfigContext);
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
|
||||
}
|
||||
|
||||
|
||||
/** 封装参数 & 统一请求 **/
|
||||
public JSONObject packageParamAndReq(String apiUri, JSONObject reqParams, String logPrefix, IsvConfigContext isvConfigContext, MchConfigContext mchConfigContext) throws Exception {
|
||||
public JSONObject packageParamAndReq(String apiUri, JSONObject reqParams, String logPrefix, IsvConfigContext isvConfigContext, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
YsfpayIsvParams isvParams = isvConfigContext.getIsvParamsByIfCode(getIfCode(), YsfpayIsvParams.class);
|
||||
|
||||
|
|
@ -86,7 +85,7 @@ public class YsfpayPaymentService extends AbstractPaymentService {
|
|||
}
|
||||
|
||||
reqParams.put("serProvId", isvParams.getSerProvId()); //云闪付服务商标识
|
||||
YsfpayIsvsubMchParams isvsubMchParams = mchConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), YsfpayIsvsubMchParams.class);
|
||||
YsfpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), YsfpayIsvsubMchParams.class);
|
||||
reqParams.put("merId", isvsubMchParams.getMerId()); // 商户号
|
||||
|
||||
//签名
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliBarOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ public class AliBar extends YsfpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付条码(alipay)支付】";
|
||||
AliBarOrderRQ bizRQ = (AliBarOrderRQ) rq;
|
||||
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
|
||||
|
|
@ -67,7 +67,7 @@ public class AliBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public class AliJsapi extends YsfpayPaymentService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付(alipayJs)jsapi支付】";
|
||||
JSONObject reqParams = new JSONObject();
|
||||
AliJsapiOrderRS res = ApiResBuilder.buildSuccess(AliJsapiOrderRS.class);
|
||||
|
|
@ -67,7 +67,7 @@ public class AliJsapi extends YsfpayPaymentService {
|
|||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public class WxBar extends YsfpayPaymentService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付条码(wechat)支付】";
|
||||
|
||||
WxBarOrderRQ bizRQ = (WxBarOrderRQ) rq;
|
||||
|
|
@ -67,7 +67,7 @@ public class WxBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public class WxJsapi extends YsfpayPaymentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付(wechatJs)jsapi支付】";
|
||||
JSONObject reqParams = new JSONObject();
|
||||
WxJsapiOrderRS res = ApiResBuilder.buildSuccess(WxJsapiOrderRS.class);
|
||||
|
|
@ -68,7 +68,7 @@ public class WxJsapi extends YsfpayPaymentService {
|
|||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.YsfBarOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.YsfBarOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public class YsfBar extends YsfpayPaymentService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付条码(unionpay)支付】";
|
||||
|
||||
YsfBarOrderRQ bizRQ = (YsfBarOrderRQ) rq;
|
||||
|
|
@ -68,7 +68,7 @@ public class YsfBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchConfigContext.getIsvConfigContext(), mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.YsfJsapiOrderRS;
|
|||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.util.ApiResBuilder;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public class YsfJsapi extends YsfpayPaymentService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, IsvConfigContext isvConfigContext, MchConfigContext mchConfigContext) throws Exception {
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, IsvConfigContext isvConfigContext, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付(unionpay)jsapi支付】";
|
||||
JSONObject reqParams = new JSONObject();
|
||||
YsfJsapiOrderRS res = ApiResBuilder.buildSuccess(YsfJsapiOrderRS.class);
|
||||
|
|
@ -61,7 +61,7 @@ public class YsfJsapi extends YsfpayPaymentService {
|
|||
//客户端IP
|
||||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, isvConfigContext, mchConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, isvConfigContext, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ package com.jeequan.jeepay.pay.ctrl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.ctrls.AbstractCtrl;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.utils.JeepayKit;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractMchAppRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRQ;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.ValidateService;
|
||||
|
|
@ -30,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
||||
/*
|
||||
* api 抽象接口, 公共函数
|
||||
*
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:28
|
||||
|
|
@ -59,29 +61,40 @@ public abstract class ApiController extends AbstractCtrl {
|
|||
//获取请求RQ, and 通用验证
|
||||
T bizRQ = getRQ(cls);
|
||||
|
||||
// 转换为 JSON
|
||||
JSONObject bizReqJSON = (JSONObject)JSONObject.toJSON(bizRQ);
|
||||
AbstractMchAppRQ abstractMchAppRQ = (AbstractMchAppRQ)bizRQ;
|
||||
|
||||
// [2]. 业务校验, 包括: 验签, 商户状态是否可用, 是否支持该支付方式下单等。
|
||||
String mchNo = bizReqJSON.getString("mchNo");
|
||||
//业务校验, 包括: 验签, 商户状态是否可用, 是否支持该支付方式下单等。
|
||||
String mchNo = abstractMchAppRQ.getMchNo();
|
||||
String appId = abstractMchAppRQ.getAppId();
|
||||
String sign = bizRQ.getSign();
|
||||
|
||||
if(StringUtils.isAnyEmpty(mchNo, sign)){
|
||||
if(StringUtils.isAnyBlank(mchNo, appId, sign)){
|
||||
throw new BizException("参数有误!");
|
||||
}
|
||||
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
|
||||
MchInfo mchInfo = mchConfigContext == null ? null : mchConfigContext.getMchInfo();
|
||||
MchInfo mchInfo = mchAppConfigContext == null ? null : mchAppConfigContext.getMchInfo();
|
||||
if(mchInfo == null || mchInfo.getState() != CS.YES){
|
||||
throw new BizException("商户不存在或商户状态不可用");
|
||||
}
|
||||
|
||||
// 验签
|
||||
String privateKey = mchInfo.getPrivateKey();
|
||||
MchApp mchApp = mchAppConfigContext == null ? null : mchAppConfigContext.getMchApp();
|
||||
if(mchInfo == null || mchInfo.getState() != CS.YES){
|
||||
throw new BizException("商户应用不存在或商户状态不可用");
|
||||
}
|
||||
|
||||
if(!mchApp.getMchNo().equals(mchNo)){
|
||||
throw new BizException("商户应用与商户号不匹配");
|
||||
}
|
||||
|
||||
// 验签
|
||||
String appSecret = mchApp.getAppSecret();
|
||||
|
||||
// 转换为 JSON
|
||||
JSONObject bizReqJSON = (JSONObject)JSONObject.toJSON(bizRQ);
|
||||
bizReqJSON.remove("sign");
|
||||
if(!sign.equalsIgnoreCase(JeepayKit.getSign(bizReqJSON, privateKey))){
|
||||
if(!sign.equalsIgnoreCase(JeepayKit.getSign(bizReqJSON, appSecret))){
|
||||
throw new BizException("验签失败");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package com.jeequan.jeepay.pay.ctrl.payorder;
|
|||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import com.jeequan.jeepay.core.entity.MchPayPassage;
|
||||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
|
|
@ -29,7 +30,7 @@ import com.jeequan.jeepay.pay.channel.IPaymentService;
|
|||
import com.jeequan.jeepay.pay.ctrl.ApiController;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.mq.queue.MqQueue4ChannelOrderQuery;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -102,6 +103,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
|
||||
String mchNo = bizRQ.getMchNo();
|
||||
String appId = bizRQ.getAppId();
|
||||
|
||||
// 只有新订单模式,进行校验
|
||||
if(isNewOrder && payOrderService.count(PayOrder.gw().eq(PayOrder::getMchNo, mchNo).eq(PayOrder::getMchOrderNo, bizRQ.getMchOrderNo())) > 0){
|
||||
|
|
@ -116,18 +118,19 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
|
||||
//获取支付参数 (缓存数据) 和 商户信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
if(mchConfigContext == null){
|
||||
throw new BizException("获取商户信息失败");
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
||||
MchInfo mchInfo = mchConfigContext.getMchInfo();
|
||||
MchInfo mchInfo = mchAppConfigContext.getMchInfo();
|
||||
MchApp mchApp = mchAppConfigContext.getMchApp();
|
||||
|
||||
//收银台支付并且只有新订单需要走这里, 收银台二次下单的wayCode应该为实际支付方式。
|
||||
if(isNewOrder && CS.PAY_WAY_CODE.QR_CASHIER.equals(wayCode)){
|
||||
|
||||
//生成订单
|
||||
payOrder = genPayOrder(bizRQ, mchInfo, null);
|
||||
payOrder = genPayOrder(bizRQ, mchInfo, mchApp, null);
|
||||
String payOrderId = payOrder.getPayOrderId();
|
||||
//订单入库 订单状态: 生成状态 此时没有和任何上游渠道产生交互。
|
||||
payOrderService.save(payOrder);
|
||||
|
|
@ -147,12 +150,12 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
|
||||
//获取支付接口
|
||||
IPaymentService paymentService = checkMchWayCodeAndGetService(mchConfigContext, wayCode);
|
||||
IPaymentService paymentService = checkMchWayCodeAndGetService(mchAppConfigContext, wayCode);
|
||||
String ifCode = paymentService.getIfCode();
|
||||
|
||||
//生成订单
|
||||
if(isNewOrder){
|
||||
payOrder = genPayOrder(bizRQ, mchInfo, ifCode);
|
||||
payOrder = genPayOrder(bizRQ, mchInfo, mchApp, ifCode);
|
||||
}else{
|
||||
payOrder.setIfCode(ifCode);
|
||||
}
|
||||
|
|
@ -169,7 +172,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
|
||||
//调起上游支付接口
|
||||
bizRS = (UnifiedOrderRS) paymentService.pay(bizRQ, payOrder, mchConfigContext);
|
||||
bizRS = (UnifiedOrderRS) paymentService.pay(bizRQ, payOrder, mchAppConfigContext);
|
||||
|
||||
//处理上游返回数据
|
||||
this.processChannelMsg(bizRS.getChannelRetMsg(), payOrder);
|
||||
|
|
@ -197,7 +200,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
}
|
||||
|
||||
private PayOrder genPayOrder(UnifiedOrderRQ rq, MchInfo mchInfo, String ifCode){
|
||||
private PayOrder genPayOrder(UnifiedOrderRQ rq, MchInfo mchInfo, MchApp mchApp, String ifCode){
|
||||
|
||||
PayOrder payOrder = new PayOrder();
|
||||
payOrder.setPayOrderId(SeqKit.genPayOrderId()); //生成订单ID
|
||||
|
|
@ -206,6 +209,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
payOrder.setMchName(mchInfo.getMchShortName()); //商户名称(简称)
|
||||
payOrder.setMchType(mchInfo.getType()); //商户类型
|
||||
payOrder.setMchOrderNo(rq.getMchOrderNo()); //商户订单号
|
||||
payOrder.setAppId(mchApp.getAppId()); //商户应用appId
|
||||
payOrder.setIfCode(ifCode); //接口代码
|
||||
payOrder.setWayCode(rq.getWayCode()); //支付方式
|
||||
payOrder.setAmount(rq.getAmount()); //订单金额
|
||||
|
|
@ -233,10 +237,10 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
* 校验: 商户的支付方式是否可用
|
||||
* 返回: 支付接口
|
||||
* **/
|
||||
private IPaymentService checkMchWayCodeAndGetService(MchConfigContext mchConfigContext, String wayCode){
|
||||
private IPaymentService checkMchWayCodeAndGetService(MchAppConfigContext mchAppConfigContext, String wayCode){
|
||||
|
||||
// 根据支付方式, 查询出 该商户 可用的支付接口
|
||||
MchPayPassage mchPayPassage = mchPayPassageService.findMchPayPassage(mchConfigContext.getMchNo(), wayCode);
|
||||
MchPayPassage mchPayPassage = mchPayPassageService.findMchPayPassage(mchAppConfigContext.getMchNo(), wayCode);
|
||||
if(mchPayPassage == null){
|
||||
throw new BizException("该支付方式商户未开通");
|
||||
}
|
||||
|
|
@ -252,20 +256,20 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
throw new BizException("接口不支持该支付方式");
|
||||
}
|
||||
|
||||
if(mchConfigContext.getMchType() == MchInfo.TYPE_NORMAL){ //普通商户
|
||||
if(mchAppConfigContext.getMchType() == MchInfo.TYPE_NORMAL){ //普通商户
|
||||
|
||||
if(mchConfigContext == null || mchConfigContext.getNormalMchParamsByIfCode(ifCode) == null){
|
||||
throw new BizException("商户参数未配置");
|
||||
if(mchAppConfigContext == null || mchAppConfigContext.getNormalMchParamsByIfCode(ifCode) == null){
|
||||
throw new BizException("商户应用参数未配置");
|
||||
}
|
||||
}else if(mchConfigContext.getMchType() == MchInfo.TYPE_ISVSUB){ //特约商户
|
||||
}else if(mchAppConfigContext.getMchType() == MchInfo.TYPE_ISVSUB){ //特约商户
|
||||
|
||||
mchConfigContext = configContextService.getMchConfigContext(mchConfigContext.getMchNo());
|
||||
mchAppConfigContext = configContextService.getMchAppConfigContext(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId());
|
||||
|
||||
if(mchConfigContext == null || mchConfigContext.getIsvsubMchParamsByIfCode(ifCode) == null){
|
||||
if(mchAppConfigContext == null || mchAppConfigContext.getIsvsubMchParamsByIfCode(ifCode) == null){
|
||||
throw new BizException("特约商户参数未配置");
|
||||
}
|
||||
|
||||
IsvConfigContext isvConfigContext = configContextService.getIsvConfigContext(mchConfigContext.getMchInfo().getIsvNo());
|
||||
IsvConfigContext isvConfigContext = configContextService.getIsvConfigContext(mchAppConfigContext.getMchInfo().getIsvNo());
|
||||
|
||||
if(isvConfigContext == null || isvConfigContext.getIsvParamsByIfCode(ifCode) == null){
|
||||
throw new BizException("服务商参数未配置");
|
||||
|
|
@ -359,7 +363,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
bizRS.setErrMsg(bizRS.getChannelRetMsg() != null ? bizRS.getChannelRetMsg().getChannelErrMsg() : null);
|
||||
}
|
||||
|
||||
return ApiRes.okWithSign(bizRS, configContextService.getMchConfigContext(bizRQ.getMchNo()).getMchInfo().getPrivateKey());
|
||||
return ApiRes.okWithSign(bizRS, configContextService.getMchAppConfigContext(bizRQ.getMchNo(), bizRQ.getAppId()).getMchApp().getAppSecret());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.jeequan.jeepay.core.exception.BizException;
|
|||
import com.jeequan.jeepay.core.exception.ResponseException;
|
||||
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
||||
import com.jeequan.jeepay.pay.channel.IChannelNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
|
|
@ -102,14 +102,11 @@ public class ChannelNoticeController extends AbstractCtrl {
|
|||
return this.toReturnPage("支付订单不存在");
|
||||
}
|
||||
|
||||
//查询出商户的配置信息
|
||||
String mchNo = payOrder.getMchNo();
|
||||
|
||||
//查询出商户配置参数
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
//调起接口的回调判断
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_RETURN);
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchAppConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_RETURN);
|
||||
|
||||
// 返回null 表明出现异常, 无需处理通知下游等操作。
|
||||
if(notifyResult == null || notifyResult.getChannelState() == null || notifyResult.getResponseEntity() == null){
|
||||
|
|
@ -130,7 +127,7 @@ public class ChannelNoticeController extends AbstractCtrl {
|
|||
//包含通知地址时
|
||||
if(hasReturnUrl){
|
||||
// 重定向
|
||||
response.sendRedirect(payMchNotifyService.createReturnUrl(payOrder, mchConfigContext.getMchInfo().getPrivateKey()));
|
||||
response.sendRedirect(payMchNotifyService.createReturnUrl(payOrder, mchAppConfigContext.getMchInfo().getPrivateKey()));
|
||||
return null;
|
||||
}else{
|
||||
|
||||
|
|
@ -202,14 +199,11 @@ public class ChannelNoticeController extends AbstractCtrl {
|
|||
return payNotifyService.doNotifyOrderNotExists(request);
|
||||
}
|
||||
|
||||
//查询出商户的配置信息
|
||||
String mchNo = payOrder.getMchNo();
|
||||
|
||||
//查询出商户配置参数
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
//调起接口的回调判断
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_NOTIFY);
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchAppConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_NOTIFY);
|
||||
|
||||
// 返回null 表明出现异常, 无需处理通知下游等操作。
|
||||
if(notifyResult == null || notifyResult.getChannelState() == null || notifyResult.getResponseEntity() == null){
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class QueryOrderController extends AbstractPayOrderController {
|
|||
}
|
||||
|
||||
QueryPayOrderRS bizRes = QueryPayOrderRS.buildByPayOrder(payOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchConfigContext(rq.getMchNo()).getMchInfo().getPrivateKey());
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class UnifiedOrderController extends AbstractPayOrderController {
|
|||
res.setPayData(bizRes.buildPayData());
|
||||
}
|
||||
|
||||
return ApiRes.okWithSign(res, configContextService.getMchConfigContext(rq.getMchNo()).getMchInfo().getPrivateKey());
|
||||
return ApiRes.okWithSign(res, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
|||
import com.jeequan.jeepay.core.utils.StringKit;
|
||||
import com.jeequan.jeepay.pay.channel.IChannelUserService;
|
||||
import com.jeequan.jeepay.pay.ctrl.payorder.AbstractPayOrderController;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.ChannelUserIdRQ;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.service.impl.SysConfigService;
|
||||
|
|
@ -71,6 +71,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("mchNo", rq.getMchNo());
|
||||
jsonObject.put("appId", rq.getAppId());
|
||||
jsonObject.put("ifCode", ifCode);
|
||||
jsonObject.put("redirectUrl", rq.getRedirectUrl());
|
||||
|
||||
|
|
@ -78,8 +79,8 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
String callbackUrl = sysConfigService.getDBApplicationConfig().genMchChannelUserIdApiOauth2RedirectUrlEncode(jsonObject);
|
||||
|
||||
//获取商户配置信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(rq.getMchNo());
|
||||
String redirectUrl = channelUserService.buildUserRedirectUrl(callbackUrl, mchConfigContext);
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId());
|
||||
String redirectUrl = channelUserService.buildUserRedirectUrl(callbackUrl, mchAppConfigContext);
|
||||
response.sendRedirect(redirectUrl);
|
||||
|
||||
}
|
||||
|
|
@ -92,6 +93,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
JSONObject callbackData = JSON.parseObject(JeepayKit.aesDecode(aesData));
|
||||
|
||||
String mchNo = callbackData.getString("mchNo");
|
||||
String appId = callbackData.getString("appId");
|
||||
String ifCode = callbackData.getString("ifCode");
|
||||
String redirectUrl = callbackData.getString("redirectUrl");
|
||||
|
||||
|
|
@ -103,10 +105,10 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
}
|
||||
|
||||
//获取商户配置信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
|
||||
//获取渠道用户ID
|
||||
String channelUserId = channelUserService.getChannelUserId(getReqParamJSON(), mchConfigContext);
|
||||
String channelUserId = channelUserService.getChannelUserId(getReqParamJSON(), mchAppConfigContext);
|
||||
|
||||
//同步跳转
|
||||
response.sendRedirect(StringKit.appendUrlQuery(redirectUrl, JsonKit.newJson("channelUserId", channelUserId)));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import com.jeequan.jeepay.service.impl.SysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -65,11 +65,11 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
String redirectUrlEncode = sysConfigService.getDBApplicationConfig().genOauth2RedirectUrlEncode(payOrder.getPayOrderId());
|
||||
|
||||
//获取商户配置信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(payOrder.getMchNo());
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
//获取接口并返回数据
|
||||
IChannelUserService channelUserService = getServiceByWayCode(getWayCode(), "ChannelUserService", IChannelUserService.class);
|
||||
return ApiRes.ok(channelUserService.buildUserRedirectUrl(redirectUrlEncode, mchConfigContext));
|
||||
return ApiRes.ok(channelUserService.buildUserRedirectUrl(redirectUrlEncode, mchAppConfigContext));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +85,9 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
String wayCode = getWayCode();
|
||||
|
||||
//获取商户配置信息
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(payOrder.getMchNo());
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
IChannelUserService channelUserService = getServiceByWayCode(wayCode, "ChannelUserService", IChannelUserService.class);
|
||||
return ApiRes.ok(channelUserService.getChannelUserId(getReqParamJSON(), mchConfigContext));
|
||||
return ApiRes.ok(channelUserService.getChannelUserId(getReqParamJSON(), mchAppConfigContext));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
resOrder.setMchOrderNo(payOrder.getMchOrderNo());
|
||||
resOrder.setMchName(payOrder.getMchName());
|
||||
resOrder.setAmount(payOrder.getAmount());
|
||||
resOrder.setReturnUrl(payMchNotifyService.createReturnUrl(payOrder, configContextService.getMchConfigContext(payOrder.getMchNo()).getMchInfo().getPrivateKey()));
|
||||
resOrder.setReturnUrl(payMchNotifyService.createReturnUrl(payOrder, configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId()).getMchApp().getAppSecret()));
|
||||
return ApiRes.ok(resOrder);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.pay.model;
|
||||
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import com.jeequan.jeepay.core.model.params.IsvsubMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.NormalMchParams;
|
||||
|
|
@ -24,23 +25,25 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* 商户支付参数信息
|
||||
* 用户 放置到内存, 避免多次查询操作
|
||||
* 商户应用支付参数信息
|
||||
* 放置到内存, 避免多次查询操作
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:29
|
||||
*/
|
||||
@Data
|
||||
public class MchConfigContext {
|
||||
public class MchAppConfigContext {
|
||||
|
||||
|
||||
/** 商户信息缓存 */
|
||||
private String mchNo;
|
||||
private String appId;
|
||||
private Byte mchType;
|
||||
private MchInfo mchInfo;
|
||||
private MchApp mchApp;
|
||||
|
||||
/** 商户支付配置信息缓存 */
|
||||
/** 商户支付配置信息缓存, <接口代码, 支付参数> */
|
||||
private Map<String, NormalMchParams> normalMchParamsMap = new HashMap<>();
|
||||
private Map<String, IsvsubMchParams> isvsubMchParamsMap = new HashMap<>();
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jeequan.jeepay.pay.model;
|
||||
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/*
|
||||
* 商户配置信息
|
||||
* 放置到内存, 避免多次查询操作
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:29
|
||||
*/
|
||||
@Data
|
||||
public class MchInfoConfigContext {
|
||||
|
||||
|
||||
/** 商户信息缓存 */
|
||||
private String mchNo;
|
||||
private Byte mchType;
|
||||
private MchInfo mchInfo;
|
||||
private Map<String, MchApp> appMap = new ConcurrentHashMap<>();
|
||||
|
||||
/** 重置商户APP **/
|
||||
public void putMchApp(MchApp mchApp){
|
||||
appMap.put(mchApp.getAppId(), mchApp);
|
||||
}
|
||||
|
||||
/** get商户APP **/
|
||||
public MchApp getMchApp(String appId){
|
||||
return appMap.get(appId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.pay.mq.topic;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -40,14 +41,30 @@ public class MqTopic4ModifyMchInfo extends ActiveMQTopic{
|
|||
super(CS.MQ.TOPIC_MODIFY_MCH_INFO);
|
||||
}
|
||||
|
||||
/** 接收 更新系统配置项的消息 **/
|
||||
/** 接收 [商户配置信息] 的消息
|
||||
* 已知推送节点:
|
||||
* 1. 更新商户基本资料和状态
|
||||
* 2. 删除商户时
|
||||
* **/
|
||||
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_MCH_INFO, containerFactory = "jmsListenerContainer")
|
||||
public void receive(String mchNo) {
|
||||
|
||||
log.info("重置商户信息, msg={}", mchNo);
|
||||
configContextService.initMchConfigContext(mchNo);
|
||||
log.info("接收 [商户配置信息] 的消息, msg={}", mchNo);
|
||||
configContextService.initMchInfoConfigContext(mchNo);
|
||||
}
|
||||
|
||||
/** 接收 [商户应用支付参数配置信息] 的消息
|
||||
* 已知推送节点:
|
||||
* 1. 更新商户应用配置
|
||||
* 2. 删除商户应用配置
|
||||
* **/
|
||||
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_MCH_APP, containerFactory = "jmsListenerContainer")
|
||||
public void receiveMchApp(String mchNoAndAppId) {
|
||||
|
||||
log.info("接收 [商户应用支付参数配置信息] 的消息, msg={}", mchNoAndAppId);
|
||||
JSONObject jsonObject = (JSONObject) JSONObject.parse(mchNoAndAppId);
|
||||
configContextService.initMchAppConfigContext(jsonObject.getString("mchNo"), jsonObject.getString("appId"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jeequan.jeepay.pay.rqrs;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/*
|
||||
*
|
||||
* 通用RQ, 包含mchNo和appId 必填项
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/16 10:30
|
||||
*/
|
||||
@Data
|
||||
public class AbstractMchAppRQ extends AbstractRQ {
|
||||
|
||||
/** 商户号 **/
|
||||
@NotBlank(message="商户号不能为空")
|
||||
private String mchNo;
|
||||
|
||||
/** 商户应用ID **/
|
||||
@NotBlank(message="商户应用ID不能为空")
|
||||
private String appId;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ import javax.validation.constraints.NotBlank;
|
|||
* @date 2021/6/8 17:40
|
||||
*/
|
||||
@Data
|
||||
public class ChannelUserIdRQ extends AbstractRQ{
|
||||
public class ChannelUserIdRQ extends AbstractMchAppRQ{
|
||||
|
||||
/** 商户号 **/
|
||||
@NotBlank(message="商户号不能为空")
|
||||
|
|
|
|||
|
|
@ -27,11 +27,7 @@ import javax.validation.constraints.NotBlank;
|
|||
* @date 2021/6/8 17:40
|
||||
*/
|
||||
@Data
|
||||
public class QueryPayOrderRQ extends AbstractRQ{
|
||||
|
||||
/** 商户号 **/
|
||||
@NotBlank(message="商户号不能为空")
|
||||
private String mchNo;
|
||||
public class QueryPayOrderRQ extends AbstractMchAppRQ{
|
||||
|
||||
/** 商户订单号 **/
|
||||
private String mchOrderNo;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package com.jeequan.jeepay.pay.rqrs.payorder;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractMchAppRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.*;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -36,15 +36,7 @@ import javax.validation.constraints.NotNull;
|
|||
* @date 2021/6/8 17:33
|
||||
*/
|
||||
@Data
|
||||
public class UnifiedOrderRQ extends AbstractRQ {
|
||||
|
||||
/** 商户号 **/
|
||||
@NotBlank(message="商户号不能为空")
|
||||
private String mchNo;
|
||||
|
||||
/** 商户应用ID **/
|
||||
@NotBlank(message="商户应用ID不能为空")
|
||||
private String appId;
|
||||
public class UnifiedOrderRQ extends AbstractMchAppRQ {
|
||||
|
||||
/** 商户订单号 **/
|
||||
@NotBlank(message="商户订单号不能为空")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package com.jeequan.jeepay.pay.service;
|
|||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
||||
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -58,11 +58,10 @@ public class ChannelOrderReissueService {
|
|||
return null;
|
||||
}
|
||||
|
||||
//查询出商户的配置信息
|
||||
String mchNo = payOrder.getMchNo();
|
||||
MchConfigContext mchConfigContext = configContextService.getMchConfigContext(mchNo);
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
ChannelRetMsg channelRetMsg = queryService.query(payOrder, mchConfigContext);
|
||||
ChannelRetMsg channelRetMsg = queryService.query(payOrder, mchAppConfigContext);
|
||||
if(channelRetMsg == null){
|
||||
log.error("channelRetMsg is null");
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
|
|||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.IsvInfo;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
|
||||
import com.jeequan.jeepay.core.model.params.IsvParams;
|
||||
|
|
@ -35,13 +36,10 @@ import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
|
|||
import com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.config.SystemYmlConfig;
|
||||
import com.jeequan.jeepay.pay.model.AlipayClientWrapper;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.model.*;
|
||||
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
|
||||
import com.jeequan.jeepay.service.impl.IsvInfoService;
|
||||
import com.jeequan.jeepay.service.impl.MchAppService;
|
||||
import com.jeequan.jeepay.service.impl.MchInfoService;
|
||||
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
|
|
@ -50,14 +48,13 @@ import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/*
|
||||
* 商户/服务商 配置信息上下文服务
|
||||
*
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:41
|
||||
|
|
@ -65,29 +62,49 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
@Service
|
||||
public class ConfigContextService {
|
||||
|
||||
private static final Map<String, MchConfigContext> mchConfigContextMap = new ConcurrentHashMap<>();
|
||||
/** <商户ID, 商户配置项> **/
|
||||
private static final Map<String, MchInfoConfigContext> mchInfoConfigContextMap = new ConcurrentHashMap<>();
|
||||
|
||||
/** <应用ID, 商户配置上下文> **/
|
||||
private static final Map<String, MchAppConfigContext> mchAppConfigContextMap = new ConcurrentHashMap<>();
|
||||
|
||||
/** <服务商号, 服务商配置上下文> **/
|
||||
private static final Map<String, IsvConfigContext> isvConfigContextMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired private MchInfoService mchInfoService;
|
||||
@Autowired private MchAppService mchAppService;
|
||||
@Autowired private IsvInfoService isvInfoService;
|
||||
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
|
||||
@Autowired private SystemYmlConfig mainConfig;
|
||||
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
|
||||
|
||||
/** 获取支付参数 **/
|
||||
public synchronized MchConfigContext getMchConfigContext(String mchNo){
|
||||
|
||||
MchConfigContext mchConfigContext = mchConfigContextMap.get(mchNo);
|
||||
/** 获取 [商户配置信息] **/
|
||||
public synchronized MchInfoConfigContext getMchInfoConfigContext(String mchNo){
|
||||
|
||||
MchInfoConfigContext mchInfoConfigContext = mchInfoConfigContextMap.get(mchNo);
|
||||
|
||||
//无此数据, 需要初始化
|
||||
if(mchConfigContext == null){
|
||||
initMchConfigContext(mchNo);
|
||||
if(mchInfoConfigContext == null){
|
||||
initMchInfoConfigContext(mchNo);
|
||||
}
|
||||
|
||||
return mchConfigContextMap.get(mchNo);
|
||||
return mchInfoConfigContextMap.get(mchNo);
|
||||
}
|
||||
|
||||
/** 获取支付参数 **/
|
||||
/** 获取 [商户应用支付参数配置信息] **/
|
||||
public synchronized MchAppConfigContext getMchAppConfigContext(String mchNo, String appId){
|
||||
|
||||
MchAppConfigContext mchAppConfigContext = mchAppConfigContextMap.get(appId);
|
||||
|
||||
//无此数据, 需要初始化
|
||||
if(mchAppConfigContext == null){
|
||||
initMchAppConfigContext(mchNo, appId);
|
||||
}
|
||||
|
||||
return mchAppConfigContextMap.get(appId);
|
||||
}
|
||||
|
||||
/** 获取 [ISV支付参数配置信息] **/
|
||||
public synchronized IsvConfigContext getIsvConfigContext(String isvNo){
|
||||
|
||||
IsvConfigContext isvConfigContext = isvConfigContextMap.get(isvNo);
|
||||
|
|
@ -101,34 +118,80 @@ public class ConfigContextService {
|
|||
}
|
||||
|
||||
|
||||
/** 获取支付参数 **/
|
||||
public synchronized void initMchConfigContext(String mchNo){
|
||||
/** 初始化 [商户配置信息] **/
|
||||
public synchronized void initMchInfoConfigContext(String mchNo){
|
||||
|
||||
MchConfigContext mchConfigContext = new MchConfigContext();
|
||||
//商户主体信息
|
||||
MchInfo mchInfo = mchInfoService.getById(mchNo);
|
||||
if(mchInfo == null){
|
||||
mchConfigContextMap.remove(mchNo);
|
||||
if(mchInfo == null){ // 查询不到商户主体, 可能已经删除
|
||||
|
||||
MchInfoConfigContext mchInfoConfigContext = mchInfoConfigContextMap.get(mchNo);
|
||||
|
||||
// 删除所有的商户应用
|
||||
if(mchInfoConfigContext != null){
|
||||
mchInfoConfigContext.getAppMap().forEach((k, v) -> mchAppConfigContextMap.remove(k));
|
||||
}
|
||||
|
||||
mchInfoConfigContextMap.remove(mchNo);
|
||||
return ;
|
||||
}
|
||||
|
||||
MchInfoConfigContext mchInfoConfigContext = new MchInfoConfigContext();
|
||||
|
||||
// 设置商户信息
|
||||
mchConfigContext.setMchNo(mchInfo.getMchNo());
|
||||
mchConfigContext.setMchType(mchInfo.getType());
|
||||
mchConfigContext.setMchInfo(mchInfo);
|
||||
mchInfoConfigContext.setMchNo(mchInfo.getMchNo());
|
||||
mchInfoConfigContext.setMchType(mchInfo.getType());
|
||||
mchInfoConfigContext.setMchInfo(mchInfo);
|
||||
mchAppService.list(MchApp.gw().eq(MchApp::getMchNo, mchNo)).stream().forEach( mchApp -> mchInfoConfigContext.putMchApp(mchApp));
|
||||
}
|
||||
|
||||
/** 初始化 [商户应用支付参数配置信息] **/
|
||||
public synchronized void initMchAppConfigContext(String mchNo, String appId){
|
||||
|
||||
// 获取商户的配置信息
|
||||
MchInfoConfigContext mchInfoConfigContext = getMchInfoConfigContext(mchNo);
|
||||
if(mchInfoConfigContext == null){ // 商户信息不存在
|
||||
return;
|
||||
}
|
||||
|
||||
//商户应用信息
|
||||
MchApp mchApp = mchInfoConfigContext.getMchApp(appId);
|
||||
|
||||
if(mchApp == null){ //说明商户主体信息不存在缓存
|
||||
|
||||
mchApp = mchAppService.getById(appId);
|
||||
if(mchApp == null){ // DB查询为空
|
||||
mchAppConfigContextMap.remove(appId); //清除缓存信息
|
||||
return ;
|
||||
}
|
||||
|
||||
//更新商户信息主体中的商户应用
|
||||
mchInfoConfigContext.putMchApp(mchApp);
|
||||
}
|
||||
|
||||
//商户主体信息
|
||||
MchInfo mchInfo = mchInfoConfigContext.getMchInfo();
|
||||
MchAppConfigContext mchAppConfigContext = new MchAppConfigContext();
|
||||
|
||||
// 设置商户信息
|
||||
mchAppConfigContext.setMchNo(mchInfo.getMchNo());
|
||||
mchAppConfigContext.setMchType(mchInfo.getType());
|
||||
mchAppConfigContext.setMchInfo(mchInfo);
|
||||
mchAppConfigContext.setMchApp(mchApp);
|
||||
|
||||
// 查询商户的所有支持的参数配置
|
||||
List<PayInterfaceConfig> allConfigList = payInterfaceConfigService.list(PayInterfaceConfig.gw()
|
||||
.select(PayInterfaceConfig::getIfCode, PayInterfaceConfig::getIfParams)
|
||||
.eq(PayInterfaceConfig::getState, CS.YES)
|
||||
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH)
|
||||
.eq(PayInterfaceConfig::getInfoId, mchNo)
|
||||
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
|
||||
.eq(PayInterfaceConfig::getInfoId, appId)
|
||||
);
|
||||
|
||||
// 普通商户
|
||||
if(mchInfo.getType() == CS.MCH_TYPE_NORMAL){
|
||||
|
||||
for (PayInterfaceConfig payInterfaceConfig : allConfigList) {
|
||||
mchConfigContext.getNormalMchParamsMap().put(
|
||||
mchAppConfigContext.getNormalMchParamsMap().put(
|
||||
payInterfaceConfig.getIfCode(),
|
||||
NormalMchParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams())
|
||||
);
|
||||
|
|
@ -136,10 +199,10 @@ public class ConfigContextService {
|
|||
|
||||
//放置alipay client
|
||||
|
||||
AlipayNormalMchParams alipayParams = mchConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayNormalMchParams.class);
|
||||
AlipayNormalMchParams alipayParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayNormalMchParams.class);
|
||||
if(alipayParams != null){
|
||||
|
||||
mchConfigContext.setAlipayClientWrapper(buildAlipayClientWrapper(
|
||||
mchAppConfigContext.setAlipayClientWrapper(buildAlipayClientWrapper(
|
||||
alipayParams.getUseCert(), alipayParams.getSandbox(), alipayParams.getAppId(), alipayParams.getPrivateKey(),
|
||||
alipayParams.getAlipayPublicKey(), alipayParams.getSignType(), alipayParams.getAppPublicCert(),
|
||||
alipayParams.getAlipayPublicCert(), alipayParams.getAlipayRootCert()
|
||||
|
|
@ -149,9 +212,9 @@ public class ConfigContextService {
|
|||
}
|
||||
|
||||
//放置 wxJavaService
|
||||
WxpayNormalMchParams wxpayParams = mchConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
WxpayNormalMchParams wxpayParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
if(wxpayParams != null){
|
||||
mchConfigContext.setWxServiceWrapper(buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
mchAppConfigContext.setWxServiceWrapper(buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
wxpayParams.getAppSecret(), wxpayParams.getKey(), wxpayParams.getApiVersion(), wxpayParams.getApiV3Key(),
|
||||
wxpayParams.getSerialNo(), wxpayParams.getCert(), wxpayParams.getApiClientKey()));
|
||||
}
|
||||
|
|
@ -159,22 +222,22 @@ public class ConfigContextService {
|
|||
|
||||
}else{ //服务商模式商户
|
||||
for (PayInterfaceConfig payInterfaceConfig : allConfigList) {
|
||||
mchConfigContext.getIsvsubMchParamsMap().put(
|
||||
mchAppConfigContext.getIsvsubMchParamsMap().put(
|
||||
payInterfaceConfig.getIfCode(),
|
||||
IsvsubMchParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams())
|
||||
);
|
||||
}
|
||||
|
||||
//放置 当前商户的 服务商信息
|
||||
mchConfigContext.setIsvConfigContext(getIsvConfigContext(mchInfo.getIsvNo()));
|
||||
mchAppConfigContext.setIsvConfigContext(getIsvConfigContext(mchInfo.getIsvNo()));
|
||||
|
||||
}
|
||||
|
||||
mchConfigContextMap.put(mchNo, mchConfigContext);
|
||||
mchAppConfigContextMap.put(appId, mchAppConfigContext);
|
||||
}
|
||||
|
||||
|
||||
/** 初始化 **/
|
||||
/** 初始化 [ISV支付参数配置信息] **/
|
||||
public synchronized void initIsvConfigContext(String isvNo){
|
||||
|
||||
IsvConfigContext isvConfigContext = new IsvConfigContext();
|
||||
|
|
@ -185,9 +248,9 @@ public class ConfigContextService {
|
|||
mchInfoService.list(MchInfo.gw().select(MchInfo::getMchNo).eq(MchInfo::getIsvNo, isvNo)).forEach(mchInfoItem -> {
|
||||
|
||||
//将更新已存在缓存的商户配置信息 (每个商户下存储的为同一个 服务商配置的对象指针)
|
||||
MchConfigContext mchConfigContext = mchConfigContextMap.get(mchInfoItem.getMchNo());
|
||||
if(mchConfigContext != null){
|
||||
mchConfigContext.setIsvConfigContext(null);
|
||||
MchAppConfigContext mchAppConfigContext = mchAppConfigContextMap.get(mchInfoItem.getMchNo());
|
||||
if(mchAppConfigContext != null){
|
||||
mchAppConfigContext.setIsvConfigContext(null);
|
||||
}
|
||||
});
|
||||
isvConfigContextMap.remove(isvNo); // 服务商有商户不可删除, 此处不再更新商户下的配置信息
|
||||
|
|
@ -238,9 +301,9 @@ public class ConfigContextService {
|
|||
mchInfoService.list(MchInfo.gw().select(MchInfo::getMchNo).eq(MchInfo::getIsvNo, isvNo)).forEach(mchInfoItem -> {
|
||||
|
||||
//将更新已存在缓存的商户配置信息 (每个商户下存储的为同一个 服务商配置的对象指针)
|
||||
MchConfigContext mchConfigContext = mchConfigContextMap.get(mchInfoItem.getMchNo());
|
||||
if(mchConfigContext != null){
|
||||
mchConfigContext.setIsvConfigContext(isvConfigContext);
|
||||
MchAppConfigContext mchAppConfigContext = mchAppConfigContextMap.get(mchInfoItem.getMchNo());
|
||||
if(mchAppConfigContext != null){
|
||||
mchAppConfigContext.setIsvConfigContext(isvConfigContext);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -250,7 +313,7 @@ public class ConfigContextService {
|
|||
|
||||
/*
|
||||
* 构建支付宝client 包装类
|
||||
*
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeepay.vip
|
||||
* @date 2021/6/8 17:46
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class PayMchNotifyService {
|
|||
/**
|
||||
* 创建响应URL
|
||||
*/
|
||||
public String createReturnUrl(PayOrder payOrder, String mchKey) {
|
||||
public String createReturnUrl(PayOrder payOrder, String appSecret) {
|
||||
|
||||
if(StringUtils.isEmpty(payOrder.getReturnUrl())){
|
||||
return "";
|
||||
|
|
@ -121,7 +121,7 @@ public class PayMchNotifyService {
|
|||
jsonObject.put("reqTime", System.currentTimeMillis()); //添加请求时间
|
||||
|
||||
// 报文签名
|
||||
jsonObject.put("sign", JeepayKit.getSign(jsonObject, mchKey)); // 签名
|
||||
jsonObject.put("sign", JeepayKit.getSign(jsonObject, appSecret)); // 签名
|
||||
|
||||
// 生成跳转地址
|
||||
return StringKit.appendUrlQuery(payOrder.getReturnUrl(), jsonObject);
|
||||
|
|
|
|||
Loading…
Reference in New Issue