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
}
}