@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.
@@ -0,0 +1,87 @@
1
+ # Payments
2
+
3
+ A business connects **one** Stripe account, once, in **Studio → Payments** (Stripe Connect: Stripe's own
4
+ set-up pages, no keys to copy). Every app then takes money on that account through SmartLinks. Apps never
5
+ hold Stripe keys.
6
+
7
+ - **The business is the merchant of record**: its name on the card statement, its refunds and disputes, its
8
+ Stripe dashboard. SmartLinks never holds the money. SmartLinks may take a small fee per app (often none).
9
+ - **Money is in minor units** (pence, cents): `500` is £5.00.
10
+ - **Two ways to take a payment:**
11
+ - **Hosted checkout** for fixed prices the server knows: `shop.checkout` (docs/shop.md), memberships.
12
+ The server prices it and only Stripe's webhook marks it paid.
13
+ - **In-page payment** for pay-what-you-want moments (a donation, a tip): `payments.createIntent`, confirmed
14
+ in the page with Stripe.js (Payment Element, Apple Pay, Google Pay). The browser chooses the amount, so
15
+ don't use it for a fixed price.
16
+
17
+ ## In-page payment (React)
18
+
19
+ ```typescript
20
+ import { payments } from '@proveanything/smartlinks'
21
+ import { loadStripe } from '@stripe/stripe-js'
22
+ import { Elements, PaymentElement, useStripe, useElements } from '@stripe/react-stripe-js'
23
+
24
+ const cfg = await payments.config(collectionId)
25
+ if (!cfg.ready) {
26
+ // The business hasn't connected Stripe yet: say so, and point admins to Studio → Payments.
27
+ }
28
+
29
+ // The account id matters: the payment is made on the BUSINESS's account, not SmartLinks'.
30
+ const stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
31
+
32
+ const pi = await payments.createIntent(collectionId, {
33
+ appId: 'tap-to-donate',
34
+ amount: 500, // £5.00
35
+ currency: 'GBP',
36
+ email: donorEmail, // Stripe's receipt
37
+ reference: campaignId, // yours, kept on the payment
38
+ metadata: { proofId }, // yours, up to 15 values
39
+ })
40
+
41
+ // <Elements stripe={stripePromise} options={{ clientSecret: pi.clientSecret }}>
42
+ // <PaymentElement /> … await stripe.confirmPayment({ elements, redirect: 'if_required' })
43
+ ```
44
+
45
+ `createIntent` refuses with:
46
+
47
+ | errorCode | When |
48
+ |---|---|
49
+ | `PAYMENTS_NOT_READY` (409) | The business hasn't connected Stripe, or hasn't finished Stripe's set-up. |
50
+ | `APP_NOT_INSTALLED` (404) | The app isn't switched on in this collection. |
51
+ | `INVALID_INPUT` (400) | Amount not a whole number of minor units (30 to 5,000,000), or currency not a 3-letter code. |
52
+ | `PAYMENT_REFUSED` (400) | Stripe refused it; `errorText` is Stripe's own words (for example below its minimum). |
53
+ | `SHOP_NOT_CONFIGURED` (503) | This server has no Stripe platform keys yet. |
54
+
55
+ ### Apple Pay and Google Pay on your own domain
56
+
57
+ They work on smartlinks.app as they are. On a site's own domain, register it once for the business's account:
58
+
59
+ ```typescript
60
+ await payments.admin.registerDomain(collectionId, 'donate.example.org') // → { applePay: 'active', … }
61
+ ```
62
+
63
+ ## Admin: the business's account
64
+
65
+ ```typescript
66
+ const s = await payments.admin.status(collectionId, { appIds: ['tap-to-donate', 'shop'] })
67
+ // { connected, chargesEnabled, payoutsEnabled, detailsSubmitted, fees: [{ appId, percent }] }
68
+
69
+ const { url } = await payments.admin.connect(collectionId, {
70
+ returnUrl: location.href, // back here when done (or stopped): read status again
71
+ refreshUrl: location.href, // the link ran out: make another
72
+ })
73
+ location.href = url
74
+ ```
75
+
76
+ `shop.admin.connect` does the same thing: there is one account per business, whichever app connects it.
77
+
78
+ ### Reconciling an app's payments
79
+
80
+ ```typescript
81
+ let page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate', since: '2026-12-01' })
82
+ // page.data: [{ id, amount, status: 'succeeded', created, email, metadata }]
83
+ while (page.hasMore) page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate', after: page.next! })
84
+ ```
85
+
86
+ Recording a payment is still the app's job (for example an app record after `confirmPayment` succeeds);
87
+ reconciling finds the ones a closed browser never recorded.
package/dist/openapi.yaml CHANGED
@@ -36239,6 +36239,180 @@ components:
36239
36239
  enum:
36240
36240
  - sales
36241
36241
  - purchase
