-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecent_transactions.php
More file actions
39 lines (33 loc) · 927 Bytes
/
recent_transactions.php
File metadata and controls
39 lines (33 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/db.php';
require_once __DIR__ . '/auth.php';
require_login();
header('Content-Type: application/json');
try {
$pdo = db();
$limit = (int)($_GET['limit'] ?? 10);
if ($limit <= 0) $limit = 10;
if ($limit > 50) $limit = 50;
$stmt = $pdo->prepare("
SELECT
tx_hash,
action_type,
invoice_ref,
amount_lovelace,
asset_unit,
status,
created_at
FROM invoice_transactions
ORDER BY id DESC
LIMIT ?
");
$stmt->bindValue(1, $limit, PDO::PARAM_INT);
$stmt->execute();
echo json_encode(['ok' => true, 'transactions' => $stmt->fetchAll()]);
} catch (Throwable $e) {
error_log('recent_transactions error: ' . $e->getMessage());
http_response_code(500);
echo json_encode(['ok' => false, 'error' => 'Server error.']);
}