XPay for WHMCS: installation and setup
Accept cards, ValU and other local payment methods in WHMCS through XPay Hosted Checkout.
Upload the module, activate it in WHMCS, paste your XPay Secret Key, create a webhook in the XPay Dashboard and paste its signing secret, then enter your license key. Test with an sk_test_ key before going live.
Requirements
- WHMCS 8.x or 9.x
- PHP 8.1 or newer, with the cURL and JSON extensions
- An XPay merchant account with access to the XPay Dashboard
- HTTPS on your WHMCS site
- An XPay for WHMCS license key. A 7-day free trial starts on first use.
1. Upload the files
Download the latest xpay-whmcs zip from your client area and extract it. Upload the contents of the modules folder to the root of your WHMCS installation (the folder that contains configuration.php), keeping the same paths:
If you upload as root, give the files back to the site’s user afterwards (files 644, folders 755).
2. Activate the gateway
- Open the payment gateways
In WHMCS Admin go to System Settings→Payment Gateways and open All Payment Gateways.
- Click XPay
WHMCS activates the gateway and opens its settings. The status panel at the top shows the license, the mode (test or live) and when the last payment notification arrived.

3. Enter your license key
Paste your key in License Key. The status appears under the field and in the status panel. Without a key, the module runs as a 7-day free trial from the first use.
4. Add your XPay Secret Key
- Copy the key from XPay
In the XPay Dashboard open Developers→API Keys and copy the secret key.
- Paste it in WHMCS
Paste it in Secret Key and save. A label next to the field confirms the mode:
Key starts with Mode Money sk_test_Test mode No real money is charged. Use XPay test cards. sk_live_Live mode Real payments.
5. Set up payment notifications (webhook)
When a client pays, XPay sends a signed notification (a webhook) to your WHMCS. The module verifies it and marks the invoice as Paid, even if the client closes the browser before returning to your site.
Without the webhook, payments are collected but invoices stay Unpaid.
- Open Webhooks in XPay
In the XPay Dashboard open Developers→Webhooks and add a new endpoint.
- Paste your webhook URL
The settings page in WHMCS shows your exact URL with a Copy button. It looks like this:
https://your-whmcs-domain.com/modules/gateways/callback/xpay.php - Select these 7 events
Payments
checkout.session.completedcheckout.session.async_payment_succeededcheckout.session.async_payment_failedcheckout.session.expiredRefunds
refund.createdcharge.refundedrefund.failed - Copy the signing secret
XPay shows a signing secret that starts with
whsec_. It is shown only once: paste it in Webhook Signing Secret in WHMCS and click Save Changes.
Test mode and live mode have separate API keys and separate webhooks. When you switch to an sk_live_ key, create the webhook again in live mode and save the new whsec_ secret.
6. Checkout options
| Setting | Description |
|---|---|
| Payment Page Language | Automatic (client’s browser), Arabic or English. |
| Payment Methods | Optional, comma separated, for example card,valu. Leave empty to offer every method enabled on your XPay account. |
| Pay Button Text | The text of the payment button on the invoice, for example Pay Now. |
7. Make a test payment
With an sk_test_ key, open an unpaid invoice in the client area and click the pay button. The client is taken to the secure XPay payment page:
Pay with this XPay test card:
| Card number | 5123 4500 0000 0008 |
| Expiry | 01/39 |
| CVV | 100 |
After the payment, the client returns to the invoice and the webhook marks it as Paid. The status panel in the gateway settings shows Working with the time of the last notification.
Cards are charged in Egyptian pounds. For an invoice in USD, for example, the payment page shows the USD amount and a line such as “You’ll be charged EGP 1,362.56 on your card”. The client’s bank handles the conversion.
8. Go live
- Replace the test key with your
sk_live_key. - Create the webhook again in XPay live mode with the same URL and the same 7 events.
- Paste the new
whsec_secret in WHMCS and save. - Check that the status panel shows Live mode and a valid license.
Refunds
- From WHMCS: open the invoice, go to Transactions and click Refund. Full and partial refunds are sent to XPay automatically.
- From the XPay Dashboard: refunds made there are recorded on the WHMCS invoice automatically, and the client receives the standard refund email.
- Refunds still in progress: if XPay accepts a refund but hasn’t completed it yet, WHMCS records it automatically once XPay confirms it. Don’t click Refund again in the meantime.
- Failed refunds: if XPay rejects a refund, nothing is recorded and WHMCS shows the reason in plain language (for example, a low XPay balance). Fix the cause and click Refund again.
- A refund is never recorded twice, whichever side it was started from.
Troubleshooting
“This payment method is currently unavailable” on invoices
Check the license key and its status in the gateway settings. The trial may have ended.
Invoices are not marked as paid
Check that the webhook URL and all 7 events are set in XPay, in the same mode (test or live) as your secret key, and that the signing secret matches. Failed notifications appear in Billing→Gateway Log. If you use Cloudflare or a firewall, allow /modules/gateways/callback/xpay.php.
API errors
Enable module logging in System Logs→Module Log and try again; the full XPay response is recorded there.
Need a hand? Our team can install and configure XPay on your WHMCS for you.
Open a ticket
