Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Checkouts

Caven edited this page Jan 31, 2024 · 1 revision

createCheckout

Create a custom checkout.

Usage

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)

Type Declarations

/**
 * 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

Returns a checkout object.

{
  statusCode: number | null
  error: Error | null
  data: Checkout | null
}

Source

Source ~ Type ~ Test

getCheckout

Retrieves the checkout with the given ID.

Usage

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'] })

Type Declarations

/**
 * 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

Returns a checkout object.

{
  statusCode: number | null
  error: Error | null
  data: Checkout | null
}

Source

Source ~ Type ~ Test

listCheckouts

Returns a paginated list of checkouts.

Usage

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'] })

Type Declarations

/**
 * 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

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

{
  statusCode: number | null
  error: Error | null
  data: ListCheckouts | null
}

Source

Source ~ Type ~ Test

Clone this wiki locally