<?php
// shamcash/passenger/check_status.php
include "../../../jwtconnect.php"; 

$invoice_number = filterRequest("invoice_number");

if (empty($invoice_number)) { printFailure("invoice_number required"); exit; }

try {
    $stmt = $con->prepare("SELECT status FROM invoices_shamcash_passenger WHERE invoice_number = :inv LIMIT 1");
    $stmt->execute(['inv' => $invoice_number]);
    $res = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($res) {
        echo json_encode(["status" => "success", "invoice_status" => $res['status']]);
    } else {
        printFailure("Invoice not found");
    }
} catch (PDOException $e) {
    printFailure("Error: " . $e->getMessage());
}
?>