Update: 2026-06-26 04:04:03

This commit is contained in:
Hamza-Ayed
2026-06-26 04:04:04 +03:00
parent aea0c8e44e
commit da9e6eb981
10 changed files with 325 additions and 112 deletions

View File

@@ -0,0 +1,35 @@
<?php
require_once __DIR__ . '/../../jwtconnect.php';
$providedKey = $_SERVER['HTTP_X_S2S_API_KEY'] ?? '';
if (empty($providedKey) || $providedKey !== getenv('S2S_SHARED_KEY')) {
http_response_code(401);
printFailure("Unauthorized: Invalid or missing X-S2S-Api-Key.");
exit;
}
$passenger_id = filterRequest("passenger_id");
if (empty($passenger_id)) {
printFailure("Missing required parameter: passenger_id");
exit;
}
try {
$stmtTotalWallet = $con->prepare("
SELECT COALESCE(SUM(balance), 0)
FROM `passengerWallet`
WHERE passenger_id = :passenger_id
");
$stmtTotalWallet->execute([':passenger_id' => $passenger_id]);
$totalWallet = (float)($stmtTotalWallet->fetchColumn() ?: 0.0);
printSuccess([
"totalWallet" => $totalWallet
]);
} catch (Exception $e) {
error_log("[get_s2s_passenger_wallet] " . $e->getMessage());
printFailure("An error occurred");
}
?>