WHMCS integration
Collect WHMCS invoices in M-Pesa or USDT
A gateway module for WHMCS that lets hosting clients pay an invoice with an M-Pesa prompt or a stablecoin transfer. Invoices are marked paid through the standard WHMCS payment path, so provisioning and unsuspension carry on working exactly as they do today.
- Early access
- Hosting providers, ISPs and agencies billing through WHMCS
- Standard gateway module
Why it matters
Hosting billing in Kenya is a collections problem
A Kenyan hosting provider on WHMCS usually collects most of its money over M-Pesa already, just not through WHMCS. The client pays to a paybill, sends a screenshot to support, and somebody in the admin area finds the invoice and applies the payment by hand. Multiply that by a few hundred renewals a month and it becomes a job.
The cost is not only the labour. Because the payment lands outside WHMCS, the invoice stays unpaid until a human intervenes, which means suspension emails go to clients who have already paid, services get suspended over a weekend, and support spends Monday apologising. Meanwhile the automation WHMCS is good at, provisioning and unsuspension, sits idle because nothing told it the invoice closed.
Putting M-Pesa inside WHMCS as a real gateway fixes the whole chain at once: the client pays in the client area, the callback records the transaction, and every hook that normally fires on payment fires. The stablecoin method then covers the clients who pay you from outside Kenya, where cards and bank transfers are slow and reversible.
Setup
Install the gateway in eight steps
You need file access to upload the module and an admin account to activate it. No core WHMCS files are modified.
- 01
Generate an API key pair
Create an E-Sarif merchant account and issue a test key pair first. Hosting billing is unforgiving of surprises, so you want a full test cycle before a real invoice depends on it.
- 02
Upload the gateway module
Drop the module folder into modules/gateways in your WHMCS installation, along with its callback file in modules/gateways/callback. This is a standard third-party gateway layout, not a core file edit.
- 03
Activate it under Setup, Payments, Payment Gateways
Open the All Payment Gateways tab, pick E-Sarif Checkout to activate it, and it moves into your Manage Existing Gateways list.
- 04
Enter the keys and set the display name
Paste the secret and publishable keys and set the name your clients see on the invoice, for example Pay by M-Pesa or USDT. Leave test mode enabled for now.
- 05
Register the callback URL in your merchant portal
Copy the callback URL from the module settings into the webhook configuration on your merchant account. This is what marks invoices paid, so nothing works properly until it is set.
- 06
Assign the gateway to your products
WHMCS controls which gateways appear per product and per client group. Add E-Sarif to the products you want to collect on, and remember any restricted client groups.
- 07
Pay a test invoice as a test client
Create a small invoice for a test client and pay it through the client area. With test keys, the payment confirms after a few seconds, so you can watch WHMCS record the transaction, mark the invoice paid and run its provisioning hooks.
- 08
Switch to live keys
Turn test mode off, paste the live pair, and collect one small real invoice. Confirm the transaction id is recorded against the invoice before you point clients at it.
- Display name shown on invoices
- Secret key (esk_test_...)
- Publishable key (epk_test_...)
- Payment methods: M-Pesa, stablecoins
- Settlement currency: USDT or KES
- Test mode: on
- Callback URL to register in the merchant portal
Supported features
Feature support on WHMCS
Read the recurring-capture row carefully. It is the one thing that changes how you run a hosting business on these rails.
| Feature | Status on WHMCS |
|---|---|
| M-Pesa STK push | Supported. The client enters their phone number and approves the prompt. |
| USDT and USDC | Supported on Tron, Solana, Base, BNB Chain, Ethereum, Polygon, Arbitrum, Optimism and Avalanche, which suits clients paying you from outside Kenya. |
| Invoice marked paid automatically | Yes. The callback records the transaction against the invoice and marks it paid, so WHMCS provisioning, unsuspension and email hooks fire as normal. |
| Partial payments | Handled the WHMCS way: each confirmed payment is recorded as a transaction against the invoice, and the invoice closes when the balance reaches zero. |
| Refunds | Supported, full and partial, initiated against the original checkout session and returned over M-Pesa B2C or on-chain. |
| Invoice currency | KES, USD, USDT or USDC. USD pricing is common in hosting and works without you changing your price list. |
| Automatic recurring capture | Not supported. WHMCS will still generate the recurring invoice, but the client has to approve each payment, because both methods require buyer action. |
| Client area and admin-side payment | Clients pay from the client area. Admins can send a payment link for an invoice a client cannot pay online. |
| Test mode | Supported, with a separate key pair and simulated confirmations. |
| Duplicate payment protection | Idempotency keys are derived from the invoice id and attempt, so a client refreshing the payment page cannot pay twice. |
Renewals
How to run renewals without auto-capture
Neither M-Pesa nor a stablecoin transfer can be charged without the client acting, so renewal collection becomes a reminder problem rather than a billing-engine problem. Providers who plan for that do fine.
Payment links for invoices- Lengthen your invoice-generation window so clients get the invoice, and the reminders, well before the due date.
- Send the payment link in the reminder itself, so paying is one tap rather than a login followed by navigation.
- Keep a card gateway enabled alongside E-Sarif for the clients who want unattended renewals, and let each client pick.
- Watch expired sessions in the merchant portal. A client who started a payment and abandoned it is the easiest collection call you will make that week.
FAQ
WHMCS and E-Sarif, answered
Can WHMCS accept M-Pesa payments?
Yes, through a third-party gateway module. The E-Sarif Checkout module adds M-Pesa to your WHMCS invoices, so a client can pay a hosting or domain invoice by approving a prompt on their phone, and WHMCS marks the invoice paid without you touching it.
Will services be provisioned and unsuspended automatically?
Yes. The module records the payment through the standard WHMCS invoice-payment path, so everything WHMCS normally does on payment happens: the transaction is logged, the invoice is marked paid, and provisioning, unsuspension and notification hooks fire.
Can it charge my clients automatically on renewal?
No, and this is the most important limitation to understand before you switch a hosting business over. WHMCS will still generate the recurring invoice and send the reminders, but M-Pesa and stablecoin payments both need the client to approve the payment. There is no stored instrument to charge, so renewals are client-initiated. Many providers keep a card gateway alongside E-Sarif for exactly this reason.
My hosting prices are in USD. Does that work?
Yes. Invoices can be priced in USD and the client can still pay by M-Pesa, with E-Sarif converting at session creation so the client sees an exact amount. You can settle in USDT, which keeps a dollar price list and a dollar balance consistent.
What about clients paying from outside Kenya?
That is what the stablecoin method is for. A client anywhere can pay a USDT or USDC invoice on Tron, Solana, Base, BNB Chain, Ethereum, Polygon, Arbitrum, Optimism and Avalanche without a card network or a correspondent bank in the middle, and the payment cannot be reversed after you have provisioned the service.
Does it handle partial payments on an invoice?
Yes, in the way WHMCS expects. Each confirmed payment is recorded as a transaction against the invoice, and the invoice only closes when the balance reaches zero.
How do I refund a client?
Refund from the WHMCS transaction as you would with any gateway. The refund is created against the original checkout session and returned the way the money came in. Refunds above your account threshold are held for approval before they move.
Is the secret key exposed to the client browser?
No. The module creates every checkout session server-side from your WHMCS installation using the secret key. Only the publishable key can reach a browser, and it cannot do anything except open a session and read its own status.
Which WHMCS versions are supported?
The module follows the standard third-party gateway layout under modules/gateways, so it targets currently supported WHMCS releases. Confirm your specific version with the team before you install rather than assuming, especially if you are running an older long-term release.
Other integrations
Billing somewhere other than WHMCS?
WooCommerce
A WordPress payment gateway plugin that adds M-Pesa and USDT to Woo checkout.
Read the WooCommerce guideIn developmentShopify
Take M-Pesa and stablecoin payments on a Shopify store without leaving your theme.
Read the Shopify guideIn developmentWordPress
Payment buttons and blocks for any WordPress site, with or without a shopping cart.
Read the WordPress guideEarly accessREST API and SDKs
One HTTP call returns a checkout URL. PHP, Node and browser SDKs on top of it.
Read the REST API and SDKs guideIn developmentPayment links
Get paid with a shareable link. No website, no plugin, no code.
Read the Payment links guideStop applying M-Pesa
payments by hand.
Create a merchant account, install the module with test keys, and collect a test invoice end to end before you switch a client over.