إضافة كود بوابة الواتساب وملفات التهيئة والتحكم في الطريقة

This commit is contained in:
Hamza-Ayed
2026-05-23 16:53:52 +03:00
parent 436fc2efa8
commit cca842f313
8 changed files with 656 additions and 37 deletions

View File

@@ -102,18 +102,23 @@ $otpCode = str_pad((string) random_int(0, 9999), 4, '0', STR_PAD_LEFT);
// Determine delivery method
$method = 'flash_call'; // Default fallback
$whatsappAvailable = false;
$methodInput = isset($input['method']) ? strtolower(trim($input['method'])) : null;
try {
$whatsappAvailable = WhatsAppClient::isAvailable($phone);
} catch (\Throwable $e) {
error_log('WhatsApp check failed: ' . $e->getMessage());
}
if ($whatsappAvailable) {
$method = 'whatsapp';
if ($methodInput && in_array($methodInput, ['flash_call', 'sms', 'whatsapp', 'telegram'], true)) {
$method = $methodInput;
} else {
$method = ($deviceType === 'ios') ? 'sms' : 'flash_call';
$whatsappAvailable = false;
try {
$whatsappAvailable = WhatsAppClient::isAvailable($phone);
} catch (\Throwable $e) {
error_log('WhatsApp check failed: ' . $e->getMessage());
}
if ($whatsappAvailable) {
$method = 'whatsapp';
} else {
$method = ($deviceType === 'ios') ? 'sms' : 'flash_call';
}
}
$db = Database::getInstance();