Easy Labs
SDKsNode.jsResources

Orders

Orders — methods, parameters, and examples for @easylabs/node.

An order is the application-level record of a purchase: who bought what, for how much, against which payment instrument, and which transfer captured the funds. Orders are produced by checkout, embedded checkout, payment links, and subscription invoicing — there is no createOrder method.

Methods

getOrder(orderId)

GET /orders/:id.

getOrders(params?)

GET /orders. Standard pagination.

updateOrderTags(orderId, tags)

PATCH /orders/:id. The only mutable field is tags. Pass the full tag bag you want stored — server replaces, it does not merge.

await easy.updateOrderTags(orderId, {
  fulfilment_state: "shipped",
  tracking_number: "1Z999AA10123456784",
});

To list orders for a single customer, use getCustomerOrders.

Object shape

OrderData includes:

FieldTypeNotes
id / order_numberstringUUID + human-friendly number.
subtotal_cents / tax_amount_cents / total_centsnumberAll in the smallest currency unit.
currencystringISO 4217.
merchant_id / company_idstring
sourcestring"checkout", "payment_link", "subscription", etc.
payment_instrumentPaymentInstrumentDataInstrument used.
transferTransferData | nullThe capture (null for declined / cancelled orders).
payment_link_idstring | nullSet when sourced from a payment link.
purchase_itemsPurchaseItemData[]Line items with embedded price_data + product_data.
buyer_detailsobjectemail, phone, name, billing address.
shipping_address / billing_addressAddress | null
failure_code / failure_messagestring | nullPopulated on declines.
tax_rate_idstring | null
metadata / tagsRecord<string, unknown>

Examples

Reconcile recent orders

const orders = await easy.getOrders({ limit: 100 });
for (const o of orders.data) {
  if (!o.transfer || o.transfer.state !== "SUCCEEDED") continue;
  // post o.total_cents to your ledger keyed on o.order_number
}

Attach fulfilment metadata when a webhook fires

import { EasyWebhooks } from "@easylabs/node";

// Inside your webhook handler:
const event = EasyWebhooks.constructEvent(rawBody, sigHeader, secret);
if (event.type === "checkout.session.completed") {
  const order = event.data as { id: string; order_number: string };
  await easy.updateOrderTags(order.id, {
    fulfilment_state: "queued",
    queued_at: new Date().toISOString(),
  });
}

Surface a declined order to support

const { data: order } = await easy.getOrder(orderId);
if (order.failure_code) {
  console.warn(`Order ${order.order_number} failed: ${order.failure_message} (${order.failure_code})`);
}

On this page