# Mpesa-API-INTEGRATION
## π Powered by TEKLINI TECHNOLOGIES
This repository provides a professional and robust integration for **Safaricom's M-Pesa (Daraja) APIs** into Django applications. It is designed for developers who need a clean, secure, and production-ready implementation of STK Push and OAuth authentication.
---
## π Key Features
* **Daraja 3.0 Ready**: Fully compatible with the latest Safaricom Daraja API specifications.
* **Modular Architecture**: Core logic for token generation and payment processing is decoupled for easy integration into any Django project.
* **Security First**: Built-in support for environment variables to protect sensitive credentials.
* **Lightweight**: Direct implementation using the `requests` library, avoiding unnecessary third-party dependencies.
* **Comprehensive Logging**: Detailed logging for debugging and transaction tracking.
---
## π οΈ Getting Started
### Prerequisites
* **Python 3.9+**
* **Django 4.0+**
* **pip** (Python package manager)
* **Safaricom Developer Credentials** (Consumer Key, Consumer Secret, Shortcode, Passkey)
### Setup Instructions
1. **Clone the Repository**
```bash
git clone
github.com
cd Mpesa-API-INTEGRATION
```
2. **Environment Configuration**
Create a `.env` file in the project root and populate it with your credentials:
```ini
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_SHORT_CODE=your_shortcode
MPESA_PASSKEY=your_passkey
MPESA_CALLBACK_URL=
yourdomain.com
MPESA_API_URL=
api.safaricom.co.ke
```
3. **Install Dependencies**
```bash
pip install -r requirements.txt
```
4. **Database Migrations**
```bash
python manage.py migrate
```
5. **Run the Server**
```bash
python manage.py runserver
```
---
## β‘ Usage
* **Dashboard**: Access the main interface at `
127.0.0.1`.
* **Token Management** β¦