Logo Lanfrica

madegwa-o/mpesajs-lib

Domaine:

digital infrastructure

Type de record:

software
Créateur:
mad
Hôte:
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