Checkouts - heybrostudio/lemonsqueezy.js GitHub Wiki
Create a custom checkout.
import { type NewCheckout, type Checkout, createCheckout } from '@heybrostudio/lemonsqueezy.js'
const storeId = 123456
const variantId = 234567
const newCheckout = {
productOptions: {
name: 'New Checkout Test',
description: 'a new checkout test',
},
checkoutOptions: {
embed: true,
media: true,
logo: true,
},
checkoutData: {
email: '[email protected]',
name: 'Lemon Squeezy Test',
},
expiresAt: null,
preview: true,
testMode: true,
}
const { statusCode, error, data } = await createCheckout(storeId, variantId, newCheckout)/**
* Create a checkout.
*
* @param storeId (Required) The given store id.
* @param variantId (Required) The given variant id.
* @param [checkout] (Optional) A new checkout info.
* @returns A checkout object.
*/
declare function createCheckout(
storeId: number | string,
variantId: number | string,
checkout?: NewCheckout,
): Promise<FetchResponse<Checkout>>Returns a checkout object.
{
statusCode: number | null
error: Error | null
data: Checkout | null
}Retrieves the checkout with the given ID.
import { type Checkout, getCheckout } from '@heybrostudio/lemonsqueezy.js'
const checkoutId = 456789
const { statusCode, error, data } = await getCheckout(checkoutId)With related resources:
import { type Checkout, type GetCheckoutParams, getCheckout } from '@heybrostudio/lemonsqueezy.js'
const checkoutId = 456789
const { statusCode, error, data } = await getCheckout(checkoutId, { include: ['store'] })/**
* Retrieve a checkout.
*
* @param checkoutId (Required) The checkout id.
* @param [params] (Optional) Additional parameters.
* @param [params.include] (Optional) Related resources.
* @returns A checkout object.
*/
declare function getCheckout(checkoutId: number | string, params?: GetCheckoutParams): Promise<FetchResponse<Checkout>>Returns a checkout object.
{
statusCode: number | null
error: Error | null
data: Checkout | null
}Returns a paginated list of checkouts.
import { type ListCheckouts, listCheckouts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listCheckouts()With filter:
import { type ListCheckouts, type ListCheckoutsParams, listCheckouts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listCheckouts({ filter: { storeId: 123456 } })With pagination:
import { type ListCheckouts, type ListCheckoutsParams, listCheckouts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listCheckouts({ page: { number: 1, size: 10 } })With related resources:
import { type ListCheckouts, type ListCheckoutsParams, listCheckouts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listCheckouts({ include: ['store'] })/**
* List all checkouts.
*
* @param [params] (Optional) Additional parameters.
* @param [params.filter] (Optional) Filter parameters.
* @param [params.filter.storeId] (Optional) Only return products belonging to the store with this ID.
* @param [params.filter.variantId] (Optional) Only return products belonging to the variant 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 checkout objects ordered by `created_at` (descending).
*/
declare function listCheckouts(params?: ListCheckoutsParams): Promise<FetchResponse<ListCheckouts>>Returns a paginated list of checkout objects ordered by created_at (descending).
{
statusCode: number | null
error: Error | null
data: ListCheckouts | null
}