@proveanything/smartlinks 2.2.10 → 2.2.12

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.
@@ -82,6 +82,23 @@ await payments.admin.disconnect(collectionId) // → { connected: false, discon
82
82
  Disconnecting stops every app taking payments until an account is connected again. SmartLinks forgets the
83
83
  account; the Stripe account stays the business's own, with its payments. Connecting again makes a new one.
84
84
 
85
+ ### Asking someone else to set it up
86
+
87
+ Often the person with the business's Stripe login isn't the one in Studio: the finance team, or the client
88
+ a business was built for. Email them a link instead of giving them a login:
89
+
90
+ ```typescript
91
+ await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam', note: 'For the donations page' })
92
+ // status(…).setupRequest → { email, status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported', stripeAccountName, … }
93
+ await payments.admin.cancelSetupRequest(collectionId) // the link stops working
94
+ ```
95
+
96
+ SmartLinks sends the email. Its link opens a SmartLinks page that only starts Stripe's set-up for this
97
+ business, with no login. It works for 7 days, and a new request replaces it. It can't be used once payments
98
+ are set up, and `requestSetup` is refused then (409 `ALREADY_CONNECTED`): disconnect first. The admin who
99
+ sent it is emailed when it's done, naming the Stripe account now taking the money, or if the person says
100
+ they weren't expecting it (which cancels it).
101
+
85
102
  ### Reconciling an app's payments
86
103
 
87
104
  ```typescript
@@ -90,5 +107,36 @@ let page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate',
90
107
  while (page.hasMore) page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate', after: page.next! })
91
108
  ```
92
109
 