36242
+ PaymentsPublicConfig:
36243
+ type: object
36244
+ properties:
36245
+ ready:
36246
+ type: boolean
36247
+ publishableKey:
36248
+ type: string
36249
+ accountId:
36250
+ type: string
36251
+ required:
36252
+ - ready
36253
+ - publishableKey
36254
+ - accountId
36255
+ PaymentIntentInput:
36256
+ type: object
36257
+ properties:
36258
+ appId:
36259
+ type: string
36260
+ amount:
36261
+ type: number
36262
+ currency:
36263
+ type: string
36264
+ email:
36265
+ type: string
36266
+ description:
36267
+ type: string
36268
+ reference:
36269
+ type: string
36270
+ metadata:
36271
+ type: object
36272
+ additionalProperties:
36273
+ type: object
36274
+ additionalProperties: true
36275
+ cardOnly:
36276
+ type: boolean
36277
+ idempotencyKey:
36278
+ type: string
36279
+ required:
36280
+ - appId
36281
+ - amount
36282
+ - currency
36283
+ PaymentIntentResult:
36284
+ type: object
36285
+ properties:
36286
+ paymentIntentId:
36287
+ type: string
36288
+ clientSecret:
36289
+ type: string
36290
+ publishableKey:
36291
+ type: string
36292
+ accountId:
36293
+ type: string
36294
+ amount:
36295
+ type: number
36296
+ currency:
36297
+ type: string
36298
+ fee:
36299
+ type: number
36300
+ required:
36301
+ - paymentIntentId
36302
+ - clientSecret
36303
+ - publishableKey
36304
+ - accountId
36305
+ - amount
36306
+ - currency
36307
+ - fee
36308
+ PaymentsStatus:
36309
+ type: object
36310
+ properties:
36311
+ connected:
36312
+ type: boolean
36313
+ accountId:
36314
+ type: string
36315
+ chargesEnabled:
36316
+ type: boolean
36317
+ detailsSubmitted:
36318
+ type: boolean
36319
+ payoutsEnabled:
36320
+ type: boolean
36321
+ platformReady:
36322
+ type: boolean
36323
+ publishableKeySet:
36324
+ type: boolean
36325
+ fees:
36326
+ type: array
36327
+ items:
36328
+ type: object
36329
+ additionalProperties: true
36330
+ required:
36331
+ - connected
36332
+ - platformReady
36333
+ - publishableKeySet
36334
+ - fees
36335
+ PaymentsConnectInput:
36336
+ type: object
36337
+ properties:
36338
+ returnUrl:
36339
+ type: string
36340
+ refreshUrl:
36341
+ type: string
36342
+ country:
36343
+ type: string
36344
+ required:
36345
+ - returnUrl
36346
+ - refreshUrl
36347
+ PaymentRecord:
36348
+ type: object
36349
+ properties:
36350
+ id:
36351
+ type: string
36352
+ amount:
36353
+ type: number
36354
+ amountReceived:
36355
+ type: number
36356
+ currency:
36357
+ type: string
36358
+ status:
36359
+ type: string
36360
+ created:
36361
+ type: string
36362
+ email:
36363
+ type: string
36364
+ metadata:
36365
+ type: object
36366
+ additionalProperties:
36367
+ type: string
36368
+ required:
36369
+ - id
36370
+ - amount
36371
+ - amountReceived
36372
+ - currency
36373
+ - status
36374
+ - created
36375
+ - email
36376
+ - metadata
36377
+ PaymentListParams:
36378
+ type: object
36379
+ properties:
36380
+ appId:
36381
+ type: string
36382
+ since:
36383
+ type: string
36384
+ limit:
36385
+ type: number
36386
+ after:
36387
+ type: string
36388
+ PaymentList:
36389
+ type: object
36390
+ properties:
36391
+ data:
36392
+ type: array
36393
+ items:
36394
+ $ref: "#/components/schemas/PaymentRecord"
36395
+ hasMore:
36396
+ type: boolean
36397
+ next:
36398
+ type: string
36399
+ required:
36400
+ - data
36401
+ - hasMore
36402
+ - next
36403
+ PaymentDomainResult:
36404
+ type: object
36405
+ properties:
36406
+ domain:
36407
+ type: string
36408
+ applePay:
36409
+ type: string
36410
+ googlePay:
36411
+ type: string
36412
+ required:
36413
+ - domain
36414
+ - applePay
36415
+ - googlePay
36242
36416
  ProductKey:
36243
36417
  type: object
36244
36418
  properties:
@@ -45,6 +45,7 @@ export * from "./appManifest.js";
45
45
  export * from "./appObjects.js";
46
46
  export * from "./bookings.js";
47
47
  export * from "./shop.js";
48
+ export * from "./payments.js";
48
49
  export * from "./subscriptions.js";
49
50
  export * from "./loyalty.js";
50
51
  export * from "./translations.js";
@@ -47,6 +47,7 @@ export * from "./appManifest.js";
47
47
  export * from "./appObjects.js";
48
48
  export * from "./bookings.js";
49
49
  export * from "./shop.js";
50
+ export * from "./payments.js";
50
51
  export * from "./subscriptions.js";
51
52
  export * from "./loyalty.js";
52
53
  export * from "./translations.js";
