btc-pay-checker/cmd/http/views/order.hbs

104 lines
3.1 KiB
Handlebars
Raw Normal View History

2023-07-19 11:47:46 +02:00
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
.alert {
padding: 20px;
background-color: #f9edbe;
color: #856404;
border: 1px solid #ffeeba;
border-radius: 5px;
margin: 20px 0;
}
.details {
background-color: #fff;
padding: 20px;
border-radius: 5px;
margin: 20px 0;
}
.details h2 {
margin-top: 0;
}
.details p {
margin: 10px 0;
}
</style>
</head>
<body>
<div class="container">
<div class="alert">
<h1>Bitcoin Payment</h1>
<p>Please send the exact amount of Bitcoin to the provided wallet address. Your order will be processed once the
transaction is confirmed.</p>
</div>
<p id="countdown"><strong>Time Remaining:</strong></p>
<div class="details">
<h2>Order Details</h2>
<p><strong>Order ID:</strong> {{order_id}}</p>
<p><strong>Amount:</strong> {{amount}} BTC</p>
<p><strong>Wallet Address:</strong> {{wallet_address}}</p>
<p id="dueDate"><strong>Payment Due:</strong></p>
<p id="countdown"><strong>Time Remaining:</strong> </p>
</div>
</div>
<script>
// Get the expires_at time from your server and convert it to a JavaScript Date object
const dueDate = new Date("{{expires_at}}");
// Format the date and time
const formattedDate = dueDate.toLocaleDateString() + " " + dueDate.toLocaleTimeString();
// Display the result in the element with id="dueDate"
document.getElementById("dueDate").innerHTML = "<strong>Payment Due:</strong> " + formattedDate;
// Get the expires_at time from your server and convert it to a JavaScript Date object
const countDownDate = new Date("{{expires_at}}").getTime();
// Update the countdown every 1 second
const countdownInterval = setInterval(function () {
// Get today's date and time
const now = new Date().getTime();
// Find the distance between now and the count down date
const distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="countdown"
// document.getElementById("countdown").innerHTML = "<strong>Time Remaining:</strong> " + days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
document.getElementById("countdown").innerHTML = "<strong>Time Remaining:</strong> " + minutes + "m " + seconds + "s ";
// If the countdown is finished, write some text
if (distance < 0) {
clearInterval(countdownInterval);
document.getElementById("countdown").innerHTML = "EXPIRED";
}
}, 1000);
</script>
</body>
</html>