prepare("SELECT * FROM `{$prefix}billing_invoices` WHERE invoice_id = ? LIMIT 1"); if ($stmt) { $stmt->bind_param('i', $invId); $stmt->execute(); $invRow = $stmt->get_result()->fetch_assoc(); $stmt->close(); } if (!$invRow) { $message = "Invoice #{$invId} not found."; $msgType = 'error'; } elseif ($action === 'mark_paid') { $gateway = GatewayFactory::make('manual'); $captureResult = $gateway->handleCallback([ // total_due is the new schema field; amount is the legacy column during migration 'amount' => $invRow['total_due'] ?? $invRow['amount'] ?? 0, 'currency' => $invRow['currency'] ?? 'USD', ]); $captureResult['payment_method'] = 'manual'; $homeId = intval($invRow['home_id'] ?? 0); $result = $svc->processPaymentSuccess($captureResult, $invId, intval($invRow['user_id']), $homeId, $invRow); $message = $result['success'] ? "Invoice #{$invId} marked as paid (manual)." : "Failed to mark invoice #{$invId} as paid."; if (!$result['success']) $msgType = 'error'; } elseif ($action === 'cancel') { $stmt = $db->prepare("UPDATE `{$prefix}billing_invoices` SET payment_status='cancelled' WHERE invoice_id=? LIMIT 1"); if ($stmt) { $stmt->bind_param('i', $invId); $stmt->execute(); $stmt->close(); } $message = "Invoice #{$invId} cancelled."; } elseif ($action === 'refund') { $stmt = $db->prepare("UPDATE `{$prefix}billing_invoices` SET payment_status='refunded' WHERE invoice_id=? LIMIT 1"); if ($stmt) { $stmt->bind_param('i', $invId); $stmt->execute(); $stmt->close(); } $message = "Invoice #{$invId} marked as refunded."; } if (!headers_sent()) { header('Location: admin_invoices.php?msg=' . urlencode($message) . '&type=' . $msgType); mysqli_close($db); $db = null; exit; } } // Fetch invoices $invoices = []; $res = $db->query( "SELECT i.*, u.users_login, u.users_email FROM `{$prefix}billing_invoices` i LEFT JOIN `{$prefix}users` u ON u.user_id = i.user_id ORDER BY i.invoice_id DESC LIMIT 500" ); if ($res) $invoices = $res->fetch_all(MYSQLI_ASSOC); mysqli_close($db); $db = null; if (isset($_GET['msg'])) $message = $_GET['msg']; if (isset($_GET['type'])) $msgType = $_GET['type']; ?> Admin — Invoices

Admin — All Invoices

#UserServerService RatePlayersPeriod TotalStatusMethodTxn IDActions
No invoices found.