Logo Lanfrica

Mishiesalie/mpesa_1

Domain:

digital infrastructure

Record type:

software
Creator:
Mis
Host:
# M-Pesa Payment Application A Node.js application integrated with the M-Pesa API that allows users to send and receive payments. ## Features - **Rent Payment**: Send money to a specified M-Pesa phone number - **Receive Payment**: Generate a QR code for receiving payments - **Transaction History**: View all completed transactions with details - **Real-time Updates**: Get real-time updates on transaction status using WebSockets - **Error Handling**: Robust error handling for various scenarios - **Responsive UI**: Mobile-friendly user interface ## Prerequisites - Node.js (v14 or higher) - MongoDB - M-Pesa API credentials (Safaricom Developer Account) ## Installation 1. Clone the repository: ``` git clone cd mpesa-payment-app ``` 2. Install dependencies: ``` npm install ``` 3. Create a `.env` file in the root directory with the following variables: ``` # Server Configuration PORT=3000 NODE_ENV=development # MongoDB Configuration MONGODB_URI=mongodb://localhost:27017/mpesa_app # M-Pesa API Configuration MPESA_CONSUMER_KEY=your_consumer_key MPESA_CONSUMER_SECRET=your_consumer_secret MPESA_PASSKEY=your_passkey MPESA_SHORTCODE=your_shortcode MPESA_CALLBACK_URL=localhost MPESA_INITIATOR_NAME=your_initiator_name MPESA_INITIATOR_PASSWORD=your_initiator_password # Security JWT_SECRET=your_jwt_secret_key ``` 4. Start the application: ``` # Development mode npm run dev # Production mode npm start ``` 5. Access the application at `localhost` ## API Endpoints - `POST /api/transactions/rent` - Initiate a rent payment - `POST /api/transactions/receive` - Generate a QR code for receiving payment - `GET /api/transactions` - Get all transactions - `GET /api/transactions/status/:checkoutRequestId` - Check transaction status - `POST /api/mpesa/callback` - M-Pesa callback endpoint ## Usage ### Rent Payment 1. Enter the recipient's M-Pesa phone number 2. Enter the amount to be paid 3. (Optional) Enter a reference for the payment …

Languages