# Connect to WHMCS: move your customers to PNLCS

> **Writer's brief**
> - **Audience:** a reseller already running WHMCS who wants to switch.
> - **Promise:** "Bring your customers, domains and services over from WHMCS in an afternoon, without touching your WHMCS data."
> - **Keywords:** migrate from WHMCS, WHMCS alternative Kenya, import WHMCS clients, WHMCS to PNLCS.
> - **Call to action:** run a preview import; nothing is saved until you press Run import.
> - **Reassure early:** WHMCS is only read, never changed; you can import again.

PNLCS connects **directly to your WHMCS database** and imports **clients**,
**domains** and **services**. It only reads: nothing in WHMCS is changed or
deleted, so WHMCS keeps running while you move.

**You need:** your WHMCS database details, and remote access to that database
from the PNLCS server. See [Before you start](00-before-you-start.md#moving-from-whmcs).

## What comes over, and what doesn't

| Imported | Not imported |
|---|---|
| Clients, with their custom fields | Invoices and payment history |
| Domains, linked to their client | Support tickets |
| Services (hosting accounts), linked to client, package and server | Products and prices: create them in PNLCS first |
| | Client passwords (see below) |

> ⚠️ **Passwords can't be copied.** WHMCS stores them in a form PNLCS can't
> read. Imported clients sign in the first time with **Forgot password** on
> the client login. Tell your customers before you switch (an email template
> is a good addition here).

No emails are sent to customers during the import.

## Before you import

1. **Create your packages** in PNLCS with the same names as in WHMCS
   ([Creating packages](01-creating-packages.md)). Services are matched to
   packages by name, or by a mapping you choose.
2. **Add your servers** under **Setup → Servers** with the **same hostname**
   as in WHMCS. Services are linked to servers by hostname, then by name.
3. **Set up domain pricing** ([Domain pricing](03-domain-pricing.md)) so
   imported domains renew at your prices.
4. **Allow the connection** to the WHMCS database from the PNLCS server's IP
   (in cPanel: **Remote MySQL**). A read-only database user is best.

## Step 1: connect

1. Go to **Utilities → Import WHMCS**.
2. Under **WHMCS database connection** enter:
   - **Name**: any label, e.g. "Old WHMCS";
   - **Host** and **Port** (usually `3306`);
   - **Database**, **Username**, **Password**;
   - **Table prefix**: `tbl` unless you changed it.
3. Press **Test connection**. It should say *"Connection works — N tables found."*
4. Press **Save and continue**.

> 📸 **IMAGE 1: WHMCS connection form**
> - **Show:** Utilities → Import WHMCS, the connection form and the success message.
> - **Highlight:** Test connection and the green message.
> - **Blur:** host, database name, username, password.
> - **File:** `images/connect-whmcs/01-connection.png`
> - **Alt text:** "WHMCS database connection form with a successful connection test"

## Step 2: import clients first

Import in this order: **clients → domains → services**. Domains and services
find their owner by the client's email, so the clients must already be there.

1. In the mapper, set **Import type** to **Clients**.
2. **Import mode**:
   - **Add new**: only creates clients that aren't in PNLCS yet. Use this the first time.
   - **Add and update**: also refreshes clients already imported.
   - **Update only**: changes existing clients, adds none.
3. **Match key**: how a WHMCS client is recognised in PNLCS. Email is the usual choice.
4. **Field mapping**: each WHMCS field is matched to a PNLCS field. Most are
   filled in for you (marked *suggested*). Choose **Skip** for anything you
   don't want.
5. Optional:
   - **Constant values**: give every imported client the same value, such as a client group.
   - **Regex transforms**: clean values up, e.g. keep only the digits of a phone number.
6. Press **Preview**. You see what will be imported and a **Problems found**
   list (missing emails, invalid countries...). Fix them, or skip those fields.
7. Press **Run import**.

> 📸 **IMAGE 2: Field mapping** (GIF suggested: mapping, then preview)
> - **Show:** the mapper for Clients with suggested mappings.
> - **Highlight:** Import type, Import mode, a *suggested* mapping and the Preview button.
> - **Blur:** any real client data in the preview.
> - **File:** `images/connect-whmcs/02-mapping.png`
> - **Alt text:** "Mapping WHMCS client fields to PNLCS fields"

> 💡 **Save mapping** stores your choices, so the next import (domains, or a
> final top-up on switch-over day) takes one click.

## Step 3: import domains, then services

Repeat step 2 with **Import type** set to **Domains**, then **Services**.

- **Domains** are linked to the client whose email matches the WHMCS owner.
- **Services** have a **Product mapping**: match each WHMCS product to a PNLCS
  package, or use **Match by name**. A service whose product or server isn't
  found is still imported, without that link. You can set it later on the
  service.

## Step 4: check the import log

Each run is listed under **Recent imports**. **View** shows how many records
were fetched, added, updated, skipped, and the errors with the WHMCS ID and
email of each problem record.

> 📸 **IMAGE 3: Import log**
> - **Show:** an import log with counts and one skipped record.
> - **Blur:** emails.
> - **File:** `images/connect-whmcs/03-import-log.png`
> - **Alt text:** "Import log showing added, updated and skipped records"

## Switching over

A calm way to move:

1. Import everything, and check a few customers, domains and services in PNLCS.
2. Pick a switch-over day. Run the imports once more with **Add and update**
   to pick up anything new.
3. Stop billing in WHMCS (turn off its automation) so customers aren't invoiced twice.
4. Point your billing links and website buttons at PNLCS.
5. Email customers: the new address, and **Forgot password** to set a password.

> ⚠️ Don't leave both systems invoicing the same customers. Choose one day
> and switch billing over.

## Scripts and integrations that used WHMCS's API

PNLCS has an API that uses the **same action names as WHMCS** (`addclient`,
`addorder`, `getclientsproducts`...). Scripts written for the WHMCS API usually
work with a new address and new credentials. Create credentials under
**Setup → API Credentials**; **Setup → API Documentation** lists every action.
