<?php
declare(strict_types=1);

require_once dirname(__DIR__) . '/_admin_auth.php';

golder_require_method('GET');
golder_api_admin_auth();
$master = golder_master_pdo();
golder_ensure_payment_tables($master);

$status = trim((string)($_GET['status'] ?? ''));
$sql = 'SELECT * FROM payment_requests';
$params = [];
if ($status !== '') {
    $sql .= ' WHERE status = :st';
    $params[':st'] = $status;
}
$sql .= ' ORDER BY created_at DESC LIMIT 200';
$st = $master->prepare($sql);
$st->execute($params);
$rows = $st->fetchAll() ?: [];

golder_json_response(['status' => 'ok', 'items' => $rows]);


