Documentation

Complete guide to using the ISP Billing System

1. Getting Started

The ISP Billing System is a comprehensive multi-tenant billing and subscriber management platform designed specifically for Internet Service Providers. It automates billing, payment processing, and router management.

Key Features

  • Multi-tenant architecture with complete data isolation
  • Automated billing and invoice generation
  • MikroTik RouterOS integration for automated user management
  • Multiple payment gateway support (MPesa, Selcom, Manual)
  • Hotspot and PPPoE user management
  • Comprehensive reporting and analytics
  • Role-based access control

2. Installation

Prerequisites

  • PHP 8.2 or higher
  • Composer
  • Node.js 18+ and NPM
  • MikroTik RouterOS (for router integration)
  • MySQL/PostgreSQL or SQLite

Step 1: Install Dependencies

composer install
npm install

Step 2: Environment Configuration

cp .env.example .env
php artisan key:generate

Step 3: Database Setup

For SQLite (default):

touch database/database.sqlite

Or configure MySQL/PostgreSQL in your .env file.

Step 4: Run Migrations

php artisan migrate

3. Configuration

Environment Variables

Configure the following in your .env file:

# Application
APP_NAME="ISP Billing"
APP_ENV=local
APP_DEBUG=true

# Database
DB_CONNECTION=sqlite
# Or MySQL/PostgreSQL
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=isp_billing
# DB_USERNAME=root
# DB_PASSWORD=

# MPesa (Optional - can be set per ISP)
MPESA_CONSUMER_KEY=your_key
MPESA_CONSUMER_SECRET=your_secret
MPESA_PASSKEY=your_passkey
MPESA_SHORTCODE=your_shortcode
MPESA_ENVIRONMENT=sandbox

# Selcom (Optional - can be set per ISP)
SELCOM_API_KEY=your_key
SELCOM_API_SECRET=your_secret
SELCOM_VENDOR_ID=your_vendor_id
SELCOM_ENVIRONMENT=sandbox

# SMS (Vonage/Nexmo - Optional)
VONAGE_KEY=your_key
VONAGE_SECRET=your_secret

4. MikroTik Router Setup

Enable API Access

Connect to your MikroTik router via Winbox or SSH and run:

/ip service enable api
/ip service set api port=8728

Create API User (Recommended)

/user add name=api-user password=strong-password group=full

Configure IP Binding (Security)

Restrict API access to specific IP addresses:

/ip service set api address=192.168.1.0/24

Adding Router to System

In the ISP dashboard, navigate to Routers and add your router with:

  • Router name
  • IP address
  • API username and password
  • Port (default: 8728)
  • SSL option (if using secure API)

5. Payment Gateway Setup

MPesa Configuration

  1. Register at Safaricom Developer Portal
  2. Create an app to get Consumer Key and Consumer Secret
  3. Get your Passkey from Lipa na MPesa Online account
  4. Configure in ISP Settings → Payment Gateways or in .env

Selcom Configuration

  1. Register at Selcom Developer Portal
  2. Get API Key, API Secret, and Vendor ID from your dashboard
  3. Configure in ISP Settings → Payment Gateways or in .env

Webhook Configuration

Set up webhook URLs in your payment gateway dashboards:

  • MPesa: https://test.pradytec.com/api/payments/mpesa/callback
  • Selcom: https://test.pradytec.com/api/payments/selcom/callback

6. Usage Guide

Creating Your First ISP

  1. Log in as Super Admin
  2. Navigate to Admin → ISPs
  3. Click "Create ISP"
  4. Fill in ISP details (name, email, phone, address)
  5. Configure payment gateway credentials (optional)
  6. Save the ISP

Setting Up Routers

  1. Log in as ISP Admin
  2. Go to Routers → Add Router
  3. Enter router details (name, IP, credentials)
  4. Test connection to verify access
  5. Save the router

Creating Plans

  1. Navigate to Plans → Create Plan
  2. Set plan name, price, and duration
  3. Choose access type (Hotspot or PPPoE)
  4. Configure speed limits (upload/download)
  5. Set billing type (time, data, or unlimited)
  6. Enter MikroTik speed profile name
  7. Save the plan

Adding Customers

  1. Go to Customers → Add Customer
  2. Fill in customer information
  3. Select router and plan
  4. Choose connection type (Hotspot/PPPoE)
  5. System automatically creates user on router
  6. Customer is activated and subscription created

Processing Payments

  1. Navigate to Invoices
  2. Select an invoice
  3. Click "Initiate Payment"
  4. Choose payment method (MPesa/Selcom/Manual)
  5. For MPesa: Enter phone number and confirm
  6. Payment is processed automatically
  7. Customer is activated upon successful payment

7. API Reference

The system provides RESTful API endpoints for programmatic access. All API endpoints require authentication using Laravel Sanctum.

Authentication

Include the authentication token in the Authorization header:

Authorization: Bearer {your-token}

Customer Endpoints

GET /api/isp/customers - List all customers
POST /api/isp/customers - Create customer
GET /api/isp/customers/{id} - Get customer details
PUT /api/isp/customers/{id} - Update customer
DELETE /api/isp/customers/{id} - Delete customer
POST /api/isp/customers/{id}/suspend - Suspend customer
POST /api/isp/customers/{id}/activate - Activate customer

Payment Endpoints

POST /api/payments/initiate - Initiate payment
POST /api/payments/mpesa/callback - MPesa webhook (public)
POST /api/payments/selcom/callback - Selcom webhook (public)
POST /api/payments/{payment}/confirm-manual - Confirm manual payment

Billing Endpoints

GET /api/isp/billing/invoices - List invoices
GET /api/isp/billing/payments - List payments
POST /api/isp/billing/generate-invoices - Generate invoices
GET /api/isp/billing/stats - Get billing statistics

8. Troubleshooting

Router Connection Issues

  • Verify router IP address and port are correct
  • Check that API service is enabled on router
  • Ensure firewall allows connections on API port
  • Verify username and password are correct
  • Check router logs for connection attempts

Payment Gateway Issues

  • Verify API credentials are correct
  • Check that webhook URLs are accessible from internet
  • Ensure webhook signatures are being validated
  • Check payment gateway dashboard for transaction logs
  • Verify environment (sandbox vs production) matches

Common Issues

Users not created on router

Check router connection, verify speed profile exists on router, check router logs.

Invoices not generating

Ensure scheduled jobs are running, check subscription end dates, verify invoice generation settings.

Payments not processing

Verify payment gateway credentials, check webhook configuration, review payment logs.