@proveanything/smartlinks 2.2.6 → 2.2.7

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.
@@ -47,6 +47,7 @@ export { order } from "./order.js";
47
47
  export { app } from "./appObjects.js";
48
48
  export { bookings } from "./bookings.js";
49
49
  export { shop } from "./shop.js";
50
+ export { payments } from "./payments.js";
50
51
  export { subscriptions } from "./subscriptions.js";
51
52
  export { attestations } from "./attestations.js";
52
53
  export { containers } from "./containers.js";
package/dist/api/index.js CHANGED
@@ -50,6 +50,7 @@ export { order } from "./order.js";
50
50
  export { app } from "./appObjects.js";
51
51
  export { bookings } from "./bookings.js";
52
52
  export { shop } from "./shop.js";
53
+ export { payments } from "./payments.js";
53
54
  export { subscriptions } from "./subscriptions.js";
54
55
  export { attestations } from "./attestations.js";
55
56
  export { containers } from "./containers.js";
@@ -0,0 +1,51 @@
1
+ import type { PaymentsPublicConfig, PaymentIntentInput, PaymentIntentResult, PaymentsStatus, PaymentsConnectInput, PaymentListParams, PaymentList, PaymentDomainResult } from '../types/payments.js';
2
+ export declare namespace payments {
3
+ /**
4
+ * Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
5
+ * connected Stripe in Studio → Payments.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const cfg = await payments.config(collectionId)
10
+ * if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
11
+ * ```
12
+ */
13
+ function config(collectionId: string): Promise<PaymentsPublicConfig>;
14
+ /**
15
+ * Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
16
+ * returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
17
+ * `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
18
+ *
19
+ * The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
20
+ * use a hosted checkout (`shop.checkout`), where the server prices it.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
25
+ * const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
26
+ * // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
27
+ * ```
28
+ */
29
+ function createIntent(collectionId: string, input: PaymentIntentInput): Promise<PaymentIntentResult>;
30
+ namespace admin {
31
+ /**
32
+ * The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
33
+ * what SmartLinks takes from each.
34
+ */
35
+ function status(collectionId: string, params?: {
36
+ appIds?: string[];
37
+ }): Promise<PaymentsStatus>;
38
+ /**
39
+ * Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
40
+ * `url`. The account is made the first time; every app shares it.
41
+ */
42
+ function connect(collectionId: string, input: PaymentsConnectInput): Promise<{
43
+ url: string;
44
+ expiresAt: string;
45
+ }>;
46
+ /** An app's in-page payments on the business's account, newest first (for reconciling). */
47
+ function intents(collectionId: string, params?: PaymentListParams): Promise<PaymentList>;
48
+ /** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
49
+ function registerDomain(collectionId: string, domain: string): Promise<PaymentDomainResult>;
50
+ }
51
+ }
@@ -0,0 +1,85 @@
1
+ // src/api/payments.ts
2
+ // Payments — see docs/payments.md. A business connects ONE Stripe account (Studio → Payments) and every app
3
+ // takes money on it: no Stripe keys in apps. Pages use `payments.config` and `payments.createIntent` for
4
+ // in-page payments (Payment Element, Apple Pay, Google Pay); Studio and admin screens use `payments.admin`.
5
+ // Fixed-price sales use a hosted checkout instead: `shop.checkout`, `memberships`.
6
+ import { request, post } from '../http.js';
7
+ const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/payments`;
8
+ const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/payments`;
9
+ export var payments;
10
+ (function (payments) {
11
+ /**
12
+ * Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
13
+ * connected Stripe in Studio → Payments.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const cfg = await payments.config(collectionId)
18
+ * if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
19
+ * ```
20
+ */
21
+ async function config(collectionId) {
22
+ return request(pub(collectionId));
23
+ }
24
+ payments.config = config;
25
+ /**
26
+ * Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
27
+ * returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
28
+ * `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
29
+ *
30
+ * The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
31
+ * use a hosted checkout (`shop.checkout`), where the server prices it.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
36
+ * const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
37
+ * // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
38
+ * ```
39
+ */
40
+ async function createIntent(collectionId, input) {
41
+ return post(`${pub(collectionId)}/intent`, input);
42
+ }
43
+ payments.createIntent = createIntent;
44
+ let admin;
45
+ (function (admin) {
46
+ /**
47
+ * The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
48
+ * what SmartLinks takes from each.
49
+ */
50
+ async function status(collectionId, params) {
51
+ var _a;
52
+ const q = ((_a = params === null || params === void 0 ? void 0 : params.appIds) === null || _a === void 0 ? void 0 : _a.length) ? `?appIds=${encodeURIComponent(params.appIds.join(','))}` : '';
53
+ return request(`${adm(collectionId)}${q}`);
54
+ }
55
+ admin.status = status;
56
+ /**
57
+ * Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
58
+ * `url`. The account is made the first time; every app shares it.
59
+ */
60
+ async function connect(collectionId, input) {
61
+ return post(`${adm(collectionId)}/connect`, input);
62
+ }
63
+ admin.connect = connect;
64
+ /** An app's in-page payments on the business's account, newest first (for reconciling). */
65
+ async function intents(collectionId, params) {
66
+ const q = new URLSearchParams();
67
+ if (params === null || params === void 0 ? void 0 : params.appId)
68
+ q.set('appId', params.appId);
69
+ if (params === null || params === void 0 ? void 0 : params.since)
70
+ q.set('since', params.since);
71
+ if (params === null || params === void 0 ? void 0 : params.limit)
72
+ q.set('limit', String(params.limit));
73
+ if (params === null || params === void 0 ? void 0 : params.after)
74
+ q.set('after', params.after);
75
+ const s = q.toString();
76
+ return request(`${adm(collectionId)}/intents${s ? `?${s}` : ''}`);
77
+ }
78
+ admin.intents = intents;
79
+ /** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
80
+ async function registerDomain(collectionId, domain) {
81
+ return post(`${adm(collectionId)}/domains`, { domain });
82
+ }
83
+ admin.registerDomain = registerDomain;
84
+ })(admin = payments.admin || (payments.admin = {}));
85
+ })(payments || (payments = {}));
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.2.6 | Generated: 2026-12-04T13:25:02.911Z
3
+ Version: 2.2.7 | Generated: 2026-12-04T13:31:00.283Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -164,6 +164,7 @@ The Smartlinks SDK is organized into the following namespaces:
164
164
  - **operations** - Functions for operations operations
165
165
  - **order** - Functions for order operations
166
166
  - **partner** - Functions for partner operations
167
+ - **payments** - Functions for payments operations
167
168
  - **places** - Functions for places operations
168
169
  - **products** - Functions for products operations
169
170
  - **realtime** - Functions for realtime operations
@@ -11542,6 +11543,110 @@ interface CollectionSummaryResponse {
11542
11543
 
11543
11544
  **OrderDirection** = `'sales' | 'purchase'`
11544
11545
 
11546
+ ### payments
11547
+
11548
+ **PaymentsPublicConfig** (interface)
11549
+ ```typescript
11550
+ interface PaymentsPublicConfig {
11551
+ ready: boolean
11552
+ publishableKey: string | null
11553
+ accountId: string | null
11554
+ }
11555
+ ```
11556
+
11557
+ **PaymentIntentInput** (interface)
11558
+ ```typescript
11559
+ interface PaymentIntentInput {
11560
+ appId: string
11561
+ amount: number
11562
+ currency: string
11563
+ email?: string
11564
+ description?: string
11565
+ reference?: string
11566
+ metadata?: Record<string, string | number | boolean>
11567
+ cardOnly?: boolean
11568
+ idempotencyKey?: string
11569
+ }
11570
+ ```
11571
+
11572
+ **PaymentIntentResult** (interface)
11573
+ ```typescript
11574
+ interface PaymentIntentResult {
11575
+ paymentIntentId: string
11576
+ clientSecret: string
11577
+ publishableKey: string
11578
+ accountId: string
11579
+ amount: number
11580
+ currency: string
11581
+ fee: number
11582
+ }
11583
+ ```
11584
+
11585
+ **PaymentsStatus** (interface)
11586
+ ```typescript
11587
+ interface PaymentsStatus {
11588
+ connected: boolean
11589
+ accountId?: string
11590
+ chargesEnabled?: boolean | null
11591
+ detailsSubmitted?: boolean | null
11592
+ payoutsEnabled?: boolean | null
11593
+ platformReady: boolean
11594
+ publishableKeySet: boolean
11595
+ fees: Array<{ appId: string; bps: number; percent: number }>
11596
+ }
11597
+ ```
11598
+
11599
+ **PaymentsConnectInput** (interface)
11600
+ ```typescript
11601
+ interface PaymentsConnectInput {
11602
+ returnUrl: string
11603
+ refreshUrl: string
11604
+ country?: string
11605
+ }
11606
+ ```
11607
+
11608
+ **PaymentRecord** (interface)
11609
+ ```typescript
11610
+ interface PaymentRecord {
11611
+ id: string
11612
+ amount: number
11613
+ amountReceived: number
11614
+ currency: string
11615
+ status: string
11616
+ created: string
11617
+ email: string | null
11618
+ metadata: Record<string, string>
11619
+ }
11620
+ ```
11621
+
11622
+ **PaymentListParams** (interface)
11623
+ ```typescript
11624
+ interface PaymentListParams {
11625
+ appId?: string
11626
+ since?: string
11627
+ limit?: number
11628
+ after?: string
11629
+ }
11630
+ ```
11631
+
11632
+ **PaymentList** (interface)
11633
+ ```typescript
11634
+ interface PaymentList {
11635
+ data: PaymentRecord[]
11636
+ hasMore: boolean
11637
+ next: string | null
11638
+ }
11639
+ ```
11640
+
11641
+ **PaymentDomainResult** (interface)
11642
+ ```typescript
11643
+ interface PaymentDomainResult {
11644
+ domain: string
11645
+ applePay: string
11646
+ googlePay: string
11647
+ }
11648
+ ```
11649
+
11545
11650
  ### product
11546
11651
 
11547
11652
  **ProductKey** (interface)
@@ -16209,6 +16314,28 @@ Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (
16209
16314
  **tagAttempts**(partnerId: string, uid: string) → `Promise<ClientErrorEvent[]>`
16210
16315
  What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that failed to program or register, with the host's NFC log in context. For a chip in the partner's sets, or attempts that named one of them.
16211
16316
 
16317
+ ### payments
16318
+
16319
+ **config**(collectionId: string) → `Promise<PaymentsPublicConfig>`
16320
+ Can this business take payments, and what Stripe.js needs. `ready` is false until the business has connected Stripe in Studio → Payments. ```typescript const cfg = await payments.config(collectionId) if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! }) ```
16321
+
16322
+ **createIntent**(collectionId: string, input: PaymentIntentInput) → `Promise<PaymentIntentResult>`
16323
+ Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`). `amount` is in minor units (500 = £5.00). The app must be installed in the collection. The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price use a hosted checkout (`shop.checkout`), where the server prices it. ```typescript const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email }) const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId }) // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…) ```
16324
+
16325
+ ### payments.admin
16326
+
16327
+ **status**(collectionId: string, params?: { appIds?: string[] }) → `Promise<PaymentsStatus>`
16328
+ The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see what SmartLinks takes from each.
16329
+
16330
+ **connect**(collectionId: string, input: PaymentsConnectInput) → `Promise<`
16331
+ Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to `url`. The account is made the first time; every app shares it.
16332
+
16333
+ **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
16334
+ An app's in-page payments on the business's account, newest first (for reconciling).
16335
+
16336
+ **registerDomain**(collectionId: string, domain: string) → `Promise<PaymentDomainResult>`
16337
+ Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing).
16338
+
16212
16339
  ### places
16213
16340
 
16214
16341
  **move**(collectionId: string, params: { to: string | null; items: PlaceMoveItem[]; note?: string }) → `Promise<PlaceMoveResult>`