Skip to content

SubscriptionInvoices

Branko Conjic edited this page Jun 11, 2024 · 3 revisions

getSubscriptionInvoice

Retrieves the subscription invoice with the given ID.

Usage

import { type SubscriptionInvoice, getSubscriptionInvoice } from '@lemonsqueezy/lemonsqueezy.js';

const subscriptionInvoiceId = 234567;
const { statusCode, error, data } = await getSubscriptionInvoice(subscriptionInvoiceId);

With related resources:

import { type GetSubscriptionInvoiceParams, type SubscriptionInvoice, getSubscriptionInvoice } from '@lemonsqueezy/lemonsqueezy.js';

const subscriptionInvoiceId = 234567;
const { statusCode, error, data } = await getSubscriptionInvoice(subscriptionInvoiceId, { include: ['store'] });

Type Declarations

/**
 * Retrieve a subscription invoice.
 *
 * @param subscriptionInvoiceId The given subscription invoice id.
 * @param [params] (Optional) Additional parameters.
 * @param [params.include] (Optional) Related resources.
 * @returns A subscription invoice object.
 */
declare function getSubscriptionInvoice(
	subscriptionInvoiceId: number | string,
	params?: GetSubscriptionInvoiceParams
): Promise<FetchResponse<SubscriptionInvoice>>;

Returns

Returns a subscription invoice object.

{
	statusCode: number | null;
	error: Error | null;
	data: SubscriptionInvoice | null;
}

Source

Source ~ Type ~ Test

listSubscriptionInvoices

Returns a paginated list of subscription invoices.

Usage

import { type ListSubscriptionInvoices, listSubscriptionInvoices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listSubscriptionInvoices();

With filter:

import { type ListSubscriptionInvoices, type ListSubscriptionInvoicesParams, listSubscriptionInvoices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listSubscriptionInvoices({ filter: { storeId: 123456 } });

With pagination:

import { type ListSubscriptionInvoices, type ListSubscriptionInvoicesParams, listSubscriptionInvoices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listSubscriptionInvoices({ page: { number: 1, size: 10 } });

With related resources:

import { type ListSubscriptionInvoices, type ListSubscriptionInvoicesParams, listSubscriptionInvoices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listSubscriptionInvoices({ include: ['store'] });

Type Declarations

/**
 * List all subscription invoices.
 *
 * @param [params] (Optional) Additional parameters.
 * @param [params.filter] (Optional) Filter parameters.
 * @param [params.filter.storeId] (Optional) Only return subscription invoices belonging to the store with this ID.
 * @param [params.filter.status] (Optional) Only return subscription invoices with this status.
 * @param [params.filter.refunded] (Optional) Only return subscription invoices that are `refunded` (the value should be `true` or `false`).
 * @param [params.filter.subscriptionId] (Optional) Only return subscription invoices belonging to a subscription with this ID.
 * @param [params.page] (Optional) Custom paginated queries.
 * @param [params.page.number] (Optional) The parameter determine which page to retrieve.
 * @param [params.page.size] (Optional) The parameter to determine how many results to return per page.
 * @param [params.include] (Optional) Related resources.
 * @returns A paginated list of subscription invoice objects ordered by `created_at` (descending).
 */
declare function listSubscriptionInvoices(params?: ListSubscriptionInvoicesParams): Promise<FetchResponse<ListSubscriptionInvoices>>;

Returns

Returns a paginated list of subscription invoice objects ordered by created_at (descending).

{
	statusCode: number | null;
	error: Error | null;
	data: ListSubscriptionInvoices | null;
}

Source

Source ~ Type ~ Test

generateSubscriptionInvoice

Generates a new invoice for the given subscription with given parameters.

Usage

import { type GenerateSubscriptionInvoice, generateSubscriptionInvoice } from '@lemonsqueezy/lemonsqueezy.js';

const subscriptionInvoiceId = 12345;
const { statusCode, error, data } = await generateSubscriptionInvoice(subscriptionInvoiceId);

With params:

import { type GenerateSubscriptionInvoice, type GenerateSubscriptionInvoiceParams, generateSubscriptionInvoice } from '@lemonsqueezy/lemonsqueezy.js';

const subscriptionInvoiceId = 12345;
const { statusCode, error, data } = await generateSubscriptionInvoice(subscriptionInvoiceId, {
	name: 'John Doe',
	address: '123 Main St',
	city: 'Anytown',
	state: 'CA',
	country: 'US',
	zipCode: 12345,
	notes: 'Thank you for your business!',
});

Type Declarations

/**
 * Generate subscription invoice.
 *
 * @param subscriptionInvoiceId The given subscription invoice id.
 * @param [params] (Optional) Then given parameters.
 * @param [params.name] (Optional) The full name of the customer.
 * @param [params.address] (Optional) The street address of the customer.
 * @param [params.city] (Optional) The city of the customer.
 * @param [params.state] (Optional) The state of the customer.
 * @param [params.zipCode] (Optional) The ZIP code of the customer.
 * @param [params.country] (Optional) The country of the customer.
 * @param [params.notes] (Optional) Any additional notes to include on the invoice.
 * @returns A link to download the generated invoice.
 */
declare function generateSubscriptionInvoice(
	subscriptionInvoiceId: number | string,
	params?: GenerateSubscriptionInvoiceParams
): Promise<FetchResponse<GenerateSubscriptionInvoice>>;

Returns

Returns a link to download the generated invoice.

{
	statusCode: number | null;
	error: Error | null;
	data: GenerateSubscriptionInvoice | null;
}

Source

Source ~ Type ~ Test

Clone this wiki locally