-
Notifications
You must be signed in to change notification settings - Fork 26
Orders
Branko Conjic edited this page Sep 5, 2024
·
7 revisions
Retrieves the order with the given ID.
import { type Order, getOrder } from '@lemonsqueezy/lemonsqueezy.js';
const orderId = 234567;
const { statusCode, error, data } = await getOrder(orderId);
With related resources:
import { type GetOrderParams, type Order, getOrder } from '@lemonsqueezy/lemonsqueezy.js';
const orderId = 234567;
const { statusCode, error, data } = await getOrder(orderId, { include: ['store'] });
/**
* 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 an Order object.
{
statusCode: number | null;
error: Error | null;
data: Order | null;
}
Returns a paginated list of orders.
import { type ListOrders, listOrders } from '@lemonsqueezy/lemonsqueezy.js';
const { statusCode, error, data } = await listOrders();
With filter:
import { type ListOrders, type ListOrdersParams, listOrders } from '@lemonsqueezy/lemonsqueezy.js';
const { statusCode, error, data } = await listOrders({ filter: { storeId: 234567 } });
With pagination:
import { type ListOrders, type ListOrdersParams, listOrders } from '@lemonsqueezy/lemonsqueezy.js';
const { statusCode, error, data } = await listOrders({ page: { number: 1, size: 10 } });
With related resources:
import { type ListOrders, type ListOrdersParams, listOrders } from '@lemonsqueezy/lemonsqueezy.js';
const { statusCode, error, data } = await listOrders({ include: ['store'] });
/**
* 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 a paginated list of order objects ordered by created_at
(descending).
{
statusCode: number | null;
error: Error | null;
data: ListOrders | null;
}
Generates a new invoice for the given order with given parameters.
import { type OrderInvoice, type GenerateOrderInvoiceParams, generateOrderInvoice } from '@lemonsqueezy/lemonsqueezy.js';
const orderId = 12345;
const { statusCode, error, data } = await generateOrderInvoice(orderId);
With optional parameters:
import { type OrderInvoice, type GenerateOrderInvoiceParams, generateOrderInvoice } from '@lemonsqueezy/lemonsqueezy.js';
const orderId = 12345;
const { statusCode, error, data } = await generateOrderInvoice(orderId, {
name: 'John Doe',
address: '123 Main St',
city: 'Anytown',
state: 'CA',
country: 'US',
zipCode: 12345,
notes: 'Thank you for your business!',
});
/**
* Generate order invoice.
*
* @param orderId The given order 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 generateOrderInvoice(orderId: number | string, params?: GenerateOrderInvoiceParams): Promise<FetchResponse<OrderInvoice>>;
Returns a link to download the generated invoice.
{
statusCode: number | null;
error: Error | null;
data: OrderInvoice | null;
}
Issues a partial refund for the order with given id
and given amount
in cents.
import { issueOrderRefund } from '@lemonsqueezy/lemonsqueezy.js';
const orderId = 12345;
const amount = 100;
const { statusCode, error, data } = await issueOrderRefund(orderId, amount);
/**
* Issues a partial refund of the order.
*
* @param orderId The order id.
* @param amount The amount in cents to refund. Must be less than the total amount of the order.
*/
declare function issueOrderRefund(orderId: number | string, amount: number): Promise<FetchResponse<Order>>;
Returns an Order object.
{
statusCode: number | null;
error: Error | null;
data: Order | null;
}