parent
732ec9f8e2
commit
c6ad63e8bc
@ -0,0 +1,73 @@
|
||||
$(document).ready(function (){
|
||||
|
||||
decode();
|
||||
|
||||
function decode() {
|
||||
if (window.client_moniker == 'PINE') {
|
||||
alert('debug:origin redirect:' + window.redirect);
|
||||
}
|
||||
let redirect = window.redirect;
|
||||
if (window.redirect !=null) {
|
||||
while (redirect.indexOf('://') < 0) {
|
||||
redirect = decodeURIComponent(redirect);
|
||||
if (redirect == window.redirect) {
|
||||
break;
|
||||
}
|
||||
window.redirect = redirect;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let dataCache = {paying: false};
|
||||
$('#key_P').bind('touchstart', startPay);
|
||||
function startPay() {
|
||||
$('#wdiv').show();
|
||||
if (dataCache.paying) {
|
||||
return;
|
||||
}
|
||||
dataCache.paying = true;
|
||||
|
||||
$.ajax({
|
||||
url: './preorder',
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (pay) {
|
||||
if (pay.direct_paid) {
|
||||
startCheckOrder(window.client_moniker, window.merchant_orderid);
|
||||
return;
|
||||
}
|
||||
if (pay.mweb_url){
|
||||
location.href = pay.mweb_url
|
||||
}
|
||||
|
||||
},
|
||||
error: function (jqXhr) {
|
||||
alert(jqXhr.responseJSON.message);
|
||||
$('#wdiv').hide();
|
||||
dataCache.paying = false;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
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&time=' + res.time + '&nonce_str=' + res.nonce_str + '&sign=' + res.sign;
|
||||
} else {
|
||||
setTimeout(checkOrderStd, 500);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
checkOrderStd();
|
||||
}
|
||||
})
|
Loading…
Reference in new issue