Pickup details on orders

API

Everything a person needs at the counter is now on the order, and the confirm code is no longer a mystery.

The order read is complete. GET /v1/orders/:id adds three blocks:

"fulfillment": {
  "type": "pickup",
  "name": "Sam",
  "address": "1 Sandbox Way, San Francisco, CA 94107",
  "ready_text": "Ready by 10:15 AM",
  "merchant_order_number": "A47",
  "instructions": "Pick up at the mobile order counter"
},
"lines": [{ "name": "Latte", "quantity": 1, "unit_price_minor": 525, "modifiers": [] }],
"amounts": { "subtotal_minor": 525, "tax_minor": 46, "merchant_total_minor": 571, "service_fee_minor": 40,
             "service_fee_waived": false, "credit_minor": 0, "charged_minor": 611 }

The fulfillment details are the store's own words, null until the order is placed and null when the store did not state them. type is pickup today; read it, because more types are coming. charged_minor is what the person's card is charged; total_minor is still the store's total without Layout's fee. See GET /v1/orders/:id.

order.updated. Some stores state the ready time or the name a minute after the order is placed. When that happens, one order.updated follows order.placed, with state: "placed". Like every event it carries no details: read the order again. Add it to your endpoint's events in the console to receive it. See Events.

codeReason. A cart now says why its confirm will need the person's code: person_setting, over_limit, code_outstanding, first_order_consent (build grants), or unverified, and null when none is needed. 400 code_required carries the same field, plus risk_check. codeRequired is now checked each time you read the cart, so it matches what the confirm will do. See When the answer is code_required.

A live status link. The confirm's 202 now carries order.trackUrl, Layout's live status page for the order. It is view-only, safe to show the person, and stops answering 15 minutes after the order ends.

test_place_code. A sandbox test restaurant whose confirm answers code_required until it carries the code 000000. Nothing is texted. layout test-order --place test_place_code runs it end to end from CLI 0.3.1, once that version is on npm. See Sandbox.

Why it matters

An app could not tell the person what to say at the counter, which number to quote, or what they paid without keeping the cart around. And a cart could say a code was coming when the person's settings meant none would be, leaving an app waiting on a text that never came.

What to do

Show fulfillment once the order is placed, and read the order again on order.updated. Show the person why a code is needed from codeReason, and keep handling code_required on every confirm. Run test_place_code before going live.

Breaking changes

None. Every field is new. One count is corrected: items, on the order and on every webhook, no longer counts Layout's own tax-and-fees line, so a one-item order reads 1.

All changes