cPanel & WHM
Create, suspend and remove hosting accounts on a WHM server automatically. Not yet tested against a live server.
The cPanel & WHM plugin creates a hosting account on your WHM server when an invoice is paid, and suspends, unsuspends, changes the package of and removes it as the service changes.
This plugin was written from cPanel's published WHM API 1 documentation and has not been tested against a live cPanel & WHM server yet. Try it on a test server and a test product before you sell with it, and check the results in WHM.
What it does#
| In Tidemark Billing | In WHM |
|---|---|
| Invoice paid, service activated | Creates the account (createacct) with your package, the client's email and a generated password |
| Service suspended | suspendacct, with the reason "Suspended by billing system" unless a reason was given |
| Service unsuspended | unsuspendacct |
| Service terminated | removeacct (DNS records are not kept) |
| Product or plan changed | changepackage to the product's package |
| Log in to cPanel and Open webmail buttons | One-time single sign-on sessions through create_user_session |
| Reset password | Sets a new generated password with passwd; it appears on the service page |
Customers see Log in to cPanel, Open webmail and Reset password on their service page. Staff see Log in to cPanel and Reset password under More actions on the service.
Before you start: an API token in WHM#
- In WHM open Development → Manage API Tokens and choose Generate Token.
- Name it, for example
billing. - Give it these privileges (or allow all, for a root token):
create-acct,suspend-acct,kill-acct,list-pkgs,edit-account,passwd,create-user-sessionandbasic-system-info. - Copy the token. WHM shows it once.
If WHM limits API access by IP address, allow the address of the server that runs Tidemark Billing.
Set it up#
- Open Plugins and press Enable on cPanel & WHM.
- Open Servers → Add server and choose the module cPanel & WHM.
- Fill in the Connection card:
- Hostname: the WHM hostname, for example
whm1.example.com. - Port: leave blank for the default, 2087.
- Username: the owner of the token,
rootor a reseller. - Password / API token: the token.
- Use HTTPS on. Turn Verify certificate off only if the server has a self-signed certificate; a real certificate is better.
- Hostname: the WHM hostname, for example
- In the cPanel & WHM options card you can add Nameserver 1 and Nameserver 2. Customers see them on their service page.
- Save, then press Test connection on the Servers list. A good result reads "Connected to cPanel & WHM" with the version and the number of packages available.
- Open a product, set Module to cPanel & WHM and fill in:
- WHM package (required): the exact package name from WHM (Packages → List Packages). Reseller-owned packages start with the reseller's name.
- Feature list: optional; overrides the package's feature list.
- IP address: Shared or Dedicated.
See Servers and Products and groups.
The service label is the domain#
The account's primary domain is the service's Label, for example example.com. A label that is not a valid domain makes provisioning fail with a message saying so. Fix the label and press Retry on the pending service.
The username is made from the domain: lowercase, starting with a letter, up to 8 characters. If the name is taken the plugin tries variations with a digit added, up to six times.
Passwords and logs#
The generated password is stored encrypted on the service and shown only on request. WHM API 1 documents createacct and passwd as GET calls, so the plugin sends the password as a query parameter over HTTPS, as documented. The plugin does not log URLs and strips them from connection errors, but WHM's own access logs on the server will contain the password parameter. Restrict access to those logs.
If something fails#
A failed create leaves the service pending with the error shown to staff and a Retry button. Typical causes are a wrong package name, a token missing one of the privileges above, blocked IP access, or a certificate problem. Timeouts are 10 seconds to connect and 30 seconds in total.