Logo Lanfrica

madegwa-o/mpesajs-lib

Domain:

digital infrastructure

Record type:

software
Creator:
mad
Host:
This is a javascript/Typescript library made to simplify the mpesa payment intergration process # 🧾 mpesajs-lib A lightweight JavaScript/TypeScript library for simplifying **Mpesa payment integration** via the **Safaricom Daraja API**. --- ## πŸš€ Features - Easy-to-use interface for initiating STK Push - Built with modern ES modules - Works with JavaScript and TypeScript - Designed for Node.js - Lightweight and dependency-free --- ## πŸ“¦ Installation ```bash npm install mpesajs-lib ``` --- ## πŸ› οΈ Usage ```js import { initiateStkPush } from 'mpesajs-lib'; const response = await initiateStkPush({ amount: 100, phoneNumber: '254712345678', accountReference: 'Order123', transactionDesc: 'Payment for Order #123', consumerKey: process.env.MPESA_CONSUMER_KEY, consumerSecret: process.env.MPESA_CONSUMER_SECRET, passKey: process.env.MPESA_PASSKEY, shortCode: process.env.MPESA_SHORTCODE, callbackUrl: 'yourdomain.com' }); console.log(response); ``` > πŸ” Make sure to store your credentials securely using `.env`. --- ## πŸ”§ Configuration To use this library, you need: - **Safaricom Daraja App Credentials** - Consumer Key - Consumer Secret - Pass Key - Shortcode - Registered Callback URL You can get these at: developer.safaricom.co.ke --- ## πŸ§ͺ Running Tests ```bash npm run test ``` (You can update the `test.js` file with your own tests or integrate Jest/Mocha later.) --- ## 🀝 Contributing Contributions are welcome! Follow these steps: 1. Fork the repository 2. Create a new branch (`git checkout -b feature/your-feature`) 3. Make your changes 4. Commit your changes (`git commit -m 'add your feature'`) 5. Push to the branch (`git push origin feature/your-feature`) 6. Open a Pull Request Please ensure your code is **clean**, **documented**, and **tested**. --- ## πŸ“„ License MIT Β© Oscar Madegwa --- ## 🌐 Links - πŸ“¦ NPM Package - πŸ›  API Docs - πŸ› Report Bugs - πŸ’‘ Request Features

Languages