M-Pesa Daraja API integration for Kenya government services
# Mpesaservicestoolkit
M-Pesa Daraja API integration for Kenya government services
# M-Pesa Government Services Payment Toolkit
A PHP-based integration with M-Pesa Daraja API for processing payments for Kenya government services including Business Permits, Certificates of Good Conduct, Driving License Renewals, and Marriage Certificates etc.
## 🎯 Project Overview
This project demonstrates how to integrate M-Pesa Daraja API with PHP to create a payment gateway for government services. It includes:
- **STK Push Integration** - Send payment prompts directly to customer phones
- **Government Services Configuration** - Pre-configured services with accurate pricing
- **Modern Web Interface** - Responsive HTML frontend with smooth UX
- **Error Handling** - Comprehensive error management and logging
- **Callback Processing** - Handle M-Pesa payment confirmations
## 🏛️ Supported Government Services
| Service | Amount | Processing Time |
|---------|--------|----------------|
| Business Permit Application | KES 2,000 | 7-14 working days |
| Certificate of Good Conduct | KES 1,050 | 2-3 working days |
| Driving License Renewal | KES 3,050 | 1-2 working days |
| Marriage Certificate | KES 500 | Same day service |
## ⚡ Quick Start
### Prerequisites
- PHP 8.0 or higher
- Composer
- Safaricom Developer Account
- WSL/Linux/Mac environment
### 1. Clone Repository
```bash
git clone
github.com
cd Mpesaservicestoolkit
```
### 2. Install Dependencies
```bash
composer install
```
### 3. Configure Environment
```bash
# Copy and edit environment file
cp .env.example .env
# Add your M-Pesa credentials
MPESA_CONSUMER_KEY=your_consumer_key_here
MPESA_CONSUMER_SECRET=your_consumer_secret_here
MPESA_PASSKEY=your_passkey_here
```
### 4. Create Required Directories
```bash
mkdir logs
chmod 755 logs
```
### 5. Run Application
```bash
# Start PHP development server
php -S localhost:8000 -t public/
# Open browser to
localhost
``` …