| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wifi-wcfs/public/api/ |
Upload File : |
<?php
require __DIR__ . '/../../lib.php';
try {
$input = json_decode(file_get_contents('php://input'), true) ?: [];
$planId = (string) ($input['plan_id'] ?? '');
$plan = find_plan($planId);
if (!$plan) {
json_response(['error' => 'Unknown Wi-Fi pass.'], 400);
}
$cfg = config();
$product = [
'name' => $plan['name'],
'price' => (float) $plan['price'],
'quantity' => 1,
];
$session = north_request('POST', '/api/sessions', [], [
'checkoutId' => $cfg['north_checkout_id'],
'profileId' => $cfg['north_profile_id'],
'amount' => (float) $plan['price'],
'products' => [$product],
]);
$sessionToken = $session['sessionToken'] ?? $session['token'] ?? null;
if (!$sessionToken) {
throw new RuntimeException('North response did not include a session token.');
}
$stmt = db()->prepare(
'INSERT INTO checkout_sessions
(session_token, plan_id, client_mac, client_ip, ruckus_sip, start_url, status, amount, created_at)
VALUES
(:session_token, :plan_id, :client_mac, :client_ip, :ruckus_sip, :start_url, "created", :amount, :created_at)'
);
$stmt->execute([
':session_token' => $sessionToken,
':plan_id' => $plan['id'],
':client_mac' => $input['client_mac'] ?? null,
':client_ip' => $input['client_ip'] ?? null,
':ruckus_sip' => $input['sip'] ?? null,
':start_url' => $input['start_url'] ?? null,
':amount' => (float) $plan['price'],
':created_at' => gmdate('c'),
]);
json_response([
'localSessionId' => db()->lastInsertId(),
'sessionToken' => $sessionToken,
]);
} catch (Throwable $e) {
json_response(['error' => $e->getMessage()], 500);
}