Connect WHMCS to HandyPay for one-time invoices and recurring subscriptions while keeping test and live billing completely separate.
Setup checklist
- Create an API key in the merchant portal. Start with an
hp_test_key. - Store the key in the WHMCS gateway configuration. Never place it in client-side JavaScript or a public template.
- Use
https://api.handypay.me/api/v1as the API base URL. - Register a webhook endpoint that can receive payment and subscription lifecycle events.
- Run a complete test invoice before replacing the key with an
hp_live_key.
Test safely
Test keys use a dedicated test account. Products, customers, payments, subscriptions, and webhook endpoints created with a test key cannot appear in live activity.
curl https://api.handypay.me/api/v1/test-payments \
-H "Authorization: Bearer hp_test_your_api_key_here"The same activity is visible under Test Mode in the HandyPay merchant portal.
Checkout behavior
Create a hosted payment session for each WHMCS invoice. HandyPay shows eligible payment methods for the merchant, currency, customer, and device. Card checkout remains available when an additional method is not eligible.
curl -X POST https://api.handypay.me/api/v1/payment-sessions \
-H "Authorization: Bearer hp_test_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"line_items": [{
"amount": 4999,
"currency": "usd",
"name": "WHMCS invoice #1042",
"quantity": 1
}],
"customer_email": "buyer@example.com",
"success_url": "https://billing.example.com/payment-complete",
"cancel_url": "https://billing.example.com/viewinvoice.php?id=1042",
"metadata": { "whmcs_invoice_id": "1042" }
}'Subscriptions and seats
Create a subscription product once, then create a subscription session for the customer. Set quantity for per-seat billing. Active subscriptions can be updated without replacing them.
curl -X PATCH https://api.handypay.me/api/v1/subscriptions/sub_123/quantity \
-H "Authorization: Bearer hp_test_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"quantity": 8,
"proration_behavior": "create_prorations"
}'create_prorationsplaces the adjustment on the next invoice.always_invoiceinvoices the adjustment immediately.nonechanges the seat count without a prorated adjustment.
Webhooks
Register the WHMCS callback URL with the same key mode used by checkout. A test endpoint receives test events only, and a live endpoint receives live events only.
curl -X POST https://api.handypay.me/api/v1/webhook-endpoints \
-H "Authorization: Bearer hp_test_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"url": "https://billing.example.com/modules/gateways/callback/handypay.php",
"events": [
"payment_intent.succeeded",
"payment_intent.payment_failed",
"customer.subscription.updated",
"customer.subscription.deleted"
]
}'Troubleshooting
Only card is shown: the other methods are not eligible for that account, currency, customer, or device. Card is the supported fallback.
A test payment is missing: confirm the request used an hp_test_ key, then check the portal Test Mode workspace or GET /v1/test-payments.
WHMCS is not updating: confirm the callback URL is public HTTPS, verify the webhook signature against the raw request body, and return a successful 2xx response only after the invoice update succeeds.