93
- Recording a payment is still the app's job (for example an app record after `confirmPayment` succeeds);
94
- reconciling finds the ones a closed browser never recorded.
110
+ ### Payment records: what Stripe says happened
111
+
112
+ SmartLinks keeps every in-page payment's true state for you, from Stripe's own events, never from the
113
+ payer's browser: one **app record of type `payment`** per payment, in your app (visibility admin,
114
+ `customId` = the Stripe payment id). Its `status` follows the money:
115
+
116
+ | status | meaning |
117
+ |---|---|
118
+ | `paid` | taken |
119
+ | `partially_refunded` / `refunded` | refunded in part / in full (from Stripe's dashboard or anywhere else) |
120
+ | `disputed` / `dispute_lost` | the payer's bank is disputing it / the dispute was lost (a won dispute goes back to `paid`) |
121
+
122
+ ```typescript
123
+ import { app, type AppPaymentRecordData } from '@proveanything/smartlinks'
124
+
125
+ const page = await app.records.list(collectionId, 'tap-to-donate', { recordType: 'payment' }, true)
126
+ for (const r of page.data) {
127
+ const p = r.data as AppPaymentRecordData // amounts in pence: p.amount, p.amountRefunded, p.fee
128
+ console.log(r.status, p.paymentIntentId, p.amount - p.amountRefunded, p.metadata.campaignId)
129
+ }
130
+ // one payment: { recordType: 'payment', customId: paymentIntentId }
131
+ ```
132
+
133
+ Keep `paymentIntentId` (from `createIntent`) on your own record (a donation, a ticket) and read its status
134
+ from the payment record. A payment with no record of yours (the page closed before you saved it) still has
135
+ its payment record: show it, so nothing is missed. Totals should use `amount - amountRefunded`.
136
+
137
+ Payments made before payment records existed, or whose events never arrived, are brought in with:
138
+
139
+ ```typescript
140
+ let r = await payments.admin.sync(collectionId, { appId: 'tap-to-donate' }) // → { checked, saved, hasMore, next }
141
+ while (r.hasMore) r = await payments.admin.sync(collectionId, { appId: 'tap-to-donate', after: r.next! })
142
+ ```
package/dist/openapi.yaml CHANGED
@@ -36561,6 +36561,8 @@ components:
36561
36561
  type: boolean
36562
36562
  accountId:
36563
36563
  type: string
36564
+ name:
36565
+ type: string
36564
36566
  chargesEnabled:
36565
36567
  type: boolean
36566
36568
  detailsSubmitted:
@@ -36576,11 +36578,70 @@ components:
36576
36578
  items:
36577
36579
  type: object
36578
36580
  additionalProperties: true
36581
+ setupRequest:
36582
+ $ref: "#/components/schemas/PaymentSetupRequest"
36579
36583
  required:
36580
36584
  - connected
36581
36585
  - platformReady
36582
36586
  - publishableKeySet
36583
36587
  - fees
36588
+ PaymentSetupRequest:
36589
+ type: object
36590
+ properties:
36591
+ id:
36592
+ type: string
36593
+ email:
36594
+ type: string
36595
+ name:
36596
+ type: string
36597
+ note:
36598
+ type: string
36599
+ sentByEmail:
36600
+ type: string
36601
+ sentByName:
36602
+ type: string
36603
+ sentAt:
36604
+ type: string
36605
+ expiresAt:
36606
+ type: string
36607
+ status:
36608
+ type: string
36609
+ enum:
36610
+ - pending
36611
+ - expired
36612
+ - done
36613
+ - cancelled
36614
+ - reported
36615
+ startedAt:
36616
+ type: string
36617
+ finishedAt:
36618
+ type: string
36619
+ stripeAccountName:
36620
+ type: string
36621
+ required:
36622
+ - id
36623
+ - email
36624
+ - name
36625
+ - note
36626
+ - sentByEmail
36627
+ - sentByName
36628
+ - sentAt
36629
+ - expiresAt
36630
+ - status
36631
+ - startedAt
36632
+ - finishedAt
36633
+ - stripeAccountName
36634
+ PaymentSetupRequestInput:
36635
+ type: object
36636
+ properties:
36637
+ email:
36638
+ type: string
36639
+ name:
36640
+ type: string
36641
+ note:
36642
+ type: string
36643
+ required:
36644
+ - email
36584
36645
  PaymentsConnectInput:
36585
36646
  type: object
36586
36647
  properties:
@@ -36649,6 +36710,70 @@ components:
36649
36710
  - data
36650
36711
  - hasMore
36651
36712
  - next
36713
+ PaymentSyncInput:
36714
+ type: object
36715
+ properties:
36716
+ appId:
36717
+ type: string
36718
+ since:
36719
+ type: string
36720
+ after:
36721
+ type: string
36722
+ PaymentSyncResult:
36723
+ type: object
36724
+ properties:
36725
+ checked:
36726
+ type: number
36727
+ saved:
36728
+ type: number
36729
+ hasMore:
36730
+ type: boolean
36731
+ next:
36732
+ type: string
36733
+ required:
36734
+ - checked
36735
+ - saved
36736
+ - hasMore
36737
+ - next
36738
+ AppPaymentRecordData:
36739
+ type: object
36740
+ properties:
36741
+ paymentIntentId:
36742
+ type: string
36743
+ amount:
36744
+ type: number
36745
+ currency:
36746
+ type: string
36747
+ amountRefunded:
36748
+ type: number
36749
+ fee:
36750
+ type: number
36751
+ email:
36752
+ type: string
36753
+ reference:
36754
+ type: string
36755
+ metadata:
36756
+ type: object
36757
+ additionalProperties:
36758
+ type: string
36759
+ paidAt:
36760
+ type: string
36761
+ refundedAt:
36762
+ type: string
36763
+ dispute:
36764
+ type: object
36765
+ additionalProperties: true
36766
+ required:
36767
+ - paymentIntentId
36768
+ - amount
36769
+ - currency
36770
+ - amountRefunded
36771
+ - fee
36772
+ - email
36773
+ - reference
36774
+ - metadata
36775
+ - paidAt
36776
+ - refundedAt
36652
36777
  PaymentDomainResult:
36653
36778
  type: object
36654
36779
  properties:
@@ -36662,6 +36787,14 @@ components:
36662
36787
  - domain
36663
36788
  - applePay
36664
36789
  - googlePay
36790
+ AppPaymentStatus:
36791
+ type: string
36792
+ enum:
36793
+ - paid
36794
+ - partially_refunded
36795
+ - refunded
36796
+ - disputed
36797
+ - dispute_lost
36665
36798
  ProductKey:
36666
36799
  type: object
36667
36800
  properties:
@@ -369,7 +369,10 @@ export interface BookingPrice {
369
369
  }
370
370
  /** The app's `bookingPayments` config (sites/{collectionId}/apps/{appId}), written by admins only. */
371
371
  export interface BookingPaymentsConfig {
372
- /** Close the free way in: a plain create of a priced booking fails with PAYMENT_REQUIRED. */
372
+ /**
373
+ * true: close the free way in (a plain create of a priced booking fails with PAYMENT_REQUIRED).
374
+ * false, set explicitly: payment switched off; checkout books for free. Unset: checkout charges priced bookings.
375
+ */
373
376
  required?: boolean;
374
377
  currency?: string;
375
378
  /** Appointments' price list (slots carry their own `data.prices`). */
@@ -42,6 +42,8 @@ export interface PaymentIntentResult {
42
42
  export interface PaymentsStatus {
43
43
  connected: boolean;
44
44
  accountId?: string;
45
+ /** The connected Stripe account's business name, when Stripe has one. */
46
+ name?: string | null;
45
47
  /** Stripe can take payments for this business. Null when this server can't ask Stripe. */
46
48
  chargesEnabled?: boolean | null;
47
49
  /** The business has given Stripe all it asked for. */
@@ -58,6 +60,39 @@ export interface PaymentsStatus {
58
60
  bps: number;
59
61
  percent: number;
60
62
  }>;
63
+ /** The latest request for someone else to set up payments (`payments.admin.requestSetup`), if any. */
64
+ setupRequest?: PaymentSetupRequest | null;
65
+ }
66
+ /**
67
+ * A request for someone outside Studio (the finance team, the client) to connect the business's Stripe
68
+ * account. They get an email from SmartLinks with a link that works for 7 days and needs no login.
69
+ *
70
+ * status: `pending` (waiting), `expired`, `done` (connected; `stripeAccountName` is the account they chose),
71
+ * `cancelled` (by an admin, a newer request, or payments set up another way), `reported` (the person said
72
+ * they weren't expecting it).
73
+ */
74
+ export interface PaymentSetupRequest {
75
+ id: string;
76
+ email: string;
77
+ name: string | null;
78
+ note: string | null;
79
+ sentByEmail: string | null;
80
+ sentByName: string | null;
81
+ sentAt: string;
82
+ expiresAt: string;
83
+ status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported';
84
+ /** When they first went on to Stripe. */
85
+ startedAt: string | null;
86
+ finishedAt: string | null;
87
+ stripeAccountName: string | null;
88
+ }
89
+ export interface PaymentSetupRequestInput {
90
+ /** Who will set up payments. */
91
+ email: string;
92
+ /** Their name, for the email's greeting. */
93
+ name?: string;
94
+ /** A short note shown in the email and on the set-up page (up to 500 characters). */
95
+ note?: string;
61
96
  }
62
97
  export interface PaymentsConnectInput {
63
98
  /** Where Stripe sends the person back when they finish (or stop): check `payments.admin.status`. */
@@ -93,6 +128,49 @@ export interface PaymentList {
93
128
  hasMore: boolean;
94
129
  next: string | null;
95
130
  }
131
+ export interface PaymentSyncInput {
132
+ /** Only this app's payments. */
133
+ appId?: string;
134
+ /** Only payments made on or after this date (ISO). */
135
+ since?: string;
136
+ /** Where to carry on: the `next` of the last call. */
137
+ after?: string;
138
+ }
139
+ export interface PaymentSyncResult {
140
+ /** The app payments found on this page. */
141
+ checked: number;
142
+ /** Payment records written (new or brought up to date). */
143
+ saved: number;
144
+ hasMore: boolean;
145
+ next: string | null;
146
+ }
147
+ /** A payment record's status (`record.status`), kept by SmartLinks from Stripe. */
148
+ export type AppPaymentStatus = 'paid' | 'partially_refunded' | 'refunded' | 'disputed' | 'dispute_lost';
149
+ /**
150
+ * `data` of a payment record: an app record of type `payment` (visibility admin, customId = the Stripe
151
+ * payment id), one per in-page payment, written by SmartLinks from Stripe — never by the payer's browser.
152
+ * Amounts are in minor units (pence).
153
+ */
154
+ export interface AppPaymentRecordData {
155
+ paymentIntentId: string;
156
+ amount: number;
157
+ currency: string;
158
+ amountRefunded: number;
159
+ /** What SmartLinks took (the app's fee), minor units. */
160
+ fee: number;
161
+ email: string | null;
162
+ reference: string | null;
163
+ /** The app's own metadata from `createIntent`. */
164
+ metadata: Record<string, string>;
165
+ paidAt: string;
166
+ refundedAt: string | null;
167
+ dispute?: {
168
+ status: string;
169
+ reason: string | null;
170
+ amount: number | null;
171
+ at: string;
172
+ };
173
+ }
96
174
  export interface PaymentDomainResult {
97
175
  domain: string;
98
176
  /** Stripe's status for Apple Pay on the domain: 'active', 'inactive', … */
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.2.10";
1
+ export declare const SDK_VERSION = "2.2.12";
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.10";
2
+ export const SDK_VERSION = "2.2.12";
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.2.10 | Generated: 2026-12-04T20:36:14.716Z
3
+ Version: 2.2.12 | Generated: 2026-12-05T13:57:29.945Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -11673,12 +11673,41 @@ interface PaymentIntentResult {
11673
11673
  interface PaymentsStatus {
11674
11674
  connected: boolean
11675
11675
  accountId?: string
11676
+ name?: string | null
11676
11677
  chargesEnabled?: boolean | null
11677
11678
  detailsSubmitted?: boolean | null
11678
11679
  payoutsEnabled?: boolean | null
11679
11680
  platformReady: boolean
11680
11681
  publishableKeySet: boolean
11681
11682
  fees: Array<{ appId: string; bps: number; percent: number }>
11683
+ setupRequest?: PaymentSetupRequest | null
11684
+ }
11685
+ ```
11686
+
11687
+ **PaymentSetupRequest** (interface)
11688
+ ```typescript
11689
+ interface PaymentSetupRequest {
11690
+ id: string
11691
+ email: string
11692
+ name: string | null
11693
+ note: string | null
11694
+ sentByEmail: string | null
11695
+ sentByName: string | null
11696
+ sentAt: string
11697
+ expiresAt: string
11698
+ status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported'
11699
+ startedAt: string | null
11700
+ finishedAt: string | null
11701
+ stripeAccountName: string | null
11702
+ }
11703
+ ```
11704
+
11705
+ **PaymentSetupRequestInput** (interface)
11706
+ ```typescript
11707
+ interface PaymentSetupRequestInput {
11708
+ email: string
11709
+ name?: string
11710
+ note?: string
11682
11711
  }
11683
11712
  ```
11684
11713
 
@@ -11724,6 +11753,42 @@ interface PaymentList {
11724
11753
  }
11725
11754
  ```
11726
11755
 
11756
+ **PaymentSyncInput** (interface)
11757
+ ```typescript
11758
+ interface PaymentSyncInput {
11759
+ appId?: string
11760
+ since?: string
11761
+ after?: string
11762
+ }
11763
+ ```
11764
+
11765
+ **PaymentSyncResult** (interface)
11766
+ ```typescript
11767
+ interface PaymentSyncResult {
11768
+ checked: number
11769
+ saved: number
11770
+ hasMore: boolean
11771
+ next: string | null
11772
+ }
11773
+ ```
11774
+
11775
+ **AppPaymentRecordData** (interface)
11776
+ ```typescript
11777
+ interface AppPaymentRecordData {
11778
+ paymentIntentId: string
11779
+ amount: number
11780
+ currency: string
11781
+ amountRefunded: number
11782
+ fee: number
11783
+ email: string | null
11784
+ reference: string | null
11785
+ metadata: Record<string, string>
11786
+ paidAt: string
11787
+ refundedAt: string | null
11788
+ dispute?: { status: string; reason: string | null; amount: number | null; at: string }
11789
+ }
11790
+ ```
11791
+
11727
11792
  **PaymentDomainResult** (interface)
11728
11793
  ```typescript
11729
11794
  interface PaymentDomainResult {
@@ -11733,6 +11798,8 @@ interface PaymentDomainResult {
11733
11798
  }
11734
11799
  ```
11735
11800
 
11801
+ **AppPaymentStatus** = `'paid' | 'partially_refunded' | 'refunded' | 'disputed' | 'dispute_lost'`
11802
+
11736
11803
  ### product
11737
11804
 
11738
11805
  **ProductKey** (interface)
@@ -16431,9 +16498,18 @@ Stripe's page to connect (or finish connecting) the business's Stripe account. S
16431
16498
  **disconnect**(collectionId: string) → `Promise<`
16432
16499
  Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments until one is connected again); the Stripe account itself stays the business's own, with the payments already in it. Connecting again makes a new account.
16433
16500
 
16501
+ **requestSetup**(collectionId: string, input: PaymentSetupRequestInput) → `Promise<PaymentSetupRequest>`
16502
+ Ask someone outside Studio (the finance team, the client a business was built for) to connect the business's Stripe account. SmartLinks emails them a link to a page that starts Stripe's set-up: no SmartLinks login, nothing else in reach. The link works for 7 days; a new request replaces it. The admin who sent it is emailed when it's done (naming the Stripe account) or if the person wasn't expecting it. Refused (409 ALREADY_CONNECTED) once payments are set up: disconnect first. ```typescript await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam' }) ```
16503
+
16504
+ **cancelSetupRequest**(collectionId: string) → `Promise<PaymentSetupRequest | null>`
16505
+ Cancel the waiting set-up request: its link stops working. → the request, or null when there was none.
16506
+
16434
16507
  **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
16435
16508
  An app's in-page payments on the business's account, newest first (for reconciling).
16436
16509
 
16510
+ **sync**(collectionId: string, input: PaymentSyncInput = {}) → `Promise<PaymentSyncResult>`
16511
+ Bring the app's payment records up to date from Stripe (payments made before payment records existed, or whose events never arrived). One Stripe page per call; call again with `next` while `hasMore`. The records are app records of type `payment`: read them with `app.records.list`.
16512
+
16437
16513
  **registerDomain**(collectionId: string, domain: string) → `Promise<PaymentDomainResult>`
16438
16514
  Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing).
16439
16515