@stateset/embedded 1.35.1.
You will create a customer and inventory item, place a two-unit order, check available stock,
and cancel the order to release its reservation.
The program uses a fresh in-memory database. It makes no hosted API requests and requires no
API key. For persistence across runs, start with the embedded quickstart.
Prerequisites
- Node.js 20.20.0+ and npm 10+.
- A project with
@stateset/embedded@1.35.1installed.
Run the complete example
Save this asorders-demo.mjs:
INSUFFICIENT_STOCK rejection is intentional. With ten units on hand and two allocated to the first
order, a second order for nine units cannot be satisfied under reject_if_insufficient.
The order-count assertion verifies that the failed attempt did not create another order.
Understand the results
stockPolicy: 'reject_if_insufficient' makes the availability check part of order creation.
The engine reserves stock for the order; a second manual reservation for the same units would
allocate them again. getStock returns quantity strings, and totalAmountExact returns the
order’s decimal-string total.
Continue toward fulfillment
Cancellation is the terminal path demonstrated above. Use a separate order for a shipping flow; a cancelled order is not a draft to reopen. Run the complete fulfillment and shipping example to inspect shipment state alongside the separate order and inventory outcomes. The order lifecycle reference shows which methods change state and which return shapes to inspect. A carrier label, payment provider call, and customer notification are separate integration work. An order status change alone is not evidence that those external actions occurred. For cross-system operations, use the Shopify–NetSuite integration guide and durable workflow guide.Troubleshooting
Next steps
To explore payment state separately, run the payment and refund quickstart. It verifies local retry identity and balance guards without contacting a payment provider.Order lifecycle
Read the method and state reference for the Node binding.
Create a return
Use a shipped order and its actual line-item ID to create and receive a return.
Hosted commerce API
Use the HTTP contract when operating a deployed commerce service.
Get help
Share the failed operation, runtime version and redacted error.