'error', 'message' => 'Authentication failed. Invalid or missing token.']); exit; } try { // يفترض أن Click سترسل رقم هاتف المستخدم للاستعلام عنه //$clickPhone = filterRequest("click_phone"); $clickPhone = $_GET['phone_number'] ?? null; if (empty($clickPhone)) { echo json_encode(["status" => "error", "message" => "Phone number is required."]); http_response_code(400); exit; } // البحث عن فاتورة معلقة لهذا الرقم $stmt = $con->prepare( "SELECT invoice_number, amount, user_id, user_type FROM `click_invoices` WHERE `click_phone` = :click_phone AND `status` = 'pending' ORDER BY `created_at` DESC LIMIT 1" ); $stmt->execute([':click_phone' => $clickPhone]); $invoice = $stmt->fetch(PDO::FETCH_ASSOC); if ($invoice) { // تم العثور على فاتورة، يتم إرجاع تفاصيلها لنظام Click echo json_encode([ "status" => "success", "statusInvoice" => "pending", "invoice_number" => $invoice['invoice_number'], "amount" => (float) $invoice['amount'], "description" => "شحن نقاط في تطبيق انطلق", // وصف يظهر للمستخدم في تطبيق Click "biller_name" => "Intaleq App" ]); } else { // لا توجد فاتورة معلقة echo json_encode(["status" => "error", "message" => "No pending invoice found for this number."]); http_response_code(404); } } catch (Exception $e) { error_log("Error in query_click_invoice.php: " . $e->getMessage()); echo json_encode(["status" => "error", "message" => "Internal server error."]); http_response_code(500); } ?>