@dunbackmeadow/commerce-sdk 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -256
- package/dist/index.d.ts +34 -5
- package/dist/index.js +49 -4
- package/dist/{luma-D0rL0u8I.d.ts → luma-D2AucdDY.d.ts} +243 -8
- package/dist/react/index.d.ts +27 -4
- package/dist/react/index.js +108 -9
- package/docs/API_REFERENCE.md +72 -9
- package/docs/LUMA_INTEGRATION_GUIDE.md +45 -2
- package/package.json +1 -1
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, 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
|
{
|
|
@@ -76,11 +114,32 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
|
|
|
76
114
|
] }, s.id))
|
|
77
115
|
] }),
|
|
78
116
|
/* @__PURE__ */ jsxs("label", { style: field, children: [
|
|
117
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
118
|
+
"Preferred restaurant ",
|
|
119
|
+
/* @__PURE__ */ jsx("span", { style: hint, children: "(optional)" })
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
"input",
|
|
123
|
+
{
|
|
124
|
+
style: control,
|
|
125
|
+
list: "dunback-restaurants",
|
|
126
|
+
placeholder: "Any restaurant",
|
|
127
|
+
value: value.restaurantName ?? "",
|
|
128
|
+
onChange: (e) => {
|
|
129
|
+
const name = e.target.value;
|
|
130
|
+
onChange(name.trim() ? { ...value, restaurantName: name, cuisine: void 0 } : { ...value, restaurantName: void 0, cuisine: value.drinksOnly ? void 0 : value.cuisine || firstAvailable });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
),
|
|
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)) }),
|
|
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." })
|
|
136
|
+
] }),
|
|
137
|
+
!value.restaurantName?.trim() && !value.drinksOnly && /* @__PURE__ */ jsxs("label", { style: field, children: [
|
|
79
138
|
"Cuisine",
|
|
80
|
-
/* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine, onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("select", { style: control, value: value.cuisine || "", onChange: (e) => onChange({ ...value, cuisine: e.target.value }), children: [
|
|
81
140
|
cuisines.filter((c) => !c.custom).map(option),
|
|
82
141
|
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: [
|
|
142
|
+
!!value.cuisine && !cuisines.some((c) => c.id === value.cuisine) && /* @__PURE__ */ jsxs("option", { value: value.cuisine, disabled: true, children: [
|
|
84
143
|
labelOf(value.cuisine),
|
|
85
144
|
none
|
|
86
145
|
] })
|
|
@@ -117,7 +176,7 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
|
|
|
117
176
|
/* @__PURE__ */ jsx("span", { style: hint, children: "Some restaurants limit party size or have a minimum order" })
|
|
118
177
|
] })
|
|
119
178
|
] }),
|
|
120
|
-
/* @__PURE__ */ jsxs("label", { style: checkRow, children: [
|
|
179
|
+
!value.drinksOnly && /* @__PURE__ */ jsxs("label", { style: checkRow, children: [
|
|
121
180
|
/* @__PURE__ */ jsx(
|
|
122
181
|
"input",
|
|
123
182
|
{
|
|
@@ -132,6 +191,35 @@ function DunbackCateringSettings({ cuisines, value, onChange, venueReady, metroN
|
|
|
132
191
|
/* @__PURE__ */ jsx("span", { style: hint, children: "(non-alcoholic, one per guest)" })
|
|
133
192
|
] })
|
|
134
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
|
+
] }),
|
|
135
223
|
/* @__PURE__ */ jsxs("label", { style: field, children: [
|
|
136
224
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
137
225
|
"Budget per guest ",
|
|
@@ -258,25 +346,36 @@ var STATUS = {
|
|
|
258
346
|
REFUND_PENDING: "The restaurant couldn't take the order; refund in progress",
|
|
259
347
|
NEEDS_ATTENTION: "Payment received; Dunback support is finishing the order"
|
|
260
348
|
};
|
|
261
|
-
function DunbackOrderStatus({ order, className }) {
|
|
349
|
+
function DunbackOrderStatus({ order, className, onOpenPayment }) {
|
|
262
350
|
const p = order.payment;
|
|
351
|
+
const open = (kind) => (e) => {
|
|
352
|
+
if (!onOpenPayment) return;
|
|
353
|
+
e.preventDefault();
|
|
354
|
+
onOpenPayment(e.currentTarget.href, kind);
|
|
355
|
+
};
|
|
263
356
|
return /* @__PURE__ */ jsxs("div", { className, style: className ? void 0 : box, children: [
|
|
264
357
|
/* @__PURE__ */ jsx("strong", { children: order.title }),
|
|
265
358
|
/* @__PURE__ */ jsx("p", { style: { margin: "4px 0" }, children: STATUS[order.status] || order.status }),
|
|
266
359
|
p.lastError && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: p.lastError.message }),
|
|
267
360
|
order.error && order.status !== "CONFIRMED" && /* @__PURE__ */ jsx("p", { style: { color: "#b91c1c", fontSize: 13 }, children: order.error.message }),
|
|
268
361
|
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: [
|
|
362
|
+
p.stripe && /* @__PURE__ */ jsxs("a", { href: p.stripe.checkoutUrl, onClick: open("card"), children: [
|
|
270
363
|
"Pay ",
|
|
271
364
|
money(p.stripe.amount),
|
|
272
365
|
" by card"
|
|
273
366
|
] }),
|
|
274
|
-
p.hostedPaymentUrl && /* @__PURE__ */ jsx("a", { href: p.hostedPaymentUrl, children: "Other payment options" })
|
|
367
|
+
p.hostedPaymentUrl && /* @__PURE__ */ jsx("a", { href: p.hostedPaymentUrl, onClick: open("other"), children: "Other payment options" })
|
|
275
368
|
] }),
|
|
276
369
|
order.status === "AWAITING_PAYMENT" && p.expiresAt && /* @__PURE__ */ jsxs("p", { style: { fontSize: 12, opacity: 0.7 }, children: [
|
|
277
370
|
"Pay by ",
|
|
278
371
|
new Date(p.expiresAt).toLocaleString(),
|
|
279
372
|
" to keep this order."
|
|
373
|
+
] }),
|
|
374
|
+
order.cancellation?.policy && order.cancellation.phase !== "closed" && /* @__PURE__ */ jsxs("p", { style: { fontSize: 12, opacity: 0.75 }, children: [
|
|
375
|
+
/* @__PURE__ */ jsx("strong", { children: "Cancellation policy:" }),
|
|
376
|
+
" ",
|
|
377
|
+
order.cancellation.policy,
|
|
378
|
+
order.cancellation.commitmentDeadlineUtc ? ` Commitment deadline: ${new Date(order.cancellation.commitmentDeadlineUtc).toLocaleString()}.` : ""
|
|
280
379
|
] })
|
|
281
380
|
] });
|
|
282
381
|
}
|
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 |
|
|
@@ -188,6 +197,8 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
|
|
|
188
197
|
| `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
|
|
189
198
|
| `price` | See Price |
|
|
190
199
|
| `withinBudget` | Present when a budget was set |
|
|
200
|
+
| `acceptsCard` | `false` when the restaurant hasn't set up card payments on Dunback (its Stripe account): the option can then only be paid in USDC |
|
|
201
|
+
| `paymentMethods` | `["stripe","usdc"]`, or `["usdc"]` when `acceptsCard` is false |
|
|
191
202
|
| `orderBy` | ISO; latest payment time the restaurant accepts |
|
|
192
203
|
|
|
193
204
|
### Price
|
|
@@ -196,7 +207,7 @@ per tray, so 2 trays with `serves: 8` feed 16 guests.
|
|
|
196
207
|
| --- | --- |
|
|
197
208
|
| `currency` | `"USD"` |
|
|
198
209
|
| `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
|
|
199
|
-
| `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × food and drinks |
|
|
210
|
+
| `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × (food and drinks + the restaurant's service charge). Delivery and tax are not included. |
|
|
200
211
|
| `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
|
|
201
212
|
| `totals` | `{ usdc, card, cardProcessingFee }` |
|
|
202
213
|
| `perGuest` | `{ usdc, card }` |
|
|
@@ -209,8 +220,8 @@ The card total is the USDC total grossed up for card processing.
|
|
|
209
220
|
| --- | --- |
|
|
210
221
|
| `optionId` | required |
|
|
211
222
|
| `payer` | `{ name?, email? }` (pre-fills Stripe) |
|
|
212
|
-
| `paymentMethods` | `["stripe","usdc"]` (default both) |
|
|
213
|
-
| `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts |
|
|
223
|
+
| `paymentMethods` | `["stripe","usdc"]` (default both). `stripe` is left out when the option's `acceptsCard` is false. |
|
|
224
|
+
| `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts. The hosted payment page links back to them ("Back to the event": `cancelUrl` before payment, `successUrl` after) |
|
|
214
225
|
|
|
215
226
|
Errors:
|
|
216
227
|
|
|
@@ -218,6 +229,7 @@ Errors:
|
|
|
218
229
|
| --- | --- | --- |
|
|
219
230
|
| 409 | `invalid_state` | Already selected, or not ready |
|
|
220
231
|
| 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
|
|
232
|
+
| 409 | `card_payments_unavailable` | Only `stripe` was asked for, and this restaurant can't take card payments (`acceptsCard: false`). Offer USDC or another option. |
|
|
221
233
|
| 409 | `restaurant_*` | The restaurant can't take it now |
|
|
222
234
|
|
|
223
235
|
---
|
|
@@ -235,9 +247,11 @@ Errors:
|
|
|
235
247
|
| `delivery` | `{ address: {address1, address2, city, state, zip, country}, onsiteContact: {name, phone}, deliveryNotes, editable }`. `deliveryNotes` is your note only. `editable` is true while the order is `AWAITING_PAYMENT`. |
|
|
236
248
|
| `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
|
|
237
249
|
| `payment` | See below |
|
|
238
|
-
| `fulfillment` | `{ restaurantOrderIds, providerPayment: { amount, payTo, txHash, verifiedOnChain, network },
|
|
250
|
+
| `fulfillment` | `{ restaurantOrderIds, providerPayment, confirmedAt }`. `providerPayment` is how Dunback paid the restaurant: `{ method: "usdc_x402", amount, payTo, txHash, verifiedOnChain, network }` for a USDC order, or `{ method: "stripe_connect", status: "PAID"\|"PENDING" }` for a card order (paid through the restaurant's own Stripe account) |
|
|
239
251
|
| `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
|
|
240
252
|
| `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
|
|
253
|
+
| `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
|
|
254
|
+
| `lateRefund` | `{ afterMinutes, requestableFrom }`: a delivery `afterMinutes` or more late can get a refund request; offer it only from `requestableFrom` |
|
|
241
255
|
| `error` | `{ code, message }` |
|
|
242
256
|
|
|
243
257
|
`payment` holds:
|
|
@@ -300,21 +314,68 @@ The price stays as quoted, so the correction is checked:
|
|
|
300
314
|
|
|
301
315
|
On success you also receive the `order.delivery_updated` webhook.
|
|
302
316
|
|
|
303
|
-
### `POST /orders/:id/cancel` `{ reason? }` → Order
|
|
317
|
+
### `POST /orders/:id/cancel` `{ reason?, acceptPostCommitment? }` → Order
|
|
304
318
|
|
|
305
319
|
| Order status | Result |
|
|
306
320
|
| --- | --- |
|
|
307
321
|
| `AWAITING_PAYMENT` | Cancels the payment links |
|
|
308
|
-
| `CONFIRMED`, before the
|
|
322
|
+
| `CONFIRMED`, before the commitment deadline | Cancels at the restaurant and refunds the restaurant's full amount (card automatically, USDC after review) |
|
|
323
|
+
| `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`) |
|
|
309
324
|
| Otherwise | `409 cancel_refused` or `409 invalid_state` |
|
|
310
325
|
|
|
326
|
+
### Cancellation and refund policy
|
|
327
|
+
|
|
328
|
+
Dunback applies one cancellation and refund policy to every catering order,
|
|
329
|
+
whatever the restaurant's own policy elsewhere:
|
|
330
|
+
|
|
331
|
+
- **Before the commitment deadline:** the host may cancel and is refunded the
|
|
332
|
+
restaurant's full amount (food, delivery, restaurant fees and taxes).
|
|
333
|
+
Dunback's service fee and commission are kept.
|
|
334
|
+
- **After the commitment deadline, until delivery:** the host may still cancel
|
|
335
|
+
(for example, the event is called off). The restaurant may already have
|
|
336
|
+
bought or prepared food, so Dunback decides the refund with the restaurant,
|
|
337
|
+
from nothing up to that full amount, and sends it. You get
|
|
338
|
+
`order.refund_decided` with the decision and Dunback's explanation (and
|
|
339
|
+
`order.refunded` when money moves); the host is emailed too.
|
|
340
|
+
|
|
341
|
+
Every order carries `cancellation`:
|
|
342
|
+
|
|
343
|
+
| Field | Meaning |
|
|
344
|
+
| --- | --- |
|
|
345
|
+
| `policy` | The policy in one paragraph. **Show it with the order.** Options carry the same text as `cancellationPolicy`. |
|
|
346
|
+
| `phase` | `unpaid`, `before_commitment`, `after_commitment` or `closed` |
|
|
347
|
+
| `notice` | What cancelling now means. **Show it again, and get the host's confirmation, before you call cancel.** |
|
|
348
|
+
| `commitmentDeadlineUtc`, `deliveryDeadlineUtc` | ISO instants |
|
|
349
|
+
| `refundIfCancelledNow` | `{ kind: "restaurant_full_refund", amount }`, `{ kind: "decided_by_dunback", maximum }` or null |
|
|
350
|
+
| `requiresAcceptPostCommitment` | true after the commitment deadline |
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
### `POST /orders/:id/refund-requests` `{ restaurantOrderId?, reason, impact }` → 202
|
|
354
|
+
|
|
355
|
+
For a catering delivery made at or after Dunback's catering late-delivery
|
|
356
|
+
threshold (60 minutes by default; Dunback may change it). You receive
|
|
357
|
+
`order.delivered_late` (the order, plus `lateDeliveries` and
|
|
358
|
+
`lateRefundPolicy`) when that happens; show the policy and let the host ask.
|
|
359
|
+
|
|
360
|
+
- `reason` (required): why the host is asking for a refund.
|
|
361
|
+
- `impact` (required): how the late delivery affected the event.
|
|
362
|
+
- Late deliveries are not refunded automatically. Dunback reviews the request
|
|
363
|
+
and decides the refund at its discretion, from nothing up to the
|
|
364
|
+
restaurant's part of that delivery; Dunback's service fee and commission are
|
|
365
|
+
not refunded. You get `order.refund_decided` with the decision (and
|
|
366
|
+
`order.refunded` if anything is refunded); the host is emailed.
|
|
367
|
+
- Errors: `409 not_late`, `409 already_requested`, `409 request_window_closed`
|
|
368
|
+
(30 days after delivery), `400 invalid_request`.
|
|
369
|
+
|
|
311
370
|
### Refunds
|
|
312
371
|
|
|
313
372
|
| What happened | Refund | Webhook |
|
|
314
373
|
| --- | --- | --- |
|
|
315
|
-
| The host cancels before the
|
|
374
|
+
| 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` |
|
|
375
|
+
| 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) |
|
|
316
376
|
| The restaurant couldn't take the order after payment | Everything the host paid | `order.failed` |
|
|
317
|
-
| A delivery
|
|
377
|
+
| A delivery failed, or was cancelled by the restaurant | Everything the host paid for that delivery, card processing fee included | `order.refunded` |
|
|
378
|
+
| 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`) |
|
|
318
379
|
|
|
319
380
|
Card payments are always refunded to the card; USDC refunds are sent to the
|
|
320
381
|
paying address after review. `refunds` lists every refund of the order;
|
|
@@ -352,6 +413,8 @@ The `Dunback-Signature: t=<unix>,v1=<hex>` header is
|
|
|
352
413
|
| --- | --- |
|
|
353
414
|
| `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
|
|
354
415
|
| `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
|
|
416
|
+
| `order.refund_decided` | Order plus `refundDecision: { restaurantOrderId, basis, percentage, amount, explanation, refund }` |
|
|
417
|
+
| `order.delivered_late` | Order plus `lateDeliveries: [{ restaurantOrderId, lateMinutes }]` and `lateRefundPolicy` |
|
|
355
418
|
| `ping` | `{ object: "ping", appId, message }`, plus top-level `livemode`. Sent by **Send test event** in the Developer Dashboard. |
|
|
356
419
|
|
|
357
420
|
The webhook URL, its signing secret (reveal or roll) and the allowed return
|
|
@@ -224,6 +224,10 @@ Show the host two buttons:
|
|
|
224
224
|
|
|
225
225
|
Or build your own USDC screen from `order.payment.usdc`.
|
|
226
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
|
+
|
|
227
231
|
After the Stripe redirect back to `successUrl`, call `dunback.orders.get(order.id)`.
|
|
228
232
|
It re-checks Stripe, so it doesn't depend on webhook timing. Then show
|
|
229
233
|
`<DunbackOrderStatus>` until the status is `CONFIRMED`.
|
|
@@ -233,6 +237,34 @@ always before the restaurant's order deadline. When it expires, Luma receives
|
|
|
233
237
|
`order.expired`, the catering request goes back to `OPTIONS_READY`, and the
|
|
234
238
|
host can choose again.
|
|
235
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
|
+
|
|
236
268
|
## 7. Webhooks
|
|
237
269
|
|
|
238
270
|
```ts
|
|
@@ -259,7 +291,7 @@ app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, r
|
|
|
259
291
|
|
|
260
292
|
## 8. Cancellation
|
|
261
293
|
|
|
262
|
-
`dunback.orders.cancel(orderId, reason)` works in
|
|
294
|
+
`dunback.orders.cancel(orderId, reason)` works in three cases:
|
|
263
295
|
|
|
264
296
|
- **Before payment:** the payment links are cancelled.
|
|
265
297
|
- **After confirmation, before the restaurant's order deadline:** the order is
|
|
@@ -267,11 +299,22 @@ app.post("/webhooks/dunback", express.raw({ type: "application/json" }), (req, r
|
|
|
267
299
|
of the order. Dunback's commission and service fee are kept, and so is the
|
|
268
300
|
card processing fee (Stripe keeps it). Card refunds are automatic; USDC
|
|
269
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`.
|
|
270
308
|
|
|
271
309
|
If the host isn't at fault (a late or failed delivery, or the restaurant
|
|
272
310
|
cancelled), everything they paid is refunded, card processing fee included.
|
|
273
311
|
|
|
274
|
-
|
|
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.
|
|
275
318
|
|
|
276
319
|
## 9. Testing checklist (sandbox)
|
|
277
320
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dunbackmeadow/commerce-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Official Node.js/TypeScript SDK for the Dunback Meadow commerce API. Order from your app or agent and pay by card (Stripe) or USDC. Event catering is available now; more product types are coming.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|