mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
📝
添加微信支付回调注解
This commit is contained in:
parent
a9acbca787
commit
a30e3c655a
@ -138,6 +138,14 @@ public class WXLitePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
return openid;
|
return openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 微信支付回调 分v2 和v3 的处理方式
|
||||||
|
*
|
||||||
|
* @param data 通知结果
|
||||||
|
* @return 支付回调对象
|
||||||
|
* @throws WxPayException 微信异常类
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
log.info("微信支付回调data数据:{}", data.getBody());
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
@ -157,6 +165,7 @@ public class WXLitePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
// 转换结果
|
// 转换结果
|
||||||
|
Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
|
|
||||||
return PayOrderNotifyRespDTO
|
return PayOrderNotifyRespDTO
|
||||||
.builder()
|
.builder()
|
||||||
|
@ -85,7 +85,7 @@ public class WXNativePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
|
|
||||||
private WxPayNativeOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException {
|
private WxPayNativeOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException {
|
||||||
//前端
|
//前端
|
||||||
String trade_type = reqDTO.getChannelExtras().get("trade_type");
|
String tradeType = reqDTO.getChannelExtras().get("trade_type");
|
||||||
// 构建 WxPayUnifiedOrderRequest 对象
|
// 构建 WxPayUnifiedOrderRequest 对象
|
||||||
WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest
|
WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
@ -95,7 +95,7 @@ public class WXNativePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
.timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
.timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
||||||
.spbillCreateIp(reqDTO.getUserIp())
|
.spbillCreateIp(reqDTO.getUserIp())
|
||||||
.notifyUrl(reqDTO.getNotifyUrl())
|
.notifyUrl(reqDTO.getNotifyUrl())
|
||||||
.productId(trade_type)
|
.productId(tradeType)
|
||||||
.build();
|
.build();
|
||||||
// 执行请求
|
// 执行请求
|
||||||
return client.createOrder(request);
|
return client.createOrder(request);
|
||||||
@ -110,12 +110,20 @@ public class WXNativePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp()));
|
request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp()));
|
||||||
request.setNotifyUrl(reqDTO.getNotifyUrl());
|
request.setNotifyUrl(reqDTO.getNotifyUrl());
|
||||||
// 执行请求
|
// 执行请求
|
||||||
// log.info("支付字段request:{}",request.getTimeExpire());
|
|
||||||
|
|
||||||
return client.createOrderV3(TradeTypeEnum.NATIVE, request);
|
return client.createOrderV3(TradeTypeEnum.NATIVE, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 微信支付回调 分v2 和v3 的处理方式
|
||||||
|
*
|
||||||
|
* @param data 通知结果
|
||||||
|
* @return 支付回调对象
|
||||||
|
* @throws WxPayException 微信异常类
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
log.info("微信支付回调data数据:{}", data.getBody());
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
@ -135,6 +143,7 @@ public class WXNativePayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
// 转换结果
|
// 转换结果
|
||||||
|
Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
|
|
||||||
return PayOrderNotifyRespDTO
|
return PayOrderNotifyRespDTO
|
||||||
.builder()
|
.builder()
|
||||||
|
@ -96,7 +96,6 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
// 构建 WxPayUnifiedOrderRequest 对象
|
// 构建 WxPayUnifiedOrderRequest 对象
|
||||||
WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder()
|
WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder()
|
||||||
.outTradeNo(reqDTO.getMerchantOrderId())
|
.outTradeNo(reqDTO.getMerchantOrderId())
|
||||||
// TODO 芋艿:貌似没 title?
|
|
||||||
.body(reqDTO.getBody())
|
.body(reqDTO.getBody())
|
||||||
.totalFee(reqDTO.getAmount().intValue()) // 单位分
|
.totalFee(reqDTO.getAmount().intValue()) // 单位分
|
||||||
.timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
.timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
||||||
@ -112,7 +111,6 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
// 构建 WxPayUnifiedOrderRequest 对象
|
// 构建 WxPayUnifiedOrderRequest 对象
|
||||||
WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request();
|
WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request();
|
||||||
request.setOutTradeNo(reqDTO.getMerchantOrderId());
|
request.setOutTradeNo(reqDTO.getMerchantOrderId());
|
||||||
// TODO 芋艿:貌似没 title?
|
|
||||||
request.setDescription(reqDTO.getBody());
|
request.setDescription(reqDTO.getBody());
|
||||||
request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount().intValue())); // 单位分
|
request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount().intValue())); // 单位分
|
||||||
request.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"));
|
request.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"));
|
||||||
@ -131,6 +129,14 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
return openid;
|
return openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 微信支付回调 分v2 和v3 的处理方式
|
||||||
|
*
|
||||||
|
* @param data 通知结果
|
||||||
|
* @return 支付回调对象
|
||||||
|
* @throws WxPayException 微信异常类
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
log.info("微信支付回调data数据:{}", data.getBody());
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
@ -143,14 +149,13 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException {
|
private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException {
|
||||||
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
// 转换结果
|
// 转换结果
|
||||||
|
Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
return PayOrderNotifyRespDTO
|
return PayOrderNotifyRespDTO
|
||||||
.builder()
|
.builder()
|
||||||
.orderExtensionNo(result.getOutTradeNo())
|
.orderExtensionNo(result.getOutTradeNo())
|
||||||
|
Loading…
Reference in New Issue
Block a user