require '../core/DB.php'; require '../core/Notify.php'; $cfg = require '../config/sepay.php'; if ($_SERVER['HTTP_API_KEY'] !== $cfg['api_key']) http_response_code(403); $data = json_decode(file_get_contents("php://input"), true); $db = DB::connect(); $content = $data['content']; if (!preg_match('/NAP\s?(BEO\w+)/',$content,$m)) exit; $token = $m[1]; $s = $db->query("SELECT * FROM sessions WHERE token='$token' AND status='pending'")->fetch_assoc(); if (!$s) exit; $db->query("UPDATE sessions SET status='paid', paid_at=NOW(), bank_txid='{$data['transaction_id']}' WHERE id={$s['id']}"); Notify::telegram("✅ Nạp tiền thành công\nToken: $token\nSố tiền: {$s['amount']}đ");