# Mama Havillah Global M-Pesa Backend
This is a Node.js/Express backend for M-Pesa STK Push integration using Safaricom Daraja API.
## Features
- /api/mpesa/stkpush: Initiate STK Push
- /api/mpesa/callback: Receive payment result
- CORS enabled
- Environment variables for credentials
## Setup
1. Copy .env.example to .env and fill in your Daraja API credentials.
2. Run `npm install` to install dependencies.
3. Start the server with `node server.js` or `npm start`.
## Deployment
- Ready for Render or Heroku. See below for step-by-step instructions.
### Render Deployment
1. Create a free account at
render.com
2. Create a new Web Service, connect your repo or upload code
3. Set environment variables: CONSUMER_KEY, CONSUMER_SECRET, PASSKEY
4. Deploy and use your public URL in your frontend
### Heroku Deployment
1. Install Heroku CLI
2. Run `heroku create`
3. Set environment variables: `heroku config:set CONSUMER_KEY=... CONSUMER_SECRET=... PASSKEY=...`
4. Push code: `git push heroku main`
5. Use your Heroku app URL in your frontend
## API Endpoints
- POST /api/mpesa/stkpush
- POST /api/mpesa/callback
## Example .env
```
CONSUMER_KEY=your_consumer_key
CONSUMER_SECRET=your_consumer_secret
PASSKEY=your_passkey
```
## Notes
- Use HTTPS for production
- Check backend logs for troubleshooting
git init
git add .
git commit -m "Initial M-Pesa backend setup"
git --version
git remote add origin
github.com
git branch -M main
git push -u origin main