<?php
require_once __DIR__.'/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
require_once __DIR__.'/../../engine/Logger.php';
require_once __DIR__.'/../../engine/SudannaPayEngine.php';
$ctx = Kernel::handle(['auth' => true]);
$u   = $ctx['user'];
$limit  = min((int)($_GET['limit']??20),50);
$type   = preg_replace('/[^a-z_]/','',$_GET['type']??'');
$result = SudannaPayEngine::getHistory((int)$u['id'], $limit, $type?:null);
echo json_encode(['ok'=>true,'data'=>$result], JSON_UNESCAPED_UNICODE);
