# Admin Panel

The Admin Panel provides administrative features for managing the HivePay platform.

!!!warning Admin Access Required
The Admin Panel is only available to users with admin privileges. Contact the HivePay team if you need admin access for your deployment.
!!!

---

## Accessing Admin Panel

1. Log in with an admin API key
2. Navigate to `/admin` in the dashboard
3. Admin features appear in the sidebar

---

## Merchant Management

### List All Merchants

View all registered merchants:

| Column | Description |
|--------|-------------|
| ID | Merchant identifier |
| Name | Business name |
| Hive Account | Payment destination |
| Status | Active/Inactive |
| Created | Registration date |

### Search Merchants

Use the search box to find merchants by:
- Merchant ID
- Business name
- Hive account

### Filter by Status

- **All** - Show all merchants
- **Active** - Active merchants only
- **Inactive** - Deactivated merchants

---

## Merchant Actions

### View Merchant Details

Click on a merchant to see:
- Full merchant information
- Payment statistics
- Recent payments
- Webhook configuration

### Activate/Deactivate Merchant

Toggle a merchant's active status:

1. Find the merchant in the list
2. Click the status toggle or action menu
3. Confirm the action

!!!warning Effect of Deactivation
Deactivating a merchant:
- Prevents new payment creation
- Does not affect pending payments
- Does not delete merchant data
!!!

---

## Bulk Operations

### Export Merchants

Export merchant list to CSV:

1. Apply filters if needed
2. Click **Export**
3. Choose format (CSV or JSON)
4. Download file

### Pagination

Navigate large merchant lists:
- Items per page: 20, 50, 100
- Previous/Next navigation
- Jump to specific page

---

## System Statistics

The admin dashboard shows platform-wide statistics:

| Metric | Description |
|--------|-------------|
| Total Merchants | Number of registered merchants |
| Active Merchants | Currently active merchants |
| Total Payments | All-time payment count |
| Today's Payments | Payments created today |
| Processing Volume | Total HIVE/HBD processed |

---

## Billing Overview

The admin Billing page (`/admin/billing`) summarises invoicing platform-wide.

### Aggregate Stats

| Metric | Description |
|--------|-------------|
| Merchants | Total billable merchants (excluding the HivePay Billing admin) |
| Behind | Merchants with overdue invoices or 2+ outstanding invoices |
| Total Outstanding | Sum of all unpaid invoice amounts (USD) |
| Total Paid (All Time) | Sum of all paid invoice amounts to date (USD) |
| Current-Month Volume | Running volume across all merchants |
| Current-Month Projected | Projected total billing for the running month |

### Per-Merchant Drawer

Click any merchant row to view their full billing summary — current-month volume, projected invoice, outstanding invoices with `invoicePaymentUrl`, and paid history.

### Generating Monthly Invoices

Click **Generate Invoices** to roll up a calendar month:

1. Select the month and year
2. Confirm the run
3. The system creates one invoice per merchant whose volume exceeds 0 for that month, skipping any period that already has an invoice (idempotent)

### Fee Tier Schedule

Admins can view and edit the active tier schedule from the Billing page:

- Tiers must be contiguous starting at `$0`
- Only the last tier may be open-ended (`maxVolumeCents = null`)
- Editing the schedule affects future and projected calculations — already-issued invoices are not retroactively recomputed

---

## Audit Logging

Admin actions are logged for security:

- Merchant activation/deactivation
- Settings changes
- Access timestamps

Contact the HivePay team for audit log access.

---

## Self-Hosted Deployments

If you're running your own HivePay instance:

1. Admin privileges are configured during deployment
2. See the deployment documentation for setup
3. Admin users are defined in the database seed
