Skip to main content
This reference covers @stateset/embedded 1.35.1. The returns quickstart contains a complete program that creates a shipped order, returns one item, verifies an idempotent retry, and follows the RMA through receipt.

1. Validate eligibility

Read the order before creating a return. Verify that it is shipped, that the requested line belongs to it, and that the quantity is eligible. Apply your business’s return policy before approving a request; the record’s existence alone is not an approval.

2. Create the return authorization

In this snippet, order is a shipped order read from the same database and commerce is your Commerce instance:
Use items and orderItemId; this Node method does not accept lineItems keyed only by SKU. The new return’s status is requested. Preserve the same key and request for a retry of this operation. The quickstart checks that replay returns the same RMA ID.

3. Approve or reject

For a requested RMA that should be rejected, the alternative is commerce.returns.reject(rma.id, 'Reason for rejection'). The second argument is a string. Choose one path based on the current state and the policy decision.

4. Add tracking, then receive

addTracking takes a tracking-number string and moves the approved RMA to in_transit. markReceived moves it to received. In a production workflow, call receipt after the parcel has actually arrived; updating the record does not contact a carrier or inspect an item.

5. Inspect and complete

A disposition records how each returned item is handled: restock, quarantine, refurbishment, scrap or return to vendor. The engine rejects completion when items lack dispositions.
Node binding 1.35.1 exposes returns.complete(id) but does not expose an item-disposition setter or the completion write-off option. The quickstart therefore stops at received and verifies that premature completion is rejected. Use an integration that supports the disposition step before attempting an end-to-end production completion flow.
After the required item handling has been recorded through a supported interface, completion is a separate transition. Treat any refund as its own financial operation and verify it in the payment system. Receiving or completing an RMA alone is not proof of a payment-provider refund.

Cancelling

For an RMA whose current state permits cancellation:
Cancellation is subject to state and disposition guards. Read the record and handle a rejected transition; do not use cancellation as a generic error-cleanup step after goods have been received or dispositioned.

Finding returns

These methods return the Node binding’s records. For example, ReturnOutput includes the return ID, order ID, status, reason, version, creation time and optional idempotency key. Do not assume it contains the full item-disposition or payment-provider record.
Last modified on September 20, 2026