mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-17 12:35:07 +08:00
tina提交支付宝扫码支付
This commit is contained in:
@ -6,7 +6,7 @@ import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreServic
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitRespDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.NotifyDataDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.PayNotifyDataDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import cn.iocoder.yudao.userserver.modules.pay.controller.order.vo.PayOrderSubmitReqVO;
|
||||
import cn.iocoder.yudao.userserver.modules.pay.controller.order.vo.PayOrderSubmitRespVO;
|
||||
@ -58,14 +58,17 @@ public class PayOrderController {
|
||||
@ApiOperation("通知微信公众号支付的结果")
|
||||
public String notifyWxPayOrder(@PathVariable("channelId") Long channelId,
|
||||
@RequestBody String xmlData) throws Exception {
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), NotifyDataDTO.builder().origData(xmlData).build());
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), PayNotifyDataDTO.builder().body(xmlData).build());
|
||||
return "success";
|
||||
}
|
||||
|
||||
@PostMapping("/notify/alipay-qr/{channelId}")
|
||||
@ApiOperation("通知支付宝扫码支付的结果")
|
||||
public String notifyAlipayQrPayOrder(@PathVariable("channelId") Long channelId,
|
||||
@RequestBody String data) {
|
||||
@RequestParam Map<String, String> params,
|
||||
@RequestBody String originData) throws Exception{
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_QR.getCode(),
|
||||
PayNotifyDataDTO.builder().params(params).body(originData).build());
|
||||
return "success";
|
||||
}
|
||||
|
||||
@ -82,7 +85,7 @@ public class PayOrderController {
|
||||
@RequestParam Map<String, String> params,
|
||||
@RequestBody String originData) throws Exception {
|
||||
//TODO @jason 校验 是否支付宝调用。 使用 支付宝publickey payclient 或许加一个校验方法
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), NotifyDataDTO.builder().params(params).origData(originData).build());
|
||||
payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), PayNotifyDataDTO.builder().params(params).body(originData).build());
|
||||
return "success";
|
||||
}
|
||||
|
||||
@ -100,4 +103,12 @@ public class PayOrderController {
|
||||
return "支付成功";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/return/alipay-qr/{channelId}")
|
||||
@ApiOperation("支付宝wap页面回跳")
|
||||
public String returnAliPayQrPayOrder(@PathVariable("channelId") Long channelId){
|
||||
//TODO @jason 校验 是否支付宝调用。 支付宝publickey 可以根据 appId 跳转不同的页面
|
||||
System.out.println("支付成功");
|
||||
return "支付成功";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
|
||||
<title>支付测试页</title>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
|
||||
<script src="qrcode.min.js" type="text/javascript"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div>点击如下按钮,发起支付宝扫码支付的测试</div>
|
||||
<div>
|
||||
<button id="alipay_wap">支付宝扫码支付</button>
|
||||
</div>
|
||||
<div id="qrcode"></div>
|
||||
</body>
|
||||
<style>
|
||||
#qrcode{
|
||||
padding-left: 20px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
let shopOrderId = undefined;
|
||||
let payOrderId = undefined;
|
||||
let server = 'http://127.0.0.1:28080';
|
||||
$(function() {
|
||||
// 自动发起商城订单编号
|
||||
$.ajax({
|
||||
url: server + "/api/shop/order/create",
|
||||
method: 'POST',
|
||||
success: function( result ) {
|
||||
if (result.code !== 0) {
|
||||
alert('创建商城订单失败,原因:' + result.msg)
|
||||
return;
|
||||
}
|
||||
shopOrderId = result.data.id;
|
||||
payOrderId = result.data.payOrderId;
|
||||
console.log("商城订单:" + shopOrderId)
|
||||
console.log("支付订单:" + payOrderId)
|
||||
}
|
||||
})
|
||||
});
|
||||
// 支付宝扫码支付
|
||||
$( "#alipay_wap").on( "click", function() {
|
||||
// 提交支付
|
||||
$.ajax({
|
||||
url: server + "/api/pay/order/submit",
|
||||
method: 'POST',
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
"id": payOrderId,
|
||||
"channelCode": 'alipay_qr'
|
||||
}),
|
||||
success: function( result ) {
|
||||
if (result.code !== 0) {
|
||||
alert('提交支付订单失败,原因:' + result.msg)
|
||||
return;
|
||||
}
|
||||
//提交支付后返回的参数
|
||||
let data = result.data.invokeResponse;
|
||||
new QRCode($("#qrcode")[0],{
|
||||
text: data.qrCode, //内容
|
||||
width:98, //宽度
|
||||
height:98, //高度
|
||||
correctLevel: 3,//二维码纠错级别
|
||||
background: "#ffffff",//背景颜色
|
||||
foreground: "#000000"//二维码颜色
|
||||
});
|
||||
|
||||
console.log("data.qrCode===",data.qrCode)
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</html>
|
1
yudao-user-server/src/main/resources/static/qrcode.min.js
vendored
Normal file
1
yudao-user-server/src/main/resources/static/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user