AutoSuspend Testing Guide
Important
This guide covers proper testing procedures for the AutoSuspend script. Following the correct sequence prevents “stuck” suspension states.
Overview
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.
Warning
The script uses state tracking to determine if a service is already suspended. Testing must follow the proper sequence to keep the database state synchronized with the actual gateway status.
How It Works
Suspension Trigger: When client credit ≤ $0 or outstanding invoices exceed credit
State Tracking: Script records
suspend = 'yes'inmod_fusionpbx_suspend_accountSkip Logic: If already marked as suspended, script skips (prevents duplicate API calls)
Unsuspension: When credit is restored, script sets
suspend = 'no'and re-enables gateway
Critical Testing Rules
✅ 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 |
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 |
Where to Verify Gateway Status
Tip
CORRECT: Check the gateway status directly in the FusionPBX tenant UI:
Login to FusionPBX → Gateways → Check if gateway is Enabled/Disabled
Check Sofia Status to confirm gateway is running/stopped
Danger
INCORRECT: Do NOT use ictVoIPBilling → Client Services → Gateways to verify:
This view is not live - it shows cached/synced data
Must be manually resynced to reflect current FusionPBX state
Will show stale data if gateway was changed by autosuspend
Proper Testing Sequence
Test 1: Suspension
Set client credit to $0 or create unpaid invoice exceeding credit
Run autosuspend script in browser (debug mode)
Verify output shows “Suspending service…”
Check FusionPBX tenant - gateway should be disabled
Confirm
mod_fusionpbx_suspend_accountshowssuspend = 'yes'
Test 2: Unsuspension
Add credit to client account (or pay invoice)
Run autosuspend script again
Verify output shows “Unsuspending service…”
Check FusionPBX tenant - gateway should be enabled
Confirm
mod_fusionpbx_suspend_accountshowssuspend = 'no'
Test 3: Re-Suspension
Remove credit again
Run autosuspend script
Should now suspend properly (state was reset in Test 2)
Troubleshooting Stuck States
If testing was done out of sequence and the script shows “Already suspended - skipping” but the gateway is actually enabled:
Option 1: Complete the Cycle
Add credit and run unsuspend first, then remove credit and suspend again.
Option 2: Reset Database State (Admin Only)
-- Check current state
SELECT * FROM mod_fusionpbx_suspend_account WHERE service_id = [SERVICE_ID];
-- Reset to allow fresh suspension
UPDATE mod_fusionpbx_suspend_account
SET suspend = 'no', updated_at = NOW()
WHERE service_id = [SERVICE_ID];
Warning
After resetting the database, you must run the autosuspend script to re-sync the actual gateway state.
CRON Setup
For production use, set up the CRON job with the ?runfrom=cron parameter:
# Run every 5 minutes (recommended)
*/5 * * * * TZ=America/Toronto curl -s "https://yourwhmcs.com/modules/servers/fusionpbx/autosuspend.php?runfrom=cron" >/dev/null 2>&1
Note
The ?runfrom=cron parameter suppresses HTML output and runs silently.
Debug vs CRON Mode
Mode |
URL |
Output |
|---|---|---|
Debug (Browser) |
|
Full HTML with status messages |
CRON |
|
Silent (no output) |
Database Table
The mod_fusionpbx_suspend_account table tracks suspension state:
Column |
Type |
Description |
|---|---|---|
id |
int |
Primary key |
service_id |
int |
WHMCS hosting service ID |
client_id |
int |
WHMCS client ID |
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