Logo Lanfrica

Eccb7/Mpesa-Daraja

Domain:

digital infrastructure

Record type:

software
Creator:
Ecc
Host:
This repo acts a s a guide to Daraja API within a rails app and python # M-Pesa Daraja API Implementation Examples (Python/Django & Ruby on Rails) ## Introduction This repository contains detailed guides and example structures for integrating the Safaricom M-Pesa Daraja API into web applications using popular backend frameworks: Python (with Django) and Ruby (with Ruby on Rails). The goal is to provide a clear path for developers to implement common M-Pesa functionalities, including: * **STK Push (Lipa Na M-Pesa Online):** Initiating payment prompts on customer phones. * **C2B (Customer To Business):** Handling payments made by customers to your PayBill or Till Number, including URL registration, validation, and confirmation. * **B2C (Business To Customer):** Sending money from your business account to customers (e.g., payouts, refunds). * **B2B (Business To Business):** Transferring funds between business shortcodes. * **Account Balance:** Querying the balance of your M-Pesa shortcode. A key focus is the implementation of **webhooks (callbacks)**, which are essential for receiving real-time transaction status updates from Safaricom. **Note:** These guides are based on the structure observed in a Node.js example and expanded based on the official Daraja API documentation. They emphasize secure credential handling and provide detailed steps for each API interaction. ## Frameworks Covered 1. **Python (Django):** A high-level Python web framework that encourages rapid development and clean, pragmatic design. 2. **Ruby on Rails:** A popular web application framework written in Ruby, following the model-view-controller (MVC) pattern. ## Example File Structures Below are the typical file structures and key files created as per the implementation guides. These represent the core logic for M-Pesa integration within a larger application. ### 1. Python (Django) Structure ``` mpesa_project/ ├── mpesa_project/ # Django project settings │ ├── __init__.py │ ├── settings.py # Add 'mpesa_api' to INSTALLED_APP …

Languages

Licenses