@dunbackmeadow/commerce-sdk 0.8.0 → 0.10.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 +256 -256
- package/dist/index.d.ts +9 -3
- package/dist/index.js +21 -3
- package/dist/{luma-Dh_6I01C.d.ts → luma-WIhD5QRd.d.ts} +171 -10
- package/dist/react/index.d.ts +8 -2
- package/dist/react/index.js +74 -7
- package/docs/API_REFERENCE.md +19 -8
- package/docs/LUMA_INTEGRATION_GUIDE.md +6 -0
- package/package.json +1 -1
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-
|
|
2
|
-
export { g as ATTENDING_STATUSES, h as Address, i as AllergyCoverage, j as Attendee, B as BuildCateringRequestArgs, k as
|
|
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-WIhD5QRd.js';
|
|
2
|
+
export { g as ATTENDING_STATUSES, h as Address, i as AllergyCoverage, j as Attendee, B as BuildCateringRequestArgs, k as CateringBudgetResult, l as CateringItem, m as CateringMealType, n as CateringOption, o as CateringPolicies, p as CateringRequestStatus, q as CateringServiceStyle, r as CuisineId, s as CustomCuisineId, t as DUNBACK_REGISTRATION_QUESTION, u as DeliveredLateData, v as DrinkTypeId, w as DunbackEventSettings, x as LumaEventLike, y as LumaGuestLike, z as OrderCancellation, E as OrderDelivery, F as OrderRevision, G as OrderStatus, P as PartyDiet, H as PingData, I as Price, J as PriceLine, K as RefundDecidedData, M as StandardCuisineId, N as UnavailableReason, Q as UnavailableReasonCode, T as UnfedGuests, X as UsdcPaymentInstructions, Y as WebhookEventType, Z as buildCateringRequest, _ as canOrderFood, $ as guestsWithUnsharedAllergies, a0 as toDunbackAddress, a1 as toDunbackAttendees, a2 as toVenueLocation } from './luma-WIhD5QRd.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,9 @@ 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
|
|
319
|
+
if (!settings.drinksOnly && !settings.restaurantName && !settings.cuisine && !settings.dishPreferences?.length && settings.mealType !== "breakfast") {
|
|
320
|
+
throw new Error("Choose a restaurant, a cuisine or the dishes you'd like for the catering.");
|
|
321
|
+
}
|
|
312
322
|
const onsite = args.onsiteContact || settings.onsiteContact || (host.phone ? { name: host.name, phone: host.phone, email: host.email } : null);
|
|
313
323
|
if (!onsite) throw new Error("An on-site contact with a phone number is required for delivery.");
|
|
314
324
|
const attendees = [...toDunbackAttendees(guests), ...args.extraAttendees || []];
|
|
@@ -317,10 +327,18 @@ function buildCateringRequest(args) {
|
|
|
317
327
|
partnerReference: `luma:${event.api_id || event.id}`,
|
|
318
328
|
event: { name: event.name, startsAt: event.start_at, timeZone: event.timezone, ...event.url ? { url: event.url } : {} },
|
|
319
329
|
...settings.deliveryDeadlineLocal ? { deliveryDeadlineLocal: settings.deliveryDeadlineLocal } : {},
|
|
320
|
-
...settings.restaurantName ? { restaurantName: settings.restaurantName } : { cuisine: settings.cuisine },
|
|
330
|
+
...settings.restaurantName ? { restaurantName: settings.restaurantName } : settings.drinksOnly || !settings.cuisine ? {} : { cuisine: settings.cuisine },
|
|
321
331
|
serviceStyle: settings.serviceStyle ?? "meal_boxes",
|
|
322
|
-
includeDrinks: settings.includeDrinks ?? true,
|
|
332
|
+
...settings.drinksOnly ? { drinksOnly: true } : { includeDrinks: settings.includeDrinks ?? true },
|
|
333
|
+
...settings.drinkTypes?.length ? { drinkTypes: settings.drinkTypes } : {},
|
|
323
334
|
...settings.budgetPerGuest ? { budgetPerGuest: settings.budgetPerGuest } : {},
|
|
335
|
+
...settings.maxTotal ? { maxTotal: settings.maxTotal } : {},
|
|
336
|
+
...settings.maxPerGuest ? { maxPerGuest: settings.maxPerGuest } : {},
|
|
337
|
+
// Dish rules are about food: not for a drinks-only order.
|
|
338
|
+
...!settings.drinksOnly && settings.dishPreferences?.length ? { dishPreferences: settings.dishPreferences } : {},
|
|
339
|
+
...!settings.drinksOnly && settings.mealType ? { mealType: settings.mealType } : {},
|
|
340
|
+
...!settings.drinksOnly && settings.spicyShare != null ? { spicyShare: settings.spicyShare } : {},
|
|
341
|
+
...!settings.drinksOnly && settings.partyDiet?.length ? { partyDiet: settings.partyDiet } : {},
|
|
324
342
|
deliveryAddress: args.deliveryAddress || toDunbackAddress(event.geo_address_json),
|
|
325
343
|
onsiteContact: onsite,
|
|
326
344
|
deliveryNotes: settings.deliveryNotes || "",
|
|
@@ -149,9 +149,10 @@ interface CateringRequestInput {
|
|
|
149
149
|
*/
|
|
150
150
|
restaurantName?: string;
|
|
151
151
|
/**
|
|
152
|
-
* Required
|
|
153
|
-
*
|
|
154
|
-
*
|
|
152
|
+
* Required unless you give restaurantName, dishPreferences or mealType
|
|
153
|
+
* "breakfast" (then any cuisine). Restaurants whose primary cuisine this is
|
|
154
|
+
* are matched first; restaurants listing it as their secondary cuisine only
|
|
155
|
+
* when none of those can cater.
|
|
155
156
|
*/
|
|
156
157
|
cuisine?: CuisineId;
|
|
157
158
|
/**
|
|
@@ -161,10 +162,50 @@ interface CateringRequestInput {
|
|
|
161
162
|
secondaryCuisine?: CuisineId;
|
|
162
163
|
/** Buffet (trays to share) or individual meal boxes. Default "meal_boxes". */
|
|
163
164
|
serviceStyle?: CateringServiceStyle;
|
|
164
|
-
/**
|
|
165
|
+
/** Food catering: also non-alcoholic drinks, one per guest. Default true. */
|
|
165
166
|
includeDrinks?: boolean;
|
|
166
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Drinks only, no food, one drink per guest: from `restaurantName` (a cafe,
|
|
169
|
+
* a boba shop...) or any restaurant serving `drinkTypes`. Don't send a
|
|
170
|
+
* cuisine with it. `serviceStyle` "meal_boxes" = individual cups, "buffet" =
|
|
171
|
+
* shared containers (carafes, gallons). Default false.
|
|
172
|
+
*/
|
|
173
|
+
drinksOnly?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Which drinks: ids from `listDrinkTypes()` ("coffee", "boba", "milk_tea"...)
|
|
176
|
+
* or a short word for any other ("horchata"). Up to 8. With `drinksOnly`,
|
|
177
|
+
* only restaurants serving them are matched and guests are shared among the
|
|
178
|
+
* types; with food, the drinks come from these types when the restaurant has them.
|
|
179
|
+
*/
|
|
180
|
+
drinkTypes?: DrinkTypeId[];
|
|
181
|
+
/** Soft: options above this card price per guest are only flagged `withinBudget: false`. */
|
|
167
182
|
budgetPerGuest?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Hard budget, USD: options priced above it are not offered. Compared with
|
|
185
|
+
* what the host would pay: the card total, or the USDC total at a restaurant
|
|
186
|
+
* that takes no card. When it leaves fewer than three options,
|
|
187
|
+
* `CateringRequest.budget.message` says how far to raise it for three.
|
|
188
|
+
*/
|
|
189
|
+
maxTotal?: number;
|
|
190
|
+
/** Hard budget per guest, USD (see `maxTotal`). */
|
|
191
|
+
maxPerGuest?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Kinds of dishes the host wants, up to 8: "sushi", "seafood", "pastries",
|
|
194
|
+
* "bagels", "tacos"... The mains come from dishes that match; a guest no
|
|
195
|
+
* matching dish is safe for gets another safe main (its allergyCoverage
|
|
196
|
+
* entry says `outsidePreferences: true`). Any cuisine when none is given.
|
|
197
|
+
*/
|
|
198
|
+
dishPreferences?: string[];
|
|
199
|
+
/**
|
|
200
|
+
* The kind of food, whatever the delivery time: "breakfast" (pastries,
|
|
201
|
+
* bagels, egg dishes, fruit...), "lunch" or "dinner". Without it, a delivery
|
|
202
|
+
* before 10:30 prefers breakfast food without requiring it.
|
|
203
|
+
*/
|
|
204
|
+
mealType?: CateringMealType;
|
|
205
|
+
/** About this share (0..1) of the main servings spicy; 0 = nothing spicy. */
|
|
206
|
+
spicyShare?: number;
|
|
207
|
+
/** Diets every guest's food must fit, e.g. ["vegetarian"] for an all-vegetarian event. */
|
|
208
|
+
partyDiet?: PartyDiet[];
|
|
168
209
|
deliveryAddress: Address;
|
|
169
210
|
/** Who receives the delivery at the venue. */
|
|
170
211
|
onsiteContact: {
|
|
@@ -180,6 +221,34 @@ interface CateringRequestInput {
|
|
|
180
221
|
};
|
|
181
222
|
attendees: Attendee[];
|
|
182
223
|
}
|
|
224
|
+
type CateringMealType = "breakfast" | "lunch" | "dinner";
|
|
225
|
+
type PartyDiet = "vegetarian" | "vegan" | "halal" | "kosher" | "gluten_free" | "dairy_free" | "pescatarian";
|
|
226
|
+
/** What a hard budget (`maxTotal` / `maxPerGuest`) did to the options. */
|
|
227
|
+
interface CateringBudgetResult {
|
|
228
|
+
maxTotal: number | null;
|
|
229
|
+
maxPerGuest: number | null;
|
|
230
|
+
/** The budget for the whole order (the tighter of the two), USD. */
|
|
231
|
+
limit: number;
|
|
232
|
+
/** Options offered (all within the budget). */
|
|
233
|
+
withinBudget: number;
|
|
234
|
+
/** Options left out for being over the budget. */
|
|
235
|
+
overBudget: number;
|
|
236
|
+
/** With fewer than three options: about how far to raise the budget for three (null otherwise). */
|
|
237
|
+
suggestedMaxTotal: number | null;
|
|
238
|
+
suggestedMaxPerGuest: number | null;
|
|
239
|
+
/**
|
|
240
|
+
* Show this to the host when set, e.g. "Only 2 catering offers fit your
|
|
241
|
+
* budget of $1,000. Raising your budget to about $1,150 would give you 3
|
|
242
|
+
* offers to choose from."
|
|
243
|
+
*/
|
|
244
|
+
message: string | null;
|
|
245
|
+
}
|
|
246
|
+
/** A drink type from `listDrinkTypes()`, or any short word ("horchata"). */
|
|
247
|
+
type DrinkTypeId = "coffee" | "tea" | "milk_tea" | "boba" | "fruit_tea" | "smoothie" | "juice" | "soda" | "hot_chocolate" | "water" | (string & {});
|
|
248
|
+
interface DrinkType {
|
|
249
|
+
id: DrinkTypeId;
|
|
250
|
+
label: string;
|
|
251
|
+
}
|
|
183
252
|
interface PriceLine {
|
|
184
253
|
code: "food" | "delivery" | "restaurant_fee" | "tax" | "platform_fee" | "service_fee";
|
|
185
254
|
/** "Free delivery" (amount 0) when the restaurant waived the delivery fee. */
|
|
@@ -191,7 +260,7 @@ interface PriceLine {
|
|
|
191
260
|
interface Price {
|
|
192
261
|
currency: "USD";
|
|
193
262
|
lines: PriceLine[];
|
|
194
|
-
/** The host's service fee: serviceFeeRate x food and drinks (the `service_fee` line). */
|
|
263
|
+
/** The host's service fee: serviceFeeRate x (food and drinks + the restaurant's service charge) (the `service_fee` line). */
|
|
195
264
|
dunbackServiceFee: number;
|
|
196
265
|
/** Dunback's service fee rate on catering orders (0.05 = 5%). */
|
|
197
266
|
serviceFeeRate: number;
|
|
@@ -227,12 +296,24 @@ interface CateringItem {
|
|
|
227
296
|
dietaryTags: string[];
|
|
228
297
|
/** true for a shared dish added so the order reaches the restaurant's minimum. */
|
|
229
298
|
addedForMinimum?: boolean;
|
|
299
|
+
/** The request's dishPreferences this dish matches ("sushi"). */
|
|
300
|
+
matches?: string[];
|
|
301
|
+
/** true for a spicy main (see spicyShare). */
|
|
302
|
+
spicy?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* A drink's choices, from the restaurant's own options: ["Sweetness: 50%",
|
|
305
|
+
* "Toppings: Boba"]. Each option mixes them differently (favorites: the
|
|
306
|
+
* restaurant's defaults; value: no paid add-ons; variety: several versions).
|
|
307
|
+
*/
|
|
308
|
+
modifiers?: string[];
|
|
230
309
|
}
|
|
231
310
|
interface AllergyCoverage {
|
|
232
311
|
/** "no peanut, shellfish", "vegetarian", "no restrictions", ... */
|
|
233
312
|
constraint: string;
|
|
234
313
|
guests: number;
|
|
235
314
|
dishes: string[];
|
|
315
|
+
/** None of the dishes asked for (dishPreferences / mealType) is safe for these guests: they get other safe dishes. */
|
|
316
|
+
outsidePreferences?: boolean;
|
|
236
317
|
}
|
|
237
318
|
interface UnfedGuests {
|
|
238
319
|
constraint: string;
|
|
@@ -260,7 +341,19 @@ interface CateringOption {
|
|
|
260
341
|
/** Guests no dish on this menu is known to be safe for. Show this to the host. */
|
|
261
342
|
unfedGuests: UnfedGuests[];
|
|
262
343
|
price: Price;
|
|
344
|
+
/** With budgetPerGuest (soft) or maxTotal / maxPerGuest (hard; always true then). */
|
|
263
345
|
withinBudget?: boolean;
|
|
346
|
+
/** With spicyShare only: main servings that are spicy, of all main servings. */
|
|
347
|
+
spicyServings?: number;
|
|
348
|
+
mainServings?: number;
|
|
349
|
+
/**
|
|
350
|
+
* false when this restaurant hasn't set up card payments on Dunback (its
|
|
351
|
+
* Stripe account): the option can then only be paid in USDC, and selecting
|
|
352
|
+
* it with paymentMethods ["stripe"] fails with card_payments_unavailable.
|
|
353
|
+
*/
|
|
354
|
+
acceptsCard: boolean;
|
|
355
|
+
/** How this option can be paid: ["stripe", "usdc"], or ["usdc"] when acceptsCard is false. */
|
|
356
|
+
paymentMethods: Array<"stripe" | "usdc">;
|
|
264
357
|
/** Pay before this instant (ISO), or the restaurant can't make the event time. */
|
|
265
358
|
orderBy: string | null;
|
|
266
359
|
/** Dunback's catering cancellation and refund policy, in one paragraph. Show it with the option. */
|
|
@@ -292,11 +385,26 @@ interface CateringRequest {
|
|
|
292
385
|
restaurant: {
|
|
293
386
|
requested: string;
|
|
294
387
|
found: boolean | null;
|
|
388
|
+
/** The restaurant found: may differ from `requested` (part of a name, or a misspelling). */
|
|
295
389
|
name: string | null;
|
|
390
|
+
/** true: no restaurant has that name; `name` is the closest spelling found (e.g. "Ragoon Ruby" -> "Rangoon Ruby Palo Alto"). Show the host which restaurant it is. */
|
|
391
|
+
closeMatch?: boolean;
|
|
296
392
|
available: boolean | null;
|
|
297
393
|
reason: string | null;
|
|
298
394
|
} | null;
|
|
299
395
|
serviceStyle: CateringServiceStyle;
|
|
396
|
+
/** Drinks only, no food. */
|
|
397
|
+
drinksOnly: boolean;
|
|
398
|
+
includeDrinks: boolean;
|
|
399
|
+
drinkTypes: DrinkType[];
|
|
400
|
+
dishPreferences: string[];
|
|
401
|
+
mealType: CateringMealType | null;
|
|
402
|
+
spicyShare: number | null;
|
|
403
|
+
partyDiet: PartyDiet[];
|
|
404
|
+
maxTotal: number | null;
|
|
405
|
+
maxPerGuest: number | null;
|
|
406
|
+
/** With a hard budget only. Show `budget.message` to the host when it is set. */
|
|
407
|
+
budget: CateringBudgetResult | null;
|
|
300
408
|
guestCount: number;
|
|
301
409
|
deliveryDeadlineLocal: string;
|
|
302
410
|
timeZone: string;
|
|
@@ -317,7 +425,7 @@ interface CateringRequest {
|
|
|
317
425
|
updatedAt: string;
|
|
318
426
|
}
|
|
319
427
|
/** Why a restaurant can't cater an event. Unknown codes may be added: treat them as "other". */
|
|
320
|
-
type UnavailableReasonCode = "party_too_large" | "below_minimum_order" | "notice_too_short" | "no_buffet_dishes" | "style_not_offered" | "outside_delivery_area" | "not_serving_then" | "different_cuisine" | "restaurant_declined";
|
|
428
|
+
type UnavailableReasonCode = "party_too_large" | "below_minimum_order" | "notice_too_short" | "no_buffet_dishes" | "style_not_offered" | "outside_delivery_area" | "not_serving_then" | "different_cuisine" | "no_matching_dishes" | "over_budget" | "restaurant_declined";
|
|
321
429
|
interface UnavailableReason {
|
|
322
430
|
/** Restaurant name. */
|
|
323
431
|
name: string;
|
|
@@ -390,7 +498,15 @@ interface Order {
|
|
|
390
498
|
timeZone: string;
|
|
391
499
|
guestCount: number;
|
|
392
500
|
delivery: OrderDelivery;
|
|
501
|
+
/** What was priced and paid for. */
|
|
393
502
|
items: CateringItem[];
|
|
503
|
+
/**
|
|
504
|
+
* Set when the restaurant changed the order after calling the host and
|
|
505
|
+
* getting their agreement (webhook `order.revised`). `revision.items` is
|
|
506
|
+
* what it will now prepare. The price never changes with a revision.
|
|
507
|
+
* Show the note and the revised items to the host.
|
|
508
|
+
*/
|
|
509
|
+
revision: OrderRevision | null;
|
|
394
510
|
allergyCoverage: AllergyCoverage[];
|
|
395
511
|
unfedGuests: UnfedGuests[];
|
|
396
512
|
price: Price;
|
|
@@ -421,12 +537,21 @@ interface Order {
|
|
|
421
537
|
};
|
|
422
538
|
fulfillment: {
|
|
423
539
|
restaurantOrderIds: string[];
|
|
540
|
+
/**
|
|
541
|
+
* How Dunback paid the restaurant: in USDC on Polygon for a USDC/x402 order,
|
|
542
|
+
* or through the restaurant's Stripe account for a card order (details
|
|
543
|
+
* of a card payout are not shared).
|
|
544
|
+
*/
|
|
424
545
|
providerPayment: {
|
|
546
|
+
method?: "usdc_x402";
|
|
425
547
|
amount: number;
|
|
426
548
|
payTo: string;
|
|
427
549
|
txHash: string | null;
|
|
428
550
|
verifiedOnChain: boolean;
|
|
429
551
|
network: "polygon";
|
|
552
|
+
} | {
|
|
553
|
+
method: "stripe_connect";
|
|
554
|
+
status: "PAID" | "PENDING";
|
|
430
555
|
};
|
|
431
556
|
confirmedAt: string;
|
|
432
557
|
} | null;
|
|
@@ -559,7 +684,23 @@ interface RefundDecidedData extends Order {
|
|
|
559
684
|
} | null;
|
|
560
685
|
};
|
|
561
686
|
}
|
|
562
|
-
|
|
687
|
+
interface OrderRevision {
|
|
688
|
+
/** "Revised by restaurant with user agreement." */
|
|
689
|
+
note: string;
|
|
690
|
+
revisedAt: string;
|
|
691
|
+
/** The restaurant's reason, as told to the host. */
|
|
692
|
+
reason: string;
|
|
693
|
+
items: Array<{
|
|
694
|
+
name: string;
|
|
695
|
+
quantity: number;
|
|
696
|
+
modifiers: string[];
|
|
697
|
+
}>;
|
|
698
|
+
history: Array<{
|
|
699
|
+
revisedAt: string;
|
|
700
|
+
reason: string;
|
|
701
|
+
}>;
|
|
702
|
+
}
|
|
703
|
+
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
704
|
/** `data` of a `ping` event, sent by "Send test event" in the Developer Dashboard. */
|
|
564
705
|
interface PingData {
|
|
565
706
|
object: "ping";
|
|
@@ -609,16 +750,36 @@ interface DunbackEventSettings {
|
|
|
609
750
|
* a cuisine picker: the restaurant settles it, and all options come from it.
|
|
610
751
|
*/
|
|
611
752
|
restaurantName?: string;
|
|
612
|
-
/** Required when no restaurantName is set. */
|
|
753
|
+
/** Required when no restaurantName is set, unless drinksOnly, dishPreferences or mealType "breakfast". */
|
|
613
754
|
cuisine?: CuisineId;
|
|
755
|
+
/**
|
|
756
|
+
* Drinks only, no food (coffee for a morning meetup, boba for a study
|
|
757
|
+
* group): from restaurantName, or any restaurant serving drinkTypes. No cuisine.
|
|
758
|
+
*/
|
|
759
|
+
drinksOnly?: boolean;
|
|
760
|
+
/** Which drinks ("coffee", "boba"...; listDrinkTypes()). With food, the drinks come from these types. */
|
|
761
|
+
drinkTypes?: DrinkTypeId[];
|
|
614
762
|
/**
|
|
615
763
|
* Buffet (trays to share) or individual meal boxes. Pass it to
|
|
616
764
|
* listCuisines(venue, { serviceStyle }) too: fewer restaurants offer buffets.
|
|
617
765
|
* Default "meal_boxes".
|
|
618
766
|
*/
|
|
619
767
|
serviceStyle?: CateringServiceStyle;
|
|
768
|
+
/** Food catering: also one drink per guest. Default true. */
|
|
620
769
|
includeDrinks?: boolean;
|
|
770
|
+
/** Soft: options above it are flagged withinBudget: false. */
|
|
621
771
|
budgetPerGuest?: number;
|
|
772
|
+
/** Hard budget (USD): options above it aren't offered (see CateringRequestInput.maxTotal). */
|
|
773
|
+
maxTotal?: number;
|
|
774
|
+
maxPerGuest?: number;
|
|
775
|
+
/** Dishes the host wants: "sushi", "seafood", "pastries", "bagels"... */
|
|
776
|
+
dishPreferences?: string[];
|
|
777
|
+
/** "breakfast" for breakfast food (pastries, bagels, eggs...) whatever the time. */
|
|
778
|
+
mealType?: CateringMealType;
|
|
779
|
+
/** About this share (0..1) of the main servings spicy; 0 = nothing spicy. */
|
|
780
|
+
spicyShare?: number;
|
|
781
|
+
/** Diets every guest's food must fit, e.g. ["vegetarian"]. */
|
|
782
|
+
partyDiet?: PartyDiet[];
|
|
622
783
|
/**
|
|
623
784
|
* The host's estimate of how many guests will attend (or the event's
|
|
624
785
|
* capacity). Pass it to listCuisines(venue, { guests }) so only cuisines
|
|
@@ -750,4 +911,4 @@ declare function canOrderFood(settings: DunbackEventSettings | null | undefined,
|
|
|
750
911
|
reason?: string;
|
|
751
912
|
};
|
|
752
913
|
|
|
753
|
-
export { type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C,
|
|
914
|
+
export { guestsWithUnsharedAllergies as $, type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, type DrinkType as D, type OrderDelivery as E, type OrderRevision as F, type OrderStatus as G, type PingData as H, type Price as I, type PriceLine as J, type RefundDecidedData as K, type LateRefundRequestInput as L, type StandardCuisineId as M, type UnavailableReason as N, type Order as O, type PartyDiet as P, type UnavailableReasonCode as Q, type RestaurantSummary as R, type SelectOptionInput as S, type UnfedGuests as T, type UpdateDeliveryInput as U, type VenueLocation as V, type WebhookEvent as W, type UsdcPaymentInstructions as X, type WebhookEventType as Y, buildCateringRequest as Z, canOrderFood as _, type Cuisine as a, toDunbackAddress as a0, toDunbackAttendees as a1, toVenueLocation as a2, 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 CateringBudgetResult as k, type CateringItem as l, type CateringMealType as m, type CateringOption as n, type CateringPolicies as o, type CateringRequestStatus as p, type CateringServiceStyle as q, type CuisineId as r, type CustomCuisineId as s, DUNBACK_REGISTRATION_QUESTION as t, type DeliveredLateData as u, type DrinkTypeId as v, type DunbackEventSettings as w, type LumaEventLike as x, type LumaGuestLike as y, type OrderCancellation as z };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { n as CateringOption, a as Cuisine, w as DunbackEventSettings, R as RestaurantSummary, D as DrinkType, O as Order, I as Price } from '../luma-WIhD5QRd.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
|
/**
|
package/dist/react/index.js
CHANGED
|
@@ -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: "
|
|
60
|
-
|
|
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 ",
|
package/docs/API_REFERENCE.md
CHANGED
|
@@ -106,11 +106,17 @@ serves them. Hosts can pick them like any other: send the `id` as `cuisine`.
|
|
|
106
106
|
| `event.timeZone` | IANA, required | Venue time zone |
|
|
107
107
|
| `event.url` | URL | |
|
|
108
108
|
| `deliveryDeadlineLocal` | `YYYY-MM-DDTHH:mm` | Default: `startsAt` minus 30 min, venue-local |
|
|
109
|
-
| `restaurantName` | string | A restaurant the host prefers (`/catalog/restaurants`): all options come from it. Send it or `cuisine`, not both. If it can't cater, `restaurant.available` is false and `restaurant.reason` says why; the options are from other restaurants |
|
|
110
|
-
| `cuisine` | cuisine id
|
|
109
|
+
| `restaurantName` | string | A restaurant the host prefers (`/catalog/restaurants`): all options come from it. Part of a name matches every location; small misspellings are tolerated when no restaurant matches exactly (`restaurant.closeMatch: true`). Send it or `cuisine`, not both. If it can't cater, `restaurant.available` is false and `restaurant.reason` says why; the options are from other restaurants |
|
|
110
|
+
| `cuisine` | cuisine id | A standard id or a `custom:…` id from `/catalog/cuisines`. Required unless you send `restaurantName`, `dishPreferences` or `mealType: "breakfast"` (then any cuisine) |
|
|
111
111
|
| `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`. |
|
|
112
112
|
| `includeDrinks` | bool | Default true. Non-alcoholic only. |
|
|
113
|
-
| `
|
|
113
|
+
| `dishPreferences` | string[], up to 8 | Kinds of dishes the host wants: `"sushi"`, `"seafood"`, `"pastries"`, `"bagels"`, `"tacos"`… The mains come from dishes that match (name, description, category, tags; `"seafood"` also by a fish or shellfish allergen), and only restaurants with such dishes take part. A guest none of them is safe for gets another safe main (`allergyCoverage[].outsidePreferences: true`) |
|
|
114
|
+
| `mealType` | `breakfast`, `lunch` or `dinner` | The kind of food, whatever the delivery time. Breakfast food: dishes in the restaurant's breakfast or brunch menu, or that read like breakfast (pastries, bagels, egg dishes, oatmeal, fruit platters…). Without it, a delivery before 10:30 prefers breakfast food without requiring it |
|
|
115
|
+
| `spicyShare` | number 0–1 | About this share of the main servings spicy (`0.33` = a third; `0` = nothing spicy). Spicy: the restaurant's spice level 2 or more, or, without a level, the dish's wording ("spicy", "Sichuan", "jalapeño"…) |
|
|
116
|
+
| `partyDiet` | array of `vegetarian`, `vegan`, `halal`, `kosher`, `gluten_free`, `dairy_free`, `pescatarian` | Every guest's food must fit, as if each guest had said so (an all-vegetarian event) |
|
|
117
|
+
| `maxTotal` | number, USD | Hard budget for the order: options priced above it are not offered. Compared with what the host would pay (the card total; the USDC total at a restaurant that takes no card). See `budget` below |
|
|
118
|
+
| `maxPerGuest` | number, USD | Hard budget per guest, like `maxTotal` |
|
|
119
|
+
| `budgetPerGuest` | number | Soft: only flags options above it (`withinBudget: false`) |
|
|
114
120
|
| `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
|
|
115
121
|
| `onsiteContact` | `{name, phone, email?}`, required | Receives the delivery |
|
|
116
122
|
| `deliveryNotes` | string | |
|
|
@@ -147,10 +153,12 @@ Composing usually takes 5–30 s. When it finishes, you receive the
|
|
|
147
153
|
| `object` | `"catering_request"` |
|
|
148
154
|
| `status` | `COMPOSING`, `OPTIONS_READY`, `NO_OPTIONS`, `SELECTED` or `FAILED` |
|
|
149
155
|
| `partnerReference`, `event`, `cuisine`, `guestCount` | As sent; `event` gains `startsAtLocal` |
|
|
156
|
+
| `dishPreferences`, `mealType`, `spicyShare`, `partyDiet`, `maxTotal`, `maxPerGuest` | As sent (`[]` / `null` when not) |
|
|
157
|
+
| `budget` | With `maxTotal` / `maxPerGuest` only: `{ maxTotal, maxPerGuest, limit, withinBudget, overBudget, suggestedMaxTotal, suggestedMaxPerGuest, message }`. When the budget leaves fewer than three options, `message` says so and how far to raise it for three ("Only 2 catering offers fit your budget of $1,000. Raising your budget to about $1,150 would give you 3 offers to choose from."). **Show `message` to the host.** |
|
|
150
158
|
| `deliveryDeadlineLocal`, `timeZone`, `daypart` | |
|
|
151
159
|
| `allergySummary` | `[{ constraint, guests: [names] }]` |
|
|
152
|
-
| `options` | Up to 3;
|
|
153
|
-
| `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) |
|
|
160
|
+
| `options` | Up to 3, each from one restaurant; from different restaurants when several can cater. See below |
|
|
161
|
+
| `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`, `no_matching_dishes` (none of the dishes asked for), `over_budget` or `restaurant_declined` (more may be added) |
|
|
154
162
|
| `orderId` | Set once an option is selected |
|
|
155
163
|
| `error` | `{ code, message }`, when `FAILED` |
|
|
156
164
|
| `createdAt`, `updatedAt` | |
|
|
@@ -197,6 +205,8 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
|
|
|
197
205
|
| `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
|
|
198
206
|
| `price` | See Price |
|
|
199
207
|
| `withinBudget` | Present when a budget was set |
|
|
208
|
+
| `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 |
|
|
209
|
+
| `paymentMethods` | `["stripe","usdc"]`, or `["usdc"]` when `acceptsCard` is false |
|
|
200
210
|
| `orderBy` | ISO; latest payment time the restaurant accepts |
|
|
201
211
|
|
|
202
212
|
### Price
|
|
@@ -205,7 +215,7 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
|
|
|
205
215
|
| --- | --- |
|
|
206
216
|
| `currency` | `"USD"` |
|
|
207
217
|
| `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 |
|
|
218
|
+
| `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × (food and drinks + the restaurant's service charge). Delivery and tax are not included. |
|
|
209
219
|
| `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
|
|
210
220
|
| `totals` | `{ usdc, card, cardProcessingFee }` |
|
|
211
221
|
| `perGuest` | `{ usdc, card }` |
|
|
@@ -218,7 +228,7 @@ The card total is the USDC total grossed up for card processing.
|
|
|
218
228
|
| --- | --- |
|
|
219
229
|
| `optionId` | required |
|
|
220
230
|
| `payer` | `{ name?, email? }` (pre-fills Stripe) |
|
|
221
|
-
| `paymentMethods` | `["stripe","usdc"]` (default both) |
|
|
231
|
+
| `paymentMethods` | `["stripe","usdc"]` (default both). `stripe` is left out when the option's `acceptsCard` is false. |
|
|
222
232
|
| `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
233
|
|
|
224
234
|
Errors:
|
|
@@ -227,6 +237,7 @@ Errors:
|
|
|
227
237
|
| --- | --- | --- |
|
|
228
238
|
| 409 | `invalid_state` | Already selected, or not ready |
|
|
229
239
|
| 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
|
|
240
|
+
| 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
241
|
| 409 | `restaurant_*` | The restaurant can't take it now |
|
|
231
242
|
|
|
232
243
|
---
|
|
@@ -244,7 +255,7 @@ Errors:
|
|
|
244
255
|
| `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
256
|
| `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
|
|
246
257
|
| `payment` | See below |
|
|
247
|
-
| `fulfillment` | `{ restaurantOrderIds, providerPayment: { amount, payTo, txHash, verifiedOnChain, network },
|
|
258
|
+
| `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
259
|
| `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
|
|
249
260
|
| `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
|
|
250
261
|
| `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
|
|
@@ -96,6 +96,12 @@ type DunbackEventSettings = {
|
|
|
96
96
|
serviceStyle?: "buffet" | "meal_boxes"; // default "meal_boxes"
|
|
97
97
|
includeDrinks?: boolean; // default true (non-alcoholic only)
|
|
98
98
|
budgetPerGuest?: number; // USD; options above it are flagged, not hidden
|
|
99
|
+
maxTotal?: number; // USD, hard: options above it aren't offered; show request.budget.message
|
|
100
|
+
maxPerGuest?: number; // USD per guest, hard
|
|
101
|
+
dishPreferences?: string[]; // "sushi", "seafood", "pastries", "bagels"... (no cuisine needed)
|
|
102
|
+
mealType?: "breakfast" | "lunch" | "dinner"; // "breakfast": pastries, bagels, eggs... whatever the time
|
|
103
|
+
spicyShare?: number; // 0..1 of the main servings spicy; 0 = nothing spicy
|
|
104
|
+
partyDiet?: ("vegetarian" | "vegan" | "halal" | "kosher" | "gluten_free" | "dairy_free" | "pescatarian")[];
|
|
99
105
|
guestListDeadline?: string; // ISO; "Order Food" is offered from then on
|
|
100
106
|
deliveryDeadlineLocal?: string; // default: 30 min before start, venue-local "YYYY-MM-DDTHH:mm"
|
|
101
107
|
deliveryNotes?: string; // "Loading dock on Emerson St"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dunbackmeadow/commerce-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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",
|