Compare commits
2
Commits
432245a688
...
ebd6f3734a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebd6f3734a | ||
|
|
8d8c3a3817 |
@@ -174,10 +174,26 @@ function sendNabehOtp(string $receiver, string $otp, string $method = '', string
|
|||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$decoded = json_decode($response, true);
|
$decoded = json_decode($response, true);
|
||||||
if ($decoded && (($decoded['success'] ?? false) || ($decoded['status'] ?? '') === 'success')) {
|
error_log("ℹ️ [Nabeh OTP Response] " . $response);
|
||||||
return true;
|
if ($decoded) {
|
||||||
|
$statusStr = strtolower((string)($decoded['status'] ?? ''));
|
||||||
|
$msgStr = strtolower((string)($decoded['message'] ?? ''));
|
||||||
|
if (
|
||||||
|
!empty($decoded['success']) ||
|
||||||
|
in_array($statusStr, ['success', 'ok', 'true', '200', 'sent', 'queued', '1'], true) ||
|
||||||
|
($decoded['status'] ?? false) === true ||
|
||||||
|
($decoded['code'] ?? 0) === 200 ||
|
||||||
|
!empty($decoded['message_id']) ||
|
||||||
|
!empty($decoded['id']) ||
|
||||||
|
!empty($decoded['token']) ||
|
||||||
|
strpos($msgStr, 'success') !== false ||
|
||||||
|
strpos($msgStr, 'sent') !== false ||
|
||||||
|
strpos($msgStr, 'تم') !== false
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$msg = "❌ [Nabeh OTP] API returned failure response: " . $response;
|
$msg = "❌ [Nabeh OTP] API returned failure/unrecognized response: " . $response;
|
||||||
error_log($msg);
|
error_log($msg);
|
||||||
} else {
|
} else {
|
||||||
$msg = "❌ [Nabeh OTP] Empty response from cURL.";
|
$msg = "❌ [Nabeh OTP] Empty response from cURL.";
|
||||||
@@ -217,7 +233,7 @@ function sendIntaleqOtp(string $receiver, string &$otp, string $method = 'whatsa
|
|||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$decoded = json_decode($response, true);
|
$decoded = json_decode($response, true);
|
||||||
if ($decoded && ($decoded['success'] ?? false)) {
|
if ($decoded && (!empty($decoded['success']) || ($decoded['status'] ?? '') === 'success')) {
|
||||||
if (isset($decoded['otp'])) {
|
if (isset($decoded['otp'])) {
|
||||||
$otp = (string)$decoded['otp'];
|
$otp = (string)$decoded['otp'];
|
||||||
}
|
}
|
||||||
@@ -225,9 +241,8 @@ function sendIntaleqOtp(string $receiver, string &$otp, string $method = 'whatsa
|
|||||||
}
|
}
|
||||||
$msg = "❌ [Intaleq OTP] API returned failure response: " . $response;
|
$msg = "❌ [Intaleq OTP] API returned failure response: " . $response;
|
||||||
error_log($msg);
|
error_log($msg);
|
||||||
echo $msg; // Temporarily echo the raw error so we can see it in the app logs!
|
|
||||||
} else {
|
} else {
|
||||||
echo "❌ [Intaleq OTP] Empty response or cURL failed.";
|
error_log("❌ [Intaleq OTP] Empty response or cURL failed.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user