This project demonstrates the integration of the Daraja M-Pesa API using Flask. It allows users to make payments through the M-Pesa platform.
- Obtain access token from Safaricom API
- Make payment requests using the access token
- Display response messages to the user
- Python 3.x
- Flask
- Requests library
-
Clone the repository:
git clone https://github.com/your-username/your-repository.git cd your-repository -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` -
Install the required packages:
pip install -r requirements.txt
-
Run the Flask application:
flask run -
Open your web browser and navigate to
http://127.0.0.1:5000/. -
Enter your phone number and the amount, then click the "Pay" button.
-
Follow the instructions on your phone to complete the transaction.
GitHub Copilot Here is an example of a README.md file for your project:
. ├── app.py ├── access_token.py ├── templates │ └── index.html ├── .gitignore └── README.md
- app.py: Main Flask application file.
- access_token.py: Contains functions to get the access token and make payment requests.
- index.html: HTML template for the payment form.
- .gitignore: Git ignore file.
README.md: Project documentation.