A simple and lightweight Node.js library for interacting with the MeetPay API. This library provides methods to create transactions and manage payment-related interactions with MeetPay.
• Create transactions with buyer details, account ID, and webhook URL.
• Configurable API key and endpoint.
• Handles API and network errors gracefully.
• Lightweight and easy to use.
Install the package using npm:
npm install meetpay-node-apiInitialize the Client
const MeetPayClient = require('meetpay-node-api');
// Initialize the MeetPayClient with your API key
const client = new MeetPayClient('your-api-key');Create a Transaction
To create a transaction, use the createTransaction method. Provide the buyer details, account ID, transaction amount, and a webhook URL.
(async () => {
try {
const buyerDetails = {
buyer_name: 'William',
buyer_phone: '0689726060',
buyer_email: 'william@zeno.co.tz',
};
const accountId = 'mp-001'; // The user's MeetPay account ID
const amount = 1000; // Transaction amount
const webhookUrl = 'https://example.com/webhook'; // URL to receive transaction updates
const response = await client.createTransaction(accountId, buyerDetails, amount, webhookUrl);
console.log('Transaction created:', response);
} catch (error) {
console.error('Error creating transaction:', error.message);
}
})();On success, the createTransaction method will return:
{
"message": "Transaction created successfully",
"transactionId": "tr-001"
}On error, it will throw an exception with a descriptive error message.
• Missing required transaction details.
• Incomplete buyer details.
• API Error: Invalid account ID or API key.
• Network Error: Request timed out.
This project is licensed under the MIT License. See the LICENSE file for details.
If you encounter any issues or have questions, feel free to reach out: • Email: home@meetpay.africa • Documentation: MeetPay API Docs