diff --git a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js index 553318f23..9f876394f 100644 --- a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js +++ b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js @@ -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); diff --git a/src/main/ui/static/templates/alipay/v1/payment.js b/src/main/ui/static/templates/alipay/v1/payment.js index c8a8dc8ef..9c78ea26e 100644 --- a/src/main/ui/static/templates/alipay/v1/payment.js +++ b/src/main/ui/static/templates/alipay/v1/payment.js @@ -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 diff --git a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js index 7e7290d52..6b74c75cf 100644 --- a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js +++ b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js @@ -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(); + } }); \ No newline at end of file diff --git a/src/main/ui/static/templates/payment/v1/payment.js b/src/main/ui/static/templates/payment/v1/payment.js index 3fc6a65d7..781f43f4b 100644 --- a/src/main/ui/static/templates/payment/v1/payment.js +++ b/src/main/ui/static/templates/payment/v1/payment.js @@ -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); } diff --git a/src/main/ui/static/templates/payment/v1/retail_jsapi.js b/src/main/ui/static/templates/payment/v1/retail_jsapi.js index d31f1e94b..ebb0efc91 100644 --- a/src/main/ui/static/templates/payment/v1/retail_jsapi.js +++ b/src/main/ui/static/templates/payment/v1/retail_jsapi.js @@ -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); }