A Django-based captive portal solution with Safaricom M-Pesa payment integration, designed for WiFi hotspot businesses in Kenya
# SafariFi
> A Django-based captive portal for WiFi hotspots with M-Pesa payment integration.
---
SafariFi lets you monetize WiFi access by redirecting users to a login and payment portal when they connect to your hotspot. Built with Django and integrated with Safaricom’s Daraja API, it provides a simple and secure way to sell internet access using M-Pesa payments.
---
## Features
- **Secure Django backend** with configurable environment settings
- **Captive portal redirection** for Android, iOS, Windows, and Linux
- **M-Pesa integration** for real-time voucher purchase and validation
- **Device-aware** login flows
- Admin dashboard to manage users, vouchers, and payment logs
---
## Updates Made
### Security Enhancements
- Environment-based `SECRET_KEY` and `DEBUG` settings
- Proper `ALLOWED_HOSTS` configuration
- Sample `.env` file for safer secret management
### Captive Portal Improvements
- Improved OS/device detection
- Wider support for captive portal triggers (e.g., `
captive.apple.com`, `connectivitycheck.gstatic.com`)
### M-Pesa Integration
- Fully functional M-Pesa client with:
- STK push
- Callback validation
- Transaction status checks
- Environment-variable-driven configuration
### Code Fixes
- Added missing `os` import in `settings.py`
- Fixed missing `include()` in `urls.py`
- Modularized and cleaned up M-Pesa client logic
---
## Getting Started
Follow these steps to set up and run the project locally.
### 1. Clone the Repository
```bash
git clone
github.com
cd safariFi
```
### 2. Create and Activate Virtual Environment
#### On Linux/macOS:
```bash
python -m venv venv
source venv/bin/activate
```
#### On Windows:
```bash
python -m venv venv
venv\Scripts\activate
```
### 3. Install Dependencies
```bash
pip install -r requirements.txt
```
### 4. Set Up Environment Variables
Create a `.env` file in the project root (same level as `manage.py`) and add the following (adjus …