require '../core/DB.php'; $db = DB::connect(); $data = json_decode(file_get_contents("php://input"), true); $client = $db->query("SELECT * FROM clients WHERE client_key='{$data['client_key']}'")->fetch_assoc(); if (!$client) die(json_encode(['error'=>'Client không tồn tại'])); $token = 'BEO'.substr(md5(uniqid()),0,6); $db->query("INSERT INTO sessions(client_id,user_ref,amount,token) VALUES({$client['id']},'{$data['user_ref']}',{$data['amount']},'$token')"); echo json_encode([ 'pay_url' => "https://pay.beo2k.net/?token=$token" ]);