Initial commit - WASL Digital Wallet

This commit is contained in:
Hamza-Ayed
2026-06-20 21:55:06 +03:00
commit 7306c47368
61 changed files with 4157 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
if (!function_exists('normalize_phone_number')) {
/**
* Normalize phone numbers to E.164 format or standard format.
* For Syria: +963xxxxxxxx or standard digits.
*/
function normalize_phone_number(string $phone): string
{
// Remove non-numeric characters except +
$cleaned = preg_replace('/[^\d+]/', '', $phone);
// Remove leading double zeros
if (str_starts_with($cleaned, '00')) {
$cleaned = '+' . substr($cleaned, 2);
}
// If it starts with local 09, convert to +9639
if (str_starts_with($cleaned, '09') && strlen($cleaned) === 10) {
$cleaned = '+963' . substr($cleaned, 1);
}
return $cleaned;
}
}
if (!function_exists('hash_phone')) {
/**
* Generate SHA-256 hash of a normalized phone number for fast lookup.
*/
function hash_phone(string $phone): string
{
return hash('sha256', normalize_phone_number($phone));
}
}
if (!function_exists('hash_national_id')) {
/**
* Generate SHA-256 hash of a national ID for fast lookup.
*/
function hash_national_id(string $nationalId): string
{
return hash('sha256', trim($nationalId));
}
}