@dunbackmeadow/commerce-sdk 0.5.0 → 0.8.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 +2 -2
- package/dist/index.d.ts +28 -5
- package/dist/index.js +39 -3
- package/dist/{luma-Cza_vuOB.d.ts → luma-Dh_6I01C.d.ts} +181 -9
- package/dist/react/index.d.ts +21 -4
- package/dist/react/index.js +38 -6
- package/docs/API_REFERENCE.md +84 -11
- package/docs/LUMA_INTEGRATION_GUIDE.md +60 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ catering request.
|
|
|
177
177
|
## Order lifecycle
|
|
178
178
|
|
|
179
179
|
```
|
|
180
|
-
AWAITING_PAYMENT ─▶ PAID ─▶ FULFILLING ─▶ CONFIRMED ─▶ (CANCELLED)
|
|
180
|
+
AWAITING_PAYMENT ─▶ PAID ─▶ FULFILLING ─▶ CONFIRMED ─▶ (CANCELLED | REFUNDED when every delivery failed)
|
|
181
181
|
│ ├─▶ REFUNDED / REFUND_PENDING restaurant couldn't take it; buyer refunded
|
|
182
182
|
│ └─▶ NEEDS_ATTENTION Dunback support finishes it by hand
|
|
183
183
|
└─▶ EXPIRED / CANCELLED
|
|
@@ -199,7 +199,7 @@ app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, r
|
|
|
199
199
|
| Event | `data` |
|
|
200
200
|
| --- | --- |
|
|
201
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.delivery_updated` | Order |
|
|
202
|
+
| `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
|
|
203
203
|
| `ping` | `{ object: "ping", appId, message }`: sent by **Send test event** in the dashboard |
|
|
204
204
|
|
|
205
205
|
Each webhook is signed as `t=<unix>,v1=<HMAC-SHA256(secret, "<t>.<body>")>`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AppInfo, V as VenueLocation, C as CuisineQuery, a as Cuisine, b as CuisineCatalog, c as CateringRequestInput, d as CateringRequest, S as SelectOptionInput, O as Order, U as UpdateDeliveryInput, W as WebhookEvent } from './luma-
|
|
2
|
-
export {
|
|
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';
|
|
3
3
|
|
|
4
4
|
/** Any non-2xx answer from the Partner API. */
|
|
5
5
|
declare class DunbackApiError extends Error {
|
|
@@ -64,6 +64,12 @@ declare class DunbackClient {
|
|
|
64
64
|
* cuisineCatalog().
|
|
65
65
|
*/
|
|
66
66
|
listCuisines(venue?: VenueLocation | null, query?: CuisineQuery): Promise<Cuisine[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Restaurants a host can name (`restaurantName` on a catering request)
|
|
69
|
+
* instead of choosing a cuisine. With a venue, only restaurants in its metro
|
|
70
|
+
* area; `q` filters by name (for a search box).
|
|
71
|
+
*/
|
|
72
|
+
listRestaurants(venue?: VenueLocation | null, q?: string): Promise<RestaurantSummary[]>;
|
|
67
73
|
/** listCuisines() plus which metro area the counts are for (`metro` is null when Dunback doesn't serve the venue's area). */
|
|
68
74
|
cuisineCatalog(venue?: VenueLocation | null, query?: CuisineQuery): Promise<CuisineCatalog>;
|
|
69
75
|
readonly catering: {
|
|
@@ -102,8 +108,25 @@ declare class DunbackClient {
|
|
|
102
108
|
* (create a new catering request instead). Sends `order.delivery_updated`.
|
|
103
109
|
*/
|
|
104
110
|
updateDelivery: (orderId: string, input: UpdateDeliveryInput) => Promise<Order>;
|
|
105
|
-
/**
|
|
106
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Unpaid orders: cancels the payment links. Confirmed orders: cancels at
|
|
113
|
+
* the restaurant. Before the commitment deadline the restaurant's full
|
|
114
|
+
* refund is sent; after it (until delivery) pass
|
|
115
|
+
* `{ acceptPostCommitment: true }` once the host has seen
|
|
116
|
+
* `order.cancellation.notice`, and Dunback decides the refund with the
|
|
117
|
+
* restaurant (webhook `order.refund_decided`). Without it, that call fails
|
|
118
|
+
* with 409 `post_commitment_confirmation_required`.
|
|
119
|
+
*/
|
|
120
|
+
cancel: (orderId: string, reason?: string, options?: CancelOrderOptions) => Promise<Order>;
|
|
121
|
+
/**
|
|
122
|
+
* Asks for a refund of a catering delivery made at or after the catering
|
|
123
|
+
* late-delivery threshold (webhook `order.delivered_late`). The host
|
|
124
|
+
* gives the reason and how the delay affected the event; Dunback decides
|
|
125
|
+
* the refund (0 up to the restaurant's part; Dunback's fees aren't
|
|
126
|
+
* refunded) and sends `order.refund_decided`. Errors: 409 `not_late`,
|
|
127
|
+
* `already_requested`, `request_window_closed`.
|
|
128
|
+
*/
|
|
129
|
+
requestRefund: (orderId: string, input: LateRefundRequestInput) => Promise<LateRefundRequest>;
|
|
107
130
|
/** Polls until the order leaves AWAITING_PAYMENT/PAID/FULFILLING. */
|
|
108
131
|
waitForSettlement: (orderId: string, { timeoutMs, intervalMs }?: {
|
|
109
132
|
timeoutMs?: number | undefined;
|
|
@@ -183,4 +206,4 @@ declare function payOrderWithX402(order: Pick<Order, "id" | "payment">, signer:
|
|
|
183
206
|
maxAmountUsdc?: number;
|
|
184
207
|
}): Promise<Order>;
|
|
185
208
|
|
|
186
|
-
export { AppInfo, CateringRequest, CateringRequestInput, Cuisine, CuisineCatalog, CuisineQuery, DEFAULT_BASE_URL, DunbackApiError, DunbackClient, type DunbackClientOptions, Order, PAYMENT_ERROR_CODES, SANDBOX_BASE_URL, SelectOptionInput, type TypedDataToSign, UpdateDeliveryInput, VenueLocation, WebhookEvent, type X402Signer, isPaymentError, payOrderWithX402, signWebhookPayload, verifyWebhook };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -107,6 +107,21 @@ var DunbackClient = class {
|
|
|
107
107
|
async listCuisines(venue, query = {}) {
|
|
108
108
|
return (await this.cuisineCatalog(venue, query)).data;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Restaurants a host can name (`restaurantName` on a catering request)
|
|
112
|
+
* instead of choosing a cuisine. With a venue, only restaurants in its metro
|
|
113
|
+
* area; `q` filters by name (for a search box).
|
|
114
|
+
*/
|
|
115
|
+
async listRestaurants(venue, q = "") {
|
|
116
|
+
const p = new URLSearchParams();
|
|
117
|
+
for (const k of ["city", "state", "zip"]) {
|
|
118
|
+
const v = String(venue?.[k] ?? "").trim();
|
|
119
|
+
if (v) p.set(k, v);
|
|
120
|
+
}
|
|
121
|
+
if (q.trim()) p.set("q", q.trim());
|
|
122
|
+
const qs = p.toString();
|
|
123
|
+
return (await this.request("GET", `/catalog/restaurants${qs ? `?${qs}` : ""}`)).data;
|
|
124
|
+
}
|
|
110
125
|
/** listCuisines() plus which metro area the counts are for (`metro` is null when Dunback doesn't serve the venue's area). */
|
|
111
126
|
async cuisineCatalog(venue, query = {}) {
|
|
112
127
|
const q = new URLSearchParams();
|
|
@@ -167,8 +182,28 @@ var DunbackClient = class {
|
|
|
167
182
|
* (create a new catering request instead). Sends `order.delivery_updated`.
|
|
168
183
|
*/
|
|
169
184
|
updateDelivery: (orderId, input) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/delivery`, input),
|
|
170
|
-
/**
|
|
171
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Unpaid orders: cancels the payment links. Confirmed orders: cancels at
|
|
187
|
+
* the restaurant. Before the commitment deadline the restaurant's full
|
|
188
|
+
* refund is sent; after it (until delivery) pass
|
|
189
|
+
* `{ acceptPostCommitment: true }` once the host has seen
|
|
190
|
+
* `order.cancellation.notice`, and Dunback decides the refund with the
|
|
191
|
+
* restaurant (webhook `order.refund_decided`). Without it, that call fails
|
|
192
|
+
* with 409 `post_commitment_confirmation_required`.
|
|
193
|
+
*/
|
|
194
|
+
cancel: (orderId, reason, options = {}) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/cancel`, {
|
|
195
|
+
reason,
|
|
196
|
+
...options.acceptPostCommitment ? { acceptPostCommitment: true } : {}
|
|
197
|
+
}),
|
|
198
|
+
/**
|
|
199
|
+
* Asks for a refund of a catering delivery made at or after the catering
|
|
200
|
+
* late-delivery threshold (webhook `order.delivered_late`). The host
|
|
201
|
+
* gives the reason and how the delay affected the event; Dunback decides
|
|
202
|
+
* the refund (0 up to the restaurant's part; Dunback's fees aren't
|
|
203
|
+
* refunded) and sends `order.refund_decided`. Errors: 409 `not_late`,
|
|
204
|
+
* `already_requested`, `request_window_closed`.
|
|
205
|
+
*/
|
|
206
|
+
requestRefund: (orderId, input) => this.request("POST", `/orders/${encodeURIComponent(orderId)}/refund-requests`, input),
|
|
172
207
|
/** Polls until the order leaves AWAITING_PAYMENT/PAID/FULFILLING. */
|
|
173
208
|
waitForSettlement: async (orderId, { timeoutMs = 15 * 6e4, intervalMs = 5e3 } = {}) => {
|
|
174
209
|
const until = Date.now() + timeoutMs;
|
|
@@ -273,6 +308,7 @@ function toVenueLocation(geo) {
|
|
|
273
308
|
function buildCateringRequest(args) {
|
|
274
309
|
const { event, guests, settings, host } = args;
|
|
275
310
|
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.");
|
|
276
312
|
const onsite = args.onsiteContact || settings.onsiteContact || (host.phone ? { name: host.name, phone: host.phone, email: host.email } : null);
|
|
277
313
|
if (!onsite) throw new Error("An on-site contact with a phone number is required for delivery.");
|
|
278
314
|
const attendees = [...toDunbackAttendees(guests), ...args.extraAttendees || []];
|
|
@@ -281,7 +317,7 @@ function buildCateringRequest(args) {
|
|
|
281
317
|
partnerReference: `luma:${event.api_id || event.id}`,
|
|
282
318
|
event: { name: event.name, startsAt: event.start_at, timeZone: event.timezone, ...event.url ? { url: event.url } : {} },
|
|
283
319
|
...settings.deliveryDeadlineLocal ? { deliveryDeadlineLocal: settings.deliveryDeadlineLocal } : {},
|
|
284
|
-
cuisine: settings.cuisine,
|
|
320
|
+
...settings.restaurantName ? { restaurantName: settings.restaurantName } : { cuisine: settings.cuisine },
|
|
285
321
|
serviceStyle: settings.serviceStyle ?? "meal_boxes",
|
|
286
322
|
includeDrinks: settings.includeDrinks ?? true,
|
|
287
323
|
...settings.budgetPerGuest ? { budgetPerGuest: settings.budgetPerGuest } : {},
|
|
@@ -58,6 +58,18 @@ interface CuisineCatalog {
|
|
|
58
58
|
/** The service style the counts are for; null when none was given. */
|
|
59
59
|
serviceStyle: CateringServiceStyle | null;
|
|
60
60
|
}
|
|
61
|
+
/** GET /catalog/restaurants: restaurants a host can name instead of choosing a cuisine. */
|
|
62
|
+
interface RestaurantSummary {
|
|
63
|
+
name: string;
|
|
64
|
+
cuisine: {
|
|
65
|
+
id: CuisineId;
|
|
66
|
+
label: string;
|
|
67
|
+
} | null;
|
|
68
|
+
secondaryCuisine: {
|
|
69
|
+
id: CuisineId;
|
|
70
|
+
label: string;
|
|
71
|
+
} | null;
|
|
72
|
+
}
|
|
61
73
|
/** Options for listCuisines() / cuisineCatalog(). */
|
|
62
74
|
interface CuisineQuery {
|
|
63
75
|
/** Count only restaurants that serve catering this way. */
|
|
@@ -128,7 +140,25 @@ interface CateringRequestInput {
|
|
|
128
140
|
};
|
|
129
141
|
/** Venue-local "YYYY-MM-DDTHH:mm". Default: 30 minutes before the event starts. */
|
|
130
142
|
deliveryDeadlineLocal?: string;
|
|
131
|
-
|
|
143
|
+
/**
|
|
144
|
+
* A restaurant the host prefers (see listRestaurants()). All options then
|
|
145
|
+
* come from it, and no cuisine is chosen: send restaurantName OR cuisine,
|
|
146
|
+
* never both. If it can't cater the event, the request says why
|
|
147
|
+
* (`restaurant.available: false`, `restaurant.reason`) and the options are
|
|
148
|
+
* from other restaurants.
|
|
149
|
+
*/
|
|
150
|
+
restaurantName?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Required when no restaurantName is given. Restaurants whose primary
|
|
153
|
+
* cuisine this is are matched first; restaurants listing it as their
|
|
154
|
+
* secondary cuisine only when none of those can cater.
|
|
155
|
+
*/
|
|
156
|
+
cuisine?: CuisineId;
|
|
157
|
+
/**
|
|
158
|
+
* A combination style: cuisine "chinese" + secondaryCuisine "american" asks
|
|
159
|
+
* for Chinese-American, matched only by restaurants that declared both, in that order.
|
|
160
|
+
*/
|
|
161
|
+
secondaryCuisine?: CuisineId;
|
|
132
162
|
/** Buffet (trays to share) or individual meal boxes. Default "meal_boxes". */
|
|
133
163
|
serviceStyle?: CateringServiceStyle;
|
|
134
164
|
/** Non-alcoholic drinks, one per guest. Default true. */
|
|
@@ -161,9 +191,10 @@ interface PriceLine {
|
|
|
161
191
|
interface Price {
|
|
162
192
|
currency: "USD";
|
|
163
193
|
lines: PriceLine[];
|
|
164
|
-
|
|
165
|
-
dunbackCommission: number;
|
|
194
|
+
/** The host's service fee: serviceFeeRate x food and drinks (the `service_fee` line). */
|
|
166
195
|
dunbackServiceFee: number;
|
|
196
|
+
/** Dunback's service fee rate on catering orders (0.05 = 5%). */
|
|
197
|
+
serviceFeeRate: number;
|
|
167
198
|
totals: {
|
|
168
199
|
/** What a USDC payment must be. */
|
|
169
200
|
usdc: number;
|
|
@@ -175,7 +206,6 @@ interface Price {
|
|
|
175
206
|
usdc: number;
|
|
176
207
|
card: number;
|
|
177
208
|
};
|
|
178
|
-
commissionRate: number;
|
|
179
209
|
}
|
|
180
210
|
interface CateringItem {
|
|
181
211
|
name: string;
|
|
@@ -233,6 +263,8 @@ interface CateringOption {
|
|
|
233
263
|
withinBudget?: boolean;
|
|
234
264
|
/** Pay before this instant (ISO), or the restaurant can't make the event time. */
|
|
235
265
|
orderBy: string | null;
|
|
266
|
+
/** Dunback's catering cancellation and refund policy, in one paragraph. Show it with the option. */
|
|
267
|
+
cancellationPolicy: string;
|
|
236
268
|
}
|
|
237
269
|
type CateringRequestStatus = "COMPOSING" | "OPTIONS_READY" | "NO_OPTIONS" | "SELECTED" | "FAILED";
|
|
238
270
|
interface CateringRequest {
|
|
@@ -243,10 +275,27 @@ interface CateringRequest {
|
|
|
243
275
|
event: CateringRequestInput["event"] & {
|
|
244
276
|
startsAtLocal: string;
|
|
245
277
|
};
|
|
278
|
+
/** null when the host named a restaurant instead. */
|
|
246
279
|
cuisine: {
|
|
247
280
|
id: CuisineId;
|
|
248
281
|
label: string;
|
|
249
|
-
};
|
|
282
|
+
} | null;
|
|
283
|
+
secondaryCuisine?: {
|
|
284
|
+
id: CuisineId;
|
|
285
|
+
label: string;
|
|
286
|
+
} | null;
|
|
287
|
+
/**
|
|
288
|
+
* The restaurant the host named, or null. `available` false: it can't
|
|
289
|
+
* cater this event (`reason`), and the options are from other restaurants.
|
|
290
|
+
* `found` false: no restaurant by that name. null fields: still composing.
|
|
291
|
+
*/
|
|
292
|
+
restaurant: {
|
|
293
|
+
requested: string;
|
|
294
|
+
found: boolean | null;
|
|
295
|
+
name: string | null;
|
|
296
|
+
available: boolean | null;
|
|
297
|
+
reason: string | null;
|
|
298
|
+
} | null;
|
|
250
299
|
serviceStyle: CateringServiceStyle;
|
|
251
300
|
guestCount: number;
|
|
252
301
|
deliveryDeadlineLocal: string;
|
|
@@ -381,12 +430,39 @@ interface Order {
|
|
|
381
430
|
};
|
|
382
431
|
confirmedAt: string;
|
|
383
432
|
} | null;
|
|
433
|
+
/** The latest refund. */
|
|
384
434
|
refund: {
|
|
385
435
|
status: "SUCCEEDED" | "PENDING";
|
|
386
436
|
method: "stripe" | "usdc";
|
|
387
437
|
amount: number;
|
|
388
438
|
note?: string;
|
|
389
439
|
} | null;
|
|
440
|
+
/**
|
|
441
|
+
* Every refund of the order. `reason`: "cancel" (the host cancelled: the
|
|
442
|
+
* restaurant's part), "failed" (the restaurant couldn't take it), or, for one
|
|
443
|
+
* delivery the host isn't at fault for (refunded in full), "cancelled" (by the
|
|
444
|
+
* restaurant), "late" or "not_delivered".
|
|
445
|
+
*/
|
|
446
|
+
refunds?: Array<{
|
|
447
|
+
amount: number;
|
|
448
|
+
method: "stripe" | "usdc";
|
|
449
|
+
status: "SUCCEEDED" | "PENDING";
|
|
450
|
+
reason: string;
|
|
451
|
+
detail: string | null;
|
|
452
|
+
at: string;
|
|
453
|
+
restaurantOrderId?: string;
|
|
454
|
+
}>;
|
|
455
|
+
/** Where the order stands for cancelling. Show `policy` with the order. */
|
|
456
|
+
cancellation: OrderCancellation;
|
|
457
|
+
/**
|
|
458
|
+
* Late-delivery refunds: a delivery `afterMinutes` or more past the delivery
|
|
459
|
+
* deadline counts as late. `requestableFrom` is the earliest moment that can
|
|
460
|
+
* be true: offer "request a refund" (`orders.requestRefund`) only from then.
|
|
461
|
+
*/
|
|
462
|
+
lateRefund?: {
|
|
463
|
+
afterMinutes: number;
|
|
464
|
+
requestableFrom: string | null;
|
|
465
|
+
};
|
|
390
466
|
error: {
|
|
391
467
|
code: string;
|
|
392
468
|
message: string;
|
|
@@ -394,7 +470,96 @@ interface Order {
|
|
|
394
470
|
createdAt: string;
|
|
395
471
|
updatedAt: string;
|
|
396
472
|
}
|
|
397
|
-
|
|
473
|
+
/**
|
|
474
|
+
* Dunback's uniform catering cancellation and refund policy, as it applies to
|
|
475
|
+
* an order now:
|
|
476
|
+
* "unpaid" nothing charged; cancelling closes the payment links
|
|
477
|
+
* "before_commitment" cancel for the restaurant's full refund (Dunback's fees kept)
|
|
478
|
+
* "after_commitment" may still cancel until delivery; Dunback decides the
|
|
479
|
+
* refund with the restaurant, 0 up to `refundIfCancelledNow.maximum`
|
|
480
|
+
* "closed" can't be cancelled
|
|
481
|
+
* Before cancelling, show `notice` to the host and get their confirmation.
|
|
482
|
+
* After the commitment deadline, pass `acceptPostCommitment: true` to
|
|
483
|
+
* orders.cancel(); without it the call fails with 409
|
|
484
|
+
* `post_commitment_confirmation_required` (details.cancellation has this object).
|
|
485
|
+
*/
|
|
486
|
+
interface OrderCancellation {
|
|
487
|
+
policy: string;
|
|
488
|
+
phase: "unpaid" | "before_commitment" | "after_commitment" | "closed";
|
|
489
|
+
cancellable: boolean;
|
|
490
|
+
commitmentDeadlineUtc: string | null;
|
|
491
|
+
deliveryDeadlineUtc: string | null;
|
|
492
|
+
notice: string | null;
|
|
493
|
+
refundIfCancelledNow: {
|
|
494
|
+
kind: "restaurant_full_refund";
|
|
495
|
+
amount: number | null;
|
|
496
|
+
} | {
|
|
497
|
+
kind: "decided_by_dunback";
|
|
498
|
+
maximum: number | null;
|
|
499
|
+
} | null;
|
|
500
|
+
requiresAcceptPostCommitment: boolean;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* orders.requestRefund(): a catering delivery made at or after Dunback's
|
|
504
|
+
* catering late-delivery threshold (60 minutes by default). Both texts are
|
|
505
|
+
* required and go to Dunback's reviewer.
|
|
506
|
+
*/
|
|
507
|
+
interface LateRefundRequestInput {
|
|
508
|
+
/** Which restaurant order (order.fulfillment.restaurantOrderIds); default: the late one. */
|
|
509
|
+
restaurantOrderId?: string;
|
|
510
|
+
/** Why the host is asking for a refund. */
|
|
511
|
+
reason: string;
|
|
512
|
+
/** How the late delivery affected the event. */
|
|
513
|
+
impact: string;
|
|
514
|
+
}
|
|
515
|
+
/** 202 from orders.requestRefund(). Dunback's decision follows as `order.refund_decided`. */
|
|
516
|
+
interface LateRefundRequest {
|
|
517
|
+
object: "refund_request";
|
|
518
|
+
status: "REQUESTED";
|
|
519
|
+
orderId: string;
|
|
520
|
+
restaurantOrderId: string;
|
|
521
|
+
lateMinutes: number;
|
|
522
|
+
/** The most the refund can be: the restaurant's part of that delivery. */
|
|
523
|
+
maximum: number;
|
|
524
|
+
policy: string;
|
|
525
|
+
requestedAt: string;
|
|
526
|
+
}
|
|
527
|
+
/** `data` of `order.delivered_late`: the order, and which deliveries were late. */
|
|
528
|
+
interface DeliveredLateData extends Order {
|
|
529
|
+
lateDeliveries: Array<{
|
|
530
|
+
restaurantOrderId: string;
|
|
531
|
+
lateMinutes: number;
|
|
532
|
+
}>;
|
|
533
|
+
/** Dunback's policy for late catering refunds. Show it with a "Request a refund" action. */
|
|
534
|
+
lateRefundPolicy: string;
|
|
535
|
+
}
|
|
536
|
+
/** Options for orders.cancel(). */
|
|
537
|
+
interface CancelOrderOptions {
|
|
538
|
+
/** The host confirmed cancelling after the commitment deadline (the refund is then decided by Dunback). */
|
|
539
|
+
acceptPostCommitment?: boolean;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* `data` of `order.refund_decided`: the order, plus Dunback's decision on a
|
|
543
|
+
* restaurant order the host cancelled after its commitment deadline.
|
|
544
|
+
* `refund` is null when nothing is refunded (amount 0).
|
|
545
|
+
*/
|
|
546
|
+
interface RefundDecidedData extends Order {
|
|
547
|
+
refundDecision: {
|
|
548
|
+
restaurantOrderId: string;
|
|
549
|
+
/** Why the refund was decided: a cancellation after the commitment deadline, or a late delivery. */
|
|
550
|
+
basis: "cancelled_after_commitment" | "late_delivery";
|
|
551
|
+
percentage: number;
|
|
552
|
+
amount: number;
|
|
553
|
+
explanation: string;
|
|
554
|
+
refund: {
|
|
555
|
+
status: "SUCCEEDED" | "PENDING";
|
|
556
|
+
method: "stripe" | "usdc";
|
|
557
|
+
amount: number;
|
|
558
|
+
note?: string;
|
|
559
|
+
} | null;
|
|
560
|
+
};
|
|
561
|
+
}
|
|
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";
|
|
398
563
|
/** `data` of a `ping` event, sent by "Send test event" in the Developer Dashboard. */
|
|
399
564
|
interface PingData {
|
|
400
565
|
object: "ping";
|
|
@@ -424,7 +589,8 @@ interface AppInfo {
|
|
|
424
589
|
* Helpers for the Luma integration:
|
|
425
590
|
*
|
|
426
591
|
* 1. Event creation: the host turns on "Food & drinks by Dunback Meadow" and
|
|
427
|
-
* picks a cuisine
|
|
592
|
+
* names a preferred restaurant OR picks a cuisine -> store a
|
|
593
|
+
* DunbackEventSettings with the event.
|
|
428
594
|
* 2. Registration: add DUNBACK_REGISTRATION_QUESTION to the event's form, so
|
|
429
595
|
* guests can note allergies.
|
|
430
596
|
* 3. After the guest list is final: "Order Food via Dunback Meadow" ->
|
|
@@ -438,7 +604,13 @@ interface AppInfo {
|
|
|
438
604
|
/** Stored with a Luma event when the host enables Dunback catering. */
|
|
439
605
|
interface DunbackEventSettings {
|
|
440
606
|
enabled: boolean;
|
|
441
|
-
|
|
607
|
+
/**
|
|
608
|
+
* A restaurant the host prefers (listRestaurants()). When set, don't offer
|
|
609
|
+
* a cuisine picker: the restaurant settles it, and all options come from it.
|
|
610
|
+
*/
|
|
611
|
+
restaurantName?: string;
|
|
612
|
+
/** Required when no restaurantName is set. */
|
|
613
|
+
cuisine?: CuisineId;
|
|
442
614
|
/**
|
|
443
615
|
* Buffet (trays to share) or individual meal boxes. Pass it to
|
|
444
616
|
* listCuisines(venue, { serviceStyle }) too: fewer restaurants offer buffets.
|
|
@@ -578,4 +750,4 @@ declare function canOrderFood(settings: DunbackEventSettings | null | undefined,
|
|
|
578
750
|
reason?: string;
|
|
579
751
|
};
|
|
580
752
|
|
|
581
|
-
export { type AppInfo as A, type BuildCateringRequestArgs as B, type CuisineQuery as C, DUNBACK_REGISTRATION_QUESTION as D, type
|
|
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 };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
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';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Optional, unstyled-by-default React building blocks for the three Luma
|
|
@@ -37,9 +37,15 @@ interface DunbackCateringSettingsProps {
|
|
|
37
37
|
* that many, in that style. Default true.
|
|
38
38
|
*/
|
|
39
39
|
askExpectedGuests?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* From your backend: dunback.listRestaurants(venue). Offered as suggestions
|
|
42
|
+
* in the optional "Preferred restaurant" field. When the host names a
|
|
43
|
+
* restaurant, the cuisine picker is hidden: the restaurant settles it.
|
|
44
|
+
*/
|
|
45
|
+
restaurants?: RestaurantSummary[];
|
|
40
46
|
className?: string;
|
|
41
47
|
}
|
|
42
|
-
declare function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests, className }: DunbackCateringSettingsProps): React.JSX.Element;
|
|
48
|
+
declare function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests, restaurants, className }: DunbackCateringSettingsProps): React.JSX.Element;
|
|
43
49
|
interface PriceBreakdownProps {
|
|
44
50
|
price: Price;
|
|
45
51
|
/**
|
|
@@ -59,9 +65,20 @@ interface CateringOptionsPickerProps {
|
|
|
59
65
|
className?: string;
|
|
60
66
|
}
|
|
61
67
|
declare function CateringOptionsPicker({ options, onSelect, busyOptionId, className }: CateringOptionsPickerProps): React.JSX.Element;
|
|
62
|
-
|
|
68
|
+
/** Which payment link the host chose: Stripe Checkout, or Dunback's page with the other options. */
|
|
69
|
+
type PaymentLinkKind = "card" | "other";
|
|
70
|
+
/**
|
|
71
|
+
* The order's status and, while it awaits payment, its payment links.
|
|
72
|
+
*
|
|
73
|
+
* `onOpenPayment`: open the payment page yourself instead of following the
|
|
74
|
+
* link in the current page. In a mobile app, open it in an in-app browser
|
|
75
|
+
* (SFSafariViewController / Chrome Custom Tabs) so the host can always get back
|
|
76
|
+
* to your app. Without it, the links are plain links.
|
|
77
|
+
*/
|
|
78
|
+
declare function DunbackOrderStatus({ order, className, onOpenPayment }: {
|
|
63
79
|
order: Order;
|
|
64
80
|
className?: string;
|
|
81
|
+
onOpenPayment?: (url: string, kind: PaymentLinkKind) => void;
|
|
65
82
|
}): React.JSX.Element;
|
|
66
83
|
|
|
67
|
-
export { CateringOptionsPicker, type CateringOptionsPickerProps, DunbackCateringSettings, type DunbackCateringSettingsProps, DunbackOrderStatus, PriceBreakdown, type PriceBreakdownProps };
|
|
84
|
+
export { CateringOptionsPicker, type CateringOptionsPickerProps, DunbackCateringSettings, type DunbackCateringSettingsProps, DunbackOrderStatus, type PaymentLinkKind, PriceBreakdown, type PriceBreakdownProps };
|
package/dist/react/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var checkRow = { display: "flex", alignItems: "center", gap: 8, margin: 0, curso
|
|
|
22
22
|
var field = { display: "grid", gap: 4, margin: 0, fontSize: 14, fontWeight: 500 };
|
|
23
23
|
var control = { boxSizing: "border-box", width: "100%", maxWidth: 280, font: "inherit", fontWeight: 400 };
|
|
24
24
|
var hint = { fontSize: 12.5, fontWeight: 400, opacity: 0.7 };
|
|
25
|
-
function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests = true, className }) {
|
|
25
|
+
function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroName, askExpectedGuests = true, restaurants = [], className }) {
|
|
26
26
|
const enabled = !!value?.enabled;
|
|
27
27
|
const showAvailability = venueReady !== false;
|
|
28
28
|
const firstAvailable = (showAvailability ? cuisines.find((c) => c.restaurants > 0)?.id : null) || cuisines[0]?.id || "american";
|
|
@@ -76,11 +76,32 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
|
|
|
76
76
|
] }, s.id))
|
|
77
77
|
] }),
|
|
78
78
|
/* @__PURE__ */ jsxs("label", { style: field, children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
80
|
+
"Preferred restaurant ",
|
|
81
|
+
/* @__PURE__ */ jsx("span", { style: hint, children: "(optional)" })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
"input",
|
|
85
|
+
{
|
|
86
|
+
style: control,
|
|
87
|
+
list: "dunback-restaurants",
|
|
88
|
+
placeholder: "Any restaurant",
|
|
89
|
+
value: value.restaurantName ?? "",
|
|
90
|
+
onChange: (e) => {
|
|
91
|
+
const name = e.target.value;
|
|
92
|
+
onChange(name.trim() ? { ...value, restaurantName: name, cuisine: void 0 } : { ...value, restaurantName: void 0, cuisine: value.cuisine || firstAvailable });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
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." })
|
|
98
|
+
] }),
|
|
99
|
+
!value.restaurantName?.trim() && /* @__PURE__ */ jsxs("label", { style: field, children: [
|
|
79
100
|
"Cuisine",
|
|
80
|
-
/* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine, onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
|
|
101
|
+
/* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine || "", onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
|
|
81
102
|
cuisines.filter((c) => !c.custom).map(option),
|
|
82
103
|
custom.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: venueReady === true ? "More cuisines near this venue" : "More cuisines", children: custom.map(option) }),
|
|
83
|
-
!cuisines.some((c) => c.id === value.cuisine) && /* @__PURE__ */ jsxs("option", { value: value.cuisine, disabled: true, children: [
|
|
104
|
+
!!value.cuisine && !cuisines.some((c) => c.id === value.cuisine) && /* @__PURE__ */ jsxs("option", { value: value.cuisine, disabled: true, children: [
|
|
84
105
|
labelOf(value.cuisine),
|
|
85
106
|
none
|
|
86
107
|
] })
|
|
@@ -258,25 +279,36 @@ var STATUS = {
|
|
|
258
279
|
REFUND_PENDING: "The restaurant couldn't take the order; refund in progress",
|
|
259
280
|
NEEDS_ATTENTION: "Payment received; Dunback support is finishing the order"
|
|
260
281
|
};
|
|
261
|
-
function DunbackOrderStatus({ order, className }) {
|
|
282
|
+
function DunbackOrderStatus({ order, className, onOpenPayment }) {
|
|
262
283
|
const p = order.payment;
|
|
284
|
+
const open = (kind) => (e) => {
|
|
285
|
+
if (!onOpenPayment) return;
|
|
286
|
+
e.preventDefault();
|
|
287
|
+
onOpenPayment(e.currentTarget.href, kind);
|
|
288
|
+
};
|
|
263
289
|
return /* @__PURE__ */ jsxs("div", { className, style: className ? void 0 : box, children: [
|
|
264
290
|
/* @__PURE__ */ jsx("strong", { children: order.title }),
|
|
265
291
|
/* @__PURE__ */ jsx("p", { style: { margin: "4px 0" }, children: STATUS[order.status] || order.status }),
|
|
266
292
|
p.lastError && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: p.lastError.message }),
|
|
267
293
|
order.error && order.status !== "CONFIRMED" && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: order.error.message }),
|
|
268
294
|
order.status === "AWAITING_PAYMENT" && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", marginTop: 8 }, children: [
|
|
269
|
-
p.stripe && /* @__PURE__ */ jsxs("a", { href: p.stripe.checkoutUrl, children: [
|
|
295
|
+
p.stripe && /* @__PURE__ */ jsxs("a", { href: p.stripe.checkoutUrl, onClick: open("card"), children: [
|
|
270
296
|
"Pay ",
|
|
271
297
|
money(p.stripe.amount),
|
|
272
298
|
" by card"
|
|
273
299
|
] }),
|
|
274
|
-
p.hostedPaymentUrl && /* @__PURE__ */ jsx("a", { href: p.hostedPaymentUrl, children: "Other payment options" })
|
|
300
|
+
p.hostedPaymentUrl && /* @__PURE__ */ jsx("a", { href: p.hostedPaymentUrl, onClick: open("other"), children: "Other payment options" })
|
|
275
301
|
] }),
|
|
276
302
|
order.status === "AWAITING_PAYMENT" && p.expiresAt && /* @__PURE__ */ jsxs("p", { style: { fontSize: 12, opacity: 0.7 }, children: [
|
|
277
303
|
"Pay by ",
|
|
278
304
|
new Date(p.expiresAt).toLocaleString(),
|
|
279
305
|
" to keep this order."
|
|
306
|
+
] }),
|
|
307
|
+
order.cancellation?.policy && order.cancellation.phase !== "closed" && /* @__PURE__ */ jsxs("p", { style: { fontSize: 12, opacity: 0.75 }, children: [
|
|
308
|
+
/* @__PURE__ */ jsx("strong", { children: "Cancellation policy:" }),
|
|
309
|
+
" ",
|
|
310
|
+
order.cancellation.policy,
|
|
311
|
+
order.cancellation.commitmentDeadlineUtc ? ` Commitment deadline: ${new Date(order.cancellation.commitmentDeadlineUtc).toLocaleString()}.` : ""
|
|
280
312
|
] })
|
|
281
313
|
] });
|
|
282
314
|
}
|
package/docs/API_REFERENCE.md
CHANGED
|
@@ -45,6 +45,14 @@ The app and environment the key belongs to.
|
|
|
45
45
|
|
|
46
46
|
## Catalog
|
|
47
47
|
|
|
48
|
+
### `GET /catalog/restaurants?city=&state=&zip=&q=`
|
|
49
|
+
|
|
50
|
+
Restaurants a host can name (`restaurantName` on a catering request) instead of
|
|
51
|
+
choosing a cuisine. With the venue, only restaurants in its metro area; `q`
|
|
52
|
+
filters by name. Returns `{ data: [{ name, cuisine, secondaryCuisine }], scope, metro }`.
|
|
53
|
+
When the host names a restaurant, don't offer a cuisine picker: every option
|
|
54
|
+
comes from that restaurant.
|
|
55
|
+
|
|
48
56
|
### `GET /catalog/cuisines?city=&state=&zip=&guests=&serviceStyle=`
|
|
49
57
|
|
|
50
58
|
Pass the event venue (`zip`, or `city` + `state`) to count only restaurants in
|
|
@@ -98,7 +106,8 @@ serves them. Hosts can pick them like any other: send the `id` as `cuisine`.
|
|
|
98
106
|
| `event.timeZone` | IANA, required | Venue time zone |
|
|
99
107
|
| `event.url` | URL | |
|
|
100
108
|
| `deliveryDeadlineLocal` | `YYYY-MM-DDTHH:mm` | Default: `startsAt` minus 30 min, venue-local |
|
|
101
|
-
| `
|
|
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, required without `restaurantName` | A standard id or a `custom:…` id from `/catalog/cuisines` |
|
|
102
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`. |
|
|
103
112
|
| `includeDrinks` | bool | Default true. Non-alcoholic only. |
|
|
104
113
|
| `budgetPerGuest` | number | Flags options above it |
|
|
@@ -196,12 +205,10 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
|
|
|
196
205
|
| --- | --- |
|
|
197
206
|
| `currency` | `"USD"` |
|
|
198
207
|
| `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `dunbackServiceFee` | |
|
|
208
|
+
| `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × food and drinks |
|
|
209
|
+
| `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
|
|
202
210
|
| `totals` | `{ usdc, card, cardProcessingFee }` |
|
|
203
211
|
| `perGuest` | `{ usdc, card }` |
|
|
204
|
-
| `commissionRate` | |
|
|
205
212
|
|
|
206
213
|
The card total is the USDC total grossed up for card processing.
|
|
207
214
|
|
|
@@ -212,7 +219,7 @@ The card total is the USDC total grossed up for card processing.
|
|
|
212
219
|
| `optionId` | required |
|
|
213
220
|
| `payer` | `{ name?, email? }` (pre-fills Stripe) |
|
|
214
221
|
| `paymentMethods` | `["stripe","usdc"]` (default both) |
|
|
215
|
-
| `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts |
|
|
222
|
+
| `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) |
|
|
216
223
|
|
|
217
224
|
Errors:
|
|
218
225
|
|
|
@@ -232,13 +239,16 @@ Errors:
|
|
|
232
239
|
| --- | --- |
|
|
233
240
|
| `id` | `ord_…` |
|
|
234
241
|
| `object` | `"order"` |
|
|
235
|
-
| `status` | `AWAITING_PAYMENT`, `PAID`, `FULFILLING`, `CONFIRMED`, `EXPIRED`, `CANCELLED`, `REFUNDED`, `REFUND_PENDING` or `NEEDS_ATTENTION` |
|
|
242
|
+
| `status` | `AWAITING_PAYMENT`, `PAID`, `FULFILLING`, `CONFIRMED`, `EXPIRED`, `CANCELLED`, `REFUNDED`, `REFUND_PENDING` or `NEEDS_ATTENTION`. A `CONFIRMED` order becomes `REFUNDED` / `REFUND_PENDING` when all its deliveries failed (see Refunds) |
|
|
236
243
|
| `title`, `summary`, `restaurant`, `deliveryDeadlineLocal`, `timeZone`, `guestCount` | |
|
|
237
244
|
| `delivery` | `{ address: {address1, address2, city, state, zip, country}, onsiteContact: {name, phone}, deliveryNotes, editable }`. `deliveryNotes` is your note only. `editable` is true while the order is `AWAITING_PAYMENT`. |
|
|
238
245
|
| `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
|
|
239
246
|
| `payment` | See below |
|
|
240
247
|
| `fulfillment` | `{ restaurantOrderIds, providerPayment: { amount, payTo, txHash, verifiedOnChain, network }, confirmedAt }` |
|
|
241
|
-
| `refund` | `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
|
|
248
|
+
| `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
|
|
249
|
+
| `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
|
|
250
|
+
| `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
|
|
251
|
+
| `lateRefund` | `{ afterMinutes, requestableFrom }`: a delivery `afterMinutes` or more late can get a refund request; offer it only from `requestableFrom` |
|
|
242
252
|
| `error` | `{ code, message }` |
|
|
243
253
|
|
|
244
254
|
`payment` holds:
|
|
@@ -301,14 +311,75 @@ The price stays as quoted, so the correction is checked:
|
|
|
301
311
|
|
|
302
312
|
On success you also receive the `order.delivery_updated` webhook.
|
|
303
313
|
|
|
304
|
-
### `POST /orders/:id/cancel` `{ reason? }` → Order
|
|
314
|
+
### `POST /orders/:id/cancel` `{ reason?, acceptPostCommitment? }` → Order
|
|
305
315
|
|
|
306
316
|
| Order status | Result |
|
|
307
317
|
| --- | --- |
|
|
308
318
|
| `AWAITING_PAYMENT` | Cancels the payment links |
|
|
309
|
-
| `CONFIRMED`, before the
|
|
319
|
+
| `CONFIRMED`, before the commitment deadline | Cancels at the restaurant and refunds the restaurant's full amount (card automatically, USDC after review) |
|
|
320
|
+
| `CONFIRMED`, after the commitment deadline, before delivery | Requires `"acceptPostCommitment": true` (else `409 post_commitment_confirmation_required`, with `details.cancellation`). Cancels at the restaurant; Dunback decides the refund (`order.refund_decided`) |
|
|
310
321
|
| Otherwise | `409 cancel_refused` or `409 invalid_state` |
|
|
311
322
|
|
|
323
|
+
### Cancellation and refund policy
|
|
324
|
+
|
|
325
|
+
Dunback applies one cancellation and refund policy to every catering order,
|
|
326
|
+
whatever the restaurant's own policy elsewhere:
|
|
327
|
+
|
|
328
|
+
- **Before the commitment deadline:** the host may cancel and is refunded the
|
|
329
|
+
restaurant's full amount (food, delivery, restaurant fees and taxes).
|
|
330
|
+
Dunback's service fee and commission are kept.
|
|
331
|
+
- **After the commitment deadline, until delivery:** the host may still cancel
|
|
332
|
+
(for example, the event is called off). The restaurant may already have
|
|
333
|
+
bought or prepared food, so Dunback decides the refund with the restaurant,
|
|
334
|
+
from nothing up to that full amount, and sends it. You get
|
|
335
|
+
`order.refund_decided` with the decision and Dunback's explanation (and
|
|
336
|
+
`order.refunded` when money moves); the host is emailed too.
|
|
337
|
+
|
|
338
|
+
Every order carries `cancellation`:
|
|
339
|
+
|
|
340
|
+
| Field | Meaning |
|
|
341
|
+
| --- | --- |
|
|
342
|
+
| `policy` | The policy in one paragraph. **Show it with the order.** Options carry the same text as `cancellationPolicy`. |
|
|
343
|
+
| `phase` | `unpaid`, `before_commitment`, `after_commitment` or `closed` |
|
|
344
|
+
| `notice` | What cancelling now means. **Show it again, and get the host's confirmation, before you call cancel.** |
|
|
345
|
+
| `commitmentDeadlineUtc`, `deliveryDeadlineUtc` | ISO instants |
|
|
346
|
+
| `refundIfCancelledNow` | `{ kind: "restaurant_full_refund", amount }`, `{ kind: "decided_by_dunback", maximum }` or null |
|
|
347
|
+
| `requiresAcceptPostCommitment` | true after the commitment deadline |
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
### `POST /orders/:id/refund-requests` `{ restaurantOrderId?, reason, impact }` → 202
|
|
351
|
+
|
|
352
|
+
For a catering delivery made at or after Dunback's catering late-delivery
|
|
353
|
+
threshold (60 minutes by default; Dunback may change it). You receive
|
|
354
|
+
`order.delivered_late` (the order, plus `lateDeliveries` and
|
|
355
|
+
`lateRefundPolicy`) when that happens; show the policy and let the host ask.
|
|
356
|
+
|
|
357
|
+
- `reason` (required): why the host is asking for a refund.
|
|
358
|
+
- `impact` (required): how the late delivery affected the event.
|
|
359
|
+
- Late deliveries are not refunded automatically. Dunback reviews the request
|
|
360
|
+
and decides the refund at its discretion, from nothing up to the
|
|
361
|
+
restaurant's part of that delivery; Dunback's service fee and commission are
|
|
362
|
+
not refunded. You get `order.refund_decided` with the decision (and
|
|
363
|
+
`order.refunded` if anything is refunded); the host is emailed.
|
|
364
|
+
- Errors: `409 not_late`, `409 already_requested`, `409 request_window_closed`
|
|
365
|
+
(30 days after delivery), `400 invalid_request`.
|
|
366
|
+
|
|
367
|
+
### Refunds
|
|
368
|
+
|
|
369
|
+
| What happened | Refund | Webhook |
|
|
370
|
+
| --- | --- | --- |
|
|
371
|
+
| The host cancels before the commitment deadline (`POST /orders/:id/cancel`) | The restaurant's part of the order. Dunback's commission and service fee are kept. A card payment's processing fee is not refunded (Stripe keeps it). | `order.cancelled` |
|
|
372
|
+
| The host cancels after the commitment deadline, before delivery (`acceptPostCommitment: true`) | What Dunback decides with the restaurant: 0% to 100% of the restaurant's part | `order.cancelled`, then `order.refund_decided` (and `order.refunded` if anything is refunded) |
|
|
373
|
+
| The restaurant couldn't take the order after payment | Everything the host paid | `order.failed` |
|
|
374
|
+
| A delivery failed, or was cancelled by the restaurant | Everything the host paid for that delivery, card processing fee included | `order.refunded` |
|
|
375
|
+
| A delivery was at or after the catering late-delivery threshold, and the host requested a refund | What Dunback decides: 0% to 100% of the restaurant's part of that delivery | `order.refund_decided` (and `order.refunded`) |
|
|
376
|
+
|
|
377
|
+
Card payments are always refunded to the card; USDC refunds are sent to the
|
|
378
|
+
paying address after review. `refunds` lists every refund of the order;
|
|
379
|
+
`refund` is the latest one. When every delivery of an order failed, the order
|
|
380
|
+
becomes `REFUNDED` (or `REFUND_PENDING` while a refund is still due); when only
|
|
381
|
+
some did, it stays `CONFIRMED` and `order.refunded` tells you about each refund.
|
|
382
|
+
|
|
312
383
|
### `POST /orders/:id/pay/x402?t=<token>` (x402 resource; no API key, the URL is `payment.usdc.x402Url`)
|
|
313
384
|
|
|
314
385
|
1. Without `PAYMENT-SIGNATURE`, the endpoint returns
|
|
@@ -338,7 +409,9 @@ The `Dunback-Signature: t=<unix>,v1=<hex>` header is
|
|
|
338
409
|
| Event | `data` |
|
|
339
410
|
| --- | --- |
|
|
340
411
|
| `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
|
|
341
|
-
| `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.delivery_updated` | Order |
|
|
412
|
+
| `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
|
|
413
|
+
| `order.refund_decided` | Order plus `refundDecision: { restaurantOrderId, basis, percentage, amount, explanation, refund }` |
|
|
414
|
+
| `order.delivered_late` | Order plus `lateDeliveries: [{ restaurantOrderId, lateMinutes }]` and `lateRefundPolicy` |
|
|
342
415
|
| `ping` | `{ object: "ping", appId, message }`, plus top-level `livemode`. Sent by **Send test event** in the Developer Dashboard. |
|
|
343
416
|
|
|
344
417
|
The webhook URL, its signing secret (reveal or roll) and the allowed return
|
|
@@ -18,7 +18,9 @@ implementation is in [`examples/luma-integration`](../examples/luma-integration)
|
|
|
18
18
|
|
|
19
19
|
If a payment fails, Luma receives `order.payment_failed` with a message to show
|
|
20
20
|
the host. If the restaurant can't take the order after payment, the host is
|
|
21
|
-
refunded automatically and Luma receives `order.failed`.
|
|
21
|
+
refunded automatically and Luma receives `order.failed`. If a delivery is
|
|
22
|
+
late, fails or is cancelled by the restaurant, the host is refunded in full
|
|
23
|
+
automatically and Luma receives `order.refunded`.
|
|
22
24
|
|
|
23
25
|
## 1. Setup
|
|
24
26
|
|
|
@@ -128,8 +130,9 @@ the question.
|
|
|
128
130
|
`allergyConsent: true`. If a host asks about allergies in their own question
|
|
129
131
|
instead, that answer is **not** sent, because the guest didn't see Dunback's
|
|
130
132
|
consent wording. Before ordering, call `guestsWithUnsharedAllergies(guests)`
|
|
131
|
-
and show the host those names, for example: _"
|
|
132
|
-
|
|
133
|
+
and show the host those names in plain words, for example: _"These guests'
|
|
134
|
+
allergy notes weren't shared with the restaurant based on their choice: Ana,
|
|
135
|
+
Ben. Please check their meals."_ If the host's own
|
|
133
136
|
question has the consent wording too, pass `{ otherQuestionsHaveConsent: true }`
|
|
134
137
|
to both helpers.
|
|
135
138
|
|
|
@@ -221,6 +224,10 @@ Show the host two buttons:
|
|
|
221
224
|
|
|
222
225
|
Or build your own USDC screen from `order.payment.usdc`.
|
|
223
226
|
|
|
227
|
+
Always pass `successUrl` and `cancelUrl`. Stripe sends the host back to
|
|
228
|
+
them, and Dunback's payment page (`hostedPaymentUrl`) shows a **Back to the
|
|
229
|
+
event** button linking to `cancelUrl` before payment and `successUrl` after it.
|
|
230
|
+
|
|
224
231
|
After the Stripe redirect back to `successUrl`, call `dunback.orders.get(order.id)`.
|
|
225
232
|
It re-checks Stripe, so it doesn't depend on webhook timing. Then show
|
|
226
233
|
`<DunbackOrderStatus>` until the status is `CONFIRMED`.
|
|
@@ -230,6 +237,34 @@ always before the restaurant's order deadline. When it expires, Luma receives
|
|
|
230
237
|
`order.expired`, the catering request goes back to `OPTIONS_READY`, and the
|
|
231
238
|
host can choose again.
|
|
232
239
|
|
|
240
|
+
### Mobile apps
|
|
241
|
+
|
|
242
|
+
In the Luma app, open the payment links in an **in-app browser**, not in the
|
|
243
|
+
app's own web view:
|
|
244
|
+
|
|
245
|
+
- **iOS:** `SFSafariViewController` (or `ASWebAuthenticationSession`).
|
|
246
|
+
- **Android:** Chrome Custom Tabs.
|
|
247
|
+
- **React Native / Expo:** `WebBrowser.openAuthSessionAsync(url, successUrl)`.
|
|
248
|
+
|
|
249
|
+
The in-app browser slides over the app with its own **Done** / close button,
|
|
250
|
+
so the host can always get back, and the app keeps its place. Stripe Checkout
|
|
251
|
+
also expects to run in a real browser, not in an embedded web view.
|
|
252
|
+
|
|
253
|
+
To come straight back after paying, make `successUrl` and `cancelUrl` links
|
|
254
|
+
that open the app: register them as iOS universal links and Android app links
|
|
255
|
+
(for example `https://lu.ma/event/manage/<id>?dunback=paid`). When the
|
|
256
|
+
in-app browser reaches one, close it and call `dunback.orders.get(order.id)`.
|
|
257
|
+
|
|
258
|
+
If you show `<DunbackOrderStatus>` in a web view, pass `onOpenPayment` so its
|
|
259
|
+
links open in the in-app browser instead of replacing your page:
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
<DunbackOrderStatus
|
|
263
|
+
order={order}
|
|
264
|
+
onOpenPayment={(url) => openInAppBrowser(url)} // your native bridge
|
|
265
|
+
/>
|
|
266
|
+
```
|
|
267
|
+
|
|
233
268
|
## 7. Webhooks
|
|
234
269
|
|
|
235
270
|
```ts
|
|
@@ -252,17 +287,34 @@ app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, r
|
|
|
252
287
|
| `order.failed` | Show the message. The host was refunded (`refund`). |
|
|
253
288
|
| `order.needs_attention` | Show "Dunback support is finishing your order". Dunback contacts the host. |
|
|
254
289
|
| `order.cancelled` | Show the cancellation and the refund |
|
|
290
|
+
| `order.refunded` | A delivery was late, failed or was cancelled by the restaurant: show the refund (`refunds`) |
|
|
255
291
|
|
|
256
292
|
## 8. Cancellation
|
|
257
293
|
|
|
258
|
-
`dunback.orders.cancel(orderId, reason)` works in
|
|
294
|
+
`dunback.orders.cancel(orderId, reason)` works in three cases:
|
|
259
295
|
|
|
260
296
|
- **Before payment:** the payment links are cancelled.
|
|
261
297
|
- **After confirmation, before the restaurant's order deadline:** the order is
|
|
262
|
-
cancelled at the restaurant and the host is refunded
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
298
|
+
cancelled at the restaurant and the host is refunded the restaurant's part
|
|
299
|
+
of the order. Dunback's commission and service fee are kept, and so is the
|
|
300
|
+
card processing fee (Stripe keeps it). Card refunds are automatic; USDC
|
|
301
|
+
refunds are sent after review.
|
|
302
|
+
- **After the restaurant's order deadline, until delivery:** the host can
|
|
303
|
+
still cancel (for example, the event is called off). Pass
|
|
304
|
+
`{ acceptPostCommitment: true }`. Dunback decides the refund with the
|
|
305
|
+
restaurant, from nothing up to the restaurant's part, and sends
|
|
306
|
+
`order.refund_decided`. Without it, the call fails with
|
|
307
|
+
`post_commitment_confirmation_required`.
|
|
308
|
+
|
|
309
|
+
If the host isn't at fault (a late or failed delivery, or the restaurant
|
|
310
|
+
cancelled), everything they paid is refunded, card processing fee included.
|
|
311
|
+
|
|
312
|
+
**Before you call `orders.cancel()`,** show Dunback's cancellation notice and
|
|
313
|
+
policy in your page: `order.cancellation.notice` (what cancelling now means)
|
|
314
|
+
and `order.cancellation.policy`. Then ask the host to confirm there, with a
|
|
315
|
+
confirm button and a button to keep the order. Use an in-page confirmation
|
|
316
|
+
rather than a browser pop-up (`window.confirm`): pop-ups can't show the policy
|
|
317
|
+
clearly and are often blocked or hidden in mobile apps.
|
|
266
318
|
|
|
267
319
|
## 9. Testing checklist (sandbox)
|
|
268
320
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dunbackmeadow/commerce-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|