Logo Lanfrica

Frankie-lii/mpesa-intergration2

Domain:

digital infrastructure

Record type:

software
Creator:
Fra
Host:
# M-Pesa STK Push — Quick Start ## 1. Install dependencies ```bash pip install -r requirements.txt ``` ## 2. Set your callback URL in .env Your credentials are already in .env. You just need to add your ngrok URL: ```bash # Terminal 1 — get a public URL ngrok http 8000 # Copy the https URL e.g. abc123.ngrok-free.app # Edit .env and set: # MPESA_CALLBACK_URL=abc123.ngrok-free.app ``` ## 3. Run the server ```bash # Terminal 2 uvicorn main:app --reload --port 8000 ``` ## 4. Open browser Visit: localhost Enter your real Safaricom number → you'll get an M-Pesa PIN prompt on your phone. --- ## Sandbox test number `254708374149` — always succeeds, any PIN ## Files - `main.py` — FastAPI backend (token, STK push, callback, polling) - `static/index.html` — Frontend UI - `.env` — Your credentials (never commit to git)

Languages