@dunbackmeadow/commerce-sdk 0.8.0 → 0.9.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.
package/README.md CHANGED
@@ -1,256 +1,256 @@
1
- # Dunback Meadow Commerce SDK
2
-
3
- `@dunbackmeadow/commerce-sdk` lets your app or agent order **event catering**
4
- from restaurants on Dunback Meadow. More product types will follow. Buyers pay
5
- **by card (Stripe)** or in **USDC on Polygon** (a wallet transfer or x402).
6
-
7
- Dunback handles three things:
8
-
9
- - **Restaurant selection.** Its catering agent finds restaurants that serve
10
- the chosen cuisine, deliver to the venue, and can make the event time.
11
- - **Allergy-aware menus.** Each guest gets a dish that is safe for their
12
- allergies and diet, according to the restaurant's allergen data.
13
- - **Payment and placement.** Dunback verifies the buyer's payment, pays the
14
- restaurant, and confirms the order back to you.
15
-
16
- ```
17
- Your app Dunback Meadow Restaurant agent
18
- ──────── ────────────── ────────────────
19
- catering.create(guests) ───────▶ catering agent composes 3 options ───▶ quote_cart (prices)
20
- ◀── webhook catering.options_ready (price + fee breakdowns)
21
- catering.select(option) ───────▶ order + payment links
22
- payer pays (card / USDC / x402) ▶ verifies payment (Stripe API / on-chain)
23
- pays restaurant in USDC via x402 ─────▶ books the order
24
- ◀── webhook order.confirmed
25
- ```
26
-
27
- ## Install
28
-
29
- ```bash
30
- npm install @dunbackmeadow/commerce-sdk
31
- ```
32
-
33
- You need Node 18 or later. React is optional and only needed for `@dunbackmeadow/commerce-sdk/react`.
34
-
35
- ## Credentials
36
-
37
- Get your credentials in the **Dunback Developer Dashboard**
38
- (<https://dunbackmeadow.com/developer>, or Menu → More… → Developer Dashboard
39
- in the Dunback app):
40
-
41
- 1. Apply for developer access (individual or business). Dunback reviews it,
42
- usually within 2 business days.
43
- 2. Create an **app**. Each app has a **sandbox** and a **production** environment.
44
- 3. In each environment, create the **API key** and set your **webhook URL**
45
- and **allowed return hosts**.
46
-
47
- | What | Example | Where it lives |
48
- | --- | --- | --- |
49
- | API key | `dbk_test_app-k3m9x2q7w4ze_…` / `dbk_live_app-k3m9x2q7w4ze_…` | Your servers only. Never put it in a browser or a mobile app. Shown once when created. |
50
- | Webhook signing secret | `whsec_…` | Your servers; used to verify `Dunback-Signature`. One per environment. |
51
- | Allowed return hosts | `lu.ma` | Set in the dashboard; Stripe success and cancel URLs must be on these hosts. |
52
-
53
- One key per app and environment at a time: to rotate, delete the key in the
54
- dashboard and create a new one. A deleted key stops working within a minute.
55
-
56
- The client picks the environment from the key:
57
-
58
- | Key | Base URL |
59
- | --- | --- |
60
- | `dbk_test_…` | `https://sandbox.dunbackmeadow.com/api/partner/v1` |
61
- | `dbk_live_…` | `https://dunbackmeadow.com/api/partner/v1` |
62
-
63
- In the sandbox:
64
-
65
- - Stripe runs in test mode.
66
- - Orders go to Dunback's test restaurants.
67
- - USDC payments use small real amounts on Polygon. There is no testnet USDC support yet.
68
-
69
- Check a key with `await dunback.me()`: it returns the app and environment.
70
-
71
- ## Quick start
72
-
73
- ```ts
74
- import { DunbackClient } from "@dunbackmeadow/commerce-sdk";
75
-
76
- const dunback = new DunbackClient({ apiKey: process.env.DUNBACK_API_KEY! });
77
-
78
- // 1. Send the event and guest list
79
- const request = await dunback.catering.create({
80
- partnerReference: "luma:evt-AbC123",
81
- event: { name: "Founders Dinner", startsAt: "2026-11-14T02:00:00Z", timeZone: "America/Los_Angeles" },
82
- cuisine: "mexican",
83
- deliveryAddress: { address1: "100 University Ave", city: "Palo Alto", state: "CA", zip: "94301" },
84
- onsiteContact: { name: "Sam Host", phone: "+14155550100" },
85
- host: { name: "Sam Host", email: "sam@example.com" },
86
- attendees: [
87
- { name: "Ana", email: "ana@example.com", allergies: "peanuts", allergyConsent: true },
88
- { name: "Ben", phone: "+14155550101", allergies: "" },
89
- { name: "Cleo", dietaryPreferences: "vegetarian", allergyConsent: true },
90
- ],
91
- });
92
-
93
- // 2. Options are ready in seconds. Use the webhook in production; polling works too.
94
- const ready = await dunback.catering.waitForOptions(request.id);
95
- for (const o of ready.options) {
96
- console.log(o.title, o.price.totals.card, o.price.lines, o.allergyCoverage, o.unfedGuests);
97
- }
98
-
99
- // 3. The host picks one, and you get payment links
100
- const order = await dunback.catering.select(ready.id, { optionId: ready.options[0].id });
101
- order.payment.stripe?.checkoutUrl; // card: Stripe Checkout
102
- order.payment.usdc; // USDC: amount, address, EIP-681 link, x402Url
103
- order.payment.hostedPaymentUrl; // Dunback page offering both
104
-
105
- // 4. Wait for the order.confirmed webhook, or poll
106
- const final = await dunback.orders.waitForSettlement(order.id);
107
- ```
108
-
109
- ## Paying
110
-
111
- | Method | Who it suits | How Dunback verifies |
112
- | --- | --- | --- |
113
- | **Card** (`payment.stripe.checkoutUrl`) | People | Signed Stripe webhook, plus a re-read of the Checkout Session: paid, USD, exact amount, this order |
114
- | **USDC transfer** (`payment.usdc`) | People with a wallet, treasury tools | Polygon logs: a transfer of the exact tagged amount to the receiver is matched automatically. You can also call `orders.confirmUsdcPayment(id, txHash)` with any amount ≥ the total. |
115
- | **x402** (`payOrderWithX402`) | Agents | EIP-3009 authorization, verified and settled on-chain by Dunback's x402 facilitator |
116
-
117
- The **card total** includes card processing, so it is a little higher than
118
- the **USDC total**. Both are shown in `price.totals`, and the line items are in
119
- `price.lines`.
120
-
121
- Payment links expire at `payment.expiresAt`. That is usually 60 minutes, and
122
- always before the restaurant's order deadline. When a link expires, the host
123
- can select an option again to get new links.
124
-
125
- ### Agent payment with x402
126
-
127
- ```ts
128
- import { payOrderWithX402 } from "@dunbackmeadow/commerce-sdk";
129
-
130
- const paid = await payOrderWithX402(order, {
131
- address: account.address,
132
- signTypedData: (td) => account.signTypedData(td), // viem
133
- // signTypedData: (td) => wallet.signTypedData(td.domain, td.types, td.message), // ethers v6
134
- }, { maxAmountUsdc: 500 });
135
- // paid.status === "CONFIRMED"
136
- ```
137
-
138
- ### Payment errors
139
-
140
- Payment problems come back as `DunbackApiError` with a `code` you can show to the payer:
141
-
142
- | code | Meaning |
143
- | --- | --- |
144
- | `payment_pending` | The transaction isn't confirmed yet. Retry in a few seconds. |
145
- | `payment_not_found` | That transaction didn't send USDC to Dunback. |
146
- | `payment_amount_short` | Less than the order total arrived. |
147
- | `payment_already_used` | That transaction already paid another order. |
148
- | `invalid_payment_signature`, `invalid_payment`, `insufficient_funds`, `settlement_failed` | The x402 authorization was rejected. |
149
- | `order_deadline_passed` | It's too late for the restaurant to make the event time. |
150
-
151
- `isPaymentError(e)` tells you whether an error is one of these.
152
-
153
- Asynchronous card failures, such as a declined bank debit, arrive as the
154
- `order.payment_failed` webhook. `order.payment.lastError` holds the message.
155
-
156
- ## Correcting the delivery address
157
-
158
- Until an order is paid, you (or the payer, on the hosted payment page) can
159
- correct the delivery address, on-site contact and note:
160
-
161
- ```ts
162
- const updated = await dunback.orders.updateDelivery(order.id, {
163
- deliveryAddress: { address1: "120 University Ave", address2: "Suite 300", city: "Palo Alto", state: "CA", zip: "94301" },
164
- onsiteContact: { name: "Sam Lee", phone: "+15550000000" },
165
- deliveryNotes: "Loading dock on Bryant St.", // replaces the current note
166
- });
167
- // updated.delivery shows the corrected details
168
- ```
169
-
170
- The price stays as quoted, so the new address must stay within about a mile
171
- of the original and inside the restaurant's delivery area. Otherwise the call
172
- fails with `422 address_moved` or `outside_delivery_area`; create a new
173
- catering request instead. Addresses where Dunback hasn't launched delivery
174
- fail with `422 delivery_area_not_launched`, both here and when you create a
175
- catering request.
176
-
177
- ## Order lifecycle
178
-
179
- ```
180
- AWAITING_PAYMENT ─▶ PAID ─▶ FULFILLING ─▶ CONFIRMED ─▶ (CANCELLED | REFUNDED when every delivery failed)
181
- │ ├─▶ REFUNDED / REFUND_PENDING restaurant couldn't take it; buyer refunded
182
- │ └─▶ NEEDS_ATTENTION Dunback support finishes it by hand
183
- └─▶ EXPIRED / CANCELLED
184
- ```
185
-
186
- ## Webhooks
187
-
188
- ```ts
189
- import express from "express";
190
- import { verifyWebhook } from "@dunbackmeadow/commerce-sdk";
191
-
192
- app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, res) => {
193
- const event = verifyWebhook(req.body, req.header("Dunback-Signature"), process.env.DUNBACK_WEBHOOK_SECRET!);
194
- // event.type, event.data (CateringRequest or Order)
195
- res.sendStatus(200);
196
- });
197
- ```
198
-
199
- | Event | `data` |
200
- | --- | --- |
201
- | `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
202
- | `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
203
- | `ping` | `{ object: "ping", appId, message }`: sent by **Send test event** in the dashboard |
204
-
205
- Each webhook is signed as `t=<unix>,v1=<HMAC-SHA256(secret, "<t>.<body>")>`.
206
- A non-2xx answer is retried after 1 s, 5 s and 25 s. Handle events
207
- idempotently by `event.id`.
208
-
209
- ## Reliability
210
-
211
- - POST helpers send an `Idempotency-Key`. Pass your own (for example, per button
212
- click) to make retries safe across processes. Dunback keeps keys for 24 h.
213
- - The client retries network errors and 5xx responses for GETs and for POSTs
214
- that carry an idempotency key.
215
- - `orders.get()` also re-checks Stripe, so it is safe to call right after a
216
- Checkout redirect.
217
-
218
- ## Allergies
219
-
220
- Guests write allergy notes in their own words. Dunback turns them into
221
- allergens (the US "Big 9" plus a few more) and diets. A dish is offered to a
222
- guest with an allergy only when the restaurant has **declared** that dish's
223
- allergens and none of them match. If no dish is known to be safe for a guest,
224
- the option lists that guest in `unfedGuests` rather than guessing. Show those
225
- warnings to the host. Allergy-labelled portions are requested from the
226
- restaurant in the delivery note.
227
-
228
- **Consent.** Allergy and diet notes are health information, so each guest
229
- must agree to share theirs. Send `allergyConsent: true` for every guest whose
230
- `allergies` or `dietaryPreferences` says more than "none". Without it, the
231
- request fails with `400 allergy_consent_required`, and `details.guests` lists
232
- the guests concerned. `toDunbackAttendees()` sets `allergyConsent` for answers
233
- to `DUNBACK_REGISTRATION_QUESTION`, whose wording asks for that consent.
234
-
235
- **Retention.** Dunback deletes guest data 30 days after the event. Orders are
236
- kept longer for accounting, without guest names.
237
-
238
- ## React components (optional)
239
-
240
- ```tsx
241
- import { DunbackCateringSettings, CateringOptionsPicker, DunbackOrderStatus } from "@dunbackmeadow/commerce-sdk/react";
242
- ```
243
-
244
- These components only render data. Your backend makes every Dunback call.
245
-
246
- ## More
247
-
248
- - Developer Dashboard and documentation: <https://dunbackmeadow.com/developer>
249
- - [Luma integration guide](docs/LUMA_INTEGRATION_GUIDE.md)
250
- - [API reference](docs/API_REFERENCE.md)
251
- - [examples/luma-integration](examples/luma-integration): Express backend and host panel
252
- - [examples/agent-x402-payment.ts](examples/agent-x402-payment.ts): an agent ordering and paying with x402
253
-
254
- ## License
255
-
256
- MIT
1
+ # Dunback Meadow Commerce SDK
2
+
3
+ `@dunbackmeadow/commerce-sdk` lets your app or agent order **event catering**
4
+ from restaurants on Dunback Meadow. More product types will follow. Buyers pay
5
+ **by card (Stripe)** or in **USDC on Polygon** (a wallet transfer or x402).
6
+
7
+ Dunback handles three things:
8
+
9
+ - **Restaurant selection.** Its catering agent finds restaurants that serve
10
+ the chosen cuisine, deliver to the venue, and can make the event time.
11
+ - **Allergy-aware menus.** Each guest gets a dish that is safe for their
12
+ allergies and diet, according to the restaurant's allergen data.
13
+ - **Payment and placement.** Dunback verifies the buyer's payment, pays the
14
+ restaurant, and confirms the order back to you.
15
+
16
+ ```
17
+ Your app Dunback Meadow Restaurant agent
18
+ ──────── ────────────── ────────────────
19
+ catering.create(guests) ───────▶ catering agent composes 3 options ───▶ quote_cart (prices)
20
+ ◀── webhook catering.options_ready (price + fee breakdowns)
21
+ catering.select(option) ───────▶ order + payment links
22
+ payer pays (card / USDC / x402) ▶ verifies payment (Stripe API / on-chain)
23
+ pays restaurant in USDC via x402 ─────▶ books the order
24
+ ◀── webhook order.confirmed
25
+ ```
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm install @dunbackmeadow/commerce-sdk
31
+ ```
32
+
33
+ You need Node 18 or later. React is optional and only needed for `@dunbackmeadow/commerce-sdk/react`.
34
+
35
+ ## Credentials
36
+
37
+ Get your credentials in the **Dunback Developer Dashboard**
38
+ (<https://dunbackmeadow.com/developer>, or Menu → More… → Developer Dashboard
39
+ in the Dunback app):
40
+
41
+ 1. Apply for developer access (individual or business). Dunback reviews it,
42
+ usually within 2 business days.
43
+ 2. Create an **app**. Each app has a **sandbox** and a **production** environment.
44
+ 3. In each environment, create the **API key** and set your **webhook URL**
45
+ and **allowed return hosts**.
46
+
47
+ | What | Example | Where it lives |
48
+ | --- | --- | --- |
49
+ | API key | `dbk_test_app-k3m9x2q7w4ze_…` / `dbk_live_app-k3m9x2q7w4ze_…` | Your servers only. Never put it in a browser or a mobile app. Shown once when created. |
50
+ | Webhook signing secret | `whsec_…` | Your servers; used to verify `Dunback-Signature`. One per environment. |
51
+ | Allowed return hosts | `lu.ma` | Set in the dashboard; Stripe success and cancel URLs must be on these hosts. |
52
+
53
+ One key per app and environment at a time: to rotate, delete the key in the
54
+ dashboard and create a new one. A deleted key stops working within a minute.
55
+
56
+ The client picks the environment from the key:
57
+
58
+ | Key | Base URL |
59
+ | --- | --- |
60
+ | `dbk_test_…` | `https://sandbox.dunbackmeadow.com/api/partner/v1` |
61
+ | `dbk_live_…` | `https://dunbackmeadow.com/api/partner/v1` |
62
+
63
+ In the sandbox:
64
+
65
+ - Stripe runs in test mode.
66
+ - Orders go to Dunback's test restaurants.
67
+ - USDC payments use small real amounts on Polygon. There is no testnet USDC support yet.
68
+
69
+ Check a key with `await dunback.me()`: it returns the app and environment.
70
+
71
+ ## Quick start
72
+
73
+ ```ts
74
+ import { DunbackClient } from "@dunbackmeadow/commerce-sdk";
75
+
76
+ const dunback = new DunbackClient({ apiKey: process.env.DUNBACK_API_KEY! });
77
+
78
+ // 1. Send the event and guest list
79
+ const request = await dunback.catering.create({
80
+ partnerReference: "luma:evt-AbC123",
81
+ event: { name: "Founders Dinner", startsAt: "2026-11-14T02:00:00Z", timeZone: "America/Los_Angeles" },
82
+ cuisine: "mexican",
83
+ deliveryAddress: { address1: "100 University Ave", city: "Palo Alto", state: "CA", zip: "94301" },
84
+ onsiteContact: { name: "Sam Host", phone: "+14155550100" },
85
+ host: { name: "Sam Host", email: "sam@example.com" },
86
+ attendees: [
87
+ { name: "Ana", email: "ana@example.com", allergies: "peanuts", allergyConsent: true },
88
+ { name: "Ben", phone: "+14155550101", allergies: "" },
89
+ { name: "Cleo", dietaryPreferences: "vegetarian", allergyConsent: true },
90
+ ],
91
+ });
92
+
93
+ // 2. Options are ready in seconds. Use the webhook in production; polling works too.
94
+ const ready = await dunback.catering.waitForOptions(request.id);
95
+ for (const o of ready.options) {
96
+ console.log(o.title, o.price.totals.card, o.price.lines, o.allergyCoverage, o.unfedGuests);
97
+ }
98
+
99
+ // 3. The host picks one, and you get payment links
100
+ const order = await dunback.catering.select(ready.id, { optionId: ready.options[0].id });
101
+ order.payment.stripe?.checkoutUrl; // card: Stripe Checkout
102
+ order.payment.usdc; // USDC: amount, address, EIP-681 link, x402Url
103
+ order.payment.hostedPaymentUrl; // Dunback page offering both
104
+
105
+ // 4. Wait for the order.confirmed webhook, or poll
106
+ const final = await dunback.orders.waitForSettlement(order.id);
107
+ ```
108
+
109
+ ## Paying
110
+
111
+ | Method | Who it suits | How Dunback verifies |
112
+ | --- | --- | --- |
113
+ | **Card** (`payment.stripe.checkoutUrl`) | People | Signed Stripe webhook, plus a re-read of the Checkout Session: paid, USD, exact amount, this order |
114
+ | **USDC transfer** (`payment.usdc`) | People with a wallet, treasury tools | Polygon logs: a transfer of the exact tagged amount to the receiver is matched automatically. You can also call `orders.confirmUsdcPayment(id, txHash)` with any amount ≥ the total. |
115
+ | **x402** (`payOrderWithX402`) | Agents | EIP-3009 authorization, verified and settled on-chain by Dunback's x402 facilitator |
116
+
117
+ The **card total** includes card processing, so it is a little higher than
118
+ the **USDC total**. Both are shown in `price.totals`, and the line items are in
119
+ `price.lines`.
120
+
121
+ Payment links expire at `payment.expiresAt`. That is usually 60 minutes, and
122
+ always before the restaurant's order deadline. When a link expires, the host
123
+ can select an option again to get new links.
124
+
125
+ ### Agent payment with x402
126
+
127
+ ```ts
128
+ import { payOrderWithX402 } from "@dunbackmeadow/commerce-sdk";
129
+
130
+ const paid = await payOrderWithX402(order, {
131
+ address: account.address,
132
+ signTypedData: (td) => account.signTypedData(td), // viem
133
+ // signTypedData: (td) => wallet.signTypedData(td.domain, td.types, td.message), // ethers v6
134
+ }, { maxAmountUsdc: 500 });
135
+ // paid.status === "CONFIRMED"
136
+ ```
137
+
138
+ ### Payment errors
139
+
140
+ Payment problems come back as `DunbackApiError` with a `code` you can show to the payer:
141
+
142
+ | code | Meaning |
143
+ | --- | --- |
144
+ | `payment_pending` | The transaction isn't confirmed yet. Retry in a few seconds. |
145
+ | `payment_not_found` | That transaction didn't send USDC to Dunback. |
146
+ | `payment_amount_short` | Less than the order total arrived. |
147
+ | `payment_already_used` | That transaction already paid another order. |
148
+ | `invalid_payment_signature`, `invalid_payment`, `insufficient_funds`, `settlement_failed` | The x402 authorization was rejected. |
149
+ | `order_deadline_passed` | It's too late for the restaurant to make the event time. |
150
+
151
+ `isPaymentError(e)` tells you whether an error is one of these.
152
+
153
+ Asynchronous card failures, such as a declined bank debit, arrive as the
154
+ `order.payment_failed` webhook. `order.payment.lastError` holds the message.
155
+
156
+ ## Correcting the delivery address
157
+
158
+ Until an order is paid, you (or the payer, on the hosted payment page) can
159
+ correct the delivery address, on-site contact and note:
160
+
161
+ ```ts
162
+ const updated = await dunback.orders.updateDelivery(order.id, {
163
+ deliveryAddress: { address1: "120 University Ave", address2: "Suite 300", city: "Palo Alto", state: "CA", zip: "94301" },
164
+ onsiteContact: { name: "Sam Lee", phone: "+15550000000" },
165
+ deliveryNotes: "Loading dock on Bryant St.", // replaces the current note
166
+ });
167
+ // updated.delivery shows the corrected details
168
+ ```
169
+
170
+ The price stays as quoted, so the new address must stay within about a mile
171
+ of the original and inside the restaurant's delivery area. Otherwise the call
172
+ fails with `422 address_moved` or `outside_delivery_area`; create a new
173
+ catering request instead. Addresses where Dunback hasn't launched delivery
174
+ fail with `422 delivery_area_not_launched`, both here and when you create a
175
+ catering request.
176
+
177
+ ## Order lifecycle
178
+
179
+ ```
180
+ AWAITING_PAYMENT ─▶ PAID ─▶ FULFILLING ─▶ CONFIRMED ─▶ (CANCELLED | REFUNDED when every delivery failed)
181
+ │ ├─▶ REFUNDED / REFUND_PENDING restaurant couldn't take it; buyer refunded
182
+ │ └─▶ NEEDS_ATTENTION Dunback support finishes it by hand
183
+ └─▶ EXPIRED / CANCELLED
184
+ ```
185
+
186
+ ## Webhooks
187
+
188
+ ```ts
189
+ import express from "express";
190
+ import { verifyWebhook } from "@dunbackmeadow/commerce-sdk";
191
+
192
+ app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, res) => {
193
+ const event = verifyWebhook(req.body, req.header("Dunback-Signature"), process.env.DUNBACK_WEBHOOK_SECRET!);
194
+ // event.type, event.data (CateringRequest or Order)
195
+ res.sendStatus(200);
196
+ });
197
+ ```
198
+
199
+ | Event | `data` |
200
+ | --- | --- |
201
+ | `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
202
+ | `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated`, `order.revised` | Order |
203
+ | `ping` | `{ object: "ping", appId, message }`: sent by **Send test event** in the dashboard |
204
+
205
+ Each webhook is signed as `t=<unix>,v1=<HMAC-SHA256(secret, "<t>.<body>")>`.
206
+ A non-2xx answer is retried after 1 s, 5 s and 25 s. Handle events
207
+ idempotently by `event.id`.
208
+
209
+ ## Reliability
210
+
211
+ - POST helpers send an `Idempotency-Key`. Pass your own (for example, per button
212
+ click) to make retries safe across processes. Dunback keeps keys for 24 h.
213
+ - The client retries network errors and 5xx responses for GETs and for POSTs
214
+ that carry an idempotency key.
215
+ - `orders.get()` also re-checks Stripe, so it is safe to call right after a
216
+ Checkout redirect.
217
+
218
+ ## Allergies
219
+
220
+ Guests write allergy notes in their own words. Dunback turns them into
221
+ allergens (the US "Big 9" plus a few more) and diets. A dish is offered to a
222
+ guest with an allergy only when the restaurant has **declared** that dish's
223
+ allergens and none of them match. If no dish is known to be safe for a guest,
224
+ the option lists that guest in `unfedGuests` rather than guessing. Show those
225
+ warnings to the host. Allergy-labelled portions are requested from the
226
+ restaurant in the delivery note.
227
+
228
+ **Consent.** Allergy and diet notes are health information, so each guest
229
+ must agree to share theirs. Send `allergyConsent: true` for every guest whose
230
+ `allergies` or `dietaryPreferences` says more than "none". Without it, the
231
+ request fails with `400 allergy_consent_required`, and `details.guests` lists
232
+ the guests concerned. `toDunbackAttendees()` sets `allergyConsent` for answers
233
+ to `DUNBACK_REGISTRATION_QUESTION`, whose wording asks for that consent.
234
+
235
+ **Retention.** Dunback deletes guest data 30 days after the event. Orders are
236
+ kept longer for accounting, without guest names.
237
+
238
+ ## React components (optional)
239
+
240
+ ```tsx
241
+ import { DunbackCateringSettings, CateringOptionsPicker, DunbackOrderStatus } from "@dunbackmeadow/commerce-sdk/react";
242
+ ```
243
+
244
+ These components only render data. Your backend makes every Dunback call.
245
+
246
+ ## More
247
+
248
+ - Developer Dashboard and documentation: <https://dunbackmeadow.com/developer>
249
+ - [Luma integration guide](docs/LUMA_INTEGRATION_GUIDE.md)
250
+ - [API reference](docs/API_REFERENCE.md)
251
+ - [examples/luma-integration](examples/luma-integration): Express backend and host panel
252
+ - [examples/agent-x402-payment.ts](examples/agent-x402-payment.ts): an agent ordering and paying with x402
253
+
254
+ ## License
255
+
256
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AppInfo, V as VenueLocation, C as CuisineQuery, a as Cuisine, R as RestaurantSummary, b as CuisineCatalog, c as CateringRequestInput, d as CateringRequest, S as SelectOptionInput, O as Order, U as UpdateDeliveryInput, e as CancelOrderOptions, L as LateRefundRequestInput, f as LateRefundRequest, W as WebhookEvent } from './luma-Dh_6I01C.js';
2
- export { g as ATTENDING_STATUSES, h as Address, i as AllergyCoverage, j as Attendee, B as BuildCateringRequestArgs, k as CateringItem, l as CateringOption, m as CateringPolicies, n as CateringRequestStatus, o as CateringServiceStyle, p as CuisineId, q as CustomCuisineId, D as DUNBACK_REGISTRATION_QUESTION, r as DeliveredLateData, s as DunbackEventSettings, t as LumaEventLike, u as LumaGuestLike, v as OrderCancellation, w as OrderDelivery, x as OrderStatus, P as PingData, y as Price, z as PriceLine, E as RefundDecidedData, F as StandardCuisineId, G as UnavailableReason, H as UnavailableReasonCode, I as UnfedGuests, J as UsdcPaymentInstructions, K as WebhookEventType, M as buildCateringRequest, N as canOrderFood, Q as guestsWithUnsharedAllergies, T as toDunbackAddress, X as toDunbackAttendees, Y as toVenueLocation } from './luma-Dh_6I01C.js';
1
+ import { A as AppInfo, V as VenueLocation, C as CuisineQuery, a as Cuisine, R as RestaurantSummary, D as DrinkType, b as CuisineCatalog, c as CateringRequestInput, d as CateringRequest, S as SelectOptionInput, O as Order, U as UpdateDeliveryInput, e as CancelOrderOptions, L as LateRefundRequestInput, f as LateRefundRequest, W as WebhookEvent } from './luma-D2AucdDY.js';
2
+ export { g as ATTENDING_STATUSES, h as Address, i as AllergyCoverage, j as Attendee, B as BuildCateringRequestArgs, k as CateringItem, l as CateringOption, m as CateringPolicies, n as CateringRequestStatus, o as CateringServiceStyle, p as CuisineId, q as CustomCuisineId, r as DUNBACK_REGISTRATION_QUESTION, s as DeliveredLateData, t as DrinkTypeId, u as DunbackEventSettings, v as LumaEventLike, w as LumaGuestLike, x as OrderCancellation, y as OrderDelivery, z as OrderRevision, E as OrderStatus, P as PingData, F as Price, G as PriceLine, H as RefundDecidedData, I as StandardCuisineId, J as UnavailableReason, K as UnavailableReasonCode, M as UnfedGuests, N as UsdcPaymentInstructions, Q as WebhookEventType, T as buildCateringRequest, X as canOrderFood, Y as guestsWithUnsharedAllergies, Z as toDunbackAddress, _ as toDunbackAttendees, $ as toVenueLocation } from './luma-D2AucdDY.js';
3
3
 
4
4
  /** Any non-2xx answer from the Partner API. */
5
5
  declare class DunbackApiError extends Error {
@@ -70,6 +70,12 @@ declare class DunbackClient {
70
70
  * area; `q` filters by name (for a search box).
71
71
  */
72
72
  listRestaurants(venue?: VenueLocation | null, q?: string): Promise<RestaurantSummary[]>;
73
+ /**
74
+ * Drink types a host can ask for (`drinkTypes` on a catering request), for
75
+ * drinks-only catering or the drinks with food. Any other short word works
76
+ * too and is matched against the restaurants' drink names.
77
+ */
78
+ listDrinkTypes(): Promise<DrinkType[]>;
73
79
  /** listCuisines() plus which metro area the counts are for (`metro` is null when Dunback doesn't serve the venue's area). */
74
80
  cuisineCatalog(venue?: VenueLocation | null, query?: CuisineQuery): Promise<CuisineCatalog>;
75
81
  readonly catering: {
@@ -206,4 +212,4 @@ declare function payOrderWithX402(order: Pick<Order, "id" | "payment">, signer:
206
212
  maxAmountUsdc?: number;
207
213
  }): Promise<Order>;
208
214
 
209
- export { AppInfo, CancelOrderOptions, CateringRequest, CateringRequestInput, Cuisine, CuisineCatalog, CuisineQuery, DEFAULT_BASE_URL, DunbackApiError, DunbackClient, type DunbackClientOptions, LateRefundRequest, LateRefundRequestInput, Order, PAYMENT_ERROR_CODES, RestaurantSummary, SANDBOX_BASE_URL, SelectOptionInput, type TypedDataToSign, UpdateDeliveryInput, VenueLocation, WebhookEvent, type X402Signer, isPaymentError, payOrderWithX402, signWebhookPayload, verifyWebhook };
215
+ export { AppInfo, CancelOrderOptions, CateringRequest, CateringRequestInput, Cuisine, CuisineCatalog, CuisineQuery, DEFAULT_BASE_URL, DrinkType, DunbackApiError, DunbackClient, type DunbackClientOptions, LateRefundRequest, LateRefundRequestInput, Order, PAYMENT_ERROR_CODES, RestaurantSummary, SANDBOX_BASE_URL, SelectOptionInput, type TypedDataToSign, UpdateDeliveryInput, VenueLocation, WebhookEvent, type X402Signer, isPaymentError, payOrderWithX402, signWebhookPayload, verifyWebhook };
package/dist/index.js CHANGED
@@ -122,6 +122,14 @@ var DunbackClient = class {
122
122
  const qs = p.toString();
123
123
  return (await this.request("GET", `/catalog/restaurants${qs ? `?${qs}` : ""}`)).data;
124
124
  }
125
+ /**
126
+ * Drink types a host can ask for (`drinkTypes` on a catering request), for
127
+ * drinks-only catering or the drinks with food. Any other short word works
128
+ * too and is matched against the restaurants' drink names.
129
+ */
130
+ async listDrinkTypes() {
131
+ return (await this.request("GET", "/catalog/drink-types")).data;
132
+ }
125
133
  /** listCuisines() plus which metro area the counts are for (`metro` is null when Dunback doesn't serve the venue's area). */
126
134
  async cuisineCatalog(venue, query = {}) {
127
135
  const q = new URLSearchParams();
@@ -308,7 +316,7 @@ function toVenueLocation(geo) {
308
316
  function buildCateringRequest(args) {
309
317
  const { event, guests, settings, host } = args;
310
318
  if (!settings?.enabled) throw new Error("Dunback catering is not enabled for this event.");
311
- if (!settings.restaurantName && !settings.cuisine) throw new Error("Choose a restaurant or a cuisine for the catering.");
319
+ if (!settings.drinksOnly && !settings.restaurantName && !settings.cuisine) throw new Error("Choose a restaurant or a cuisine for the catering.");
312
320
  const onsite = args.onsiteContact || settings.onsiteContact || (host.phone ? { name: host.name, phone: host.phone, email: host.email } : null);
313
321
  if (!onsite) throw new Error("An on-site contact with a phone number is required for delivery.");
314
322
  const attendees = [...toDunbackAttendees(guests), ...args.extraAttendees || []];
@@ -317,9 +325,10 @@ function buildCateringRequest(args) {
317
325
  partnerReference: `luma:${event.api_id || event.id}`,
318
326
  event: { name: event.name, startsAt: event.start_at, timeZone: event.timezone, ...event.url ? { url: event.url } : {} },
319
327
  ...settings.deliveryDeadlineLocal ? { deliveryDeadlineLocal: settings.deliveryDeadlineLocal } : {},
320
- ...settings.restaurantName ? { restaurantName: settings.restaurantName } : { cuisine: settings.cuisine },
328
+ ...settings.restaurantName ? { restaurantName: settings.restaurantName } : settings.drinksOnly ? {} : { cuisine: settings.cuisine },
321
329
  serviceStyle: settings.serviceStyle ?? "meal_boxes",
322
- includeDrinks: settings.includeDrinks ?? true,
330
+ ...settings.drinksOnly ? { drinksOnly: true } : { includeDrinks: settings.includeDrinks ?? true },
331
+ ...settings.drinkTypes?.length ? { drinkTypes: settings.drinkTypes } : {},
323
332
  ...settings.budgetPerGuest ? { budgetPerGuest: settings.budgetPerGuest } : {},
324
333
  deliveryAddress: args.deliveryAddress || toDunbackAddress(event.geo_address_json),
325
334
  onsiteContact: onsite,
@@ -161,8 +161,22 @@ interface CateringRequestInput {
161
161
  secondaryCuisine?: CuisineId;
162
162
  /** Buffet (trays to share) or individual meal boxes. Default "meal_boxes". */
163
163
  serviceStyle?: CateringServiceStyle;
164
- /** Non-alcoholic drinks, one per guest. Default true. */
164
+ /** Food catering: also non-alcoholic drinks, one per guest. Default true. */
165
165
  includeDrinks?: boolean;
166
+ /**
167
+ * Drinks only, no food, one drink per guest: from `restaurantName` (a cafe,
168
+ * a boba shop...) or any restaurant serving `drinkTypes`. Don't send a
169
+ * cuisine with it. `serviceStyle` "meal_boxes" = individual cups, "buffet" =
170
+ * shared containers (carafes, gallons). Default false.
171
+ */
172
+ drinksOnly?: boolean;
173
+ /**
174
+ * Which drinks: ids from `listDrinkTypes()` ("coffee", "boba", "milk_tea"...)
175
+ * or a short word for any other ("horchata"). Up to 8. With `drinksOnly`,
176
+ * only restaurants serving them are matched and guests are shared among the
177
+ * types; with food, the drinks come from these types when the restaurant has them.
178
+ */
179
+ drinkTypes?: DrinkTypeId[];
166
180
  /** Options above this card price per guest are flagged `withinBudget: false`. */
167
181
  budgetPerGuest?: number;
168
182
  deliveryAddress: Address;
@@ -180,6 +194,12 @@ interface CateringRequestInput {
180
194
  };
181
195
  attendees: Attendee[];
182
196
  }
197
+ /** A drink type from `listDrinkTypes()`, or any short word ("horchata"). */
198
+ type DrinkTypeId = "coffee" | "tea" | "milk_tea" | "boba" | "fruit_tea" | "smoothie" | "juice" | "soda" | "hot_chocolate" | "water" | (string & {});
199
+ interface DrinkType {
200
+ id: DrinkTypeId;
201
+ label: string;
202
+ }
183
203
  interface PriceLine {
184
204
  code: "food" | "delivery" | "restaurant_fee" | "tax" | "platform_fee" | "service_fee";
185
205
  /** "Free delivery" (amount 0) when the restaurant waived the delivery fee. */
@@ -191,7 +211,7 @@ interface PriceLine {
191
211
  interface Price {
192
212
  currency: "USD";
193
213
  lines: PriceLine[];
194
- /** The host's service fee: serviceFeeRate x food and drinks (the `service_fee` line). */
214
+ /** The host's service fee: serviceFeeRate x (food and drinks + the restaurant's service charge) (the `service_fee` line). */
195
215
  dunbackServiceFee: number;
196
216
  /** Dunback's service fee rate on catering orders (0.05 = 5%). */
197
217
  serviceFeeRate: number;
@@ -227,6 +247,12 @@ interface CateringItem {
227
247
  dietaryTags: string[];
228
248
  /** true for a shared dish added so the order reaches the restaurant's minimum. */
229
249
  addedForMinimum?: boolean;
250
+ /**
251
+ * A drink's choices, from the restaurant's own options: ["Sweetness: 50%",
252
+ * "Toppings: Boba"]. Each option mixes them differently (favorites: the
253
+ * restaurant's defaults; value: no paid add-ons; variety: several versions).
254
+ */
255
+ modifiers?: string[];
230
256
  }
231
257
  interface AllergyCoverage {
232
258
  /** "no peanut, shellfish", "vegetarian", "no restrictions", ... */
@@ -261,6 +287,14 @@ interface CateringOption {
261
287
  unfedGuests: UnfedGuests[];
262
288
  price: Price;
263
289
  withinBudget?: boolean;
290
+ /**
291
+ * false when this restaurant hasn't set up card payments on Dunback (its
292
+ * Stripe account): the option can then only be paid in USDC, and selecting
293
+ * it with paymentMethods ["stripe"] fails with card_payments_unavailable.
294
+ */
295
+ acceptsCard: boolean;
296
+ /** How this option can be paid: ["stripe", "usdc"], or ["usdc"] when acceptsCard is false. */
297
+ paymentMethods: Array<"stripe" | "usdc">;
264
298
  /** Pay before this instant (ISO), or the restaurant can't make the event time. */
265
299
  orderBy: string | null;
266
300
  /** Dunback's catering cancellation and refund policy, in one paragraph. Show it with the option. */
@@ -297,6 +331,10 @@ interface CateringRequest {
297
331
  reason: string | null;
298
332
  } | null;
299
333
  serviceStyle: CateringServiceStyle;
334
+ /** Drinks only, no food. */
335
+ drinksOnly: boolean;
336
+ includeDrinks: boolean;
337
+ drinkTypes: DrinkType[];
300
338
  guestCount: number;
301
339
  deliveryDeadlineLocal: string;
302
340
  timeZone: string;
@@ -390,7 +428,15 @@ interface Order {
390
428
  timeZone: string;
391
429
  guestCount: number;
392
430
  delivery: OrderDelivery;
431
+ /** What was priced and paid for. */
393
432
  items: CateringItem[];
433
+ /**
434
+ * Set when the restaurant changed the order after calling the host and
435
+ * getting their agreement (webhook `order.revised`). `revision.items` is
436
+ * what it will now prepare. The price never changes with a revision.
437
+ * Show the note and the revised items to the host.
438
+ */
439
+ revision: OrderRevision | null;
394
440
  allergyCoverage: AllergyCoverage[];
395
441
  unfedGuests: UnfedGuests[];
396
442
  price: Price;
@@ -421,12 +467,21 @@ interface Order {
421
467
  };
422
468
  fulfillment: {
423
469
  restaurantOrderIds: string[];
470
+ /**
471
+ * How Dunback paid the restaurant: in USDC on Polygon for a USDC/x402 order,
472
+ * or through the restaurant's Stripe account for a card order (details
473
+ * of a card payout are not shared).
474
+ */
424
475
  providerPayment: {
476
+ method?: "usdc_x402";
425
477
  amount: number;
426
478
  payTo: string;
427
479
  txHash: string | null;
428
480
  verifiedOnChain: boolean;
429
481
  network: "polygon";
482
+ } | {
483
+ method: "stripe_connect";
484
+ status: "PAID" | "PENDING";
430
485
  };
431
486
  confirmedAt: string;
432
487
  } | null;
@@ -559,7 +614,23 @@ interface RefundDecidedData extends Order {
559
614
  } | null;
560
615
  };
561
616
  }
562
- type WebhookEventType = "catering.options_ready" | "catering.no_options" | "catering.failed" | "order.created" | "order.confirmed" | "order.payment_failed" | "order.expired" | "order.failed" | "order.needs_attention" | "order.cancelled" | "order.refunded" | "order.refund_decided" | "order.delivered_late" | "order.delivery_updated" | "ping";
617
+ interface OrderRevision {
618
+ /** "Revised by restaurant with user agreement." */
619
+ note: string;
620
+ revisedAt: string;
621
+ /** The restaurant's reason, as told to the host. */
622
+ reason: string;
623
+ items: Array<{
624
+ name: string;
625
+ quantity: number;
626
+ modifiers: string[];
627
+ }>;
628
+ history: Array<{
629
+ revisedAt: string;
630
+ reason: string;
631
+ }>;
632
+ }
633
+ type WebhookEventType = "catering.options_ready" | "catering.no_options" | "catering.failed" | "order.created" | "order.confirmed" | "order.payment_failed" | "order.expired" | "order.failed" | "order.needs_attention" | "order.cancelled" | "order.refunded" | "order.refund_decided" | "order.delivered_late" | "order.delivery_updated" | "order.revised" | "ping";
563
634
  /** `data` of a `ping` event, sent by "Send test event" in the Developer Dashboard. */
564
635
  interface PingData {
565
636
  object: "ping";
@@ -609,14 +680,22 @@ interface DunbackEventSettings {
609
680
  * a cuisine picker: the restaurant settles it, and all options come from it.
610
681
  */
611
682
  restaurantName?: string;
612
- /** Required when no restaurantName is set. */
683
+ /** Required when no restaurantName is set, unless drinksOnly. */
613
684
  cuisine?: CuisineId;
685
+ /**
686
+ * Drinks only, no food (coffee for a morning meetup, boba for a study
687
+ * group): from restaurantName, or any restaurant serving drinkTypes. No cuisine.
688
+ */
689
+ drinksOnly?: boolean;
690
+ /** Which drinks ("coffee", "boba"...; listDrinkTypes()). With food, the drinks come from these types. */
691
+ drinkTypes?: DrinkTypeId[];
614
692
  /**
615
693
  * Buffet (trays to share) or individual meal boxes. Pass it to
616
694
  * listCuisines(venue, { serviceStyle }) too: fewer restaurants offer buffets.
617
695
  * Default "meal_boxes".
618
696
  */
619
697
  serviceStyle?: CateringServiceStyle;
698
+ /** Food catering: also one drink per guest. Default true. */
620
699
  includeDrinks?: boolean;
621
700
  budgetPerGuest?: number;
622
701
  /**
@@ -750,4 +829,4 @@ declare function canOrderFood(settings: DunbackEventSettings | null | undefined,
750
829
  reason?: string;
751
830
  };
752
831
 
753
- export { type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, DUNBACK_REGISTRATION_QUESTION as D, type RefundDecidedData as E, type StandardCuisineId as F, type UnavailableReason as G, type UnavailableReasonCode as H, type UnfedGuests as I, type UsdcPaymentInstructions as J, type WebhookEventType as K, type LateRefundRequestInput as L, buildCateringRequest as M, canOrderFood as N, type Order as O, type PingData as P, guestsWithUnsharedAllergies as Q, type RestaurantSummary as R, type SelectOptionInput as S, toDunbackAddress as T, type UpdateDeliveryInput as U, type VenueLocation as V, type WebhookEvent as W, toDunbackAttendees as X, toVenueLocation as Y, type Cuisine as a, type CuisineCatalog as b, type CateringRequestInput as c, type CateringRequest as d, type CancelOrderOptions as e, type LateRefundRequest as f, ATTENDING_STATUSES as g, type Address as h, type AllergyCoverage as i, type Attendee as j, type CateringItem as k, type CateringOption as l, type CateringPolicies as m, type CateringRequestStatus as n, type CateringServiceStyle as o, type CuisineId as p, type CustomCuisineId as q, type DeliveredLateData as r, type DunbackEventSettings as s, type LumaEventLike as t, type LumaGuestLike as u, type OrderCancellation as v, type OrderDelivery as w, type OrderStatus as x, type Price as y, type PriceLine as z };
832
+ export { toVenueLocation as $, type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, type DrinkType as D, type OrderStatus as E, type Price as F, type PriceLine as G, type RefundDecidedData as H, type StandardCuisineId as I, type UnavailableReason as J, type UnavailableReasonCode as K, type LateRefundRequestInput as L, type UnfedGuests as M, type UsdcPaymentInstructions as N, type Order as O, type PingData as P, type WebhookEventType as Q, type RestaurantSummary as R, type SelectOptionInput as S, buildCateringRequest as T, type UpdateDeliveryInput as U, type VenueLocation as V, type WebhookEvent as W, canOrderFood as X, guestsWithUnsharedAllergies as Y, toDunbackAddress as Z, toDunbackAttendees as _, type Cuisine as a, type CuisineCatalog as b, type CateringRequestInput as c, type CateringRequest as d, type CancelOrderOptions as e, type LateRefundRequest as f, ATTENDING_STATUSES as g, type Address as h, type AllergyCoverage as i, type Attendee as j, type CateringItem as k, type CateringOption as l, type CateringPolicies as m, type CateringRequestStatus as n, type CateringServiceStyle as o, type CuisineId as p, type CustomCuisineId as q, DUNBACK_REGISTRATION_QUESTION as r, type DeliveredLateData as s, type DrinkTypeId as t, type DunbackEventSettings as u, type LumaEventLike as v, type LumaGuestLike as w, type OrderCancellation as x, type OrderDelivery as y, type OrderRevision as z };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { l as CateringOption, a as Cuisine, s as DunbackEventSettings, R as RestaurantSummary, O as Order, y as Price } from '../luma-Dh_6I01C.js';
2
+ import { l as CateringOption, a as Cuisine, u as DunbackEventSettings, R as RestaurantSummary, D as DrinkType, O as Order, F as Price } from '../luma-D2AucdDY.js';
3
3
 
4
4
  /**
5
5
  * Optional, unstyled-by-default React building blocks for the three Luma
@@ -43,9 +43,15 @@ interface DunbackCateringSettingsProps {
43
43
  * restaurant, the cuisine picker is hidden: the restaurant settles it.
44
44
  */
45
45
  restaurants?: RestaurantSummary[];
46
+ /**
47
+ * From your backend: dunback.listDrinkTypes(). Offered as "Which drinks?"
48
+ * for a drinks-only order and for the drinks with food. Defaults to the
49
+ * standard types.
50
+ */
51
+ drinkTypes?: DrinkType[];
46
52
  className?: string;
47
53
  }
48
- declare function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests, restaurants, className }: DunbackCateringSettingsProps): React.JSX.Element;
54
+ declare function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests, restaurants, drinkTypes, className }: DunbackCateringSettingsProps): React.JSX.Element;
49
55
  interface PriceBreakdownProps {
50
56
  price: Price;
51
57
  /**
@@ -6,6 +6,21 @@ var SERVICE_STYLES = [
6
6
  { id: "meal_boxes", label: "Individual meal boxes", hint: "(one packed meal per guest; guests pick their own)" },
7
7
  { id: "buffet", label: "Buffet", hint: "(trays and platters to share)" }
8
8
  ];
9
+ var DRINK_STYLES = [
10
+ { id: "meal_boxes", label: "Individual drinks", hint: "(one cup per guest)" },
11
+ { id: "buffet", label: "Shared containers", hint: "(carafes and gallons to pour from)" }
12
+ ];
13
+ var DEFAULT_DRINK_TYPES = [
14
+ { id: "coffee", label: "Coffee" },
15
+ { id: "tea", label: "Tea" },
16
+ { id: "milk_tea", label: "Milk tea" },
17
+ { id: "boba", label: "Boba (bubble tea)" },
18
+ { id: "fruit_tea", label: "Fruit tea" },
19
+ { id: "smoothie", label: "Smoothies & slushes" },
20
+ { id: "juice", label: "Juice & lemonade" },
21
+ { id: "soda", label: "Soda & sparkling" },
22
+ { id: "hot_chocolate", label: "Hot chocolate" }
23
+ ];
9
24
  var noticeText = (h) => h >= 48 && h % 24 === 0 ? `${h / 24} days` : `${h} hours`;
10
25
  var box = { border: "1px solid rgba(127,127,127,.3)", borderRadius: 10, padding: 14 };
11
26
  var checkbox = {
@@ -22,7 +37,7 @@ var checkRow = { display: "flex", alignItems: "center", gap: 8, margin: 0, curso
22
37
  var field = { display: "grid", gap: 4, margin: 0, fontSize: 14, fontWeight: 500 };
23
38
  var control = { boxSizing: "border-box", width: "100%", maxWidth: 280, font: "inherit", fontWeight: 400 };
24
39
  var hint = { fontSize: 12.5, fontWeight: 400, opacity: 0.7 };
25
- function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests = true, restaurants = [], className }) {
40
+ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests = true, restaurants = [], drinkTypes = DEFAULT_DRINK_TYPES, className }) {
26
41
  const enabled = !!value?.enabled;
27
42
  const showAvailability = venueReady !== false;
28
43
  const firstAvailable = (showAvailability ? cuisines.find((c) => c.restaurants > 0)?.id : null) || cuisines[0]?.id || "american";
@@ -56,8 +71,31 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
56
71
  enabled && value && // Indented to line up with the title above (checkbox 16 + gap 10).
57
72
  /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: 14, marginTop: 14, paddingLeft: 26 }, children: [
58
73
  /* @__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: [
74
+ /* @__PURE__ */ jsx("legend", { style: { ...field, padding: 0, marginBottom: 4 }, children: "What should we order?" }),
75
+ [
76
+ { drinks: false, label: "Food", hint: "(with or without drinks)" },
77
+ { drinks: true, label: "Drinks only", hint: "(coffee, tea, boba... from a cafe or drink shop)" }
78
+ ].map((k) => /* @__PURE__ */ jsxs("label", { style: { ...checkRow, alignItems: "flex-start" }, children: [
79
+ /* @__PURE__ */ jsx(
80
+ "input",
81
+ {
82
+ type: "radio",
83
+ name: "dunback-order-kind",
84
+ style: { ...checkbox, marginTop: 2 },
85
+ checked: !!value.drinksOnly === k.drinks,
86
+ onChange: () => onChange(k.drinks ? { ...value, drinksOnly: true, cuisine: void 0 } : { ...value, drinksOnly: false, cuisine: value.restaurantName?.trim() ? void 0 : value.cuisine || firstAvailable })
87
+ }
88
+ ),
89
+ /* @__PURE__ */ jsxs("span", { children: [
90
+ k.label,
91
+ " ",
92
+ /* @__PURE__ */ jsx("span", { style: hint, children: k.hint })
93
+ ] })
94
+ ] }, k.label))
95
+ ] }),
96
+ /* @__PURE__ */ jsxs("fieldset", { style: { border: 0, padding: 0, margin: 0, display: "grid", gap: 6 }, children: [
97
+ /* @__PURE__ */ jsx("legend", { style: { ...field, padding: 0, marginBottom: 4 }, children: value.drinksOnly ? "How should drinks be served?" : "How should food be served?" }),
98
+ (value.drinksOnly ? DRINK_STYLES : SERVICE_STYLES).map((s) => /* @__PURE__ */ jsxs("label", { style: { ...checkRow, alignItems: "flex-start" }, children: [
61
99
  /* @__PURE__ */ jsx(
62
100
  "input",
63
101
  {
@@ -89,14 +127,14 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
89
127
  value: value.restaurantName ?? "",
90
128
  onChange: (e) => {
91
129
  const name = e.target.value;
92
- onChange(name.trim() ? { ...value, restaurantName: name, cuisine: void 0 } : { ...value, restaurantName: void 0, cuisine: value.cuisine || firstAvailable });
130
+ onChange(name.trim() ? { ...value, restaurantName: name, cuisine: void 0 } : { ...value, restaurantName: void 0, cuisine: value.drinksOnly ? void 0 : value.cuisine || firstAvailable });
93
131
  }
94
132
  }
95
133
  ),
96
134
  restaurants.length > 0 && /* @__PURE__ */ jsx("datalist", { id: "dunback-restaurants", children: restaurants.map((r) => /* @__PURE__ */ jsx("option", { value: r.name, children: r.cuisine ? `${r.cuisine.label}${r.secondaryCuisine ? `-${r.secondaryCuisine.label}` : ""}` : "" }, r.name)) }),
97
- /* @__PURE__ */ jsx("span", { style: hint, children: value.restaurantName?.trim() ? "All catering options will come from this restaurant. If it can't cater your event, you'll see why, with options from other restaurants." : "Leave empty to choose a cuisine instead." })
135
+ /* @__PURE__ */ jsx("span", { style: hint, children: value.restaurantName?.trim() ? "All catering options will come from this restaurant. If it can't cater your event, you'll see why, with options from other restaurants." : value.drinksOnly ? "Leave empty for any cafe or drink shop serving the drinks you pick." : "Leave empty to choose a cuisine instead." })
98
136
  ] }),
99
- !value.restaurantName?.trim() && /* @__PURE__ */ jsxs("label", { style: field, children: [
137
+ !value.restaurantName?.trim() && !value.drinksOnly && /* @__PURE__ */ jsxs("label", { style: field, children: [
100
138
  "Cuisine",
101
139
  /* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine || "", onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
102
140
  cuisines.filter((c) => !c.custom).map(option),
@@ -138,7 +176,7 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
138
176
  /* @__PURE__ */ jsx("span", { style: hint, children: "Some restaurants limit party size or have a minimum order" })
139
177
  ] })
140
178
  ] }),
141
- /* @__PURE__ */ jsxs("label", { style: checkRow, children: [
179
+ !value.drinksOnly && /* @__PURE__ */ jsxs("label", { style: checkRow, children: [
142
180
  /* @__PURE__ */ jsx(
143
181
  "input",
144
182
  {
@@ -153,6 +191,35 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
153
191
  /* @__PURE__ */ jsx("span", { style: hint, children: "(non-alcoholic, one per guest)" })
154
192
  ] })
155
193
  ] }),
194
+ (value.drinksOnly || (value.includeDrinks ?? true)) && /* @__PURE__ */ jsxs("fieldset", { style: { border: 0, padding: 0, margin: 0, display: "grid", gap: 6 }, children: [
195
+ /* @__PURE__ */ jsxs("legend", { style: { ...field, padding: 0, marginBottom: 4 }, children: [
196
+ "Which drinks? ",
197
+ /* @__PURE__ */ jsxs("span", { style: hint, children: [
198
+ "(optional",
199
+ value.drinksOnly ? "; guests are shared among the ones you pick" : "",
200
+ ")"
201
+ ] })
202
+ ] }),
203
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px 14px" }, children: drinkTypes.map((t) => {
204
+ const on = (value.drinkTypes || []).includes(t.id);
205
+ return /* @__PURE__ */ jsxs("label", { style: checkRow, children: [
206
+ /* @__PURE__ */ jsx(
207
+ "input",
208
+ {
209
+ type: "checkbox",
210
+ style: checkbox,
211
+ checked: on,
212
+ onChange: () => {
213
+ const next = on ? (value.drinkTypes || []).filter((x) => x !== t.id) : [...value.drinkTypes || [], t.id];
214
+ onChange({ ...value, drinkTypes: next.length ? next : void 0 });
215
+ }
216
+ }
217
+ ),
218
+ /* @__PURE__ */ jsx("span", { children: t.label })
219
+ ] }, t.id);
220
+ }) }),
221
+ /* @__PURE__ */ jsx("span", { style: hint, children: "Each option mixes the restaurant's own choices, like sweetness and toppings." })
222
+ ] }),
156
223
  /* @__PURE__ */ jsxs("label", { style: field, children: [
157
224
  /* @__PURE__ */ jsxs("span", { children: [
158
225
  "Budget per guest ",
@@ -197,6 +197,8 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
197
197
  | `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
