1.6.0 • Published 5 months ago

@basel_mn/qv-api-client v1.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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-client

Usage

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 invoices
  • getInvoice(id): Get a specific invoice by ID
  • getInvoiceStatus(id): Get the status of an invoice
  • sendInvoiceReminder(id): Send a reminder for an invoice
  • createInvoicePayment(id, paymentData): Create a payment for an invoice

Payments API

  • getPayments(params?): Get a list of payments
  • getPayment(id): Get a specific payment by ID
  • getPaymentMethods(): Get available payment methods

Swish API

  • getStatus(invoiceId, orderId?): Get Swish payment status
  • initiatePayment(paymentData): Initiate a Swish payment
  • initiateRefund(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.

1.6.0

5 months ago

1.5.1

5 months ago

1.5.0

5 months ago

1.4.0

6 months ago

1.3.0

6 months ago

1.2.0

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.2

6 months ago

1.0.0

6 months ago