From aa77eb029f355f576d96fe148d689e6314f49779 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 3 Nov 2021 09:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=20QR=20=E6=94=AF=E4=BB=98=E7=9A=84=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/impl/alipay/AlipayQrPayClient.java | 1 + .../client/impl/PayClientFactoryImplTest.java | 6 +++++- .../pay/controller/order/PayOrderController.java | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java index e9b5245ffc..9c0ec38065 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java @@ -53,6 +53,7 @@ public class AlipayQrPayClient extends AbstractPayClient // 构建 AlipayTradePrecreateRequest AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.setBizModel(model); + request.setNotifyUrl(reqDTO.getNotifyUrl()); // 执行请求 AlipayTradePrecreateResponse response; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java index d7f8e462fa..582840e4ec 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java @@ -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.WXPubPayClient; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import com.alipay.api.response.AlipayTradePrecreateResponse; import org.junit.jupiter.api.Test; import java.io.FileInputStream; @@ -75,6 +76,7 @@ public class PayClientFactoryImplTest { * {@link AlipayQrPayClient} */ @Test + @SuppressWarnings("unchecked") public void testCreatePayClient_ALIPAY_QR() { // 创建配置 AlipayPayClientConfig config = new AlipayPayClientConfig(); @@ -89,8 +91,10 @@ public class PayClientFactoryImplTest { PayClient client = payClientFactory.getPayClient(channelId); // 发起支付 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 result = (CommonResult) client.unifiedOrder(reqDTO); System.out.println(JsonUtils.toJsonString(result)); + System.out.println(result.getData().getQrCode()); } /** diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java index 74a7249a82..077904614e 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java @@ -51,11 +51,25 @@ public class PayOrderController { // ========== 支付渠道的回调 ========== @PostMapping("/notify/wx-pub/{channelId}") - @ApiOperation("通知微信公众号的结果") + @ApiOperation("通知微信公众号支付的结果") public String notifyWxPayOrder(@PathVariable("channelId") Long channelId, @RequestBody String xmlData) throws Exception { payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), xmlData); 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"; + } + }