@@ -0,0 +1,101 @@
1
+ /** What a page needs before it shows a payment form. */
2
+ export interface PaymentsPublicConfig {
3
+ /** True when the business has connected Stripe and this server can take payments. */
4
+ ready: boolean;
5
+ /** SmartLinks' Stripe publishable key: `loadStripe(publishableKey, { stripeAccount: accountId })`. */
6
+ publishableKey: string | null;
7
+ /** The business's connected Stripe account. */
8
+ accountId: string | null;
9
+ }
10
+ export interface PaymentIntentInput {
11
+ /** The app taking the payment. It must be installed and switched on in the collection. */
12
+ appId: string;
13
+ /** Minor units (pence, cents), a whole number: 500 = £5.00. */
14
+ amount: number;
15
+ /** Three-letter code: 'GBP'. */
16
+ currency: string;
17
+ /** Stripe emails its receipt here. */
18
+ email?: string;
19
+ /** Shown in the business's Stripe dashboard and on Stripe's receipt. */
20
+ description?: string;
21
+ /** Your own reference (a campaign, a ticket batch), kept on the payment as metadata.reference. */
22
+ reference?: string;
23
+ /** Up to 15 of your own values (strings or numbers), kept on the payment. `kind`, `collectionId`, `appId` and `reference` are ours. */
24
+ metadata?: Record<string, string | number | boolean>;
25
+ /** Card only (no Link, no other methods). Apple Pay and Google Pay are cards. */
26
+ cardOnly?: boolean;
27
+ /** The same key twice gives the same payment, not a second one. */
28
+ idempotencyKey?: string;
29
+ }
30
+ export interface PaymentIntentResult {
31
+ paymentIntentId: string;
32
+ /** Pass to Stripe Elements (`elements({ clientSecret })`) or `stripe.confirmPayment`. */
33
+ clientSecret: string;
34
+ publishableKey: string;
35
+ accountId: string;
36
+ amount: number;
37
+ currency: string;
38
+ /** What SmartLinks takes from this payment for this app (minor units). Often 0. */
39
+ fee: number;
40
+ }
41
+ /** The business's payments account, as Studio → Payments shows it. */
42
+ export interface PaymentsStatus {
43
+ connected: boolean;
44
+ accountId?: string;
45
+ /** Stripe can take payments for this business. Null when this server can't ask Stripe. */
46
+ chargesEnabled?: boolean | null;
47
+ /** The business has given Stripe all it asked for. */
48
+ detailsSubmitted?: boolean | null;
49
+ /** Stripe can pay money out to the business's bank. */
50
+ payoutsEnabled?: boolean | null;
51
+ /** This server has SmartLinks' Stripe platform key. */
52
+ platformReady: boolean;
53
+ /** This server can give pages the publishable key (in-page payments). */
54
+ publishableKeySet: boolean;
55
+ /** What SmartLinks takes from each app asked about (`appIds`). */
56
+ fees: Array<{
57
+ appId: string;
58
+ bps: number;
59
+ percent: number;
60
+ }>;
61
+ }
62
+ export interface PaymentsConnectInput {
63
+ /** Where Stripe sends the person back when they finish (or stop): check `payments.admin.status`. */
64
+ returnUrl: string;
65
+ /** Where Stripe sends them if the link ran out: make a new link there. */
66
+ refreshUrl: string;
67
+ /** Two-letter country for a new account ('GB' unless you say). */
68
+ country?: string;
69
+ }
70
+ /** One payment on the business's account. */
71
+ export interface PaymentRecord {
72
+ id: string;
73
+ amount: number;
74
+ amountReceived: number;
75
+ currency: string;
76
+ /** Stripe's status: 'succeeded', 'requires_payment_method', 'processing', 'canceled', … */
77
+ status: string;
78
+ created: string;
79
+ email: string | null;
80
+ metadata: Record<string, string>;
81
+ }
82
+ export interface PaymentListParams {
83
+ appId?: string;
84
+ /** ISO date: only payments made since. */
85
+ since?: string;
86
+ /** Up to 500 (100 unless you say). */
87
+ limit?: number;
88
+ /** The `next` of the previous page. */
89
+ after?: string;
90
+ }
91
+ export interface PaymentList {
92
+ data: PaymentRecord[];
93
+ hasMore: boolean;
94
+ next: string | null;
95
+ }
96
+ export interface PaymentDomainResult {
97
+ domain: string;
98
+ /** Stripe's status for Apple Pay on the domain: 'active', 'inactive', … */
99
+ applePay: string;
100
+ googlePay: string;
101
+ }
@@ -0,0 +1,5 @@
1
+ // src/types/payments.ts
2
+ // Payments: the business's one Stripe Connect account, and in-page payments for any app. See docs/payments.md.
3
+ //
4
+ // Money is always a whole number of MINOR units (pence, cents): 500 = £5.00.
5
+ export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.2.6";
1
+ export declare const SDK_VERSION = "2.2.7";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/write-version.mjs from package.json. Do not edit.
2
- export const SDK_VERSION = "2.2.6";
2
+ export const SDK_VERSION = "2.2.7";
@@ -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>`