This project demonstrates how to initiate an M-Pesa STK Push using the Django framework and the django_daraja
library.
- Python 3.8 or higher
- django_daraja library
git clone https://github.com/yourusername/django-stk-push.git
cd django-stk-push
Create a virtual environment to manage your project dependencies. This ensures that your project uses the correct versions of packages.
python -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`
pip install -r requirments.txt
Update your Django settings.py file with your M-Pesa API credentials. These credentials are necessary for authenticating your requests to the M-Pesa API.
DARAJA_CONSUMER_KEY = 'your_consumer_key'
DARAJA_CONSUMER_SECRET = 'your_consumer_secret'
DARAJA_SHORTCODE = 'your_shortcode'
DARAJA_PASSKEY = 'your_passkey'
replace all of these with your actual Mpesa credentials
python manage.py runserver
Navigate to http://127.0.0.1:8000/ in your web browser to access your application. Enter the required details and submit the form to initiate an STK push. 😊🔥