This project demonstrates the use of the DARAJA API to initiate STK Push payments. The setup guides you through configuring the project to make secure STK Push requests and handle callbacks.
Follow these instructions to set up and run the project on your local machine.
- Python 3.x
- Virtualenv
-
Clone the repository:
git clone [email protected]:anomalous254/daraja_api_presentation.git cd daraja_api_presentation
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
-
For macOS/Linux:
source venv/bin/activate
-
For Windows:
venv\Scripts\activate
-
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the root directory of the project and add the following environment variables:DEBUG=True DARAJA_API_CONSUMER_KEY=<your-consumer-key> DARAJA_API_CONSUMER_SECRET=<your-consumer-secret> DARAJA_API_PASS_KEY=<your-pass-key> DARAJA_API_SHORT_CODE=<your-short-code> SECRET_KEY=<your-secret-key>
-
Set up the callback URL:
- Navigate to the
daraja_api
folder (in thecore.py
). - In the
send_stk_push
function, update the request body to include your callback URL:
# Example placeholder for the callback URL 'CallbackURL': 'https://yourdomain.com/path/to/callback'
- Navigate to the
To start the project, run:
python manage.py migrate
python manage.py runserver