mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:34:39 -04:00
add timer
This commit is contained in:
parent
2be83cb897
commit
3de0e6367f
@ -85,6 +85,13 @@ class Blockonomics implements MethodInterface
|
|||||||
return "Something went wrong";
|
return "Something went wrong";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTenMinutesCountDownEndTime()
|
||||||
|
{
|
||||||
|
$duration_in_sec = 10 * 60; // 10 minutes in seconds
|
||||||
|
$current_time = time();
|
||||||
|
return $current_time + $duration_in_sec;
|
||||||
|
}
|
||||||
|
|
||||||
public function getBTCPrice()
|
public function getBTCPrice()
|
||||||
{
|
{
|
||||||
$currency_code = $this->driver_class->client->getCurrencyCode();
|
$currency_code = $this->driver_class->client->getCurrencyCode();
|
||||||
@ -105,6 +112,7 @@ class Blockonomics implements MethodInterface
|
|||||||
$data['btc_amount'] = round($btc_amount, 10);
|
$data['btc_amount'] = round($btc_amount, 10);
|
||||||
$data['btc_address'] = $this->getBTCAddress();
|
$data['btc_address'] = $this->getBTCAddress();
|
||||||
$data['invoice_id'] = $this->invoice_id;
|
$data['invoice_id'] = $this->invoice_id;
|
||||||
|
$data['end_time'] = $this->getTenMinutesCountDownEndTime();
|
||||||
return render('gateways.blockonomics.pay', $data);
|
return render('gateways.blockonomics.pay', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,36 @@
|
|||||||
<input name="btcAmount" value="BTC {{$btc_amount}} ≈ {{$amount}} {{$currency}}" readonly>
|
<input name="btcAmount" value="BTC {{$btc_amount}} ≈ {{$amount}} {{$currency}}" readonly>
|
||||||
<div>To this bitcoin address</div>
|
<div>To this bitcoin address</div>
|
||||||
<input name="btcAddress" value="{{$btc_address}}" readonly>
|
<input name="btcAddress" value="{{$btc_address}}" readonly>
|
||||||
|
<div id="countdown"></div>
|
||||||
|
<script>
|
||||||
|
// Get the end time as a Unix timestamp (seconds)
|
||||||
|
var endTimeUnix = {{ $end_time }};
|
||||||
|
console.log("End time (Unix timestamp):", endTimeUnix); // For debugging
|
||||||
|
|
||||||
|
// Convert Unix timestamp to milliseconds for JavaScript Date
|
||||||
|
var countDownDate = endTimeUnix * 1000;
|
||||||
|
|
||||||
|
function updateCountdown() {
|
||||||
|
var now = new Date().getTime();
|
||||||
|
var distance = countDownDate - now;
|
||||||
|
|
||||||
|
if (distance < 0) {
|
||||||
|
document.getElementById("countdown").innerHTML = "EXPIRED";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||||
|
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||||
|
|
||||||
|
document.getElementById("countdown").innerHTML =
|
||||||
|
"0" + minutes + ":" +
|
||||||
|
(seconds < 10 ? "0" : "") + seconds + " min";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update immediately and then every second
|
||||||
|
updateCountdown();
|
||||||
|
var x = setInterval(updateCountdown, 1000);
|
||||||
|
</script>
|
||||||
|
|
||||||
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
|
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
|
||||||
@csrf
|
@csrf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user