@relyon/kit 0.0.0-stage → 1.0.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/AGENTS.md +75 -0
- package/CHANGELOG.md +1053 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +239 -0
- package/README.md +117 -2
- package/dist/adapters/express.d.ts +39 -0
- package/dist/adapters/express.js +106 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +15 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +38 -0
- package/dist/agent-card.d.ts +14 -0
- package/dist/agent-card.js +58 -0
- package/dist/agent-docs.d.ts +36 -0
- package/dist/agent-docs.js +78 -0
- package/dist/agent-hooks.d.ts +66 -0
- package/dist/agent-hooks.js +280 -0
- package/dist/agents.d.ts +24 -0
- package/dist/agents.js +120 -0
- package/dist/api-key.d.ts +6 -0
- package/dist/api-key.js +33 -0
- package/dist/cache.d.ts +46 -0
- package/dist/cache.js +86 -0
- package/dist/cart-tokens.d.ts +31 -0
- package/dist/cart-tokens.js +58 -0
- package/dist/cart-transfer.d.ts +95 -0
- package/dist/cart-transfer.js +387 -0
- package/dist/catalog-enrichment.d.ts +6 -0
- package/dist/catalog-enrichment.js +71 -0
- package/dist/catalog-reads.d.ts +126 -0
- package/dist/catalog-reads.js +104 -0
- package/dist/catalog.d.ts +78 -0
- package/dist/catalog.js +288 -0
- package/dist/charge-claims.d.ts +11 -0
- package/dist/charge-claims.js +47 -0
- package/dist/check.d.ts +44 -0
- package/dist/check.js +152 -0
- package/dist/checklist-manifest.d.ts +72 -0
- package/dist/checklist-manifest.js +341 -0
- package/dist/checkout.d.ts +222 -0
- package/dist/checkout.js +353 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +727 -0
- package/dist/confirmation.d.ts +78 -0
- package/dist/confirmation.js +124 -0
- package/dist/context.d.ts +81 -0
- package/dist/context.js +10 -0
- package/dist/discovery.d.ts +151 -0
- package/dist/discovery.js +346 -0
- package/dist/doctor-cart-transfer.d.ts +33 -0
- package/dist/doctor-cart-transfer.js +186 -0
- package/dist/doctor-catalog.d.ts +8 -0
- package/dist/doctor-catalog.js +47 -0
- package/dist/doctor-evidence.d.ts +22 -0
- package/dist/doctor-evidence.js +57 -0
- package/dist/doctor-merchant.d.ts +48 -0
- package/dist/doctor-merchant.js +74 -0
- package/dist/doctor-source.d.ts +5 -0
- package/dist/doctor-source.js +142 -0
- package/dist/doctor-variants.d.ts +70 -0
- package/dist/doctor-variants.js +102 -0
- package/dist/doctor.d.ts +215 -0
- package/dist/doctor.js +1689 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.js +200 -0
- package/dist/feed-mapping.d.ts +114 -0
- package/dist/feed-mapping.js +152 -0
- package/dist/feed-values.d.ts +13 -0
- package/dist/feed-values.js +40 -0
- package/dist/feeds.d.ts +104 -0
- package/dist/feeds.js +366 -0
- package/dist/identify.d.ts +102 -0
- package/dist/identify.js +124 -0
- package/dist/identity.d.ts +37 -0
- package/dist/identity.js +54 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +41 -0
- package/dist/init.d.ts +157 -0
- package/dist/init.js +912 -0
- package/dist/kit-config.d.ts +19 -0
- package/dist/kit-config.js +43 -0
- package/dist/kit-environment.d.ts +20 -0
- package/dist/kit-environment.js +32 -0
- package/dist/kit-updates.d.ts +47 -0
- package/dist/kit-updates.js +77 -0
- package/dist/kit-version-project.d.ts +18 -0
- package/dist/kit-version-project.js +214 -0
- package/dist/kit-version.d.ts +37 -0
- package/dist/kit-version.js +162 -0
- package/dist/kit.d.ts +516 -0
- package/dist/kit.js +1309 -0
- package/dist/layers/pages.d.ts +3 -0
- package/dist/layers/pages.js +5 -0
- package/dist/layers/payments.d.ts +7 -0
- package/dist/layers/payments.js +9 -0
- package/dist/layers/products.d.ts +10 -0
- package/dist/layers/products.js +13 -0
- package/dist/live.d.ts +13 -0
- package/dist/live.js +52 -0
- package/dist/mcp.d.ts +270 -0
- package/dist/mcp.js +312 -0
- package/dist/next-steps.d.ts +101 -0
- package/dist/next-steps.js +257 -0
- package/dist/order-pending.d.ts +57 -0
- package/dist/order-pending.js +127 -0
- package/dist/orders.d.ts +12 -0
- package/dist/orders.js +21 -0
- package/dist/payments-init.d.ts +19 -0
- package/dist/payments-init.js +70 -0
- package/dist/payments-routes.d.ts +54 -0
- package/dist/payments-routes.js +123 -0
- package/dist/payments.d.ts +165 -0
- package/dist/payments.js +192 -0
- package/dist/pnpm-workspace.d.ts +58 -0
- package/dist/pnpm-workspace.js +250 -0
- package/dist/policies.d.ts +111 -0
- package/dist/policies.js +317 -0
- package/dist/preview-hosts.d.ts +64 -0
- package/dist/preview-hosts.js +175 -0
- package/dist/private-config.d.ts +169 -0
- package/dist/private-config.js +820 -0
- package/dist/progress.d.ts +54 -0
- package/dist/progress.js +153 -0
- package/dist/protocol-inputs.d.ts +22 -0
- package/dist/protocol-inputs.js +151 -0
- package/dist/public-origin.d.ts +50 -0
- package/dist/public-origin.js +180 -0
- package/dist/refusals.d.ts +86 -0
- package/dist/refusals.js +157 -0
- package/dist/relay.d.ts +107 -0
- package/dist/relay.js +655 -0
- package/dist/release-notes.d.ts +2 -0
- package/dist/release-notes.js +290 -0
- package/dist/relyon-cart-tokens.d.ts +101 -0
- package/dist/relyon-cart-tokens.js +521 -0
- package/dist/relyon.d.ts +141 -0
- package/dist/relyon.js +238 -0
- package/dist/robots.d.ts +27 -0
- package/dist/robots.js +127 -0
- package/dist/rules.d.ts +144 -0
- package/dist/rules.js +347 -0
- package/dist/sdk/generated/public-api.d.ts +4816 -0
- package/dist/sdk/generated/public-api.js +1 -0
- package/dist/sdk/index.d.ts +24 -0
- package/dist/sdk/index.js +34 -0
- package/dist/sdk/signatures.d.ts +17 -0
- package/dist/sdk/signatures.js +33 -0
- package/dist/setup.d.ts +37 -0
- package/dist/setup.js +94 -0
- package/dist/signatures.d.ts +112 -0
- package/dist/signatures.js +443 -0
- package/dist/state.d.ts +185 -0
- package/dist/state.js +96 -0
- package/dist/store-payments.d.ts +48 -0
- package/dist/store-payments.js +143 -0
- package/dist/structured-fields.d.ts +26 -0
- package/dist/structured-fields.js +200 -0
- package/dist/templates.d.ts +19 -0
- package/dist/templates.js +193 -0
- package/dist/test-checkout-command.d.ts +32 -0
- package/dist/test-checkout-command.js +161 -0
- package/dist/test-checkout.d.ts +88 -0
- package/dist/test-checkout.js +292 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +18 -0
- package/dist/ucp-versions.d.ts +57 -0
- package/dist/ucp-versions.js +129 -0
- package/dist/util.d.ts +23 -0
- package/dist/util.js +68 -0
- package/dist/variants.d.ts +67 -0
- package/dist/variants.js +146 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.js +10 -0
- package/dist/waiting.d.ts +43 -0
- package/dist/waiting.js +57 -0
- package/dist/webhook-command.d.ts +48 -0
- package/dist/webhook-command.js +367 -0
- package/dist/webhook-registration.d.ts +47 -0
- package/dist/webhook-registration.js +69 -0
- package/dist/webmcp-schema.d.ts +14 -0
- package/dist/webmcp-schema.js +140 -0
- package/dist/webmcp-script.d.ts +3 -0
- package/dist/webmcp-script.js +176 -0
- package/dist/webmcp-store.d.ts +102 -0
- package/dist/webmcp-store.js +116 -0
- package/dist/webmcp.d.ts +242 -0
- package/dist/webmcp.js +866 -0
- package/dist/wire-names.d.ts +85 -0
- package/dist/wire-names.js +109 -0
- package/package.json +118 -4
- package/release-notes.json +290 -0
- package/scripts/install-notice.cjs +7 -0
- package/skills/relyon-agents/SKILL.md +327 -0
- package/skills/relyon-catalog/SKILL.md +499 -0
- package/skills/relyon-catalog/references/example-store.md +218 -0
- package/skills/relyon-checkout/SKILL.md +603 -0
- package/skills/relyon-checkout/references/checkout-flow.md +257 -0
- package/skills/relyon-checkout/references/checkout-page.md +315 -0
- package/skills/relyon-go-live/SKILL.md +344 -0
- package/skills/relyon-orders/SKILL.md +191 -0
- package/skills/relyon-orders/references/webhook-receiver.md +113 -0
- package/skills/relyon-payments/SKILL.md +117 -0
- package/skills/relyon-setup/SKILL.md +1061 -0
- package/skills/relyon-setup/references/QUICKSTART.md +239 -0
- package/skills/relyon-setup/references/durable-state.md +209 -0
- package/skills/relyon-setup/references/express-server.md +388 -0
- package/skills/relyon-setup/references/next-app-router.md +251 -0
- package/templates/common/STORE-README.md +67 -0
- package/templates/common/gitignore +8 -0
- package/templates/common/scripts/check-pricing.ts +22 -0
- package/templates/common/scripts/serve.mjs +13 -0
- package/templates/common/server/catalog.ts +79 -0
- package/templates/common/server/checkout-flow.d.ts +34 -0
- package/templates/common/server/pages.ts +184 -0
- package/templates/common/server/storage.ts +114 -0
- package/templates/common/server/store.ts +67 -0
- package/templates/express/server/express.ts +20 -0
- package/templates/express/tsconfig.build.json +6 -0
- package/templates/express/tsconfig.json +9 -0
- package/templates/next/app/[[...path]]/route.ts +24 -0
- package/templates/next/next.config.mjs +19 -0
- package/templates/next/tsconfig.json +12 -0
- package/templates/payments/express.ts +39 -0
- package/templates/payments/next.ts +38 -0
- package/templates/payments/node.ts +39 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Example store module
|
|
2
|
+
|
|
3
|
+
The app's own catalog, cart pricing and orders for a small store that sells candles. Every
|
|
4
|
+
price, stock level, coupon, shipping rate and tax rate lives here, in the app.
|
|
5
|
+
The kit calls `priceCart` and `createOrder`; the app's own pages call
|
|
6
|
+
`listProducts`, `getProduct` and `priceCart`. Replace the in-memory data with
|
|
7
|
+
the app's database.
|
|
8
|
+
|
|
9
|
+
These candle records are synthetic teaching data, not supplier or merchant
|
|
10
|
+
facts. Do not copy their brand, MPN, condition, stock or prices into a real
|
|
11
|
+
POD/dropship store. Replace them with verified supplier records first.
|
|
12
|
+
|
|
13
|
+
Amounts are integers in minor units (cents). Rounding is done once per value
|
|
14
|
+
with integer math, so the totals always add up exactly.
|
|
15
|
+
|
|
16
|
+
```js store.js
|
|
17
|
+
// The app's own store logic. Relyon never prices a cart; this module does.
|
|
18
|
+
import { StoreRefusal } from "@relyon/store-kit";
|
|
19
|
+
|
|
20
|
+
const PRIMARY_HOSTNAME = (process.env.STORE_HOSTNAMES ?? process.env.STORE_HOSTNAME ?? "localhost")
|
|
21
|
+
.split(",").map(host => host.trim()).filter(Boolean)[0];
|
|
22
|
+
if (!PRIMARY_HOSTNAME) throw new Error("Configure at least one store hostname");
|
|
23
|
+
const ORIGIN = process.env.STORE_PUBLIC_URL ?? `https://${PRIMARY_HOSTNAME}`;
|
|
24
|
+
if (new URL(ORIGIN).origin !== ORIGIN || new URL(ORIGIN).protocol !== "https:"
|
|
25
|
+
|| new URL(ORIGIN).hostname !== PRIMARY_HOSTNAME) {
|
|
26
|
+
throw new Error("STORE_PUBLIC_URL must be the HTTPS origin of the primary store hostname");
|
|
27
|
+
}
|
|
28
|
+
const CURRENCY = "USD";
|
|
29
|
+
const PRODUCTS = [
|
|
30
|
+
{ id: "lavender-candle", title: "Lavender candle", description: "Hand-poured soy candle with lavender oil. 40-hour burn.", price: 2400, stock: 25 },
|
|
31
|
+
{ id: "cedar-candle", title: "Cedar candle", description: "Hand-poured soy candle with cedarwood oil. 40-hour burn.", price: 2600, stock: 0 },
|
|
32
|
+
{ id: "candle-trio", title: "Candle trio", description: "Three small candles: lavender, cedar and citrus.", price: 5300, stock: 10 },
|
|
33
|
+
];
|
|
34
|
+
const SHIPPING_OPTIONS = [
|
|
35
|
+
{ id: "ground", label: "Ground (3-5 days)", amount: 599 },
|
|
36
|
+
{ id: "pickup", label: "Pick up in store", amount: 0, fulfillment_type: "pickup" },
|
|
37
|
+
];
|
|
38
|
+
const COUPONS = { WELCOME10: { label: "10% off your first order", basisPoints: 1000 } };
|
|
39
|
+
const TAX_BASIS_POINTS = 700; // a flat example rate; real stores compute tax from the address
|
|
40
|
+
const orders = new Map(); // the app's orders table, unique on the Relyon payment ID
|
|
41
|
+
|
|
42
|
+
/** A product as the app's pages and Relyon's discovery index see it. */
|
|
43
|
+
function indexProduct(product) {
|
|
44
|
+
return {
|
|
45
|
+
merchant_product_id: product.id,
|
|
46
|
+
title: product.title,
|
|
47
|
+
description: product.description,
|
|
48
|
+
url: `${ORIGIN}/products/${product.id}`,
|
|
49
|
+
images: [`${ORIGIN}/images/${product.id}.jpg`],
|
|
50
|
+
from_price: { amount: product.price, currency: CURRENCY }, // display only
|
|
51
|
+
availability: product.stock > 0 ? "in_stock" : "out_of_stock",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Full source-backed product; feed facts are separate from the display minimum. */
|
|
56
|
+
function sourceProduct(product) {
|
|
57
|
+
return {
|
|
58
|
+
...indexProduct(product),
|
|
59
|
+
// Synthetic fixture only: this example attests the store owns its candle brand.
|
|
60
|
+
// Real stores must supply their own verified brand and SKU/MPN; never infer them.
|
|
61
|
+
brand: "Example Candle Co",
|
|
62
|
+
mpn: product.id,
|
|
63
|
+
agent: { visible: true, purchasable: true },
|
|
64
|
+
feed: { exactPrice: { amount: product.price, currency: CURRENCY }, condition: "new", ownBrand: true },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The kit's paginated source, independent of syncCatalog and mirror persistence. */
|
|
69
|
+
export const catalogSource = {
|
|
70
|
+
async listProducts({ cursor, limit, query }) {
|
|
71
|
+
const offset = cursor === undefined ? 0 : Number(cursor);
|
|
72
|
+
if (!Number.isSafeInteger(offset) || offset < 0) throw new Error("Invalid catalog cursor");
|
|
73
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 500) throw new Error("Invalid catalog limit");
|
|
74
|
+
const words = (query ?? "").toLowerCase().split(/\s+/).filter(Boolean);
|
|
75
|
+
const matches = PRODUCTS.filter(product =>
|
|
76
|
+
words.every(word => `${product.title} ${product.description}`.toLowerCase().includes(word)));
|
|
77
|
+
const end = offset + limit;
|
|
78
|
+
return {
|
|
79
|
+
products: matches.slice(offset, end).map(sourceProduct),
|
|
80
|
+
nextCursor: end < matches.length ? String(end) : null,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
async getProduct(id) {
|
|
84
|
+
const product = PRODUCTS.find(item => item.id === id);
|
|
85
|
+
return product ? sourceProduct(product) : null;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Products for Relyon's index, which agent checkout buys from: the same facts
|
|
91
|
+
* as the source, including the merchant-supplied brand and MPN that Google and
|
|
92
|
+
* ChatGPT checkout require, without the kit-only feed block.
|
|
93
|
+
*/
|
|
94
|
+
export async function listProducts() {
|
|
95
|
+
return PRODUCTS.map((product) => {
|
|
96
|
+
const { feed, ...indexed } = sourceProduct(product);
|
|
97
|
+
return indexed;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** One product for the app's product page: the same source-backed facts the feeds carry, so its JSON-LD has the same brand and MPN. */
|
|
102
|
+
export function getProduct(id) {
|
|
103
|
+
const product = PRODUCTS.find((item) => item.id === id);
|
|
104
|
+
return product ? sourceProduct(product) : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Prices a cart: one cart line per input line, in the same order, and totals
|
|
109
|
+
* that add up. Relyon charges exactly `totals.total`. Throw a StoreRefusal to
|
|
110
|
+
* turn the cart away; agents get it in their protocol's error format.
|
|
111
|
+
*/
|
|
112
|
+
export async function priceCart(lines, address, coupons, context) {
|
|
113
|
+
if (!Array.isArray(lines) || lines.length === 0) throw new StoreRefusal("empty_cart", "The cart is empty.");
|
|
114
|
+
const wanted = new Map();
|
|
115
|
+
const priced = lines.map((line, index) => {
|
|
116
|
+
const product = PRODUCTS.find((item) => item.id === line.product_id);
|
|
117
|
+
if (!product) throw new StoreRefusal("unknown_product", "That product isn't sold here.", 404);
|
|
118
|
+
if (!Number.isSafeInteger(line.quantity) || line.quantity < 1 || line.quantity > 99) {
|
|
119
|
+
throw new StoreRefusal("invalid_quantity", "Quantity must be between 1 and 99.");
|
|
120
|
+
}
|
|
121
|
+
if (line.options && Object.keys(line.options).length > 0) {
|
|
122
|
+
throw new StoreRefusal("unsupported_options", `${product.title} has no options to choose.`);
|
|
123
|
+
}
|
|
124
|
+
wanted.set(product.id, (wanted.get(product.id) ?? 0) + line.quantity);
|
|
125
|
+
if (wanted.get(product.id) > product.stock) {
|
|
126
|
+
throw new StoreRefusal("out_of_stock", `${product.title} is out of stock.`, 409);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
id: `line_${index + 1}`,
|
|
130
|
+
merchant_product_id: product.id,
|
|
131
|
+
title: product.title,
|
|
132
|
+
quantity: line.quantity,
|
|
133
|
+
unit_amount: product.price,
|
|
134
|
+
amount: product.price * line.quantity,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
const subtotal = priced.reduce((sum, line) => sum + line.amount, 0);
|
|
138
|
+
|
|
139
|
+
const discounts = [];
|
|
140
|
+
for (const code of new Set(coupons ?? [])) {
|
|
141
|
+
const coupon = COUPONS[String(code).toUpperCase()];
|
|
142
|
+
if (!coupon) throw new StoreRefusal("invalid_coupon", `The code ${code} isn't valid.`);
|
|
143
|
+
discounts.push({ code: String(code).toUpperCase(), label: coupon.label, amount: Math.floor((subtotal * coupon.basisPoints) / 10000) });
|
|
144
|
+
}
|
|
145
|
+
const discount = discounts.reduce((sum, item) => sum + item.amount, 0);
|
|
146
|
+
if (discount > subtotal) throw new StoreRefusal("invalid_coupon", "Those codes can't be combined.");
|
|
147
|
+
|
|
148
|
+
const optionId = context?.shippingOptionId ?? null;
|
|
149
|
+
const option = optionId === null ? null : SHIPPING_OPTIONS.find((item) => item.id === optionId);
|
|
150
|
+
if (optionId !== null && !option) throw new StoreRefusal("invalid_shipping_option", "Choose one of the offered shipping options.");
|
|
151
|
+
const shipping = option ? option.amount : 0;
|
|
152
|
+
const tax = Math.round(((subtotal - discount) * TAX_BASIS_POINTS) / 10000);
|
|
153
|
+
const total = subtotal - discount + shipping + tax;
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
currency: CURRENCY,
|
|
157
|
+
lines: priced,
|
|
158
|
+
discounts,
|
|
159
|
+
shipping_options: SHIPPING_OPTIONS,
|
|
160
|
+
...(option ? { shipping_option_id: option.id } : {}),
|
|
161
|
+
...(address ? { shipping_address: address } : {}),
|
|
162
|
+
totals: { currency: CURRENCY, subtotal, discount, shipping, tax, total },
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Called by the kit exactly once for each succeeded payment. Keyed by the
|
|
168
|
+
* payment ID as well, so the app's own records can never hold one payment twice.
|
|
169
|
+
*/
|
|
170
|
+
export async function createOrder(cart, payment) {
|
|
171
|
+
const existing = orders.get(payment.id);
|
|
172
|
+
if (existing) return existing;
|
|
173
|
+
for (const line of cart.lines) {
|
|
174
|
+
const product = PRODUCTS.find((item) => item.id === line.merchant_product_id);
|
|
175
|
+
if (product) product.stock = Math.max(0, product.stock - line.quantity);
|
|
176
|
+
}
|
|
177
|
+
const order = {
|
|
178
|
+
id: `order_${orders.size + 1}`,
|
|
179
|
+
paymentId: payment.id,
|
|
180
|
+
// Relyon's order ID (ord_…), for agent checkouts and the store's own checkout page, used to report fulfillment.
|
|
181
|
+
relyonOrderId: typeof payment.order_id === "string" ? payment.order_id
|
|
182
|
+
: payment.id.startsWith("ord_") ? payment.id : null,
|
|
183
|
+
total: cart.totals.total,
|
|
184
|
+
currency: cart.currency,
|
|
185
|
+
lines: cart.lines.map(({ merchant_product_id, title, quantity, amount }) => ({ merchant_product_id, title, quantity, amount })),
|
|
186
|
+
status: "paid",
|
|
187
|
+
};
|
|
188
|
+
orders.set(payment.id, order);
|
|
189
|
+
return order;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function findOrderByPayment(paymentId) {
|
|
193
|
+
return orders.get(paymentId) ?? null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function findOrder(id) {
|
|
197
|
+
return [...orders.values()].find((order) => order.id === id) ?? null;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
A cart this module returns for two lavender candles, ground shipping and the
|
|
202
|
+
`WELCOME10` code:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"currency": "USD",
|
|
207
|
+
"lines": [
|
|
208
|
+
{ "id": "line_1", "merchant_product_id": "lavender-candle", "title": "Lavender candle", "quantity": 2, "unit_amount": 2400, "amount": 4800 }
|
|
209
|
+
],
|
|
210
|
+
"discounts": [{ "code": "WELCOME10", "label": "10% off your first order", "amount": 480 }],
|
|
211
|
+
"shipping_options": [
|
|
212
|
+
{ "id": "ground", "label": "Ground (3-5 days)", "amount": 599 },
|
|
213
|
+
{ "id": "pickup", "label": "Pick up in store", "amount": 0, "fulfillment_type": "pickup" }
|
|
214
|
+
],
|
|
215
|
+
"shipping_option_id": "ground",
|
|
216
|
+
"totals": { "currency": "USD", "subtotal": 4800, "discount": 480, "shipping": 599, "tax": 302, "total": 5221 }
|
|
217
|
+
}
|
|
218
|
+
```
|