Update codebase

This commit is contained in:
Hamza-Ayed
2026-08-09 16:56:13 +03:00
parent 95e2e4f35d
commit b64debaa88
1058 changed files with 164327 additions and 113928 deletions
@@ -12,7 +12,7 @@ try {
exit;
}
$stmt = $con->prepare("SELECT status FROM click_invoices WHERE invoice_number = :invoice_number LIMIT 1");
$stmt = $con->prepare("SELECT status FROM cliq_invoices WHERE invoice_number = :invoice_number LIMIT 1");
$stmt->execute([':invoice_number' => $invoiceNumber]);
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -38,7 +38,7 @@ try {
// 1. البحث عن الفاتورة وتحديث حالتها
$stmt = $con->prepare(
"UPDATE `click_invoices`
"UPDATE `cliq_invoices`
SET `status` = 'completed', `click_transaction_id` = :transaction_id
WHERE `invoice_number` = :invoice_number AND `status` = 'pending'"
);
@@ -52,7 +52,7 @@ try {
$invoiceId = $con->lastInsertId(); // ملاحظة: هذا قد لا يعمل دائماً مع UPDATE، الأفضل جلب الـ ID
// جلب ID الفاتورة بعد التأكد من وجودها
$idStmt = $con->prepare("SELECT id FROM `click_invoices` WHERE `invoice_number` = :invoice_number");
$idStmt = $con->prepare("SELECT id FROM `cliq_invoices` WHERE `invoice_number` = :invoice_number");
$idStmt->execute([':invoice_number' => $invoiceNumber]);
$invoiceRecord = $idStmt->fetch();
$invoiceId = $invoiceRecord['id'];
@@ -7,11 +7,20 @@ try {
$userId = filterRequest("user_id");
$userType = filterRequest("user_type");
$amount = filterRequest("amount");
$cliqPhone = filterRequest("cliq_phone");
$cliqPhone = filterRequest("cliq_phone") ?: filterRequest("click_phone");
$phone = filterRequest("phone");
if (empty($userId) || empty($userType) || !is_numeric($amount) || $amount <= 0 || empty($cliqPhone)) {
echo json_encode(["status" => "failure", "message" => "Invalid input provided."]);
echo json_encode([
"status" => "failure",
"message" => "Invalid input provided.",
"debug" => [
"userId" => $userId,
"userType" => $userType,
"amount" => $amount,
"cliqPhone" => $cliqPhone
]
]);
exit;
}
@@ -37,14 +46,12 @@ try {
$upd = $con->prepare("
UPDATE cliq_invoices
SET amount = :amount,
phone = :phone,
cliq_phone = :cliq_phone,
updated_at = NOW()
WHERE id = :id
");
$upd->execute([
':amount' => $amount,
':phone' => $phone ?: null,
':cliq_phone' => $cliqPhone,
':id' => $existing['id'],
]);
@@ -62,15 +69,14 @@ try {
$ins = $con->prepare("
INSERT INTO cliq_invoices
(invoice_number, user_id, user_type, phone, amount, cliq_phone, status, created_at, updated_at)
(invoice_number, user_id, user_type, amount, cliq_phone, status, created_at, updated_at)
VALUES
(:invoice_number, :user_id, :user_type, :phone, :amount, :cliq_phone, 'pending', NOW(), NOW())
(:invoice_number, :user_id, :user_type, :amount, :cliq_phone, 'pending', NOW(), NOW())
");
$ins->execute([
':invoice_number' => $invoiceNumber,
':user_id' => $userId,
':user_type' => $userType,
':phone' => $phone ?: null,
':amount' => $amount,
':cliq_phone' => $cliqPhone
]);
@@ -32,7 +32,7 @@ try {
// البحث عن فاتورة معلقة لهذا الرقم
$stmt = $con->prepare(
"SELECT invoice_number, amount, user_id, user_type
FROM `click_invoices`
FROM `cliq_invoices`
WHERE `click_phone` = :click_phone AND `status` = 'pending'
ORDER BY `created_at` DESC LIMIT 1"
);