实例支持 扫码二维码支付成功 后, 网页 自动弹出 支付成功的提示首先要申请 微信扫码支付的权限,即:开通微支付,然后 在config.cs中配置 你申请的信息@model dynamic
@{
Layout = null;
}
<!docTYPE html>
<html>
<head>
<title>微信扫码支付Demo</title>
</head>
<body>
<div>
<div>打开微信扫描下方二维码支付</div>
<div><img id="qrcode" src="@URL.Content("~/Images/loading.gif")" /></div>
</div>
<script src="~/Scripts/jquery.min.js"></script>
<script type="text/Javascript">
var Timer1;
$.ajax({
type: 'post',
url: '@Url.Action("CreateOrder")',
data: {aMount:1},
method: 'POST'
})
.done(
function formatdata(data, textStatus, jqXHR) {
$("#qrcode").attr('src', '@Url.Action("QrCode")?data=' data.result);
timer1 = setInterval(showResult(data.tradeno), 3000);
});
function showResult(order_no) {
return function() {
$.ajax({
url: "@Url.Action("_CheckStatus", "Home")?order_no=" order_no,
method: 'get',
dataType: 'json',
cache: false, //不保存缓存
success: function(data) {
if (data.code == 1) {
clearInterval(timer1);
Alert('支付已成功,感谢您的支持!');
window.location.href = "http://www.haolizi.net";
}
}
});
}
}
</script>
</body>
</html>