A Node.js implementation of the Safaricom M-Pesa Daraja API — including STK Push, C2B, B2C, and Transaction Status endpoints. Built for learning, testing, and integrating mobile payments into web and mobile apps.
# 💸 M-Pesa Daraja API (Node.js)
This project is a **Node.js implementation** of the **Safaricom M-Pesa Daraja API**, built to simplify integration of **mobile payments** into web and mobile applications.
It provides ready-to-use endpoints for performing **STK Push**, **C2B**, **B2C**, **Balance Inquiry**, and **Transaction Status** requests using the official M-Pesa APIs.
---
## 🚀 Features
- ✅ Secure **OAuth Token Generation**
- 💰 **STK Push** (Customer to Business Payment)
- 🔁 **C2B & B2C Transactions**
- 📊 **Transaction Status & Account Balance Queries**
- ⚙️ Built with **Node.js + Express**
- 🧠 Well-structured for learning or production integration
---
## 🧩 Tech Stack
- **Node.js** – Backend runtime
- **Express.js** – API framework
- **Axios / Fetch** – For HTTP requests
- **Dotenv** – For environment variable management
---
## 🗝️ Setup
```bash
# Clone this repository
git clone
github.com
# Navigate into the folder
cd mpesa-api
# Install dependencies
npm install
# Add your environment variables
touch .env