Skip to main content

Overview

After checkout, Henry orchestrates fulfillment across merchants and keeps you updated through the Orders SDK helpers. Use them to power order history, customer support tools, and backend automations without building custom polling infrastructure.
import HenrySDK from '@henrylabs/sdk';

const client = new HenrySDK({
  apiKey: process.env.HENRY_API_KEY!,
});

Retrieve the latest status

Call client.orders.retrieveStatus with the ID returned from checkout to fetch the latest order snapshot.
async function getOrder(orderId: string) {
  const response = await client.orders.retrieveStatus(orderId);
  return response.data;
}

const order = await getOrder('123e4567-e89b-12d3-a456-426614174000');
console.log(order.status, order.statusMessage);
The response includes:
  • status and statusMessage — machine and human-friendly states (for example pending, processing, ordered).
  • Monetary totals: subtotal, tax, shipping, and grandTotal, each returned as strings.
  • products — array of items with productName, quantity, and the metadata you supplied when adding to cart.
  • shippingDetails — validated address and contact information used for fulfillment.

Polling pattern

Henry returns immediately once an order is created, even if downstream merchants are still processing it. Poll the SDK helper until the status stabilizes or until you pivot to webhooks.
function pollOrderStatus(orderId: string, intervalMs = 5000) {
  let timer: NodeJS.Timeout;

  const stop = () => clearInterval(timer);

  timer = setInterval(async () => {
    const order = await getOrder(orderId);
    console.log(`${orderId}: ${order.status}`);

    if (['delivered', 'cancelled', 'failed'].includes(order.status)) {
      stop();
    }
  }, intervalMs);

  return stop;
}

const stopPolling = pollOrderStatus(order.id);
Persist statusMessage alongside status so support teams can read the canonical explanation without cross-referencing merchant dashboards.

Handling errors

  • 401 Unauthorized — confirm the API key you passed to the SDK.
  • 404 Order not found — the order ID may be invalid or belongs to a different environment (sandbox vs production).
  • 500 Internal Server Error — rare, but retry with exponential backoff; if it persists, share the orderId and timestamp with support.
Looking for real-time updates? Reach out to your Henry account team to enable beta webhooks for order lifecycle events.