# Mpesa_API
## **PLP Academy Practice**
# Mpesa Daraja API Integration with Django
This guide provides a simple explanation of how to integrate the **Mpesa Daraja API** into a Django project. Mpesa is a popular mobile money service in Africa, and the Daraja API allows developers to integrate Mpesa payment functionalities into their applications.
---
## **Why Integrate Mpesa Daraja API?**
1. **Mobile Money Payments**:
- Mpesa is widely used in Africa, making it an essential payment method for businesses targeting this region.
- The Daraja API enables seamless integration of Mpesa payments into your Django application.
2. **Real-Time Payments**:
- The API supports real-time payment notifications, allowing you to update your system immediately when a payment is made.
3. **Security**:
- Mpesa Daraja API uses secure authentication methods (OAuth) to ensure safe transactions.
4. **Scalability**:
- The API is designed to handle high transaction volumes, making it suitable for growing businesses.
---
## **Requirements**
To integrate Mpesa Daraja API into your Django project, you need the following dependencies:
### **Dependencies**
Create a `requirements.txt` file with the following packages:
```plaintext
Django==4.2.7
requests==2.31.0
django-environ==0.11.2
python-dotenv==1.0.0
```
- **Django**: The web framework used to build the project.
- **requests**: A Python library for making HTTP requests to the Daraja API.
- **django-environ**: A library for managing environment variables in Django.
- **python-dotenv**: A library to load environment variables from a `.env` file.
---
## **Steps to Integrate Mpesa Daraja API in Django**
### **1. Set Up Your Django Project**
If you haven't already, create a Django project and app:
```bash
django-admin startproject myproject
cd myproject
python manage.py startapp mpesa
```
Add the `mpesa` app to `INSTALLED_APPS` in `settings.py`:
```python
INSTALLED_APPS = [
...
'mpesa',
]
```
### **2. Install Dependencies**
Inst …