@proveanything/smartlinks 2.1.36 → 2.1.37
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/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/shop.d.ts +106 -0
- package/dist/api/shop.js +171 -0
- package/dist/docs/API_SUMMARY.md +354 -1
- package/dist/docs/overview.md +481 -480
- package/dist/docs/shop.md +176 -0
- package/dist/openapi.yaml +627 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/shop.d.ts +377 -0
- package/dist/types/shop.js +5 -0
- package/docs/API_SUMMARY.md +354 -1
- package/docs/overview.md +481 -480
- package/docs/shop.md +176 -0
- package/openapi.yaml +627 -0
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export { tags } from "./tags.js";
|
|
|
44
44
|
export { order } from "./order.js";
|
|
45
45
|
export { app } from "./appObjects.js";
|
|
46
46
|
export { bookings } from "./bookings.js";
|
|
47
|
+
export { shop } from "./shop.js";
|
|
47
48
|
export { attestations } from "./attestations.js";
|
|
48
49
|
export { containers } from "./containers.js";
|
|
49
50
|
export { lots } from "./lots.js";
|
package/dist/api/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export { tags } from "./tags.js";
|
|
|
47
47
|
export { order } from "./order.js";
|
|
48
48
|
export { app } from "./appObjects.js";
|
|
49
49
|
export { bookings } from "./bookings.js";
|
|
50
|
+
export { shop } from "./shop.js";
|
|
50
51
|
export { attestations } from "./attestations.js";
|
|
51
52
|
export { containers } from "./containers.js";
|
|
52
53
|
export { lots } from "./lots.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ShopPublicConfig, ShopProduct, ShopCheckoutInput, ShopCheckoutResult, ShopBuyerOrder, ShopPage, ShopSettingsView, ShopSettingsPatch, ShopConnectStatus, ShopPrice, ShopPriceInput, ShopPriceUpdate, ShopPriceListParams, ShopAdminOrder, ShopOrderListParams, ShopShipInput, ShopRefundInput } from '../types/shop.js';
|
|
2
|
+
export declare namespace shop {
|
|
3
|
+
/**
|
|
4
|
+
* What a shop front shows: currency, the seller's details (UK law: shown before paying), shipping rates,
|
|
5
|
+
* policies, and `ready` (false until the shop can take payments).
|
|
6
|
+
*/
|
|
7
|
+
function config(collectionId: string): Promise<ShopPublicConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* What is for sale, in the shop's currency, with stock (`inStock`, `available`) and whether the buyer must
|
|
10
|
+
* sign in first (`needsSignIn`: a proof or access goes to an account).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const { items } = await shop.products(collectionId)
|
|
15
|
+
* items.map((p) => `${p.name}: ${formatMoney(p.amount, p.currency)}${p.inStock ? '' : ' (sold out)'}`)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function products(collectionId: string, params?: {
|
|
19
|
+
productIds?: string[];
|
|
20
|
+
}): Promise<{
|
|
21
|
+
currency: string;
|
|
22
|
+
items: ShopProduct[];
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Start paying: the server prices the basket, holds the stock and returns Stripe's checkout page. Send the
|
|
26
|
+
* buyer to `checkoutUrl`. Signed-in buyers' orders are theirs (`shop.myOrders`).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const { checkoutUrl } = await shop.checkout(collectionId, {
|
|
31
|
+
* lines: [{ productId: 'soap', quantity: 2 }],
|
|
32
|
+
* shippingRateId: 'std',
|
|
33
|
+
* successUrl: `${location.origin}/thanks`, // ?session_id= is added
|
|
34
|
+
* cancelUrl: `${location.origin}/basket`,
|
|
35
|
+
* })
|
|
36
|
+
* location.href = checkoutUrl
|
|
37
|
+
* ```
|
|
38
|
+
* @throws `SHOP_NOT_READY`, `NOT_FOR_SALE`, `OUT_OF_STOCK`, `SHIPPING_REQUIRED`, `SIGN_IN_REQUIRED`,
|
|
39
|
+
* `DIGITAL_CONSENT_REQUIRED`, `INVALID_INPUT` (e.g. a return page on another site), `PAYMENT_UNAVAILABLE` (nothing was charged)
|
|
40
|
+
*/
|
|
41
|
+
function checkout(collectionId: string, input: ShopCheckoutInput): Promise<ShopCheckoutResult>;
|
|
42
|
+
/**
|
|
43
|
+
* The thank-you page: the order a Stripe checkout paid for, from the `session_id` on the success URL.
|
|
44
|
+
* Its `status` is `pending-payment` for a moment while the payment is confirmed: check again shortly.
|
|
45
|
+
* `downloads` has links for bought files once it's paid.
|
|
46
|
+
*/
|
|
47
|
+
function orderBySession(collectionId: string, sessionId: string): Promise<ShopBuyerOrder>;
|
|
48
|
+
/** The signed-in buyer's orders, newest first, with their download links. @throws `SIGN_IN_REQUIRED` */
|
|
49
|
+
function myOrders(collectionId: string, params?: {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
}): Promise<ShopPage<ShopBuyerOrder>>;
|
|
53
|
+
/** Format minor units as money for the person: `formatMoney(1299, 'GBP')` → "£12.99". */
|
|
54
|
+
function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
55
|
+
/** The seller's side: settings, Stripe, prices and orders (collection admins). */
|
|
56
|
+
namespace admin {
|
|
57
|
+
/** The settings, what's still needed to take payments (`readiness`), and what SmartLinks takes (`fee`, read-only). */
|
|
58
|
+
function settings(collectionId: string): Promise<ShopSettingsView>;
|
|
59
|
+
/** Change settings: merged into what's stored; `shipping.rates` is replaced as a whole. */
|
|
60
|
+
function updateSettings(collectionId: string, patch: ShopSettingsPatch): Promise<ShopSettingsView>;
|
|
61
|
+
/**
|
|
62
|
+
* Connect the seller's Stripe account (a new one, set up on Stripe's own pages). Send the seller to `url`;
|
|
63
|
+
* Stripe brings them back to `returnUrl` (done or not: check `connectStatus`) or `refreshUrl` (the link ran out).
|
|
64
|
+
*/
|
|
65
|
+
function connect(collectionId: string, input: {
|
|
66
|
+
returnUrl: string;
|
|
67
|
+
refreshUrl: string;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
url: string;
|
|
70
|
+
expiresAt: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** Whether Stripe is connected, and whether it can take payments and pay out yet. */
|
|
73
|
+
function connectStatus(collectionId: string): Promise<ShopConnectStatus>;
|
|
74
|
+
function listPrices(collectionId: string, params?: ShopPriceListParams): Promise<ShopPage<ShopPrice>>;
|
|
75
|
+
/**
|
|
76
|
+
* Put a product (or variant) on sale, or change its price in that currency (one price per product per
|
|
77
|
+
* currency). @throws `INVALID_INPUT`, `APP_NOT_INSTALLED`
|
|
78
|
+
*/
|
|
79
|
+
function setPrice(collectionId: string, input: ShopPriceInput): Promise<ShopPrice>;
|
|
80
|
+
function updatePrice(collectionId: string, priceId: string, changes: ShopPriceUpdate): Promise<ShopPrice>;
|
|
81
|
+
/** Take it off sale for good (or set `active: false` to pause). */
|
|
82
|
+
function removePrice(collectionId: string, priceId: string): Promise<{
|
|
83
|
+
deleted: true;
|
|
84
|
+
}>;
|
|
85
|
+
/** Shop orders, newest first. Unpaid and expired checkouts are left out unless asked for. */
|
|
86
|
+
function listOrders(collectionId: string, params?: ShopOrderListParams): Promise<ShopPage<ShopAdminOrder>>;
|
|
87
|
+
function getOrder(collectionId: string, orderId: string): Promise<ShopAdminOrder>;
|
|
88
|
+
/**
|
|
89
|
+
* Send some or all of what's left, with tracking. The held stock leaves; the buyer's "shipped" email
|
|
90
|
+
* goes out if the shop has one. @throws `NOT_SHIPPABLE`, `NOTHING_TO_SHIP`
|
|
91
|
+
*/
|
|
92
|
+
function ship(collectionId: string, orderId: string, input?: ShopShipInput): Promise<ShopAdminOrder>;
|
|
93
|
+
/**
|
|
94
|
+
* Refund through Stripe: lines, shipping, a goodwill amount, or everything left. Unsent stock goes back;
|
|
95
|
+
* digital delivery is withdrawn. @throws `NOT_REFUNDABLE`, `NOTHING_TO_REFUND`
|
|
96
|
+
*/
|
|
97
|
+
function refund(collectionId: string, orderId: string, input?: ShopRefundInput): Promise<ShopAdminOrder>;
|
|
98
|
+
/** An app that delivers a line itself (`deliveryConfig.kind: 'app'`) says it's done. */
|
|
99
|
+
function markDelivered(collectionId: string, orderId: string, itemId: string, input?: {
|
|
100
|
+
note?: string;
|
|
101
|
+
reference?: string;
|
|
102
|
+
}): Promise<ShopAdminOrder>;
|
|
103
|
+
/** Cancel a checkout that hasn't been paid (its stock is released). @throws `NOT_PENDING` */
|
|
104
|
+
function cancelCheckout(collectionId: string, orderId: string): Promise<ShopAdminOrder>;
|
|
105
|
+
}
|
|
106
|
+
}
|
package/dist/api/shop.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// src/api/shop.ts
|
|
2
|
+
// Basic commerce — see docs/shop.md. A shop front (any page, any site) uses the public calls; the Shop app and
|
|
3
|
+
// Studio use `shop.admin`. Prices, totals and "paid" are never taken from the browser: the server prices the
|
|
4
|
+
// basket, and only Stripe's webhook marks an order paid.
|
|
5
|
+
import { request, post, put, patch, del } from '../http.js';
|
|
6
|
+
const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/shop`;
|
|
7
|
+
const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/shop`;
|
|
8
|
+
function qs(params) {
|
|
9
|
+
if (!params)
|
|
10
|
+
return '';
|
|
11
|
+
const parts = [];
|
|
12
|
+
for (const [k, v] of Object.entries(params)) {
|
|
13
|
+
if (v === undefined || v === null || v === '')
|
|
14
|
+
continue;
|
|
15
|
+
parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(Array.isArray(v) ? v.join(',') : String(v))}`);
|
|
16
|
+
}
|
|
17
|
+
return parts.length ? `?${parts.join('&')}` : '';
|
|
18
|
+
}
|
|
19
|
+
export var shop;
|
|
20
|
+
(function (shop) {
|
|
21
|
+
/**
|
|
22
|
+
* What a shop front shows: currency, the seller's details (UK law: shown before paying), shipping rates,
|
|
23
|
+
* policies, and `ready` (false until the shop can take payments).
|
|
24
|
+
*/
|
|
25
|
+
async function config(collectionId) {
|
|
26
|
+
return request(`${pub(collectionId)}/config`);
|
|
27
|
+
}
|
|
28
|
+
shop.config = config;
|
|
29
|
+
/**
|
|
30
|
+
* What is for sale, in the shop's currency, with stock (`inStock`, `available`) and whether the buyer must
|
|
31
|
+
* sign in first (`needsSignIn`: a proof or access goes to an account).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const { items } = await shop.products(collectionId)
|
|
36
|
+
* items.map((p) => `${p.name}: ${formatMoney(p.amount, p.currency)}${p.inStock ? '' : ' (sold out)'}`)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
async function products(collectionId, params) {
|
|
40
|
+
return request(`${pub(collectionId)}/products${qs({ productIds: params === null || params === void 0 ? void 0 : params.productIds })}`);
|
|
41
|
+
}
|
|
42
|
+
shop.products = products;
|
|
43
|
+
/**
|
|
44
|
+
* Start paying: the server prices the basket, holds the stock and returns Stripe's checkout page. Send the
|
|
45
|
+
* buyer to `checkoutUrl`. Signed-in buyers' orders are theirs (`shop.myOrders`).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const { checkoutUrl } = await shop.checkout(collectionId, {
|
|
50
|
+
* lines: [{ productId: 'soap', quantity: 2 }],
|
|
51
|
+
* shippingRateId: 'std',
|
|
52
|
+
* successUrl: `${location.origin}/thanks`, // ?session_id= is added
|
|
53
|
+
* cancelUrl: `${location.origin}/basket`,
|
|
54
|
+
* })
|
|
55
|
+
* location.href = checkoutUrl
|
|
56
|
+
* ```
|
|
57
|
+
* @throws `SHOP_NOT_READY`, `NOT_FOR_SALE`, `OUT_OF_STOCK`, `SHIPPING_REQUIRED`, `SIGN_IN_REQUIRED`,
|
|
58
|
+
* `DIGITAL_CONSENT_REQUIRED`, `INVALID_INPUT` (e.g. a return page on another site), `PAYMENT_UNAVAILABLE` (nothing was charged)
|
|
59
|
+
*/
|
|
60
|
+
async function checkout(collectionId, input) {
|
|
61
|
+
return post(`${pub(collectionId)}/checkout`, input);
|
|
62
|
+
}
|
|
63
|
+
shop.checkout = checkout;
|
|
64
|
+
/**
|
|
65
|
+
* The thank-you page: the order a Stripe checkout paid for, from the `session_id` on the success URL.
|
|
66
|
+
* Its `status` is `pending-payment` for a moment while the payment is confirmed: check again shortly.
|
|
67
|
+
* `downloads` has links for bought files once it's paid.
|
|
68
|
+
*/
|
|
69
|
+
async function orderBySession(collectionId, sessionId) {
|
|
70
|
+
return request(`${pub(collectionId)}/orders/by-session/${encodeURIComponent(sessionId)}`);
|
|
71
|
+
}
|
|
72
|
+
shop.orderBySession = orderBySession;
|
|
73
|
+
/** The signed-in buyer's orders, newest first, with their download links. @throws `SIGN_IN_REQUIRED` */
|
|
74
|
+
async function myOrders(collectionId, params) {
|
|
75
|
+
return request(`${pub(collectionId)}/orders/mine${qs(params)}`);
|
|
76
|
+
}
|
|
77
|
+
shop.myOrders = myOrders;
|
|
78
|
+
/** Format minor units as money for the person: `formatMoney(1299, 'GBP')` → "£12.99". */
|
|
79
|
+
function formatMoney(amount, currency, locale) {
|
|
80
|
+
try {
|
|
81
|
+
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount / 100);
|
|
82
|
+
}
|
|
83
|
+
catch (_a) {
|
|
84
|
+
return `${(amount / 100).toFixed(2)} ${currency}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
shop.formatMoney = formatMoney;
|
|
88
|
+
/** The seller's side: settings, Stripe, prices and orders (collection admins). */
|
|
89
|
+
let admin;
|
|
90
|
+
(function (admin) {
|
|
91
|
+
/** The settings, what's still needed to take payments (`readiness`), and what SmartLinks takes (`fee`, read-only). */
|
|
92
|
+
async function settings(collectionId) {
|
|
93
|
+
return request(`${adm(collectionId)}/settings`);
|
|
94
|
+
}
|
|
95
|
+
admin.settings = settings;
|
|
96
|
+
/** Change settings: merged into what's stored; `shipping.rates` is replaced as a whole. */
|
|
97
|
+
async function updateSettings(collectionId, patch) {
|
|
98
|
+
return put(`${adm(collectionId)}/settings`, patch);
|
|
99
|
+
}
|
|
100
|
+
admin.updateSettings = updateSettings;
|
|
101
|
+
/**
|
|
102
|
+
* Connect the seller's Stripe account (a new one, set up on Stripe's own pages). Send the seller to `url`;
|
|
103
|
+
* Stripe brings them back to `returnUrl` (done or not: check `connectStatus`) or `refreshUrl` (the link ran out).
|
|
104
|
+
*/
|
|
105
|
+
async function connect(collectionId, input) {
|
|
106
|
+
return post(`${adm(collectionId)}/connect`, input);
|
|
107
|
+
}
|
|
108
|
+
admin.connect = connect;
|
|
109
|
+
/** Whether Stripe is connected, and whether it can take payments and pay out yet. */
|
|
110
|
+
async function connectStatus(collectionId) {
|
|
111
|
+
return request(`${adm(collectionId)}/connect/status`);
|
|
112
|
+
}
|
|
113
|
+
admin.connectStatus = connectStatus;
|
|
114
|
+
async function listPrices(collectionId, params) {
|
|
115
|
+
return request(`${adm(collectionId)}/prices${qs(params)}`);
|
|
116
|
+
}
|
|
117
|
+
admin.listPrices = listPrices;
|
|
118
|
+
/**
|
|
119
|
+
* Put a product (or variant) on sale, or change its price in that currency (one price per product per
|
|
120
|
+
* currency). @throws `INVALID_INPUT`, `APP_NOT_INSTALLED`
|
|
121
|
+
*/
|
|
122
|
+
async function setPrice(collectionId, input) {
|
|
123
|
+
return post(`${adm(collectionId)}/prices`, input);
|
|
124
|
+
}
|
|
125
|
+
admin.setPrice = setPrice;
|
|
126
|
+
async function updatePrice(collectionId, priceId, changes) {
|
|
127
|
+
return patch(`${adm(collectionId)}/prices/${encodeURIComponent(priceId)}`, changes);
|
|
128
|
+
}
|
|
129
|
+
admin.updatePrice = updatePrice;
|
|
130
|
+
/** Take it off sale for good (or set `active: false` to pause). */
|
|
131
|
+
async function removePrice(collectionId, priceId) {
|
|
132
|
+
return del(`${adm(collectionId)}/prices/${encodeURIComponent(priceId)}`);
|
|
133
|
+
}
|
|
134
|
+
admin.removePrice = removePrice;
|
|
135
|
+
/** Shop orders, newest first. Unpaid and expired checkouts are left out unless asked for. */
|
|
136
|
+
async function listOrders(collectionId, params) {
|
|
137
|
+
return request(`${adm(collectionId)}/orders${qs(params)}`);
|
|
138
|
+
}
|
|
139
|
+
admin.listOrders = listOrders;
|
|
140
|
+
async function getOrder(collectionId, orderId) {
|
|
141
|
+
return request(`${adm(collectionId)}/orders/${encodeURIComponent(orderId)}`);
|
|
142
|
+
}
|
|
143
|
+
admin.getOrder = getOrder;
|
|
144
|
+
/**
|
|
145
|
+
* Send some or all of what's left, with tracking. The held stock leaves; the buyer's "shipped" email
|
|
146
|
+
* goes out if the shop has one. @throws `NOT_SHIPPABLE`, `NOTHING_TO_SHIP`
|
|
147
|
+
*/
|
|
148
|
+
async function ship(collectionId, orderId, input = {}) {
|
|
149
|
+
return post(`${adm(collectionId)}/orders/${encodeURIComponent(orderId)}/ship`, input);
|
|
150
|
+
}
|
|
151
|
+
admin.ship = ship;
|
|
152
|
+
/**
|
|
153
|
+
* Refund through Stripe: lines, shipping, a goodwill amount, or everything left. Unsent stock goes back;
|
|
154
|
+
* digital delivery is withdrawn. @throws `NOT_REFUNDABLE`, `NOTHING_TO_REFUND`
|
|
155
|
+
*/
|
|
156
|
+
async function refund(collectionId, orderId, input = {}) {
|
|
157
|
+
return post(`${adm(collectionId)}/orders/${encodeURIComponent(orderId)}/refund`, input);
|
|
158
|
+
}
|
|
159
|
+
admin.refund = refund;
|
|
160
|
+
/** An app that delivers a line itself (`deliveryConfig.kind: 'app'`) says it's done. */
|
|
161
|
+
async function markDelivered(collectionId, orderId, itemId, input = {}) {
|
|
162
|
+
return post(`${adm(collectionId)}/orders/${encodeURIComponent(orderId)}/lines/${encodeURIComponent(itemId)}/delivered`, input);
|
|
163
|
+
}
|
|
164
|
+
admin.markDelivered = markDelivered;
|
|
165
|
+
/** Cancel a checkout that hasn't been paid (its stock is released). @throws `NOT_PENDING` */
|
|
166
|
+
async function cancelCheckout(collectionId, orderId) {
|
|
167
|
+
return post(`${adm(collectionId)}/orders/${encodeURIComponent(orderId)}/expire`, {});
|
|
168
|
+
}
|
|
169
|
+
admin.cancelCheckout = cancelCheckout;
|
|
170
|
+
})(admin = shop.admin || (shop.admin = {}));
|
|
171
|
+
})(shop || (shop = {}));
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.37 | Generated: 2026-11-21T13:39:32.434Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -166,6 +166,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
166
166
|
- **realtime** - Functions for realtime operations
|
|
167
167
|
- **research** - Functions for research operations
|
|
168
168
|
- **secrets** - Functions for secrets operations
|
|
169
|
+
- **shop** - Functions for shop operations
|
|
169
170
|
- **tagCodes** - Functions for tagCodes operations
|
|
170
171
|
- **tags** - Functions for tags operations
|
|
171
172
|
- **template** - Functions for template operations
|
|
@@ -11775,6 +11776,294 @@ interface SegmentRecipientsResponse {
|
|
|
11775
11776
|
|
|
11776
11777
|
**SegmentFilterRule** = ``
|
|
11777
11778
|
|
|
11779
|
+
### shop
|
|
11780
|
+
|
|
11781
|
+
**ShopPrice** (interface)
|
|
11782
|
+
```typescript
|
|
11783
|
+
interface ShopPrice {
|
|
11784
|
+
id: string
|
|
11785
|
+
collectionId: string
|
|
11786
|
+
productId: string
|
|
11787
|
+
variantId: string | null
|
|
11788
|
+
appId: string
|
|
11789
|
+
currency: string
|
|
11790
|
+
amount: number
|
|
11791
|
+
compareAtAmount: number | null
|
|
11792
|
+
delivery: ShopDelivery
|
|
11793
|
+
deliveryConfig: ShopDeliveryConfig | Record<string, never>
|
|
11794
|
+
trackStock: boolean
|
|
11795
|
+
active: boolean
|
|
11796
|
+
sort: number
|
|
11797
|
+
metadata: Record<string, any>
|
|
11798
|
+
createdAt: string
|
|
11799
|
+
updatedAt: string
|
|
11800
|
+
}
|
|
11801
|
+
```
|
|
11802
|
+
|
|
11803
|
+
**ShopPriceInput** (interface)
|
|
11804
|
+
```typescript
|
|
11805
|
+
interface ShopPriceInput {
|
|
11806
|
+
productId: string
|
|
11807
|
+
variantId?: string | null
|
|
11808
|
+
appId?: string
|
|
11809
|
+
currency?: string
|
|
11810
|
+
amount: number
|
|
11811
|
+
compareAtAmount?: number | null
|
|
11812
|
+
delivery?: ShopDelivery
|
|
11813
|
+
deliveryConfig?: ShopDeliveryConfig
|
|
11814
|
+
trackStock?: boolean
|
|
11815
|
+
active?: boolean
|
|
11816
|
+
sort?: number
|
|
11817
|
+
metadata?: Record<string, any>
|
|
11818
|
+
}
|
|
11819
|
+
```
|
|
11820
|
+
|
|
11821
|
+
**ShopPriceListParams** (interface)
|
|
11822
|
+
```typescript
|
|
11823
|
+
interface ShopPriceListParams {
|
|
11824
|
+
productId?: string
|
|
11825
|
+
currency?: string
|
|
11826
|
+
active?: boolean
|
|
11827
|
+
appId?: string
|
|
11828
|
+
limit?: number
|
|
11829
|
+
offset?: number
|
|
11830
|
+
}
|
|
11831
|
+
```
|
|
11832
|
+
|
|
11833
|
+
**ShopShippingRate** (interface)
|
|
11834
|
+
```typescript
|
|
11835
|
+
interface ShopShippingRate {
|
|
11836
|
+
id: string
|
|
11837
|
+
label: string
|
|
11838
|
+
amount: number
|
|
11839
|
+
days?: string
|
|
11840
|
+
}
|
|
11841
|
+
```
|
|
11842
|
+
|
|
11843
|
+
**ShopSettings** (interface)
|
|
11844
|
+
```typescript
|
|
11845
|
+
interface ShopSettings {
|
|
11846
|
+
currency: string
|
|
11847
|
+
appId: string
|
|
11848
|
+
seller: { name?: string; address?: string; email?: string; phone?: string; vatNumber?: string }
|
|
11849
|
+
vat: { registered: boolean; rate: number }
|
|
11850
|
+
shipping: {
|
|
11851
|
+
rates: ShopShippingRate[]
|
|
11852
|
+
freeOver: number | null
|
|
11853
|
+
collection: { label: string } | null
|
|
11854
|
+
}
|
|
11855
|
+
policies: { returns?: string; terms?: string; privacy?: string }
|
|
11856
|
+
stripe: { accountId: string | null }
|
|
11857
|
+
stockContainerId: string | null
|
|
11858
|
+
checkout: {
|
|
11859
|
+
successUrl: string | null
|
|
11860
|
+
cancelUrl: string | null
|
|
11861
|
+
expiresMinutes: number
|
|
11862
|
+
allowedHosts: string[]
|
|
11863
|
+
}
|
|
11864
|
+
digital: { euBuyers: boolean }
|
|
11865
|
+
interaction: { interactionId: string | null }
|
|
11866
|
+
}
|
|
11867
|
+
```
|
|
11868
|
+
|
|
11869
|
+
**ShopReadiness** (interface)
|
|
11870
|
+
```typescript
|
|
11871
|
+
interface ShopReadiness {
|
|
11872
|
+
ready: boolean
|
|
11873
|
+
missing: { key: string; text: string }[]
|
|
11874
|
+
}
|
|
11875
|
+
```
|
|
11876
|
+
|
|
11877
|
+
**ShopConnectStatus** (interface)
|
|
11878
|
+
```typescript
|
|
11879
|
+
interface ShopConnectStatus {
|
|
11880
|
+
connected: boolean
|
|
11881
|
+
chargesEnabled?: boolean
|
|
11882
|
+
detailsSubmitted?: boolean
|
|
11883
|
+
payoutsEnabled?: boolean
|
|
11884
|
+
id?: string
|
|
11885
|
+
}
|
|
11886
|
+
```
|
|
11887
|
+
|
|
11888
|
+
**ShopPublicConfig** (interface)
|
|
11889
|
+
```typescript
|
|
11890
|
+
interface ShopPublicConfig {
|
|
11891
|
+
currency: string
|
|
11892
|
+
seller: { name: string | null; address: string | null; email: string | null; vatNumber?: string }
|
|
11893
|
+
vat: { registered: boolean; rate: number }
|
|
11894
|
+
shipping: ShopSettings['shipping']
|
|
11895
|
+
policies: ShopSettings['policies']
|
|
11896
|
+
digital: { euBuyers: boolean }
|
|
11897
|
+
ready: boolean
|
|
11898
|
+
}
|
|
11899
|
+
```
|
|
11900
|
+
|
|
11901
|
+
**ShopProduct** (interface)
|
|
11902
|
+
```typescript
|
|
11903
|
+
interface ShopProduct {
|
|
11904
|
+
priceId: string
|
|
11905
|
+
productId: string
|
|
11906
|
+
variantId: string | null
|
|
11907
|
+
name: string
|
|
11908
|
+
description: string | null
|
|
11909
|
+
heroImage: any
|
|
11910
|
+
amount: number
|
|
11911
|
+
compareAtAmount: number | null
|
|
11912
|
+
currency: string
|
|
11913
|
+
delivery: ShopDelivery
|
|
11914
|
+
deliveryKind: ShopDigitalKind | null
|
|
11915
|
+
needsSignIn: boolean
|
|
11916
|
+
available: number | null
|
|
11917
|
+
inStock: boolean
|
|
11918
|
+
}
|
|
11919
|
+
```
|
|
11920
|
+
|
|
11921
|
+
**ShopCheckoutLine** (interface)
|
|
11922
|
+
```typescript
|
|
11923
|
+
interface ShopCheckoutLine {
|
|
11924
|
+
productId: string
|
|
11925
|
+
variantId?: string | null
|
|
11926
|
+
quantity?: number
|
|
11927
|
+
}
|
|
11928
|
+
```
|
|
11929
|
+
|
|
11930
|
+
**ShopCheckoutInput** (interface)
|
|
11931
|
+
```typescript
|
|
11932
|
+
interface ShopCheckoutInput {
|
|
11933
|
+
lines: ShopCheckoutLine[]
|
|
11934
|
+
shippingRateId?: string
|
|
11935
|
+
email?: string
|
|
11936
|
+
successUrl?: string
|
|
11937
|
+
cancelUrl?: string
|
|
11938
|
+
acceptances?: { digitalImmediate?: boolean }
|
|
11939
|
+
}
|
|
11940
|
+
```
|
|
11941
|
+
|
|
11942
|
+
**ShopCheckoutResult** (interface)
|
|
11943
|
+
```typescript
|
|
11944
|
+
interface ShopCheckoutResult {
|
|
11945
|
+
orderId: string
|
|
11946
|
+
checkoutUrl: string
|
|
11947
|
+
expiresAt: string
|
|
11948
|
+
total: number
|
|
11949
|
+
currency: string
|
|
11950
|
+
}
|
|
11951
|
+
```
|
|
11952
|
+
|
|
11953
|
+
**ShopOrderLine** (interface)
|
|
11954
|
+
```typescript
|
|
11955
|
+
interface ShopOrderLine {
|
|
11956
|
+
id: string
|
|
11957
|
+
productId: string
|
|
11958
|
+
variantId: string | null
|
|
11959
|
+
name: string | null
|
|
11960
|
+
quantity: number
|
|
11961
|
+
unitAmount: number | null
|
|
11962
|
+
lineTotal: number | null
|
|
11963
|
+
delivery: ShopDelivery | null
|
|
11964
|
+
deliveryKind: ShopDigitalKind | null
|
|
11965
|
+
quantityDone: number
|
|
11966
|
+
quantityRefunded: number
|
|
11967
|
+
priceId: string | null
|
|
11968
|
+
appId: string
|
|
11969
|
+
files?: string[]
|
|
11970
|
+
fee?: { bps: number; amount: number }
|
|
11971
|
+
}
|
|
11972
|
+
```
|
|
11973
|
+
|
|
11974
|
+
**ShopShipment** (interface)
|
|
11975
|
+
```typescript
|
|
11976
|
+
interface ShopShipment {
|
|
11977
|
+
id: string
|
|
11978
|
+
at: string
|
|
11979
|
+
lines: { itemId: string; quantity: number }[]
|
|
11980
|
+
carrier?: string
|
|
11981
|
+
trackingNumber?: string
|
|
11982
|
+
trackingUrl?: string
|
|
11983
|
+
}
|
|
11984
|
+
```
|
|
11985
|
+
|
|
11986
|
+
**ShopOrder** (interface)
|
|
11987
|
+
```typescript
|
|
11988
|
+
interface ShopOrder {
|
|
11989
|
+
id: string
|
|
11990
|
+
collectionId: string
|
|
11991
|
+
orderRef: string | null
|
|
11992
|
+
status: ShopOrderStatus
|
|
11993
|
+
source: 'shop'
|
|
11994
|
+
contactId: string | null
|
|
11995
|
+
currency: string
|
|
11996
|
+
subtotal: number | null
|
|
11997
|
+
shipping: number | null
|
|
11998
|
+
tax: number | null
|
|
11999
|
+
total: number | null
|
|
12000
|
+
refunded: number
|
|
12001
|
+
paidAt: string | null
|
|
12002
|
+
expiresAt: string | null
|
|
12003
|
+
createdAt: string
|
|
12004
|
+
updatedAt: string
|
|
12005
|
+
email: string | null
|
|
12006
|
+
shippingChoice: ShopShippingRate | null
|
|
12007
|
+
shippingAddress: Record<string, any> | null
|
|
12008
|
+
shipments: ShopShipment[]
|
|
12009
|
+
lines: ShopOrderLine[]
|
|
12010
|
+
}
|
|
12011
|
+
```
|
|
12012
|
+
|
|
12013
|
+
**ShopOrderListParams** (interface)
|
|
12014
|
+
```typescript
|
|
12015
|
+
interface ShopOrderListParams {
|
|
12016
|
+
status?: string
|
|
12017
|
+
contactId?: string
|
|
12018
|
+
includeExpired?: boolean
|
|
12019
|
+
limit?: number
|
|
12020
|
+
offset?: number
|
|
12021
|
+
}
|
|
12022
|
+
```
|
|
12023
|
+
|
|
12024
|
+
**ShopPage<T>** (interface)
|
|
12025
|
+
```typescript
|
|
12026
|
+
interface ShopPage<T> {
|
|
12027
|
+
items: T[]
|
|
12028
|
+
total: number
|
|
12029
|
+
limit: number
|
|
12030
|
+
offset: number
|
|
12031
|
+
}
|
|
12032
|
+
```
|
|
12033
|
+
|
|
12034
|
+
**ShopShipInput** (interface)
|
|
12035
|
+
```typescript
|
|
12036
|
+
interface ShopShipInput {
|
|
12037
|
+
lines?: { itemId: string; quantity?: number }[]
|
|
12038
|
+
carrier?: string
|
|
12039
|
+
trackingNumber?: string
|
|
12040
|
+
trackingUrl?: string
|
|
12041
|
+
}
|
|
12042
|
+
```
|
|
12043
|
+
|
|
12044
|
+
**ShopRefundInput** (interface)
|
|
12045
|
+
```typescript
|
|
12046
|
+
interface ShopRefundInput {
|
|
12047
|
+
lines?: { itemId: string; quantity?: number }[]
|
|
12048
|
+
shipping?: boolean
|
|
12049
|
+
amount?: number
|
|
12050
|
+
restock?: boolean
|
|
12051
|
+
reason?: string
|
|
12052
|
+
}
|
|
12053
|
+
```
|
|
12054
|
+
|
|
12055
|
+
**ShopDelivery** = `'physical' | 'digital'`
|
|
12056
|
+
|
|
12057
|
+
**ShopDigitalKind** = `'proof' | 'download' | 'access' | 'app'`
|
|
12058
|
+
|
|
12059
|
+
**ShopDeliveryConfig** = ``
|
|
12060
|
+
|
|
12061
|
+
**ShopPriceUpdate** = `Partial<Omit<ShopPriceInput, 'productId' | 'variantId' | 'currency'>>`
|
|
12062
|
+
|
|
12063
|
+
**ShopSettingsPatch** = `Partial<Omit<ShopSettings, 'stripe' | 'shipping' | 'checkout' | 'vat' | 'seller' | 'digital' | 'interaction'>> & {`
|
|
12064
|
+
|
|
12065
|
+
**ShopOrderStatus** = `'pending-payment' | 'paid' | 'fulfilled' | 'partly-refunded' | 'refunded' | 'expired'`
|
|
12066
|
+
|
|
11778
12067
|
### tags
|
|
11779
12068
|
|
|
11780
12069
|
**Tag** (interface)
|
|
@@ -15490,6 +15779,70 @@ Append Responses items (input/output/tool) to a session — the manual-persisten
|
|
|
15490
15779
|
**clear**(collectionId: string, id: string) → `Promise<`
|
|
15491
15780
|
Archive (soft-delete) a session.
|
|
15492
15781
|
|
|
15782
|
+
### shop
|
|
15783
|
+
|
|
15784
|
+
**config**(collectionId: string) → `Promise<ShopPublicConfig>`
|
|
15785
|
+
What a shop front shows: currency, the seller's details (UK law: shown before paying), shipping rates, policies, and `ready` (false until the shop can take payments).
|
|
15786
|
+
|
|
15787
|
+
**products**(collectionId: string, params?: { productIds?: string[] }) → `Promise<`
|
|
15788
|
+
What is for sale, in the shop's currency, with stock (`inStock`, `available`) and whether the buyer must sign in first (`needsSignIn`: a proof or access goes to an account). ```typescript const { items } = await shop.products(collectionId) items.map((p) => `${p.name}: ${formatMoney(p.amount, p.currency)}${p.inStock ? '' : ' (sold out)'}`) ```
|
|
15789
|
+
|
|
15790
|
+
**checkout**(collectionId: string, input: ShopCheckoutInput) → `Promise<ShopCheckoutResult>`
|
|
15791
|
+
Start paying: the server prices the basket, holds the stock and returns Stripe's checkout page. Send the buyer to `checkoutUrl`. Signed-in buyers' orders are theirs (`shop.myOrders`). ```typescript const { checkoutUrl } = await shop.checkout(collectionId, { lines: [{ productId: 'soap', quantity: 2 }], shippingRateId: 'std', successUrl: `${location.origin}/thanks`, // ?session_id= is added cancelUrl: `${location.origin}/basket`, }) location.href = checkoutUrl ``` `DIGITAL_CONSENT_REQUIRED`, `INVALID_INPUT` (e.g. a return page on another site), `PAYMENT_UNAVAILABLE` (nothing was charged)
|
|
15792
|
+
|
|
15793
|
+
**orderBySession**(collectionId: string, sessionId: string) → `Promise<ShopBuyerOrder>`
|
|
15794
|
+
The thank-you page: the order a Stripe checkout paid for, from the `session_id` on the success URL. Its `status` is `pending-payment` for a moment while the payment is confirmed: check again shortly. `downloads` has links for bought files once it's paid.
|
|
15795
|
+
|
|
15796
|
+
**myOrders**(collectionId: string, params?: { limit?: number; offset?: number }) → `Promise<ShopPage<ShopBuyerOrder>>`
|
|
15797
|
+
The signed-in buyer's orders, newest first, with their download links. @throws `SIGN_IN_REQUIRED`
|
|
15798
|
+
|
|
15799
|
+
**formatMoney**(amount: number, currency: string, locale?: string) → `string`
|
|
15800
|
+
Format minor units as money for the person: `formatMoney(1299, 'GBP')` → "£12.99".
|
|
15801
|
+
|
|
15802
|
+
### shop.admin
|
|
15803
|
+
|
|
15804
|
+
**settings**(collectionId: string) → `Promise<ShopSettingsView>`
|
|
15805
|
+
The settings, what's still needed to take payments (`readiness`), and what SmartLinks takes (`fee`, read-only).
|
|
15806
|
+
|
|
15807
|
+
**updateSettings**(collectionId: string, patch: ShopSettingsPatch) → `Promise<ShopSettingsView>`
|
|
15808
|
+
Change settings: merged into what's stored; `shipping.rates` is replaced as a whole.
|
|
15809
|
+
|
|
15810
|
+
**connect**(collectionId: string, input: { returnUrl: string; refreshUrl: string }) → `Promise<`
|
|
15811
|
+
Connect the seller's Stripe account (a new one, set up on Stripe's own pages). Send the seller to `url`; Stripe brings them back to `returnUrl` (done or not: check `connectStatus`) or `refreshUrl` (the link ran out).
|
|
15812
|
+
|
|
15813
|
+
**connectStatus**(collectionId: string) → `Promise<ShopConnectStatus>`
|
|
15814
|
+
Whether Stripe is connected, and whether it can take payments and pay out yet.
|
|
15815
|
+
|
|
15816
|
+
**listPrices**(collectionId: string, params?: ShopPriceListParams) → `Promise<ShopPage<ShopPrice>>`
|
|
15817
|
+
Whether Stripe is connected, and whether it can take payments and pay out yet.
|
|
15818
|
+
|
|
15819
|
+
**setPrice**(collectionId: string, input: ShopPriceInput) → `Promise<ShopPrice>`
|
|
15820
|
+
Put a product (or variant) on sale, or change its price in that currency (one price per product per currency). @throws `INVALID_INPUT`, `APP_NOT_INSTALLED`
|
|
15821
|
+
|
|
15822
|
+
**updatePrice**(collectionId: string, priceId: string, changes: ShopPriceUpdate) → `Promise<ShopPrice>`
|
|
15823
|
+
Put a product (or variant) on sale, or change its price in that currency (one price per product per currency). @throws `INVALID_INPUT`, `APP_NOT_INSTALLED`
|
|
15824
|
+
|
|
15825
|
+
**removePrice**(collectionId: string, priceId: string) → `Promise<`
|
|
15826
|
+
Take it off sale for good (or set `active: false` to pause).
|
|
15827
|
+
|
|
15828
|
+
**listOrders**(collectionId: string, params?: ShopOrderListParams) → `Promise<ShopPage<ShopAdminOrder>>`
|
|
15829
|
+
Shop orders, newest first. Unpaid and expired checkouts are left out unless asked for.
|
|
15830
|
+
|
|
15831
|
+
**getOrder**(collectionId: string, orderId: string) → `Promise<ShopAdminOrder>`
|
|
15832
|
+
Shop orders, newest first. Unpaid and expired checkouts are left out unless asked for.
|
|
15833
|
+
|
|
15834
|
+
**ship**(collectionId: string, orderId: string, input: ShopShipInput = {}) → `Promise<ShopAdminOrder>`
|
|
15835
|
+
Send some or all of what's left, with tracking. The held stock leaves; the buyer's "shipped" email goes out if the shop has one. @throws `NOT_SHIPPABLE`, `NOTHING_TO_SHIP`
|
|
15836
|
+
|
|
15837
|
+
**refund**(collectionId: string, orderId: string, input: ShopRefundInput = {}) → `Promise<ShopAdminOrder>`
|
|
15838
|
+
Refund through Stripe: lines, shipping, a goodwill amount, or everything left. Unsent stock goes back; digital delivery is withdrawn. @throws `NOT_REFUNDABLE`, `NOTHING_TO_REFUND`
|
|
15839
|
+
|
|
15840
|
+
**markDelivered**(collectionId: string, orderId: string, itemId: string, input: { note?: string; reference?: string } = {}) → `Promise<ShopAdminOrder>`
|
|
15841
|
+
An app that delivers a line itself (`deliveryConfig.kind: 'app'`) says it's done.
|
|
15842
|
+
|
|
15843
|
+
**cancelCheckout**(collectionId: string, orderId: string) → `Promise<ShopAdminOrder>`
|
|
15844
|
+
Cancel a checkout that hasn't been paid (its stock is released). @throws `NOT_PENDING`
|
|
15845
|
+
|
|
15493
15846
|
### skills
|
|
15494
15847
|
|
|
15495
15848
|
**list**(collectionId: string) → `Promise<SkillsListResponse>`
|