198
198
  | `price` | See Price |
199
199
  | `withinBudget` | Present when a budget was set |
200
+ | `acceptsCard` | `false` when the restaurant hasn't set up card payments on Dunback (its Stripe account): the option can then only be paid in USDC |
201
+ | `paymentMethods` | `["stripe","usdc"]`, or `["usdc"]` when `acceptsCard` is false |
200
202
  | `orderBy` | ISO; latest payment time the restaurant accepts |
201
203
 
202
204
  ### Price
@@ -205,7 +207,7 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
205
207
  | --- | --- |
206
208
  | `currency` | `"USD"` |
207
209
  | `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
208
- | `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × food and drinks |
210
+ | `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × (food and drinks + the restaurant's service charge). Delivery and tax are not included. |
209
211
  | `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
210
212
  | `totals` | `{ usdc, card, cardProcessingFee }` |
211
213
  | `perGuest` | `{ usdc, card }` |
@@ -218,7 +220,7 @@ The card total is the USDC total grossed up for card processing.
218
220
  | --- | --- |
219
221
  | `optionId` | required |
220
222
  | `payer` | `{ name?, email? }` (pre-fills Stripe) |
221
- | `paymentMethods` | `["stripe","usdc"]` (default both) |
223
+ | `paymentMethods` | `["stripe","usdc"]` (default both). `stripe` is left out when the option's `acceptsCard` is false. |
222
224
  | `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts. The hosted payment page links back to them ("Back to the event": `cancelUrl` before payment, `successUrl` after) |
223
225
 
224
226
  Errors:
@@ -227,6 +229,7 @@ Errors:
227
229
  | --- | --- | --- |
228
230
  | 409 | `invalid_state` | Already selected, or not ready |
229
231
  | 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
232
+ | 409 | `card_payments_unavailable` | Only `stripe` was asked for, and this restaurant can't take card payments (`acceptsCard: false`). Offer USDC or another option. |
230
233
  | 409 | `restaurant_*` | The restaurant can't take it now |
231
234
 
232
235
  ---
@@ -244,7 +247,7 @@ Errors:
244
247
  | `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`. |
245
248
  | `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
246
249
  | `payment` | See below |
247
- | `fulfillment` | `{ restaurantOrderIds, providerPayment: { amount, payTo, txHash, verifiedOnChain, network }, confirmedAt }` |
250
+ | `fulfillment` | `{ restaurantOrderIds, providerPayment, confirmedAt }`. `providerPayment` is how Dunback paid the restaurant: `{ method: "usdc_x402", amount, payTo, txHash, verifiedOnChain, network }` for a USDC order, or `{ method: "stripe_connect", status: "PAID"\|"PENDING" }` for a card order (paid through the restaurant's own Stripe account) |
248
251
  | `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
249
252
  | `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
250
253
  | `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunbackmeadow/commerce-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Official Node.js/TypeScript SDK for the Dunback Meadow commerce API. Order from your app or agent and pay by card (Stripe) or USDC. Event catering is available now; more product types are coming.",
5
5
  "repository": {
6
6
  "type": "git",