A Node.js Express application that integrates with the PayChangu API to process mobile money payments in Malawi. This application provides a simple RESTful API for initializing payments, checking payment status, and managing transactions.
# PayChangu Payment Integration API
A Node.js Express application that integrates with the PayChangu API to process mobile money payments in Malawi. This application provides a simple RESTful API for initializing payments, checking payment status, and managing transactions.
## 📋 Table of Contents
- Overview
- Features
- Prerequisites
- Installation
- Configuration
- API Endpoints
- Usage Examples
- Payment Flow
- Error Handling
- Development Notes
- Troubleshooting
- Contributing
- License
## 🌟 Overview
This application serves as a middleware between your application and the PayChangu API, providing a simplified interface for processing mobile money payments. It supports major mobile money operators in Malawi including Airtel Money and TNM Mpamba.
## ✨ Features
- **Payment Initialization**: Initialize mobile money payments with PayChangu
- **Payment Verification**: Check payment status and completion
- **Transaction Management**: Store and retrieve payment information
- **Auto-polling**: Automatic status checking for pending payments
- **Multiple Operators**: Support for Airtel and TNM mobile money services
- **Error Handling**: Comprehensive error handling and validation
- **RESTful API**: Clean and intuitive API endpoints
## 🔧 Prerequisites
Before running this application, make sure you have:
- Node.js (version 14 or higher)
- npm or yarn package manager
- PayChangu API account and token
- Valid mobile money number for testing
## 🚀 Installation
1. **Clone or download the project files**
```bash
# If using git
git clone
cd paychangu
# Or download and extract the files to your project directory
```
2. **Install dependencies**
```bash
npm install
```
3. **Start the application**
```bash
npm start
# or
node index.js
```
The server will start on port 3030 by default.
## ⚙️ Configuration
### Environment Setup
Before using the application, you need to configure the following in `index.js`:
```javascript
const PAYCHANGU_TOKEN = "Bearer YOUR_PAYCHANGU_A …