Linting
parent
7c7af39f4b
commit
4f68edb3c7
|
@ -435,47 +435,47 @@ $(document).ready(function (){
|
||||||
|
|
||||||
// checkout-blockonomics page (blockonomics_payment route) handling START ***
|
// checkout-blockonomics page (blockonomics_payment route) handling START ***
|
||||||
if($('#blockonomics_div').length > 0){
|
if($('#blockonomics_div').length > 0){
|
||||||
var orderid = $('#blockonomics_div').data('orderid') || '';
|
var orderid = $('#blockonomics_div').data('orderid') || '';
|
||||||
var timestamp = $('#blockonomics_div').data('timestamp') || -1;
|
var timestamp = $('#blockonomics_div').data('timestamp') || -1;
|
||||||
var address = $('#blockonomics_div').data('address') || '';
|
var address = $('#blockonomics_div').data('address') || '';
|
||||||
var blSocket = new WebSocket('wss://www.blockonomics.co/payment/' + address + '?timestamp=' + timestamp);
|
var blSocket = new WebSocket('wss://www.blockonomics.co/payment/' + address + '?timestamp=' + timestamp);
|
||||||
blSocket.onopen = function (msg){
|
blSocket.onopen = function (msg){
|
||||||
};
|
};
|
||||||
var timeOutMinutes = 10;
|
var timeOutMinutes = 10;
|
||||||
setTimeout(function(){
|
setTimeout(function (){
|
||||||
$('#blockonomics_waiting').html('<b>Payment expired</b><br><br><b><a href=\'/checkout/payment\'>Click here</a></b> to try again.<br><br>If you already paid, your order will be processed automatically.');
|
$('#blockonomics_waiting').html('<b>Payment expired</b><br><br><b><a href=\'/checkout/payment\'>Click here</a></b> to try again.<br><br>If you already paid, your order will be processed automatically.');
|
||||||
showNotification('Payment expired', 'danger');
|
showNotification('Payment expired', 'danger');
|
||||||
blSocket.close();
|
blSocket.close();
|
||||||
}, 1000 * 60 * timeOutMinutes);
|
}, 1000 * 60 * timeOutMinutes);
|
||||||
|
|
||||||
var countdownel = $('#blockonomics_timeout');
|
var countdownel = $('#blockonomics_timeout');
|
||||||
var endDatebl = new Date((new Date()).getTime() + 1000 * 60 * timeOutMinutes);
|
var endDatebl = new Date((new Date()).getTime() + 1000 * 60 * timeOutMinutes);
|
||||||
var blcountdown = setInterval(function(){
|
var blcountdown = setInterval(function (){
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
var distance = endDatebl - now;
|
var distance = endDatebl - now;
|
||||||
if(distance < 0){
|
if(distance < 0){
|
||||||
clearInterval(blcountdown);
|
clearInterval(blcountdown);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||||
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||||
countdownel.html(minutes + 'm ' + seconds + 's');
|
countdownel.html(minutes + 'm ' + seconds + 's');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
blSocket.onmessage = function (msg){
|
blSocket.onmessage = function (msg){
|
||||||
var data = JSON.parse(msg.data);
|
var data = JSON.parse(msg.data);
|
||||||
if((data.status === 0) || (data.status === 1) || (data.status === 2)){
|
if((data.status === 0) || (data.status === 1) || (data.status === 2)){
|
||||||
// redirect to order confirmation page
|
// redirect to order confirmation page
|
||||||
var orderMessage = '<br>View <b><a href="/payment/' + orderid + '">Order</a></b>';
|
var orderMessage = '<br>View <b><a href="/payment/' + orderid + '">Order</a></b>';
|
||||||
$('#blockonomics_waiting').html('Payment detected (<b>' + data.value / 1e8 + ' BTC</b>).' + orderMessage);
|
$('#blockonomics_waiting').html('Payment detected (<b>' + data.value / 1e8 + ' BTC</b>).' + orderMessage);
|
||||||
showNotification('Payment detected', 'success');
|
showNotification('Payment detected', 'success');
|
||||||
$('#cart-count').html('0');
|
$('#cart-count').html('0');
|
||||||
blSocket.close();
|
blSocket.close();
|
||||||
$.ajax({ method: 'POST', url: '/product/emptycart' }).done(function(){
|
$.ajax({ method: 'POST', url: '/product/emptycart' }).done(function (){
|
||||||
window.location.replace('/payment/' + orderid);
|
window.location.replace('/payment/' + orderid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// checkout-blockonomics page (blockonomics_payment route) handling *** END
|
// checkout-blockonomics page (blockonomics_payment route) handling *** END
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue