monobank-helper
v1.0.38
Published
A TypeScript SDK for interacting with Monobank API, providing methods for invoice management, payment processing, and QR terminal operations.
Downloads
16
Maintainers
Readme
Monobank Helper
Introduction
This is a TypeScript SDK designed to interact with the Monobank API. It provides various methods for invoice management, payment processing, and QR terminal operations.
Installation
To install the package, you can use npm:
npm install monobank-helper
Usage
First, import and instantiate the MonobankSdk
class with your API key:
import MonobankSdk from 'monobank-helper';
const apiKey = 'your-api-key';
const monobankSdk = new MonobankSdk(apiKey);
Create an Invoice
To create an invoice, use the following code:
const requestBody = {
// your request body here
};
monobankSdk.createInvoice(requestBody, 'CMS Name', 'CMS Version')
.then(response => {
console.log('Invoice Created:', response);
})
.catch(error => {
console.error('Error creating invoice:', error);
});
Get Invoice Status
To get the status of an invoice, use the following code:
const invoiceId = 'your-invoice-id';
monobankSdk.getInvoiceStatus(invoiceId)
.then(response => {
console.log('Invoice Status:', response);
})
.catch(error => {
console.error('Error fetching invoice status:', error);
});
Cancel Invoice Payment
To cancel an invoice payment, use the following code:
const requestBody = {
// your request body here
};
monobankSdk.cancelInvoicePayment(requestBody)
.then(response => {
console.log('Invoice Payment Cancelled:', response);
})
.catch(error => {
console.error('Error canceling invoice payment:', error);
});
Invalidate an Invoice
To invalidate an invoice, use the following code:
const requestBody = {
// your request body here
};
monobankSdk.invalidateInvoice(requestBody)
.then(response => {
console.log('Invoice Invalidated:', response);
})
.catch(error => {
console.error('Error invalidating invoice:', error);
});
Get Public Key
To get the public key for signature verification, use the following code:
monobankSdk.getPublicKey()
.then(response => {
console.log('Public Key:', response);
})
.catch(error => {
console.error('Error fetching public key:', error);
});
Get QR Terminal Info
To get information about a QR terminal, use the following code:
const qrId = 'your-qr-id';
monobankSdk.getQrTerminalInfo(qrId)
.then(response => {
console.log('QR Terminal Info:', response);
})
.catch(error => {
console.error('Error fetching QR terminal info:', error);
});
Delete Payment Amount
To delete a payment amount, use the following code:
const qrId = 'your-qr-id';
monobankSdk.deletePaymentAmount(qrId)
.then(() => {
console.log('Payment Amount Deleted');
})
.catch(error => {
console.error('Error deleting payment amount:', error);
});
Get QR Terminal List
To get a list of QR terminals, use the following code:
monobankSdk.getQrTerminalList()
.then(response => {
console.log('QR Terminal List:', response);
})
.catch(error => {
console.error('Error fetching QR terminal list:', error);
});
Create Payment Using Card Token
To create a payment using a card token, use the following code:
const requestBody = {
// your request body here
};
monobankSdk.createPayment(requestBody, 'CMS Name', 'CMS Version')
.then(response => {
console.log('Payment Created:', response);
})
.catch(error => {
console.error('Error creating payment:', error);
});
Create Payment Using Card Details
To create a payment using card details, use the following code:
const requestBody = {
// your request body here
};
monobankSdk.createCardPayment(requestBody, 'CMS Name', 'CMS Version')
.then(response => {
console.log('Card Payment Created:', response);
})
.catch(error => {
console.error('Error creating card payment:', error);
});