Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
Caven edited this page Jan 31, 2024 · 2 revisions

getOrder

Retrieves the order with the given ID.

Usage

import { type Order, getOrder } from '@heybrostudio/lemonsqueezy.js'

const orderId = 234567
const { statusCode, error, data } = await getOrder(orderId)

With related resources:

import { type GetOrderParams, type Order, getOrder } from '@heybrostudio/lemonsqueezy.js'

const orderId = 234567
const { statusCode, error, data } = await getOrder(orderId, { include: ['store'] })

Type Declarations

/**
 * Retrieve an order.
 *
 * @param orderId The given order id.
 * @param [params] (Optional) Additional parameters.
 * @param [params.include] (Optional) Related resources.
 * @returns An order object.
 */
declare function getOrder(orderId: number | string, params?: GetOrderParams): Promise<FetchResponse<Order>>

Returns

Returns an order object.

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

Source

Source ~ Type ~ Test

listOrders

Returns a paginated list of orders.

Usage

import { type ListOrders, listOrders } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listOrders()

With filter:

import { type ListOrders, type ListOrdersParams, listOrders } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listOrders({ filter: { storeId: 234567 } })

With pagination:

import { type ListOrders, type ListOrdersParams, listOrders } from '@heybrostudio/lemonsqueezy.js'

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

With related resources:

import { type ListOrders, type ListOrdersParams, listOrders } from '@heybrostudio/lemonsqueezy.js'

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

Type Declarations

/**
 * List all orders.
 *
 * @param [params] (Optional) Additional parameters.
 * @param [params.filter] (Optional) Filter parameters.
 * @param [params.filter.storeId] (Optional) Only return orders belonging to the store with this ID.
 * @param [params.filter.userEmail] (Optional) Only return orders where the `user_email` field is equal to this email address.
 * @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 order objects ordered by `created_at` (descending).
 */
declare function listOrders(params?: ListOrdersParams): Promise<FetchResponse<ListOrders>>

Returns

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

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

Source

Source ~ Type ~ Test

Clone this wiki locally