<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } require_once DASHBOARD_ROOT . '/core/payment_client.php'; $configured = PaymentServerClient::isConfigured(); $connected = false; $totals = []; $wallets = []; $etransfers = []; $ledger = []; $errMsg = ''; $engineHealth = ['reachable' => false]; if ($configured) { $totalsResult = PaymentServerClient::getTotals(); if ($totalsResult['ok'] ?? false) { $connected = true; $totals = $totalsResult['data'] ?? []; $wallets = PaymentServerClient::getWallets()['data'] ?? []; $etransfers = PaymentServerClient::getEtransfers('pending', 20)['data'] ?? []; $ledger = PaymentServerClient::getLedger(1, 10)['data'] ?? []; } else { $errMsg = $totalsResult['error'] ?? 'Payment server unreachable'; } } else { $errMsg = 'Payment server not configured'; } try { $engineCheck = @file_get_contents('http://127.0.0.1/api/system/engine_status.php', false, stream_context_create(['http' => ['timeout' => 2]])); if ($engineCheck) { $engineData = json_decode($engineCheck, true); if ($engineData && ($engineData['ok'] ?? false)) { $engineHealth = ['reachable' => true, 'engine' => $engineData['engine'] ?? [], 'payment' => $engineData['payment'] ?? []]; } } } catch (\Throwable $e) {} $sub = $_GET['sub'] ?? 'overview'; $validSubs = ['overview', 'wallets', 'etransfers', 'ledger']; if (!in_array($sub, $validSubs)) $sub = 'overview'; 