added base64 for safe-url format and added pwa for phone

This commit is contained in:
Hafifie PKB
2024-12-10 19:24:16 +08:00
parent fa08131cb3
commit 01cee71713
3 changed files with 94 additions and 9 deletions
+20
View File
@@ -279,9 +279,29 @@ class BillplzService
}
protected function isBase64($string) {
if($this->isBase64UrlSafe($string)){
return true;
}
if (preg_match('/^[A-Za-z0-9+\/=]+$/', $string)) {
return base64_encode(base64_decode($string, true)) === $string;
}
return false;
}
protected function isBase64UrlSafe($string) {
// Convert URL-safe Base64 to standard Base64
$standardBase64 = str_replace(['-', '_'], ['+', '/'], $string);
// Add padding if necessary
$remainder = strlen($standardBase64) % 4;
if ($remainder > 0) {
$standardBase64 .= str_repeat('=', 4 - $remainder);
}
// Attempt to decode the string
$decoded = base64_decode($standardBase64, true);
return $decoded !== false; // Return true if it successfully decodes
}
}
+16 -6
View File
@@ -2,11 +2,15 @@ let checked_rad = () =>{
const radios = document.querySelectorAll('input[name="radpembayaran"]');
// let rad_payment = document.getElementById('radpembayaran');
let btn_payment = document.getElementById('bayarsbmt');
let btn_payment_phone = document.getElementById('bayarsbmt-phone');
if(radios.checked){
btn_payment.disabled = false;
btn_payment_phone.disabled = false;
}else{
btn_payment.disabled = true;
btn_payment_phone.disabled = true;
}
}
@@ -15,9 +19,11 @@ const radios = document.querySelectorAll('input[name="radpembayaran"]');
radios.forEach((radio) => {
radio.addEventListener('change', function () {
let btn_payment = document.getElementById('bayarsbmt');
let btn_payment_phone = document.getElementById('bayarsbmt-phone');
let content1 = document.getElementById('divpkb');
let content2 = document.getElementById('divkopkb');
let whole_total = document.getElementById('spanjumlah');
let whole_total_phone = document.getElementById('spanjumlah-phone');
let inputs = document.querySelectorAll(`#div${this.value} input[type="number"]`);
let values = Array.from(inputs).map(input => parseFloat(input.value) || 0).reduce((sum,value) => sum + value, 0);
@@ -31,10 +37,12 @@ radios.forEach((radio) => {
inputenabled.forEach(input =>{
input.disabled = false;
});
content1.classList.add('blurred');
content2.classList.remove('blurred');
content1?.classList.add('blurred');
content2?.classList.remove('blurred');
btn_payment.disabled = false;
whole_total.innerHTML = values + 1;
btn_payment_phone.disabled = false;
whole_total.innerHTML = formatter.format(values + 1);
whole_total_phone.innerHTML = formatter.format(values + 1);
}else{
let inputsdisabled = document.querySelectorAll(`#divkopkb input:not([type="radio"])`);
@@ -46,10 +54,12 @@ radios.forEach((radio) => {
inputenabled.forEach(input =>{
input.disabled = false;
});
content2.classList.add('blurred');
content1.classList.remove('blurred');
content2?.classList.add('blurred');
content1?.classList.remove('blurred');
btn_payment.disabled = false;
whole_total.innerHTML = values + 1;
btn_payment_phone.disabled = false;
whole_total.innerHTML = formatter.format(values + 1);
whole_total_phone.innerHTML = formatter.format(values + 1);
}
}
@@ -15,6 +15,26 @@
opacity: 0.5; /* Slight transparency */
/*pointer-events: none; */
}
@media (max-width: 768px) { /* Target screens smaller than tablets */
.sticky-footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: white; /* Adjust to match your theme */
height:100px;
box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); /* Optional shadow for better visibility */
padding: 10px; /* Add some padding for spacing */
z-index: 1000; /* Ensure it stays above other content */
text-align: center; /* Center align buttons */
}
.sticky-footer .btn {
width: 45%; /* Ensure buttons fit well side-by-side */
margin: 0 5px; /* Add spacing between buttons */
}
}
</style>
<title>Bayar SAG | Portal Pelanggan</title>
@@ -32,8 +52,8 @@
</div>
<div class="d-flex">
<div class="col-9">
<div class="d-md-flex">
<div class="col-sm-12 col-md-9">
@if($list_pkb)
<div class="col-md-11 col-sm-12 mb-4" id="divpkb">
<div class="card shadow">
@@ -203,7 +223,7 @@
@endif
</div>
<div class="col-3">
<div class="d-none d-sm-none d-md-block col-xl-3">
<div class="col-md-12">
<div class="card shadow">
<div class="card-header mb-4 bg-dark border-0">
@@ -255,6 +275,40 @@
</div>
</div>
</div>
</div>
<!-- Sticky Footer for Mobile View -->
<div class="sticky-footer d-sm-block d-md-none">
<div>
<div class="d-sm-flex">
<div class="font-weight-light small d-flex">
<div class="col-3">
<label style="text-transform: uppercase; text-align: center;font-size: 10px;"><strong>Fi Pengurusan</strong></label>
</div>
<div class="col-3">
<span class="text-primary"><strong>RM<span>1.00</span></strong></span>
</div>
<div class="col-3">
<label style="text-transform: uppercase; text-align: center;font-size: 10px;"><strong>Jumlah Keseluruhan</strong></label>
</div>
<div class="col-3">
<span class="text-primary"><strong>RM<span id="spanjumlah-phone">1.00</span></strong></span>
</div>
</div>
</div>
</div>
<div class="">
<a href="{{ route('home') }}" type="button" class="btn btn-danger">Batal</a>
@if($totalupahasal == 1.00 || $errorcount > 0)
<button type="submit" id="bayarsbmt-phone" class="btn btn-primary" disabled onclick="loadingbtn();">Bayar</button>
@else
<button type="submit" id="bayarsbmt-phone" class="btn btn-primary" onclick="loadingbtn();">Bayar</button>
@endif
</div>
</div>
</form>
</div>
<script src="{{ asset('js/miscellaneous/cart.js') }}"></script>
@@ -507,6 +561,7 @@
$("#spanbayaranarrahn").text(sumarrahn.toFixed(2));
$("#spanbayarantawarruq").text(sumtawarruq.toFixed(2));
$('#spanjumlah').text(formatter.format(sum + 1));
$('#spanjumlah-phone').text(formatter.format(sum + 1));
}
if (document.addEventListener) {