mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
增加支付宝 QR 支付的回调
This commit is contained in:
parent
696e94a1a3
commit
aa77eb029f
@ -53,6 +53,7 @@ public class AlipayQrPayClient extends AbstractPayClient<AlipayPayClientConfig>
|
|||||||
// 构建 AlipayTradePrecreateRequest
|
// 构建 AlipayTradePrecreateRequest
|
||||||
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
||||||
request.setBizModel(model);
|
request.setBizModel(model);
|
||||||
|
request.setNotifyUrl(reqDTO.getNotifyUrl());
|
||||||
|
|
||||||
// 执行请求
|
// 执行请求
|
||||||
AlipayTradePrecreateResponse response;
|
AlipayTradePrecreateResponse response;
|
||||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient
|
|||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||||
|
import com.alipay.api.response.AlipayTradePrecreateResponse;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -75,6 +76,7 @@ public class PayClientFactoryImplTest {
|
|||||||
* {@link AlipayQrPayClient}
|
* {@link AlipayQrPayClient}
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void testCreatePayClient_ALIPAY_QR() {
|
public void testCreatePayClient_ALIPAY_QR() {
|
||||||
// 创建配置
|
// 创建配置
|
||||||
AlipayPayClientConfig config = new AlipayPayClientConfig();
|
AlipayPayClientConfig config = new AlipayPayClientConfig();
|
||||||
@ -89,8 +91,10 @@ public class PayClientFactoryImplTest {
|
|||||||
PayClient client = payClientFactory.getPayClient(channelId);
|
PayClient client = payClientFactory.getPayClient(channelId);
|
||||||
// 发起支付
|
// 发起支付
|
||||||
PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
|
PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO();
|
||||||
CommonResult<?> result = client.unifiedOrder(reqDTO);
|
reqDTO.setNotifyUrl("http://niubi.natapp1.cc/api/pay/order/notify/alipay-qr/1"); // TODO @tina: 这里改成你的 natapp 回调地址
|
||||||
|
CommonResult<AlipayTradePrecreateResponse> result = (CommonResult<AlipayTradePrecreateResponse>) client.unifiedOrder(reqDTO);
|
||||||
System.out.println(JsonUtils.toJsonString(result));
|
System.out.println(JsonUtils.toJsonString(result));
|
||||||
|
System.out.println(result.getData().getQrCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,11 +51,25 @@ public class PayOrderController {
|
|||||||
// ========== 支付渠道的回调 ==========
|
// ========== 支付渠道的回调 ==========
|
||||||
|
|
||||||
@PostMapping("/notify/wx-pub/{channelId}")
|
@PostMapping("/notify/wx-pub/{channelId}")
|
||||||
@ApiOperation("通知微信公众号的结果")
|
@ApiOperation("通知微信公众号支付的结果")
|
||||||
public String notifyWxPayOrder(@PathVariable("channelId") Long channelId,
|
public String notifyWxPayOrder(@PathVariable("channelId") Long channelId,
|
||||||
@RequestBody String xmlData) throws Exception {
|
@RequestBody String xmlData) throws Exception {
|
||||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), xmlData);
|
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), xmlData);
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/notify/alipay-qr/{channelId}")
|
||||||
|
@ApiOperation("通知支付宝扫码支付的结果")
|
||||||
|
public String notifyAlipayQrPayOrder(@PathVariable("channelId") Long channelId,
|
||||||
|
@RequestBody String data) {
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/notify/test")
|
||||||
|
@ApiOperation("通知的测试接口")
|
||||||
|
public String notifyTest() {
|
||||||
|
// System.out.println(data);
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user