i-bot-payment
A simple Node.js client for interacting with the iBot Payment API.
Installation
Using npm:
npm i i-bot-payment
Usage
First, import the module and initialize the client with your API key:
const iBotPayment = require('i-bot-payment');
const payment = new iBotPayment("YOUR_API_KEY");
Methods
###Create Ticket### Use this method to create a payment item available for multiple users to make payments:
const result = await payment.createTicket(amount, description);
The result will produce a ticketId and a paymentURL. The paymentURL can be used in Telegram, which launches a webapp to allow users to make payments through the i-Bot wallet.
###Get Payment Status### To obtain information about a specific ticket:
const status = await payment.getPaymentStatus(ticketId);
The returned status will include details like users - indicating who has made payments and payOut - detailing which users have been paid from this ticket and how much.
###Send From Ticket### To send a balance from this ticket to a specific user:
const sendResult = await payment.sendFromTicket(ticketId, telegramId, amount);
It's important to note that the specified telegramId must be associated with an i-Bot wallet.
###Close Ticket### Close the ticket and send the remaining balance to the i-Bot wallet of the API key holder:
const closeResult = await payment.closeTicket(ticketId);
##Error Handling## This client has basic error handling. For production usage, ensure to add additional error checks as required by your application.
##Contributing## Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
##License## MIT