Complete guide for testing the AutoSuspend script. Follow the proper sequence to avoid stuck states.
The FusionPBX AutoSuspend script automatically suspends/unsuspends client services based on their credit balance. It tracks suspension state in the mod_fusionpbx_suspend_account database table to prevent duplicate operations.
suspend = 'yes' in mod_fusionpbx_suspend_accountsuspend = 'no' and re-enables gateway| ✅ DO | ❌ DON'T |
|---|---|
| Always complete the full suspend → unsuspend cycle | Manually enable gateway in FusionPBX UI during testing |
| Use the autosuspend script for all state changes | Directly modify mod_fusionpbx_suspend_account table during testing |
| Run in browser debug mode first to verify logic | Skip the unsuspend step before testing suspend again |
| Check debug output for "Already suspended - skipping" | Assume the script failed without checking state table |
| Verify gateway status directly in FusionPBX tenant | Use ictVoIPBilling Client Services / Gateways to verify |
| Step | Action | Expected Result |
|---|---|---|
| 1 | Set test client credit to $0.00 | Credit balance shows $0.00 in WHMCS |
| 2 | Run autosuspend in browser: https://yourwhmcs.com/modules/servers/fusionpbx/autosuspend.php |
Debug output shows "SUSPENSION TRIGGERED" |
| 3 | Verify debug output | Shows "SERVICE SUSPENDED SUCCESSFULLY - Gateway disabled" |
| 4 | Check FusionPBX | Gateway shows as Disabled |
| 5 | Verify Sofia status | Gateway should be stopped (not just disabled) |
| Step | Action | Expected Result |
|---|---|---|
| 1 | Add credit to test client (e.g., $50.00) | Credit balance shows $50.00 in WHMCS |
| 2 | Run autosuspend again | Debug output shows "Service was previously suspended, attempting to unsuspend..." |
| 3 | Verify debug output | Shows "SERVICE UNSUSPENDED SUCCESSFULLY - Gateway re-enabled" |
| 4 | Check FusionPBX | Gateway shows as Enabled |
| 5 | Verify Sofia status | Gateway should be running |
| Step | Action | Expected Result |
|---|---|---|
| 1 | Set test client credit back to $0.00 | Credit balance shows $0.00 |
| 2 | Run autosuspend | Debug output shows "SUSPENSION TRIGGERED" (not "Already suspended") |
| 3 | Verify suspension works | Gateway disabled and stopped |
The mod_fusionpbx_suspend_account table has suspend = 'yes' but the gateway was manually re-enabled outside of the autosuspend script.
1. Check current state:
SELECT * FROM mod_fusionpbx_suspend_account
WHERE userid = [CLIENT_ID];
2. If suspend = 'yes' but gateway is enabled, reset the state:
UPDATE mod_fusionpbx_suspend_account
SET suspend = 'no', updated_at = NOW()
WHERE userid = [CLIENT_ID] AND serviceid = [SERVICE_ID];
3. Re-run autosuspend:
https://yourwhmcs.com/modules/servers/fusionpbx/autosuspend.php
Once testing is complete, configure the CRON job:
*/5 * * * * TZ=America/Toronto curl -s "https://yourwhmcs.com/modules/servers/fusionpbx/autosuspend.php?runfrom=cron" >/dev/null 2>&1
Parameters:
?runfrom=cron - Suppresses HTML output, returns plain text summary| Mode | URL | Output |
|---|---|---|
| Browser (Debug) | /autosuspend.php |
Full HTML with detailed status for each client |
| CRON (Silent) | /autosuspend.php?runfrom=cron |
Plain text summary only |
| Column | Type | Description |
|---|---|---|
| id | int | Primary key |
| userid | int | WHMCS client ID |
| serviceid | int | WHMCS service/hosting ID |
| domain_name | varchar | FusionPBX tenant domain |
| suspend | varchar | Current state: 'yes' or 'no' |
| created_at | timestamp | First suspension time |
| updated_at | timestamp | Last state change |
Script Version: 1.1.0
Author: ictVoIP Canada