A Django-based e-commerce application integrated with M-Pesa STK Push for mobile payments testing in Kenya.
# M-Pesa E-commerce API Testing Application
A Django-based e-commerce application integrated with M-Pesa STK Push for mobile payments testing in Kenya.
## đź“‹ Table of Contents
- Overview
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- API Endpoints
- Testing
- Troubleshooting
- Contributing
- License
- Contact
## 🌟 Overview
This application provides a complete e-commerce solution with M-Pesa payment integration for testing purposes. It includes user authentication, product management, order processing, and real-time payment status tracking using M-Pesa's STK Push API.
## ✨ Features
### Core Features
- **User Authentication**: Registration, login, and logout functionality
- **Product Management**: Display and browse products
- **Shopping Cart**: Add products and manage quantities
- **M-Pesa Integration**: STK Push payment processing
- **Order Management**: Track order status and payment history
- **Real-time Status Updates**: AJAX-based payment status checking
### M-Pesa Features
- STK Push payment initiation
- Callback handling for payment notifications
- Transaction status tracking
- Automatic timeout detection (1 minute for testing)
- Detailed logging for debugging
### Security Features
- CSRF protection
- User authentication required for checkout
- Phone number validation (Kenyan format)
- Secure callback handling
## đź”§ Prerequisites
- Python 3.8+
- Django 3.2+
- M-Pesa Developer Account (Safaricom)
- MySQL/PostgreSQL (optional, SQLite for development)
## 📦 Installation
1. **Clone the repository**
```bash
git clone
cd mpesa-ecommerce-testing
```
2. **Create virtual environment**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Run migrations**
```bash
python manage.py makemigrations
python manage.py migrate
```
5. **Create superuser**
```bash
python manage.py createsuperuser
```
6. **Run the development serv …