【微信支付回调】: WXLitePayClient.java: 添加 v2和 v3的回调数据处理 WXNativePayClient.java: 添加 v2和 v3的回调数据处理 WXPubPayClient.java: 添加 v2和 v3的回调数据处理pull/2/head
parent
7b17e3bc2f
commit
a9acbca787
|
@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.*;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
||||||
|
@ -139,13 +140,46 @@ public class WXLitePayClient extends AbstractPayClient<WXPayClientConfig> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
|
// 微信支付 v2 回调结果处理
|
||||||
|
switch (config.getApiVersion()) {
|
||||||
|
case WXPayClientConfig.API_VERSION_V2:
|
||||||
|
return parseOrderNotifyV2(data);
|
||||||
|
case WXPayClientConfig.API_VERSION_V3:
|
||||||
|
return parseOrderNotifyV3(data);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
|
// 转换结果
|
||||||
|
|
||||||
|
return PayOrderNotifyRespDTO
|
||||||
|
.builder()
|
||||||
|
.orderExtensionNo(result.getOutTradeNo())
|
||||||
|
.channelOrderNo(result.getTradeState())
|
||||||
|
.successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
||||||
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException {
|
||||||
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
||||||
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
// 转换结果
|
// 转换结果
|
||||||
return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo())
|
return PayOrderNotifyRespDTO
|
||||||
.channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid())
|
.builder()
|
||||||
|
.orderExtensionNo(notifyResult.getOutTradeNo())
|
||||||
|
.channelOrderNo(notifyResult.getTransactionId())
|
||||||
|
.channelUserId(notifyResult.getOpenid())
|
||||||
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
|
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
|
||||||
.data(data.getBody()).build();
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.*;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
||||||
|
@ -117,13 +118,46 @@ public class WXNativePayClient extends AbstractPayClient<WXPayClientConfig> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
|
// 微信支付 v2 回调结果处理
|
||||||
|
switch (config.getApiVersion()) {
|
||||||
|
case WXPayClientConfig.API_VERSION_V2:
|
||||||
|
return parseOrderNotifyV2(data);
|
||||||
|
case WXPayClientConfig.API_VERSION_V3:
|
||||||
|
return parseOrderNotifyV3(data);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
|
// 转换结果
|
||||||
|
|
||||||
|
return PayOrderNotifyRespDTO
|
||||||
|
.builder()
|
||||||
|
.orderExtensionNo(result.getOutTradeNo())
|
||||||
|
.channelOrderNo(result.getTradeState())
|
||||||
|
.successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
||||||
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException {
|
||||||
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
||||||
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
// 转换结果
|
// 转换结果
|
||||||
return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo())
|
return PayOrderNotifyRespDTO
|
||||||
.channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid())
|
.builder()
|
||||||
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
.orderExtensionNo(notifyResult.getOutTradeNo())
|
||||||
.data(data.getBody()).build();
|
.channelOrderNo(notifyResult.getTransactionId())
|
||||||
|
.channelUserId(notifyResult.getOpenid())
|
||||||
|
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
|
||||||
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.*;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
||||||
|
@ -132,13 +133,46 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
log.info("微信支付回调data数据:{}", data.getBody());
|
||||||
|
// 微信支付 v2 回调结果处理
|
||||||
|
switch (config.getApiVersion()) {
|
||||||
|
case WXPayClientConfig.API_VERSION_V2:
|
||||||
|
return parseOrderNotifyV2(data);
|
||||||
|
case WXPayClientConfig.API_VERSION_V3:
|
||||||
|
return parseOrderNotifyV3(data);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyDataDTO data) throws WxPayException {
|
||||||
|
WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null);
|
||||||
|
WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult();
|
||||||
|
// 转换结果
|
||||||
|
|
||||||
|
return PayOrderNotifyRespDTO
|
||||||
|
.builder()
|
||||||
|
.orderExtensionNo(result.getOutTradeNo())
|
||||||
|
.channelOrderNo(result.getTradeState())
|
||||||
|
.successTime(DateUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX"))
|
||||||
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyDataDTO data) throws WxPayException {
|
||||||
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody());
|
||||||
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
|
||||||
// 转换结果
|
// 转换结果
|
||||||
return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo())
|
return PayOrderNotifyRespDTO
|
||||||
.channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid())
|
.builder()
|
||||||
|
.orderExtensionNo(notifyResult.getOutTradeNo())
|
||||||
|
.channelOrderNo(notifyResult.getTransactionId())
|
||||||
|
.channelUserId(notifyResult.getOpenid())
|
||||||
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
|
.successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
|
||||||
.data(data.getBody()).build();
|
.data(data.getBody())
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue