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
61ac241b
Commit
61ac241b
authored
Jun 18, 2021
by
xiaoyu
Browse files
微信V3接口退款
parent
072aa10c
Changes
2
Hide whitespace changes
Inline
Side-by-side
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/WxpayRefundService.java
View file @
61ac241b
...
...
@@ -95,19 +95,13 @@ public class WxpayRefundService extends AbstractRefundService {
amountJson
.
put
(
"refund"
,
refundOrder
.
getRefundAmount
());
// 退款金额
amountJson
.
put
(
"total"
,
payOrder
.
getAmount
());
// 订单总金额
amountJson
.
put
(
"currency"
,
"CNY"
);
// 币种
reqJSON
.
put
(
"amount"
,
amountJson
.
toJSONString
()
);
reqJSON
.
put
(
"amount"
,
amountJson
);
WxPayService
wxPayService
=
mchAppConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
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
());
reqJSON
.
put
(
"sub_appid"
,
isvsubMchParams
.
getSubMchAppId
());
}
else
{
// 普通商户
reqJSON
.
put
(
"appid"
,
wxPayService
.
getConfig
().
getAppId
());
reqJSON
.
put
(
"mchid"
,
wxPayService
.
getConfig
().
getMchId
());
}
JSONObject
resultJSON
=
WxpayV3Util
.
refundV3
(
reqJSON
,
mchAppConfigContext
.
getWxServiceWrapper
().
getWxPayService
().
getConfig
());
...
...
@@ -116,6 +110,10 @@ public class WxpayRefundService extends AbstractRefundService {
String
refundId
=
resultJSON
.
getString
(
"refund_id"
);
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
CONFIRM_SUCCESS
);
channelRetMsg
.
setChannelOrderId
(
refundId
);
}
else
if
(
"PROCESSING"
.
equals
(
status
)){
// 退款处理中
String
refundId
=
resultJSON
.
getString
(
"refund_id"
);
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
WAITING
);
channelRetMsg
.
setChannelOrderId
(
refundId
);
}
else
{
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
CONFIRM_FAIL
);
channelRetMsg
.
setChannelErrMsg
(
status
);
...
...
@@ -157,7 +155,14 @@ public class WxpayRefundService extends AbstractRefundService {
}
else
if
(
CS
.
PAY_IF_VERSION
.
WX_V3
.
equals
(
mchAppConfigContext
.
getWxServiceWrapper
().
getApiVersion
()))
{
//V3
WxPayService
wxPayService
=
mchAppConfigContext
.
getWxServiceWrapper
().
getWxPayService
();
setCretPath
(
mchAppConfigContext
,
wxPayService
);
// 证书路径
JSONObject
resultJSON
=
WxpayV3Util
.
refundQueryV3
(
refundOrder
.
getRefundOrderId
(),
wxPayService
.
getConfig
());
JSONObject
resultJSON
=
null
;
if
(
mchAppConfigContext
.
isIsvsubMch
())
{
WxpayIsvsubMchParams
isvsubMchParams
=
mchAppConfigContext
.
getIsvsubMchParamsByIfCode
(
getIfCode
(),
WxpayIsvsubMchParams
.
class
);
wxPayService
.
getConfig
().
setSubMchId
(
isvsubMchParams
.
getSubMchId
());
resultJSON
=
WxpayV3Util
.
refundQueryV3Isv
(
refundOrder
.
getRefundOrderId
(),
wxPayService
.
getConfig
());
}
else
{
resultJSON
=
WxpayV3Util
.
refundQueryV3
(
refundOrder
.
getRefundOrderId
(),
wxPayService
.
getConfig
());
}
String
status
=
resultJSON
.
getString
(
"status"
);
if
(
"SUCCESS"
.
equals
(
status
)){
// 退款成功
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
CONFIRM_SUCCESS
);
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/wxpay/kits/WxpayV3Util.java
View file @
61ac241b
...
...
@@ -94,6 +94,12 @@ public class WxpayV3Util {
return
JSON
.
parseObject
(
response
);
}
public
static
JSONObject
refundQueryV3Isv
(
String
refundOrderId
,
WxPayConfig
wxPayConfig
)
throws
WxPayException
{
String
url
=
String
.
format
(
"%s/v3/refund/domestic/refunds/%s?sub_mchid=%s"
,
PAY_BASE_URL
,
refundOrderId
,
wxPayConfig
.
getSubMchId
());
String
response
=
getV3
(
url
,
wxPayConfig
);
return
JSON
.
parseObject
(
response
);
}
public
static
String
postV3
(
String
url
,
String
requestStr
,
WxPayConfig
wxPayConfig
)
throws
WxPayException
{
CloseableHttpClient
httpClient
=
createApiV3HttpClient
(
wxPayConfig
);
HttpPost
httpPost
=
createHttpPost
(
url
,
requestStr
);
...
...
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