Skip to content

Akubrecah/Mpesa-Api-With-Flask-Python-Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daraja M-Pesa Integration

This project demonstrates the integration of the Daraja M-Pesa API using Flask. It allows users to make payments through the M-Pesa platform.

Features

  • Obtain access token from Safaricom API
  • Make payment requests using the access token
  • Display response messages to the user

Prerequisites

  • Python 3.x
  • Flask
  • Requests library

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/your-repository.git
    cd your-repository
    
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install the required packages:

    pip install -r requirements.txt
    

Usage

  1. Run the Flask application:

    flask run
    
  2. Open your web browser and navigate to http://127.0.0.1:5000/.

  3. Enter your phone number and the amount, then click the "Pay" button.

  4. Follow the instructions on your phone to complete the transaction.

Project Structure

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.

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published