hotspot system with mpesa captive portal intergration
# PC Hotspot System — M-Pesa Payment Proxy
M-Pesa STK Push integration for **MyPublicWiFi** hotspot. Lets users pay for WiFi via M-Pesa and get automatically connected using a voucher code.
## System Overview
```
┌─────────────┐ HTTP (port 8080) ┌──────────────────┐ HTTPS ┌──────────────────────┐
│ User phone │ ───────────────────────► │ Local Proxy │ ────────────► │ Live Server │
│ (captive │ │ (PHP on PC) │ │ fraternity.site/ │
│ portal) │ ◄─────────────────────── │ proxy_server.php│ ◄──────────── │ wificallback/ │
└─────────────┘ voucher login └────────┬─────────┘ └──────────────────────┘
│ │
│ ┌─────┴──────┐
│ │ Data.db │
│ │ (SQLite) │
│ └────────────┘
│ writes voucher codes
└──► MyPublicWiFi authenticates user
```
**How it works:**
1. User clicks "Pay with M-Pesa" on the login page
2. Local proxy sends STK Push request to the live server
3. Live server forwards to Safaricom API → user gets M-Pesa prompt on phone
4. User enters PIN → callback received by live server → voucher code generated
5. Proxy polls for status → finds voucher → writes it to MyPublicWiFi's Data.db
6. Login form auto-submits the voucher → user is connected to WiFi
## Prerequisites
- **Windows** (MyPublicWiFi only runs on Windows)
- **MyPublicWiFi** installed at `C:\Program Files (x86)\MyPublicWiFi`
- **PHP 8.0+** installed (any location — the script auto-detects)
## Installation
### 1. Install PHP
Download PHP from
windows.php.net — extract to any folder (e.g., `C:\php\`). Make sure `php.exe` exists. No other configuration is needed.
### 2. Set up the proxy files
Clone this repo and copy the files to their locations:
```
pchotspotsystem/
proxy/ → C:\Program Files (x86)\MyPublicWiFi\proxy\
proxy/login.ht …