@dunbackmeadow/commerce-sdk 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,288 @@
1
+ // src/react/index.tsx
2
+ import { useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var money = (n) => `$${Number(n || 0).toFixed(2)}`;
5
+ var SERVICE_STYLES = [
6
+ { id: "meal_boxes", label: "Individual meal boxes", hint: "(one packed meal per guest; guests pick their own)" },
7
+ { id: "buffet", label: "Buffet", hint: "(trays and platters to share)" }
8
+ ];
9
+ var noticeText = (h) => h >= 48 && h % 24 === 0 ? `${h / 24} days` : `${h} hours`;
10
+ var box = { border: "1px solid rgba(127,127,127,.3)", borderRadius: 10, padding: 14 };
11
+ var checkbox = {
12
+ width: 16,
13
+ height: 16,
14
+ minWidth: 16,
15
+ margin: 0,
16
+ padding: 0,
17
+ flex: "0 0 auto",
18
+ cursor: "pointer",
19
+ boxSizing: "border-box"
20
+ };
21
+ var checkRow = { display: "flex", alignItems: "center", gap: 8, margin: 0, cursor: "pointer", fontSize: 14 };
22
+ var field = { display: "grid", gap: 4, margin: 0, fontSize: 14, fontWeight: 500 };
23
+ var control = { boxSizing: "border-box", width: "100%", maxWidth: 280, font: "inherit", fontWeight: 400 };
24
+ var hint = { fontSize: 12.5, fontWeight: 400, opacity: 0.7 };
25
+ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests = true, className }) {
26
+ const enabled = !!value?.enabled;
27
+ const showAvailability = venueReady !== false;
28
+ const firstAvailable = (showAvailability ? cuisines.find((c) => c.restaurants > 0)?.id : null) || cuisines[0]?.id || "american";
29
+ const guests = value?.expectedGuests;
30
+ const none = guests && showAvailability ? ` (none for ${guests} guests)` : venueReady === true ? " (none near this venue yet)" : " (no restaurants yet)";
31
+ const availabilityNote = venueReady === false ? "Enter the venue's street address, city and ZIP to see which cuisines restaurants near your event offer." : venueReady === true && cuisines.length && cuisines.every((c) => c.restaurants === 0) ? guests ? `No restaurants near this venue cater for ${guests} guests yet. Try a smaller expected guest count.` : "Dunback doesn't have restaurants that can cater at this venue yet." : metroName ? `Restaurant counts are for this metro area: ${metroName}${guests ? `, for about ${guests} guests` : ""}.` : null;
32
+ const custom = cuisines.filter((c) => c.custom);
33
+ const ahead = (c) => c.noticeHours ? ` \xB7 order ${noticeText(c.noticeHours)} ahead` : "";
34
+ const option = (c) => /* @__PURE__ */ jsxs("option", { value: c.id, disabled: showAvailability && c.restaurants === 0, children: [
35
+ c.label,
36
+ showAvailability ? c.restaurants === 0 ? none : ` (${c.restaurants} restaurant${c.restaurants === 1 ? "" : "s"}${ahead(c)})` : ""
37
+ ] }, c.id);
38
+ const picked = cuisines.find((c) => c.id === value?.cuisine);
39
+ const labelOf = (id) => id.startsWith("custom:") ? id.slice(7).split("-").filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join(" ") : id;
40
+ return /* @__PURE__ */ jsxs("div", { className, style: className ? void 0 : box, children: [
41
+ /* @__PURE__ */ jsxs("label", { style: { ...checkRow, alignItems: "flex-start", gap: 10 }, children: [
42
+ /* @__PURE__ */ jsx(
43
+ "input",
44
+ {
45
+ type: "checkbox",
46
+ style: { ...checkbox, marginTop: 3 },
47
+ checked: enabled,
48
+ onChange: (e) => onChange(e.target.checked ? { enabled: true, includeDrinks: true, serviceStyle: "meal_boxes", cuisine: value?.cuisine || firstAvailable } : null)
49
+ }
50
+ ),
51
+ /* @__PURE__ */ jsxs("span", { style: { display: "grid", gap: 4 }, children: [
52
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, fontSize: 15 }, children: "Food & drinks by Dunback Meadow" }),
53
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 13, opacity: 0.75 }, children: "Guests can note allergies when they register. Once your guest list is final, order catering for everyone in one click." })
54
+ ] })
55
+ ] }),
56
+ enabled && value && // Indented to line up with the title above (checkbox 16 + gap 10).
57
+ /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: 14, marginTop: 14, paddingLeft: 26 }, children: [
58
+ /* @__PURE__ */ jsxs("fieldset", { style: { border: 0, padding: 0, margin: 0, display: "grid", gap: 6 }, children: [
59
+ /* @__PURE__ */ jsx("legend", { style: { ...field, padding: 0, marginBottom: 4 }, children: "How should food be served?" }),
60
+ SERVICE_STYLES.map((s) => /* @__PURE__ */ jsxs("label", { style: { ...checkRow, alignItems: "flex-start" }, children: [
61
+ /* @__PURE__ */ jsx(
62
+ "input",
63
+ {
64
+ type: "radio",
65
+ name: "dunback-service-style",
66
+ style: { ...checkbox, marginTop: 2 },
67
+ checked: (value.serviceStyle ?? "meal_boxes") === s.id,
68
+ onChange: () => onChange({ ...value, serviceStyle: s.id })
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsxs("span", { children: [
72
+ s.label,
73
+ " ",
74
+ /* @__PURE__ */ jsx("span", { style: hint, children: s.hint })
75
+ ] })
76
+ ] }, s.id))
77
+ ] }),
78
+ /* @__PURE__ */ jsxs("label", { style: field, children: [
79
+ "Cuisine",
80
+ /* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine, onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
81
+ cuisines.filter((c) => !c.custom).map(option),
82
+ custom.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: venueReady === true ? "More cuisines near this venue" : "More cuisines", children: custom.map(option) }),
83
+ !cuisines.some((c) => c.id === value.cuisine) && /* @__PURE__ */ jsxs("option", { value: value.cuisine, disabled: true, children: [
84
+ labelOf(value.cuisine),
85
+ none
86
+ ] })
87
+ ] }),
88
+ showAvailability && picked?.noticeHours ? /* @__PURE__ */ jsxs("span", { style: hint, children: [
89
+ "Restaurants need at least ",
90
+ noticeText(picked.noticeHours),
91
+ " notice for ",
92
+ guests,
93
+ " guests: close the guest list and order by then."
94
+ ] }) : null,
95
+ availabilityNote && /* @__PURE__ */ jsx("span", { role: venueReady === false ? "note" : void 0, style: venueReady === false ? { ...hint, opacity: 1, color: "#b45309" } : hint, children: availabilityNote })
96
+ ] }),
97
+ askExpectedGuests && /* @__PURE__ */ jsxs("label", { style: field, children: [
98
+ /* @__PURE__ */ jsxs("span", { children: [
99
+ "Expected guests ",
100
+ /* @__PURE__ */ jsx("span", { style: hint, children: "(optional)" })
101
+ ] }),
102
+ /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6, fontWeight: 400 }, children: [
103
+ /* @__PURE__ */ jsx(
104
+ "input",
105
+ {
106
+ type: "number",
107
+ min: 1,
108
+ step: 1,
109
+ style: { ...control, width: 110 },
110
+ value: value.expectedGuests ?? "",
111
+ onChange: (e) => {
112
+ const n = Math.floor(Number(e.target.value));
113
+ onChange({ ...value, expectedGuests: e.target.value && n >= 1 ? n : void 0 });
114
+ }
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx("span", { style: hint, children: "Some restaurants limit party size or have a minimum order" })
118
+ ] })
119
+ ] }),
120
+ /* @__PURE__ */ jsxs("label", { style: checkRow, children: [
121
+ /* @__PURE__ */ jsx(
122
+ "input",
123
+ {
124
+ type: "checkbox",
125
+ style: checkbox,
126
+ checked: value.includeDrinks ?? true,
127
+ onChange: (e) => onChange({ ...value, includeDrinks: e.target.checked })
128
+ }
129
+ ),
130
+ /* @__PURE__ */ jsxs("span", { children: [
131
+ "Include drinks ",
132
+ /* @__PURE__ */ jsx("span", { style: hint, children: "(non-alcoholic, one per guest)" })
133
+ ] })
134
+ ] }),
135
+ /* @__PURE__ */ jsxs("label", { style: field, children: [
136
+ /* @__PURE__ */ jsxs("span", { children: [
137
+ "Budget per guest ",
138
+ /* @__PURE__ */ jsx("span", { style: hint, children: "(optional)" })
139
+ ] }),
140
+ /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6, fontWeight: 400 }, children: [
141
+ "$",
142
+ /* @__PURE__ */ jsx(
143
+ "input",
144
+ {
145
+ type: "number",
146
+ min: 1,
147
+ step: 1,
148
+ style: { ...control, width: 110 },
149
+ value: value.budgetPerGuest ?? "",
150
+ onChange: (e) => onChange({ ...value, budgetPerGuest: e.target.value ? Number(e.target.value) : void 0 })
151
+ }
152
+ ),
153
+ /* @__PURE__ */ jsx("span", { style: hint, children: "USD; pricier options are flagged" })
154
+ ] })
155
+ ] })
156
+ ] })
157
+ ] });
158
+ }
159
+ function PriceBreakdown({ price, paymentMethod, showCard }) {
160
+ const usdc = (paymentMethod ?? (showCard === false ? "usdc" : "card")) === "usdc";
161
+ const right = { textAlign: "right" };
162
+ return /* @__PURE__ */ jsx("table", { style: { width: "100%", fontSize: 13, borderCollapse: "collapse" }, children: /* @__PURE__ */ jsxs("tbody", { children: [
163
+ price.lines.map((l) => /* @__PURE__ */ jsxs("tr", { title: l.note, children: [
164
+ /* @__PURE__ */ jsx("td", { children: l.label }),
165
+ /* @__PURE__ */ jsx("td", { style: right, children: money(l.amount) })
166
+ ] }, `${l.code}-${l.label}`)),
167
+ !usdc && price.totals.cardProcessingFee > 0 && /* @__PURE__ */ jsxs("tr", { children: [
168
+ /* @__PURE__ */ jsx("td", { children: "Card processing" }),
169
+ /* @__PURE__ */ jsx("td", { style: right, children: money(price.totals.cardProcessingFee) })
170
+ ] }),
171
+ /* @__PURE__ */ jsxs("tr", { style: { fontWeight: 700 }, children: [
172
+ /* @__PURE__ */ jsx("td", { children: "Total" }),
173
+ /* @__PURE__ */ jsx("td", { style: right, children: usdc ? `${price.totals.usdc.toFixed(2)} USDC` : money(price.totals.card) })
174
+ ] }),
175
+ /* @__PURE__ */ jsxs("tr", { style: { opacity: 0.7 }, children: [
176
+ /* @__PURE__ */ jsx("td", { children: "Per guest" }),
177
+ /* @__PURE__ */ jsx("td", { style: right, children: usdc ? `${price.perGuest.usdc.toFixed(2)} USDC` : money(price.perGuest.card) })
178
+ ] })
179
+ ] }) });
180
+ }
181
+ function CateringOptionsPicker({ options, onSelect, busyOptionId, className }) {
182
+ const [open, setOpen] = useState(options[0]?.id ?? null);
183
+ if (!options.length) return /* @__PURE__ */ jsx("p", { children: "No catering options are available for this event." });
184
+ return /* @__PURE__ */ jsxs("div", { className, style: { display: "grid", gap: 12 }, children: [
185
+ options.map((o) => /* @__PURE__ */ jsxs("div", { style: box, children: [
186
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 12, alignItems: "baseline" }, children: [
187
+ /* @__PURE__ */ jsx("strong", { children: o.title }),
188
+ /* @__PURE__ */ jsxs("span", { children: [
189
+ money(o.price.totals.card),
190
+ " ",
191
+ /* @__PURE__ */ jsxs("small", { style: { opacity: 0.7 }, children: [
192
+ "(",
193
+ money(o.price.perGuest.card),
194
+ "/guest)"
195
+ ] })
196
+ ] })
197
+ ] }),
198
+ o.withinBudget === false && /* @__PURE__ */ jsx("p", { style: { color: "#b45309", fontSize: 13, margin: "4px 0" }, children: "Above your budget per guest." }),
199
+ /* @__PURE__ */ jsx("ul", { style: { margin: "8px 0", paddingLeft: 18, fontSize: 14 }, children: o.items.map((i) => /* @__PURE__ */ jsxs("li", { children: [
200
+ i.quantity,
201
+ "\xD7 ",
202
+ i.name,
203
+ i.serves ? ` (serves ${i.serves} each)` : "",
204
+ i.role === "extra" ? " (shared)" : "",
205
+ i.addedForMinimum && /* @__PURE__ */ jsxs("small", { style: { opacity: 0.7 }, children: [
206
+ " \u2014 added to reach the restaurant's ",
207
+ money(o.restaurant.policies?.minimumOrder ?? 0),
208
+ " minimum"
209
+ ] })
210
+ ] }, `${i.role}-${i.name}`)) }),
211
+ o.price.lines.some((l) => l.code === "delivery" && l.amount === 0) && /* @__PURE__ */ jsx("p", { style: { fontSize: 13, margin: "2px 0", color: "#15803d" }, children: "Free delivery" }),
212
+ o.freeDeliveryShortfall != null && o.freeDeliveryShortfall > 0 && /* @__PURE__ */ jsxs("p", { style: { fontSize: 13, margin: "2px 0", opacity: 0.8 }, children: [
213
+ "Add ",
214
+ money(o.freeDeliveryShortfall),
215
+ " of food for free delivery (",
216
+ o.restaurant.name,
217
+ " delivers free on orders of ",
218
+ money(o.restaurant.policies?.freeDeliveryOver ?? 0),
219
+ " or more)."
220
+ ] }),
221
+ o.allergyCoverage.filter((c) => c.constraint !== "no restrictions").map((c) => /* @__PURE__ */ jsxs("p", { style: { fontSize: 13, margin: "2px 0" }, children: [
222
+ "\u2713 ",
223
+ c.guests,
224
+ " guest",
225
+ c.guests > 1 ? "s" : "",
226
+ " (",
227
+ c.constraint,
228
+ "): ",
229
+ c.dishes.join(", ")
230
+ ] }, c.constraint)),
231
+ o.unfedGuests.map((u) => /* @__PURE__ */ jsxs("p", { style: { fontSize: 13, margin: "2px 0", color: "#b91c1c" }, children: [
232
+ "\u26A0 No ",
233
+ u.what === "drink" ? "drink" : "dish",
234
+ " on this menu is confirmed safe for ",
235
+ u.guests.join(", "),
236
+ " (",
237
+ u.constraint,
238
+ ")."
239
+ ] }, `${u.constraint}-${u.what || "main"}`)),
240
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setOpen(open === o.id ? null : o.id), style: { fontSize: 13, background: "none", border: 0, padding: 0, textDecoration: "underline", cursor: "pointer" }, children: [
241
+ open === o.id ? "Hide" : "Show",
242
+ " price breakdown"
243
+ ] }),
244
+ open === o.id && /* @__PURE__ */ jsx(PriceBreakdown, { price: o.price }),
245
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 10 }, children: /* @__PURE__ */ jsx("button", { type: "button", disabled: !!busyOptionId, onClick: () => onSelect(o.id), children: busyOptionId === o.id ? "Preparing payment\u2026" : "Choose this option" }) })
246
+ ] }, o.id)),
247
+ /* @__PURE__ */ jsx("p", { style: { fontSize: 12, opacity: 0.7 }, children: "Allergy matching uses the restaurant's allergen information. Labelled portions are requested for guests with allergies; guests with severe allergies should confirm with the restaurant." })
248
+ ] });
249
+ }
250
+ var STATUS = {
251
+ AWAITING_PAYMENT: "Waiting for payment",
252
+ PAID: "Payment received, placing the order\u2026",
253
+ FULFILLING: "Payment received, placing the order\u2026",
254
+ CONFIRMED: "Confirmed by the restaurant",
255
+ EXPIRED: "Payment link expired",
256
+ CANCELLED: "Cancelled",
257
+ REFUNDED: "The restaurant couldn't take the order; payment refunded",
258
+ REFUND_PENDING: "The restaurant couldn't take the order; refund in progress",
259
+ NEEDS_ATTENTION: "Payment received; Dunback support is finishing the order"
260
+ };
261
+ function DunbackOrderStatus({ order, className }) {
262
+ const p = order.payment;
263
+ return /* @__PURE__ */ jsxs("div", { className, style: className ? void 0 : box, children: [
264
+ /* @__PURE__ */ jsx("strong", { children: order.title }),
265
+ /* @__PURE__ */ jsx("p", { style: { margin: "4px 0" }, children: STATUS[order.status] || order.status }),
266
+ p.lastError && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: p.lastError.message }),
267
+ order.error && order.status !== "CONFIRMED" && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: order.error.message }),
268
+ order.status === "AWAITING_PAYMENT" && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", marginTop: 8 }, children: [
269
+ p.stripe && /* @__PURE__ */ jsxs("a", { href: p.stripe.checkoutUrl, children: [
270
+ "Pay ",
271
+ money(p.stripe.amount),
272
+ " by card"
273
+ ] }),
274
+ p.hostedPaymentUrl && /* @__PURE__ */ jsx("a", { href: p.hostedPaymentUrl, children: "Other payment options" })
275
+ ] }),
276
+ order.status === "AWAITING_PAYMENT" && p.expiresAt && /* @__PURE__ */ jsxs("p", { style: { fontSize: 12, opacity: 0.7 }, children: [
277
+ "Pay by ",
278
+ new Date(p.expiresAt).toLocaleString(),
279
+ " to keep this order."
280
+ ] })
281
+ ] });
282
+ }
283
+ export {
284
+ CateringOptionsPicker,
285
+ DunbackCateringSettings,
286
+ DunbackOrderStatus,
287
+ PriceBreakdown
288
+ };
@@ -0,0 +1,345 @@
1
+ # Dunback Meadow Partner API v1
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | Base URL | `https://dunbackmeadow.com/api/partner/v1` |
6
+ | Sandbox | `https://sandbox.dunbackmeadow.com/api/partner/v1` |
7
+ | Auth | `Authorization: Bearer dbk_live_<appId>_<secret>` (server-to-server only) |
8
+ | Keys | Created per app and environment in the Developer Dashboard: <https://dunbackmeadow.com/developer> |
9
+ | Format | JSON in and out. Money is in USD; USDC is 1:1. |
10
+
11
+ Each environment accepts only its own keys: `dbk_test_` in the sandbox,
12
+ `dbk_live_` in production. Anything else gets `401 wrong_environment`.
13
+
14
+ | Status | code | Meaning |
15
+ | --- | --- | --- |
16
+ | 401 | `unauthorized` | Missing, malformed or deleted key |
17
+ | 401 | `wrong_environment` | A key from the other environment |
18
+ | 403 | `partner_disabled` | The app was deleted or the account isn't active |
19
+
20
+ **Errors** use one shape:
21
+
22
+ ```json
23
+ { "error": { "code": "invalid_request", "message": "…", "details": {} } }
24
+ ```
25
+
26
+ **Idempotency.** For POST requests, send `Idempotency-Key: <unique>`.
27
+ Replays return the original response with `Idempotent-Replayed: true`. Reusing a
28
+ key with a different body returns `422 idempotency_mismatch`. Keys are kept for
29
+ 24 h.
30
+
31
+ ---
32
+
33
+ ## App
34
+
35
+ ### `GET /me`
36
+
37
+ The app and environment the key belongs to.
38
+
39
+ ```json
40
+ { "object": "app", "id": "app-k3m9x2q7w4ze", "name": "Event catering", "mode": "test",
41
+ "webhookUrl": "https://api.example.com/webhooks/dunback", "allowedReturnHosts": ["example.com"] }
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Catalog
47
+
48
+ ### `GET /catalog/cuisines?city=&state=&zip=&guests=&serviceStyle=`
49
+
50
+ Pass the event venue (`zip`, or `city` + `state`) to count only restaurants in
51
+ the venue's metro area, the ones that can cater there. Without it, counts
52
+ cover the whole platform. Pass `guests` (expected guests, a whole number) to
53
+ count only restaurants whose catering policies allow that many (and
54
+ `serviceStyle` to count only those serving catering that way): most guests
55
+ per order, and a minimum order that many guests are likely to reach. The
56
+ response then includes `"guests"`, and each cuisine a `noticeHours`: the least
57
+ advance notice one of its restaurants needs for that many guests (0: none;
58
+ `null`: no restaurant). SDK: `listCuisines(venue?, { guests? })`,
59
+ or `cuisineCatalog(venue?, { guests? })` for the metro too.
60
+
61
+ ```json
62
+ {
63
+ "object": "list",
64
+ "data": [
65
+ { "id": "mexican", "label": "Mexican", "restaurants": 4 },
66
+ { "id": "custom:peruvian", "label": "Peruvian", "restaurants": 1, "custom": true }
67
+ ],
68
+ "scope": "metro",
69
+ "metro": { "id": "sf-bay-area", "name": "San Francisco Bay Area" }
70
+ }
71
+ ```
72
+
73
+ | Field | Notes |
74
+ | --- | --- |
75
+ | `scope` | `metro` with a venue, `platform` without |
76
+ | `metro` | The venue's metro area. `null` without a venue, or when Dunback doesn't serve that area (then every count is 0) |
77
+
78
+ Standard cuisine ids, always listed: `american`, `chinese`, `mexican`,
79
+ `italian`, `japanese`, `indian`, `thai`, `mediterranean`, `korean`,
80
+ `vietnamese`.
81
+
82
+ Restaurants can also declare a cuisine of their own. Such cuisines are listed
83
+ after the standard ones as `custom:<name>` (e.g. `custom:peruvian`, label
84
+ "Peruvian", `custom: true`), and only where at least one restaurant in scope
85
+ serves them. Hosts can pick them like any other: send the `id` as `cuisine`.
86
+
87
+ ---
88
+
89
+ ## Catering requests
90
+
91
+ ### `POST /catering/requests` → `202` CateringRequest (status `COMPOSING`)
92
+
93
+ | Field | Type | Notes |
94
+ | --- | --- | --- |
95
+ | `partnerReference` | string, required | Your id, e.g. `luma:evt-AbC123` |
96
+ | `event.name` | string, required | |
97
+ | `event.startsAt` | ISO 8601, required | Must be in the future |
98
+ | `event.timeZone` | IANA, required | Venue time zone |
99
+ | `event.url` | URL | |
100
+ | `deliveryDeadlineLocal` | `YYYY-MM-DDTHH:mm` | Default: `startsAt` minus 30 min, venue-local |
101
+ | `cuisine` | cuisine id, required | A standard id or a `custom:…` id from `/catalog/cuisines` |
102
+ | `serviceStyle` | `buffet` or `meal_boxes` | How food is served. `buffet`: trays and platters to share, from restaurants with catering dishes. `meal_boxes`: one packed meal per guest from restaurants' regular dishes (more dishes, usually more restaurants). Default `meal_boxes`. |
103
+ | `includeDrinks` | bool | Default true. Non-alcoholic only. |
104
+ | `budgetPerGuest` | number | Flags options above it |
105
+ | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
106
+ | `onsiteContact` | `{name, phone, email?}`, required | Receives the delivery |
107
+ | `deliveryNotes` | string | |
108
+ | `host` | `{name, email, phone?}`, required | |
109
+ | `attendees[]` | 1–1000, required | `{externalId?, name, email?, phone?, allergies?, dietaryPreferences?, allergyConsent?}` |
110
+
111
+ A request may list up to 1000 guests; more fails with `400 invalid_request`.
112
+
113
+ `email` and `phone` are optional for every guest. `allergyConsent: true` is
114
+ required for each guest whose `allergies` or `dietaryPreferences` says more than
115
+ "none": it records that the guest agreed to share those notes with Dunback and
116
+ the restaurant. Otherwise the request fails with `400 allergy_consent_required`,
117
+ and `error.details.guests` lists `{ index, externalId, name }` for each guest
118
+ concerned.
119
+
120
+ Dunback delivers only where it has launched. A delivery address outside the
121
+ launched areas fails with `422 delivery_area_not_launched`; the message names
122
+ the metro areas Dunback covers. Requests for more than 5 guests are checked
123
+ against the areas launched for catering, smaller ones against the areas
124
+ launched for individual delivery.
125
+
126
+ Composing usually takes 5–30 s. When it finishes, you receive the
127
+ `catering.options_ready`, `catering.no_options` or `catering.failed` webhook.
128
+
129
+ ### `GET /catering/requests/:id` → CateringRequest
130
+
131
+ ### `GET /catering/requests?partnerReference=…` → `{ data: CateringRequest[] }` (newest first)
132
+
133
+ ### CateringRequest
134
+
135
+ | Field | Notes |
136
+ | --- | --- |
137
+ | `id` | `creq_…` |
138
+ | `object` | `"catering_request"` |
139
+ | `status` | `COMPOSING`, `OPTIONS_READY`, `NO_OPTIONS`, `SELECTED` or `FAILED` |
140
+ | `partnerReference`, `event`, `cuisine`, `guestCount` | As sent; `event` gains `startsAtLocal` |
141
+ | `deliveryDeadlineLocal`, `timeZone`, `daypart` | |
142
+ | `allergySummary` | `[{ constraint, guests: [names] }]` |
143
+ | `options` | Up to 3; see below |
144
+ | `unavailableReasons` | `[{ name, code, reason }]` when `NO_OPTIONS`. `code`: `party_too_large`, `below_minimum_order`, `notice_too_short`, `no_buffet_dishes`, `style_not_offered`, `outside_delivery_area`, `not_serving_then`, `different_cuisine` or `restaurant_declined` (more may be added) |
145
+ | `orderId` | Set once an option is selected |
146
+ | `error` | `{ code, message }`, when `FAILED` |
147
+ | `createdAt`, `updatedAt` | |
148
+
149
+ Each option:
150
+
151
+ How the food is served is the host's choice (`serviceStyle`):
152
+
153
+ - `buffet`: trays and platters guests share. Only restaurants with catering
154
+ dishes for mains take part; their trays come first, single portions only
155
+ fill in.
156
+ - `meal_boxes` (default): one individually packed meal per guest, which
157
+ guests pick up themselves. Any restaurant's single portions qualify (no
158
+ trays), so there are more dishes to choose from and usually more
159
+ restaurants. A restaurant can opt out of packing meal boxes.
160
+
161
+ Each option repeats its `serviceStyle`, and the restaurant's order says how to pack it.
162
+
163
+ Restaurants may set their own catering policies: the most guests they cater
164
+ for in one order, a minimum order (food subtotal), free delivery at or above a
165
+ food subtotal, and advance notice by party size (e.g. more than 20 guests: 24
166
+ hours, more than 50: 72 hours). Each is optional. Dunback only offers options
167
+ that meet them: a restaurant that can't take the party, or needs more notice
168
+ than is left, is left out; an option slightly under a restaurant's minimum gets
169
+ shared sides or desserts added (`addedForMinimum`); `orderBy` is moved earlier
170
+ to the notice the restaurant needs. Free delivery shows as a `Free delivery`
171
+ price line of 0.
172
+
173
+ Restaurants that specialize in catering list catering dishes: trays and
174
+ platters that serve several people. Dunback composes with those first and adds
175
+ single portions only where needed (guests no tray suits, or a few guests left
176
+ over). Such an item has `serves`: `quantity` counts trays and `unitPrice` is
177
+ per tray, so 2 trays with `serves: 8` feed 16 guests.
178
+
179
+ | Field | Notes |
180
+ | --- | --- |
181
+ | `id` | `opt_1` … `opt_3` |
182
+ | `title` | |
183
+ | `strategy` | `favorites`, `value` or `variety` |
184
+ | `restaurant` | `{ name, distanceMiles, imageUrl, policies: { minimumOrder, maxGuests, freeDeliveryOver, noticeTiers: [{ overGuests, hours }] } }`; each policy is `null` when the restaurant has none |
185
+ | `freeDeliveryShortfall` | Food (USD) to add for the restaurant's free delivery; `null` when delivery is already free or there's no such policy |
186
+ | `items[]` | `{ name, description, imageUrl, role: "main"\|"drink"\|"extra", quantity, unitPrice, allergens, dietaryTags, serves?, addedForMinimum? }`. Each dish appears once with its full quantity: Dunback has no per-dish limit. `serves`: a catering dish (tray) serving that many people per unit; `quantity` and `unitPrice` are then per tray. `addedForMinimum`: a shared dish added to reach the restaurant's minimum order. |
187
+ | `allergyCoverage[]` | `{ constraint, guests, dishes }` |
188
+ | `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
189
+ | `price` | See Price |
190
+ | `withinBudget` | Present when a budget was set |
191
+ | `orderBy` | ISO; latest payment time the restaurant accepts |
192
+
193
+ ### Price
194
+
195
+ | Field | Notes |
196
+ | --- | --- |
197
+ | `currency` | `"USD"` |
198
+ | `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
199
+ | `restaurantAmount` | What Dunback pays the restaurant |
200
+ | `dunbackCommission` | |
201
+ | `dunbackServiceFee` | |
202
+ | `totals` | `{ usdc, card, cardProcessingFee }` |
203
+ | `perGuest` | `{ usdc, card }` |
204
+ | `commissionRate` | |
205
+
206
+ The card total is the USDC total grossed up for card processing.
207
+
208
+ ### `POST /catering/requests/:id/select` → `201` Order
209
+
210
+ | Field | Notes |
211
+ | --- | --- |
212
+ | `optionId` | required |
213
+ | `payer` | `{ name?, email? }` (pre-fills Stripe) |
214
+ | `paymentMethods` | `["stripe","usdc"]` (default both) |
215
+ | `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts |
216
+
217
+ Errors:
218
+
219
+ | Status | code | Meaning |
220
+ | --- | --- | --- |
221
+ | 409 | `invalid_state` | Already selected, or not ready |
222
+ | 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
223
+ | 409 | `restaurant_*` | The restaurant can't take it now |
224
+
225
+ ---
226
+
227
+ ## Orders
228
+
229
+ ### Order
230
+
231
+ | Field | Notes |
232
+ | --- | --- |
233
+ | `id` | `ord_…` |
234
+ | `object` | `"order"` |
235
+ | `status` | `AWAITING_PAYMENT`, `PAID`, `FULFILLING`, `CONFIRMED`, `EXPIRED`, `CANCELLED`, `REFUNDED`, `REFUND_PENDING` or `NEEDS_ATTENTION` |
236
+ | `title`, `summary`, `restaurant`, `deliveryDeadlineLocal`, `timeZone`, `guestCount` | |
237
+ | `delivery` | `{ address: {address1, address2, city, state, zip, country}, onsiteContact: {name, phone}, deliveryNotes, editable }`. `deliveryNotes` is your note only. `editable` is true while the order is `AWAITING_PAYMENT`. |
238
+ | `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
239
+ | `payment` | See below |
240
+ | `fulfillment` | `{ restaurantOrderIds, providerPayment: { amount, payTo, txHash, verifiedOnChain, network }, confirmedAt }` |
241
+ | `refund` | `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
242
+ | `error` | `{ code, message }` |
243
+
244
+ `payment` holds:
245
+
246
+ | Field | Notes |
247
+ | --- | --- |
248
+ | `expiresAt` | ISO |
249
+ | `hostedPaymentUrl` | Dunback page offering every method; safe to give the payer |
250
+ | `stripe` | `{ checkoutUrl, amount, currency: "usd" }` |
251
+ | `usdc.network`, `usdc.chainId` | `"polygon"`, `137` |
252
+ | `usdc.asset` | USDC contract on Polygon |
253
+ | `usdc.receiver` | Dunback's receiving address |
254
+ | `usdc.amount`, `usdc.amountAtomic` | Exact amount, e.g. `"412.380317"` and `"412380317"` |
255
+ | `usdc.paymentUri` | `ethereum:…` (EIP-681) |
256
+ | `usdc.note` | |
257
+ | `usdc.x402Url` | For agents |
258
+ | `received` | `{ method: "stripe"\|"usdc"\|"x402", amount, currency, reference, payer?, at }` |
259
+ | `lastError` | `{ method, code, message, at }` |
260
+
261
+ The links (`hostedPaymentUrl`, `stripe`, `usdc`) are present while the status
262
+ is `AWAITING_PAYMENT`.
263
+
264
+ ### `GET /orders/:id` → Order
265
+
266
+ This also re-checks Stripe for open card payments.
267
+
268
+ ### `POST /orders/:id/usdc/confirm` `{ txHash }` → Order
269
+
270
+ Verifies a Polygon USDC transfer to `payment.usdc.receiver`. The amount must
271
+ be ≥ the USDC total; the exact tagged amount isn't required when you supply the
272
+ hash. The call waits up to 60 s for the restaurant to confirm.
273
+
274
+ | Status | code |
275
+ | --- | --- |
276
+ | 409 | `payment_pending` |
277
+ | 400 | `payment_not_found` |
278
+ | 400 | `payment_amount_short` |
279
+ | 409 | `payment_already_used` |
280
+
281
+ ### `POST /orders/:id/delivery` → Order
282
+
283
+ Corrects the delivery details before payment. The payer can do the same on the
284
+ hosted payment page (`hostedPaymentUrl`).
285
+
286
+ | Field | Type | Notes |
287
+ | --- | --- | --- |
288
+ | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
289
+ | `onsiteContact` | `{name, phone}` | Leave out to keep the current contact |
290
+ | `deliveryNotes` | string, up to 500 | Replaces the current note; default `""` |
291
+
292
+ The price stays as quoted, so the correction is checked:
293
+
294
+ | Status | code | Meaning |
295
+ | --- | --- | --- |
296
+ | 409 | `invalid_state` | The order isn't `AWAITING_PAYMENT` |
297
+ | 422 | `delivery_area_not_launched` | Dunback doesn't deliver to that area yet |
298
+ | 422 | `outside_delivery_area` | The restaurant doesn't deliver to that address |
299
+ | 422 | `address_moved` | More than about a mile from the quoted address: create a new catering request |
300
+ | 422 | `contact_incomplete` | A required field is missing |
301
+
302
+ On success you also receive the `order.delivery_updated` webhook.
303
+
304
+ ### `POST /orders/:id/cancel` `{ reason? }` → Order
305
+
306
+ | Order status | Result |
307
+ | --- | --- |
308
+ | `AWAITING_PAYMENT` | Cancels the payment links |
309
+ | `CONFIRMED`, before the restaurant's deadline | Cancels at the restaurant and refunds |
310
+ | Otherwise | `409 cancel_refused` or `409 invalid_state` |
311
+
312
+ ### `POST /orders/:id/pay/x402?t=<token>` (x402 resource; no API key, the URL is `payment.usdc.x402Url`)
313
+
314
+ 1. Without `PAYMENT-SIGNATURE`, the endpoint returns
315
+ `402 Payment Required` with a `PAYMENT-REQUIRED` header: base64 JSON
316
+ `{ x402Version: 2, accepts: [{ scheme: "exact", network: "eip155:137", amount, asset, payTo, maxTimeoutSeconds, extra: { name: "USD Coin", version: "2" } }] }`.
317
+ 2. Retry with
318
+ `PAYMENT-SIGNATURE: base64({ x402Version: 2, scheme: "exact", network, accepted, payload: { authorization, signature } })`.
319
+ The payload is an EIP-3009 `TransferWithAuthorization`. It is verified and
320
+ settled by Dunback's facilitator.
321
+ 3. On success the response is `200` with the Order and a `PAYMENT-RESPONSE`
322
+ header. If the payment is rejected, you get `402` with `{ error: { code, message } }`.
323
+
324
+ ---
325
+
326
+ ## Webhooks
327
+
328
+ `POST` to your URL with this body:
329
+
330
+ ```json
331
+ { "id": "evt_…", "type": "order.confirmed", "created": 1763000000, "data": { … } }
332
+ ```
333
+
334
+ The `Dunback-Signature: t=<unix>,v1=<hex>` header is
335
+ `HMAC-SHA256(webhookSecret, "<t>.<raw body>")`. Reject anything older than
336
+ 5 minutes. Answer with a 2xx; anything else is retried after 1 s, 5 s and 25 s.
337
+
338
+ | Event | `data` |
339
+ | --- | --- |
340
+ | `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
341
+ | `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.delivery_updated` | Order |
342
+ | `ping` | `{ object: "ping", appId, message }`, plus top-level `livemode`. Sent by **Send test event** in the Developer Dashboard. |
343
+
344
+ The webhook URL, its signing secret (reveal or roll) and the allowed return
345
+ hosts are set per app and environment in the Developer Dashboard.