Phase 3 — Order Creation
The order creation flow after the customer confirms checkout. COOCO is the central order hub — it creates an internal record first, then synchronizes to RideNDine.
Overview
Customer → COOCO (internal) → RideNDine → COOCO (link IDs)
| Step | From | To | Action |
|---|---|---|---|
| 3.1 | Customer | COOCO | Internal — confirm checkout |
| 3.2 | COOCO | COOCO | Internal — create order record |
| 3.3 | COOCO | RideNDine | POST /orders/create |
| 3.4 | RideNDine | COOCO | Response POST /orders/create |
Step 3.1 — Confirm Checkout (Internal)
From: Customer → To: COOCO
Purpose: Begin order creation.
COOCO collects:
| Field | Description |
|---|---|
quote_id | Quote ID retrieved in Phase 2 |
fulfillment_method | DELIVERY or PICKUP |
shipping_snapshot | Snapshotted delivery address |
customer_note | Customer note |
idempotency_key | UUID — prevents double-click |
Step 3.2 — Create Order Record (Internal)
From: COOCO → To: COOCO
Purpose: COOCO is the central order hub.
Creates a record on Directus orders:
| Field | Value |
|---|---|
status | PENDING_PAYMENT |
payment_status | PENDING |
quote_id | from Step 3.1 |
totals | from quote response |
shipping_snapshot | address snapshot |
items_snapshot | cart snapshot |
idempotency_key | UUID |
Also creates order_items.
info
The chef is not yet notified to cook at this step.
Step 3.3 — Create Order on RideNDine
From: COOCO → To: RideNDine
Endpoint: POST /orders/create
Purpose: RideNDine creates the order to handle payment + coordinate delivery.
Request Body
{
"quote_id": "<quote_id>",
"external_order_id": "<orders.id>",
"merchant_id": "<stores.ridendine_merchant_id>",
"customer": {
"external_id": "<customer.id>",
"name": "<customer.name>",
"phone": "<customer.phone>",
"email": "<customer.email>"
},
"fulfillment": {
"type": "DELIVERY | PICKUP",
"address": "<shipping_snapshot.address>",
"lat": "<lat>",
"lng": "<lng>"
},
"items": [],
"totals": {}
}
Header
Idempotency-Key: cooco_order_{orders.id}
Step 3.4 — Receive Response: Link 2 Systems
From: RideNDine → To: COOCO
Purpose: Link the 2 systems + prepare for payment.
Response
{
"ridendine_order_id": "<string>",
"payment_session_id": "<string>"
}
Save to Directus
orders.ridendine_order_idorders.payment_session_id