# Moving from WHMCS

Works with WHMCS 7.x and 8.x. WHMCS itself is only read, never changed, so you can import as often as
you want: do a test import first, check everything, then a final import on the day you switch.

## What is imported

Clients (with contacts and notes), logins (passwords keep working; WHMCS 7: the client login), staff
(passwords keep working, 2FA is set up again), ticket departments, statuses, tickets with replies, notes,
attachments, ratings and log, predefined replies, currencies, product groups, products with prices,
custom fields and configurable options, servers and server groups, services (with server, subscription
and field values), orders, invoices with items, transactions, credit, cancellation requests, domains with
TLD prices, affiliates, and general settings (company, automation days, affiliate program, invoice
numbering). Ids and numbers stay the same; rows created here later start at id 1,000,000.

Not imported: e-mail templates (the billing has its own), saved cards (customers pay the next invoice by
card once and can save it again; PayPal/Skrill subscriptions keep running, see step 3), WHMCS addons and
modules of other vendors.

## Step 1: database import

Fresh installation, then in the admin area **Settings → Migration**:

1. Enter the WHMCS database (host, name, user — a read-only user is enough) and the WHMCS attachments
   folder if WHMCS runs on the same server. "Save and test" shows the WHMCS version and sizes.
2. "Start import": the next cron run imports everything; progress is shown on the page.

Large databases or no cron yet: `php bin/console import:whmcs` on the server (same result, with output).
Only some parts: `--only=clients,users,services`.

## Step 2: passwords and API keys

WHMCS encrypts hosting and server passwords, password custom fields (e.g. root passwords), payment
gateway and registrar settings with its own key. They are exported by WHMCS itself:

```
cd /path/to/whmcs
php /path/to/billing/tools/whmcs-export.php | php /path/to/billing/bin/console import:whmcs-secrets
```

WHMCS on another server: copy `tools/whmcs-export.php` into the WHMCS folder there and pipe over SSH:

```
ssh root@whmcs-server 'cd /path/to/whmcs && php whmcs-export.php' | php bin/console import:whmcs-secrets
```

Use the PHP that runs WHMCS (it needs the ionCube loader). Nothing is written to disk. Then check
**Payment gateways** and **Domains → Registrars** (imported disabled) and enable them. Servers without a
usable API key are listed; for cPanel create a WHM API token.

## Step 3: switch

1. Put WHMCS into maintenance mode, run the import (step 1) and step 2 a last time.
2. Point the billing domain (or the old WHMCS domain) to the new installation. If the old WHMCS host name
   is not this installation's domain, add it to `legacy_hosts` in config.php: old links (invoices,
   tickets) are redirected, payment notifications to the old WHMCS callback URLs keep working. If the
   old host must stay on the old server, use the bridge from **Settings → Migration**.
3. Change the webhook URLs in Stripe / PayPal (shown under Settings → Migration).
4. Switch e-mail piping to `pipe.php`, disable the WHMCS cron.
5. Check **Billing → Subscriptions** and **Reports → Gateways** in the first days.

Old PayPal Standard / Skrill subscriptions keep paying: their notifications go to the old WHMCS URLs,
which the billing answers (step 3.2).
