MikroTikSync

Billing Suspension System — Complete Flow
Automated end-to-end suspension for overdue invoices
✅ Fully Automated
Step 1

Invoice Becomes Overdue

Daily automation checks invoices at 2am. If payment is past due date + grace period, triggers suspension.

Step 2

Subscriber Marked Suspended

System updates subscriber status to "suspended" and sets router_sync="pending" to signal routers.

Step 3

Router Polls Backend

Every 5 minutes, router fetches suspend.rsc from backend via HTTPS polling.

Step 4

Router Executes Commands

RouterOS script adds client IP to "blocked" firewall list — internet access denied immediately.

Step 5

Client Loses Internet

Firewall rule blocks all traffic. Client sees "No Internet" until payment is made.

Reconnection Flow (When Client Pays)

1. Payment Recorded

Admin marks invoice as paid or payment webhook triggers

2. Status Changed to Active

Subscriber status updated to "active", router_sync="pending"

3. Router Removes Block

Next poll fetches resume command, IP removed from blocked list ✅

🔧 Configuration

  • Grace Period: Configurable per subscriber (default: 5 days)
  • Polling Interval: Every 5 minutes on routers
  • Check Time: Daily at 2:00 AM (America/Los_Angeles timezone)
  • Firewall List: IPs added to "blocked" list on MikroTik

📊 Monitoring

  • Suspended Count: See total blocked clients in dashboard
  • Pending Sync: View clients waiting for router update
  • Router Status: Check last sync timestamp per subscriber
  • Manual Override: Manually suspend/reconnect if needed

⚙️ Technical Implementation

Backend Functions:checkOverdueInvoicesdisconnectSubscriberreconnectSubscribergetSuspendRSCsetupSuspendPolling

Automations:Daily Overdue Invoice Check (2am)Auto Enforce Suspensions (6-hour intervals)

RouterOS Commands:/ip firewall address-list add address="CLIENT_IP" list=blocked/ip firewall address-list remove [find address="CLIENT_IP" and list~"blocked"]

Manual Suspension Control
⚡ Quick Actions

⚠️ Warning: Suspending a client will immediately block their internet access by adding their IP to the router's firewall blocked list. Use with caution.