8000 GitHub - occupyashanti/SafariFi-: A Django-based captive portal solution with Safaricom M-Pesa payment integration, designed for WiFi hotspot businesses in Kenya
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A Django-based captive portal solution with Safaricom M-Pesa payment integration, designed for WiFi hotspot businesses in Kenya

Notifications You must be signed in to change notification settings

occupyashanti/SafariFi-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SafariFi

A Django-based captive portal for WiFi hotspots with M-Pesa payment integration.

License: MIT Python Version Django M-Pesa Integration Made in Kenya


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., http://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

git clone https://github.com/occupyashanti/safariFi.git
cd safariFi

2. Create and Activate Virtual Environment

On Linux/macOS:

python -m venv venv
source venv/bin/activate

On Windows:

python -m venv venv
venv\Scripts\activate

3. Install Dependencies

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 (adjust values as needed):

SECRET_KEY=your_django_secret_key
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_SHORTCODE=your_shortcode
MPESA_PASSKEY=your_passkey
MPESA_CALLBACK_URL=https://yourdomain.com/api/payment/callback/

A sample .env.example file is provided for reference.

5. Apply Migrations

python manage.py migrate

6. Create a Superuser (Optional but Recommended)

python manage.py createsuperuser

Follow the prompts to set up your admin login credentials.

7. Run the Development Server

python manage.py runserver

Visit http://127.0.0.1:8000/ in your browser. You can access the Django admin panel at http://127.0.0.1:8000/admin/.


About

A Django-based captive portal solution with Safaricom M-Pesa payment integration, designed for WiFi hotspot businesses in Kenya

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0