# Onoxsoft Panel — WHMCS Server Module

Integrate **Onoxsoft Panel** (a modern Turkish cPanel-alternative) with your WHMCS billing system.

## Features

- One-click provisioning from WHMCS orders
- Suspend / Unsuspend / Terminate accounts
- Package upgrade / downgrade
- Password change
- Single Sign-On (SSO) — customers open the panel without re-logging in
- Admin SSO shortcut on service detail page
- Bulk disk/bandwidth usage sync (UsageUpdate cron)
- Idempotent API calls — safe to retry on timeout
- WHMCS module log integration — all errors visible in Admin → Logs → Module Log
- Turkish + English UI strings
- PHP 7.4+ compatible (WHMCS 8.x / 9.x)

## Requirements

| Requirement     | Version  |
|-----------------|----------|
| WHMCS           | 8.x / 9.x |
| PHP             | 7.4+     |
| Onoxsoft Panel      | 1.0+     |
| PHP extension   | curl     |

## Quick Start

See [INSTALL.md](INSTALL.md) for full installation instructions.

## Architecture

```
modules/servers/onox/
├── onox.php          — WHMCS module entry point (all required hooks)
├── lib/
│   ├── ApiClient.php     — HTTP client (cURL, Bearer token)
│   ├── ConfigOptions.php — Product config schema + value resolver
│   ├── ErrorHandler.php  — Structured logging via logModuleCall()
│   └── Helper.php        — Language loader, account ID resolver
├── templates/
│   ├── client_area.tpl   — Customer "Open Panel" widget (Smarty)
│   └── admin_area.tpl    — Admin shortcut buttons (Smarty)
└── lang/
    ├── english.php
    └── turkish.php
```

## Onoxsoft API Endpoints Used

| WHMCS Hook       | Onoxsoft Endpoint                              |
|------------------|--------------------------------------------|
| CreateAccount    | POST /api/v1/whmcs/account                 |
| SuspendAccount   | PATCH /api/v1/whmcs/account/{id}/suspend   |
| UnsuspendAccount | PATCH /api/v1/whmcs/account/{id}/unsuspend |
| TerminateAccount | DELETE /api/v1/whmcs/account/{id}          |
| ChangePassword   | PATCH /api/v1/whmcs/account/{id}/password  |
| ChangePackage    | PATCH /api/v1/whmcs/account/{id}/package   |
| UsageUpdate      | GET /api/v1/whmcs/usage-batch              |
| TestConnection   | GET /api/v1/health                         |
| ClientArea/Login | POST /api/v1/accounts/{id}/sso             |

## Security

- API token stored encrypted in WHMCS (never in plain text)
- Token masked in all WHMCS module log entries
- HMAC middleware on Onoxsoft side verifies webhook authenticity
- SSO tokens are single-use, 5-minute TTL, stored in cache only

## License

Proprietary — Onoxsoft Software. All rights reserved.
