Update OTP image generation to 3 digits, no caption, random labels and fonts, big numbers

This commit is contained in:
Hamza-Ayed
2026-05-23 18:15:51 +03:00
parent 30de96d481
commit 58e8128b65
2 changed files with 52 additions and 20 deletions

View File

@@ -97,8 +97,8 @@ if (!$rateLimit->checkIp($clientIp, 'request-otp', 30, 60)) {
exit;
}
// Generate 4-digit OTP (cryptographically secure)
$otpCode = str_pad((string) random_int(0, 9999), 4, '0', STR_PAD_LEFT);
// Generate 3-digit OTP (cryptographically secure)
$otpCode = str_pad((string) random_int(0, 999), 3, '0', STR_PAD_LEFT);
// Determine delivery method
$method = 'flash_call'; // Default fallback
@@ -180,13 +180,13 @@ try {
}
// Message caption / body
$messageText = "رمز التحقق الخاص بك هو: " . $otpCode . "\nيرجى إدخاله في التطبيق لإكمال العملية.";
$messageText = "رمز التحقق الخاص بك هو: " . $otpCode;
$sent = false;
try {
if ($imagePngBase64) {
// Send premium image message with caption
$sent = WhatsAppClient::sendMessage($phone, "رمز التحقق الخاص بك هو: " . $otpCode, $imagePngBase64);
// Send premium image message with NO caption
$sent = WhatsAppClient::sendMessage($phone, "", $imagePngBase64);
} else {
// Fallback to text message
$sent = WhatsAppClient::sendMessage($phone, $messageText);