1.6.0 • Published 5 months ago
@basel_mn/qv-api-client v1.6.0
Billmate QV API Client
Official TypeScript/JavaScript client for Billmate's QV API, providing easy access to invoices, payments, and Swish integration.
Installation
To install this package, run:
npm install @billmate/qv-api-clientUsage
TypeScript
import ApiClient from '@billmate/qv-api-client';
const client = new ApiClient({
baseURL: 'https://api.example.com',
accessToken: 'your-access-token'
});
// Invoices API
async function getInvoices() {
try {
const response = await client.invoices.getInvoices();
console.log('Invoices:', response.data);
} catch (error) {
console.error('Error:', error);
}
}
// Payments API
async function getPaymentMethods() {
try {
const methods = await client.payments.getPaymentMethods();
console.log('Payment methods:', methods);
} catch (error) {
console.error('Error:', error);
}
}
// Swish API
async function initiateSwishPayment() {
try {
const payment = await client.swish.initiatePayment({
invoiceId: '123',
// other payment details
});
console.log('Payment initiated:', payment);
} catch (error) {
console.error('Error:', error);
}
}JavaScript
const ApiClient = require('@billmate/qv-api-client').default;
const client = new ApiClient({
baseURL: 'https://api.example.com',
accessToken: 'your-access-token'
});API Reference
Invoices API
getInvoices(params?): Get a list of invoicesgetInvoice(id): Get a specific invoice by IDgetInvoiceStatus(id): Get the status of an invoicesendInvoiceReminder(id): Send a reminder for an invoicecreateInvoicePayment(id, paymentData): Create a payment for an invoice
Payments API
getPayments(params?): Get a list of paymentsgetPayment(id): Get a specific payment by IDgetPaymentMethods(): Get available payment methods
Swish API
getStatus(invoiceId, orderId?): Get Swish payment statusinitiatePayment(paymentData): Initiate a Swish paymentinitiateRefund(refundData): Initiate a Swish refund
Error Handling
The client includes built-in error handling with detailed error information:
try {
await client.invoices.getInvoices();
} catch (error) {
if (error.status === 404) {
console.error('Not found:', error.details);
} else if (error.status === 0) {
console.error('Network error:', error.details);
}
}Contributing
If you would like to contribute to this project, please fork the repository and submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.