A simple repository demonstrating how to integrate Safaricom's Daraja API with an Express.js application. It includes examples for MPesa services such as STK push, access token generation, and handling API responses. Perfect for developers looking to implement mobile money solutions in their Node.js projects.
- OAuth Token Generation: Securely generate access tokens for API authentication.
- STK Push Functionality: Initiates STK Push requests for payments.
- Callback Handling: Handles Safaricom's callback for transaction statuses.
- Environment Configuration: Securely manage sensitive credentials using
.env
.
- Clone the repository:
git clone https://github.com/DeveloperWilliams/Daraja-api-node-express.git
- Navigate to the project directory:
cd API
- Install dependencies:
npm install
Ensure to create .env file
DARAJA_CONSUMER_KEY=your_consumer_key DARAJA_CONSUMER_SECRET=your_consumer_secret DARAJA_SHORTCODE=your_shortcode DARAJA_PASSKEY=your_passkey CALLBACK_URL=https://yourdomain.com/callback (use ngrok to expose your backend on local development)
npm start
or
npm run dev
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Your Name - @dev_williee - archywilliams2@gmail.com
Project Link: https://github.com/DeveloperWilliams/Daraja-api-node-express.git