Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
252369f9
Commit
252369f9
authored
Jun 16, 2021
by
terrfly
Browse files
支付网关支持商户应用配置项的下单操作;
parent
bc3a2fa5
Changes
59
Hide whitespace changes
Inline
Side-by-side
jeepay-core/src/main/java/com/jeequan/jeepay/core/constants/CS.java
View file @
252369f9
...
...
@@ -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"
;
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/IChannelNoticeService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
,
NoticeTypeEnum
noticeTypeEnum
);
/** 数据库订单 状态更新异常 (仅异步通知使用) **/
ResponseEntity
doNotifyOrderStateUpdateFail
(
HttpServletRequest
request
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/IChannelUserService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
/*
* @Description: 301方式获取渠道侧用户ID, 如微信openId 支付宝的userId等
...
...
@@ -29,9 +29,9 @@ public interface IChannelUserService {
String
getIfCode
();
/** 获取重定向地址 **/
String
buildUserRedirectUrl
(
String
callbackUrlEncode
,
MchConfigContext
mchConfigContext
);
String
buildUserRedirectUrl
(
String
callbackUrlEncode
,
Mch
App
ConfigContext
mch
App
ConfigContext
);
/** 获取渠道用户ID **/
String
getChannelUserId
(
JSONObject
reqParams
,
MchConfigContext
mchConfigContext
);
String
getChannelUserId
(
JSONObject
reqParams
,
Mch
App
ConfigContext
mch
App
ConfigContext
);
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/IPayOrderQueryService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
/*
* 查单(渠道侧)接口定义
...
...
@@ -32,6 +32,6 @@ public interface IPayOrderQueryService {
String
getIfCode
();
/** 查询订单 **/
ChannelRetMsg
query
(
PayOrder
payOrder
,
MchConfigContext
mchConfigContext
)
throws
Exception
;
ChannelRetMsg
query
(
PayOrder
payOrder
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
throws
Exception
;
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/IPaymentService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
/*
* 调起上游渠道侧支付接口
*
*
* @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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
throws
Exception
;
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayChannelNoticeService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
,
NoticeTypeEnum
noticeTypeEnum
)
{
try
{
//配置参数获取
Byte
useCert
=
null
;
String
alipaySignType
,
alipayPublicCert
,
alipayPublicKey
=
null
;
if
(
mchConfigContext
.
isIsvsubMch
()){
if
(
mch
App
ConfigContext
.
isIsvsubMch
()){
// 获取支付参数
AlipayIsvParams
alipayParams
=
mchConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
getIfCode
(),
AlipayIsvParams
.
class
);
AlipayIsvParams
alipayParams
=
mch
App
ConfigContext
.
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
=
mch
App
ConfigContext
.
getNormalMchParamsByIfCode
(
getIfCode
(),
AlipayNormalMchParams
.
class
);
useCert
=
alipayParams
.
getUseCert
();
alipaySignType
=
alipayParams
.
getSignType
();
alipayPublicCert
=
alipayParams
.
getAlipayPublicCert
();
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayChannelUserService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
String
oauthUrl
=
AlipayConfig
.
PROD_OAUTH_URL
;
String
appId
=
null
;
if
(
mchConfigContext
.
isIsvsubMch
()){
AlipayIsvParams
isvParams
=
mchConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
getIfCode
(),
AlipayIsvParams
.
class
);
if
(
mch
App
ConfigContext
.
isIsvsubMch
()){
AlipayIsvParams
isvParams
=
mch
App
ConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
getIfCode
(),
AlipayIsvParams
.
class
);
appId
=
isvParams
.
getAppId
();
}
else
{
//获取商户配置信息
AlipayNormalMchParams
normalMchParams
=
mchConfigContext
.
getNormalMchParamsByIfCode
(
getIfCode
(),
AlipayNormalMchParams
.
class
);
AlipayNormalMchParams
normalMchParams
=
mch
App
ConfigContext
.
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
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
mch
App
ConfigContext
.
getAlipayClientWrapper
().
execute
(
request
).
getUserId
();
}
catch
(
ChannelException
e
)
{
e
.
printStackTrace
();
return
null
;
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayKit.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
(
Mch
App
ConfigContext
mch
App
ConfigContext
,
AlipayRequest
req
,
AlipayObject
model
){
//不是特约商户, 无需放置此值
if
(!
mchConfigContext
.
isIsvsubMch
()){
if
(!
mch
App
ConfigContext
.
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
=
mch
App
ConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
CS
.
IF_CODE
.
ALIPAY
,
AlipayIsvParams
.
class
);
AlipayIsvsubMchParams
isvsubMchParams
=
mch
App
ConfigContext
.
getIsvsubMchParamsByIfCode
(
CS
.
IF_CODE
.
ALIPAY
,
AlipayIsvsubMchParams
.
class
);
// 子商户信息
if
(
req
instanceof
AlipayTradePayRequest
)
((
AlipayTradePayRequest
)
req
).
putOtherTextParam
(
"app_auth_token"
,
isvsubMchParams
.
getAppAuthToken
());
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayPayOrderQueryService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
AlipayTradeQueryRequest
req
=
new
AlipayTradeQueryRequest
();
...
...
@@ -51,9 +51,9 @@ public class AlipayPayOrderQueryService implements IPayOrderQueryService {
req
.
setBizModel
(
model
);
//通用字段
AlipayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
,
model
);
AlipayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
req
,
model
);
AlipayTradeQueryResponse
resp
=
mchConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
AlipayTradeQueryResponse
resp
=
mch
App
ConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
String
result
=
resp
.
getTradeStatus
();
if
(
"TRADE_SUCCESS"
.
equals
(
result
))
{
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayPaymentService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
throws
Exception
{
return
PaywayUtil
.
getRealPaywayService
(
this
,
payOrder
.
getWayCode
()).
pay
(
rq
,
payOrder
,
mch
App
ConfigContext
);
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliApp.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
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
(
mch
App
ConfigContext
,
req
,
model
);
String
payData
=
null
;
// sdk方式需自行拦截接口异常信息
try
{
payData
=
mchConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
sdkExecute
(
req
).
getBody
();
payData
=
mch
App
ConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
sdkExecute
(
req
).
getBody
();
}
catch
(
AlipayApiException
e
)
{
throw
ChannelException
.
sysError
(
e
.
getMessage
());
}
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliBar.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
AliBarOrderRQ
bizRQ
=
(
AliBarOrderRQ
)
rq
;
...
...
@@ -71,10 +71,10 @@ public class AliBar extends AlipayPaymentService {
req
.
setBizModel
(
model
);
//统一放置 isv接口必传信息
AlipayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
,
model
);
AlipayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
req
,
model
);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradePayResponse
alipayResp
=
mchConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
AlipayTradePayResponse
alipayResp
=
mch
App
ConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
// 构造函数响应数据
AliBarOrderRS
res
=
ApiResBuilder
.
buildSuccess
(
AliBarOrderRS
.
class
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliJsapi.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
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
(
mch
App
ConfigContext
,
req
,
model
);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradeCreateResponse
alipayResp
=
mchConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
AlipayTradeCreateResponse
alipayResp
=
mch
App
ConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
// 构造函数响应数据
AliJsapiOrderRS
res
=
ApiResBuilder
.
buildSuccess
(
AliJsapiOrderRS
.
class
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliPc.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
AliPcOrderRQ
bizRQ
=
(
AliPcOrderRQ
)
rq
;
...
...
@@ -66,16 +66,16 @@ public class AliPc extends AlipayPaymentService {
req
.
setBizModel
(
model
);
//统一放置 isv接口必传信息
AlipayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
,
model
);
AlipayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
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
(
mch
App
ConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
pageExecute
(
req
).
getBody
());
}
else
{
res
.
setPayUrl
(
mchConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
pageExecute
(
req
,
"GET"
).
getBody
());
res
.
setPayUrl
(
mch
App
ConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
pageExecute
(
req
,
"GET"
).
getBody
());
}
}
catch
(
AlipayApiException
e
)
{
throw
ChannelException
.
sysError
(
e
.
getMessage
());
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliQr.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
AliQrOrderRQ
aliQrOrderRQ
=
(
AliQrOrderRQ
)
rq
;
...
...
@@ -62,10 +62,10 @@ public class AliQr extends AlipayPaymentService {
req
.
setBizModel
(
model
);
//统一放置 isv接口必传信息
AlipayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
,
model
);
AlipayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
req
,
model
);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradePrecreateResponse
alipayResp
=
mchConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
AlipayTradePrecreateResponse
alipayResp
=
mch
App
ConfigContext
.
getAlipayClientWrapper
().
execute
(
req
);
// 构造函数响应数据
AliQrOrderRS
res
=
ApiResBuilder
.
buildSuccess
(
AliQrOrderRS
.
class
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/payway/AliWap.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
){
AliWapOrderRQ
bizRQ
=
(
AliWapOrderRQ
)
rq
;
...
...
@@ -65,22 +65,22 @@ public class AliWap extends AlipayPaymentService {
req
.
setBizModel
(
model
);
//统一放置 isv接口必传信息
AlipayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
,
model
);
AlipayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
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
(
mch
App
ConfigContext
.
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
=
mch
App
ConfigContext
.
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
(
mch
App
ConfigContext
.
getAlipayClientWrapper
().
getAlipayClient
().
pageExecute
(
req
,
"GET"
).
getBody
());
}
}
catch
(
AlipayApiException
e
)
{
throw
ChannelException
.
sysError
(
e
.
getMessage
());
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayChannelNoticeService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
){
Mch
App
ConfigContext
mch
App
ConfigContext
=
configContextService
.
getMch
App
ConfigContext
(
payOrder
.
getMchNo
()
,
payOrder
.
getAppId
()
);
if
(
mch
App
ConfigContext
==
null
){
throw
new
BizException
(
"获取商户信息失败"
);
}
// 验签
if
(!
verifyNotifySign
(
request
,
mchConfigContext
))
{
if
(!
verifyNotifySign
(
request
,
mch
App
ConfigContext
))
{
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
,
mch
App
ConfigContext
.
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
,
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
(
mch
App
ConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
// V2
// 获取回调参数
WxPayOrderNotifyResult
result
=
(
WxPayOrderNotifyResult
)
params
;
WxPayService
wxPayService
=
mchConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
WxPayService
wxPayService
=
mch
App
ConfigContext
.
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
(
mch
App
ConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
// V3
// 获取回调参数
JSONObject
resultJSON
=
(
JSONObject
)
params
;
...
...
@@ -200,10 +200,10 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
/**
* V3校验通知签名
* @param request 请求信息
* @param mchConfigContext 商户配置
* @param mch
App
ConfigContext 商户配置
* @return true:校验通过 false:校验不通过
*/
private
boolean
verifyNotifySign
(
HttpServletRequest
request
,
MchConfigContext
mchConfigContext
)
throws
Exception
{
private
boolean
verifyNotifySign
(
HttpServletRequest
request
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
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
=
mch
App
ConfigContext
.
getWxServiceWrapper
().
getWxPayService
().
getConfig
();
// 自动获取微信平台证书
PrivateKey
privateKey
=
PemUtils
.
loadPrivateKey
(
new
FileInputStream
(
wxPayConfig
.
getPrivateKeyPath
()));
AutoUpdateCertificatesVerifier
verifier
=
new
AutoUpdateCertificatesVerifier
(
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayChannelUserService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
String
appId
=
null
;
String
oauth2Url
=
""
;
if
(
mchConfigContext
.
isIsvsubMch
()){
WxpayIsvParams
wxpayIsvParams
=
mchConfigContext
.
getIsvConfigContext
().
getIsvParamsByIfCode
(
CS
.
IF_CODE
.
WXPAY
,
WxpayIsvParams
.
class
);
if
(
mch
App
ConfigContext
.
isIsvsubMch
()){
WxpayIsvParams
wxpayIsvParams
=
mch
App
ConfigContext
.
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
=
mch
App
ConfigContext
.
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
String
code
=
reqParams
.
getString
(
"code"
);
try
{
return
mchConfigContext
.
getWxServiceWrapper
().
getWxMpService
().
getOAuth2Service
().
getAccessToken
(
code
).
getOpenId
();
return
mch
App
ConfigContext
.
getWxServiceWrapper
().
getWxMpService
().
getOAuth2Service
().
getAccessToken
(
code
).
getOpenId
();
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
return
null
;
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayPayOrderQueryService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
try
{
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
mchConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V2
if
(
CS
.
PAY_IF_VERSION
.
WX_V2
.
equals
(
mch
App
ConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V2
WxPayOrderQueryRequest
req
=
new
WxPayOrderQueryRequest
();
//放置isv信息
WxpayKit
.
putApiIsvInfo
(
mchConfigContext
,
req
);
WxpayKit
.
putApiIsvInfo
(
mch
App
ConfigContext
,
req
);
req
.
setOutTradeNo
(
payOrder
.
getPayOrderId
());
WxPayService
wxPayService
=
mchConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
WxPayService
wxPayService
=
mch
App
ConfigContext
.
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
(
mch
App
ConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V3
JSONObject
resultJSON
=
WxpayV3Util
.
queryOrderV3
(
payOrder
.
getPayOrderId
(),
mchConfigContext
.
getWxServiceWrapper
().
getWxPayService
().
getConfig
());
JSONObject
resultJSON
=
WxpayV3Util
.
queryOrderV3
(
payOrder
.
getPayOrderId
(),
mch
App
ConfigContext
.
getWxServiceWrapper
().
getWxPayService
().
getConfig
());
String
channelState
=
resultJSON
.
getString
(
"trade_state"
);
if
(
"SUCCESS"
.
equals
(
channelState
))
{
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayPaymentService.java
View file @
252369f9
...
...
@@ -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.Mch
App
ConfigContext
;
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
throws
Exception
{
// 微信API版本
String
apiVersion
=
mchConfigContext
.
getWxServiceWrapper
().
getApiVersion
();
String
apiVersion
=
mch
App
ConfigContext
.
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
,
mch
App
ConfigContext
);
}
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
,
mch
App
ConfigContext
);
}
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
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
(
mch
App
ConfigContext
.
isIsvsubMch
()){
WxpayIsvsubMchParams
isvsubMchParams
=
mch
App
ConfigContext
.
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
,
Mch
App
ConfigContext
mch
App
ConfigContext
)
{
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
=
mch
App
ConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
if
(
mch
App
ConfigContext
.
isIsvsubMch
()){
// 特约商户
WxpayIsvsubMchParams
isvsubMchParams
=
mch
App
ConfigContext
.
getIsvsubMchParamsByIfCode
(
getIfCode
(),
WxpayIsvsubMchParams
.
class
);
reqJSON
.
put
(
"sp_appid"
,
wxPayService
.
getConfig
().
getAppId
());
reqJSON
.
put
(
"sp_mchid"
,
wxPayService
.
getConfig
().
getMchId
());
reqJSON
.
put
(
"sub_mchid"
,
isvsubMchParams
.
getSubMchId
());
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment