[Y] 订单支付状态检查

master
taylor.dang 6 years ago
parent d1ccf17b1f
commit a2c55a6339

@ -88,7 +88,7 @@ $(document).ready(function () {
},
closeCurrentApp: false
});
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true';
startCheckOrder(window.client_moniker, window.merchant_orderid);
} else {
alert(res.memo);
if (window.tradeNo) {
@ -103,6 +103,25 @@ $(document).ready(function () {
}
}
function startCheckOrder(clientMoniker, merchantOrderId) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/clients/' + clientMoniker + '/orders/' + merchantOrderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true';
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
function waitForPaymentSuccess(orderId) {
var sock = new SockJS('/register');
var client = Stomp.over(sock);

@ -290,7 +290,7 @@ $(function () {
},
closeCurrentApp: false
});
location.href = '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
startCheckOrder(pay.order_id, '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result');
} else if (res.resultCode == '6001') {
//do nothing
} else {
@ -315,6 +315,25 @@ $(function () {
})
});
function startCheckOrder(orderId, url) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = url;
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
function weuiAlert(msg) {
var config = {
template: msg

@ -54,7 +54,7 @@ $(document).ready(function () {
},
closeCurrentApp: false
});
location.href = window.redirect;
startCheckOrder(window.order_id, window.redirect);
} else {
alert(res.memo);
}
@ -76,4 +76,22 @@ $(document).ready(function () {
}
function startCheckOrder(orderId, url) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = url;
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
});

@ -276,7 +276,7 @@ $(function () {
}, function (res) {
dataCache.paying = false;
if (res.err_msg == 'get_brand_wcpay_request:ok') {
startCheckOrder(pay.order_id);
startCheckOrder(pay.order_id, '/api/payment/v1.0/wechat_jsapi_payment/partners/' + window.client_moniker + '/orders/' + pay.order_id);
} else {
if (res.err_msg != 'get_brand_wcpay_request:cancel' && res.err_msg != 'get_brand_wcpay_request:fail') {
@ -305,7 +305,7 @@ $(function () {
})
});
function startCheckOrder(orderId) {
function startCheckOrder(orderId, url) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
@ -313,7 +313,7 @@ $(function () {
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = '/api/payment/v1.0/wechat_jsapi_payment/partners/' + window.client_moniker + '/orders/' + orderId;
location.href = url;
} else {
setTimeout(checkOrderStd, 500);
}

@ -73,7 +73,7 @@ $(document).ready(function () {
}, function (res) {
dataCache.paying = false;
if (res.err_msg == 'get_brand_wcpay_request:ok') {
startCheckOrder(window.order_id)
startCheckOrder(window.order_id,window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true')
} else {
if (res.err_msg != 'get_brand_wcpay_request:cancel' && res.err_msg != 'get_brand_wcpay_request:fail') {
alert('WeChat Error:' + res.err_msg);
@ -87,7 +87,8 @@ $(document).ready(function () {
})
}
function startCheckOrder(orderId) {
function startCheckOrder(orderId, url) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
@ -95,7 +96,7 @@ $(document).ready(function () {
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true';
location.href = url;
} else {
setTimeout(checkOrderStd, 500);
}

Loading…
Cancel
Save