Build an integration · Deliver ordersDocs navigation

Deliver waiting orders from your own system

For goods made at the moment of sale, the order waits until your program adds the stock it needs and asks Shoplio to deliver it.

On this page

When this fits

Use it for goods your own system makes when someone buys, such as a licence created on your server. A paid order waits for you in one of two statuses.

StatusHow it happensWhat delivers it
preorderedPre-orders are on and a signed-in buyer paid while the product had no stockAdding stock. Waiting pre-orders are delivered oldest first
out_of_stockThe buyer paid, but the stock ran out before deliveryYour call to deliver the order

A product with no stock and pre-orders off cannot be bought. Goods made on demand therefore need pre-orders on, as Add products and variants describes.

The steps

  1. Poll List orders with status=preordered and with status=out_of_stock. The list is newest first, so read every page and start from the oldest order.
  2. Make one item per unit of the order's quantity in your own system.
  3. Push the items with Add stock to the order's product_id, naming its variant_id when it has one.
  4. Call Deliver an order with the order id.
  5. Read the order again. Once it is delivered, the buyer has the goods.

A stock line is not tied to one order. Waiting pre-orders take new stock oldest first, and stock that is left over is open to any buyer. Work through waiting orders oldest first and push only what they need.

What the buyer sees while waiting

  • A preordered order tells the buyer it is paid and will be delivered on restock. At the product's deadline it is credited to their store balance instead.
  • An out_of_stock order tells the buyer the product ran out after they paid. With Instant Refund to Balance on, they can take store balance instead of waiting.
  • With Full Auto-Refund on, an out_of_stock order of a buyer with a store account is credited to their balance without waiting. Deliver then refuses it.

Doing it twice is safe

  • A delivered order answers 200 with already_delivered set to true. Nothing more is delivered.
  • in_progress means another attempt holds the order. Read the order again shortly.
  • With too little stock the call answers 409 with insufficient_stock, and the order stays as it was.

A program that retries after a timeout therefore never delivers an order twice. The other refusals are listed under Deliver an order.

If the docs do not cover it, ask on Telegram or use the contact form.