@proveanything/smartlinks 2.2.10 → 2.2.11

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.
@@ -90,5 +90,36 @@ let page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate',
90
90
  while (page.hasMore) page = await payments.admin.intents(collectionId, { appId: 'tap-to-donate', after: page.next! })
91
91
  ```
92
92
 
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.
93
+ ### Payment records: what Stripe says happened
94
+
95
+ SmartLinks keeps every in-page payment's true state for you, from Stripe's own events, never from the
96
+ payer's browser: one **app record of type `payment`** per payment, in your app (visibility admin,
97
+ `customId` = the Stripe payment id). Its `status` follows the money:
98
+
99
+ | status | meaning |
100
+ |---|---|
101
+ | `paid` | taken |
102
+ | `partially_refunded` / `refunded` | refunded in part / in full (from Stripe's dashboard or anywhere else) |
103
+ | `disputed` / `dispute_lost` | the payer's bank is disputing it / the dispute was lost (a won dispute goes back to `paid`) |
104
+
105
+ ```typescript
106
+ import { app, type AppPaymentRecordData } from '@proveanything/smartlinks'
107
+
108
+ const page = await app.records.list(collectionId, 'tap-to-donate', { recordType: 'payment' }, true)
109
+ for (const r of page.data) {
110
+ const p = r.data as AppPaymentRecordData // amounts in pence: p.amount, p.amountRefunded, p.fee
111
+ console.log(r.status, p.paymentIntentId, p.amount - p.amountRefunded, p.metadata.campaignId)
112
+ }
113
+ // one payment: { recordType: 'payment', customId: paymentIntentId }
114
+ ```
115
+
116
+ Keep `paymentIntentId` (from `createIntent`) on your own record (a donation, a ticket) and read its status
117
+ from the payment record. A payment with no record of yours (the page closed before you saved it) still has
118
+ its payment record: show it, so nothing is missed. Totals should use `amount - amountRefunded`.
119
+
120
+ Payments made before payment records existed, or whose events never arrived, are brought in with:
121
+
122
+ ```typescript
123
+ let r = await payments.admin.sync(collectionId, { appId: 'tap-to-donate' }) // → { checked, saved, hasMore, next }
124
+ while (r.hasMore) r = await payments.admin.sync(collectionId, { appId: 'tap-to-donate', after: r.next! })
125
+ ```
package/dist/openapi.yaml CHANGED
@@ -36649,6 +36649,70 @@ components:
36649
36649
  - data
36650
36650
  - hasMore
36651
36651
  - next
36652
+ PaymentSyncInput:
36653
+ type: object
36654
+ properties:
36655
+ appId:
36656
+ type: string
36657
+ since:
36658
+ type: string
36659
+ after:
36660
+ type: string
36661
+ PaymentSyncResult:
36662
+ type: object
36663
+ properties:
36664
+ checked:
36665
+ type: number
36666
+ saved:
36667
+ type: number
36668
+ hasMore:
36669
+ type: boolean
36670
+ next:
36671
+ type: string
36672
+ required:
36673
+ - checked
36674
+ - saved
36675
+ - hasMore
36676
+ - next
36677
+ AppPaymentRecordData:
36678
+ type: object
36679
+ properties:
36680
+ paymentIntentId:
36681
+ type: string
36682
+ amount:
36683
+ type: number
36684
+ currency:
36685
+ type: string
36686
+ amountRefunded:
36687
+ type: number
36688
+ fee:
36689
+ type: number
36690
+ email:
36691
+ type: string
36692
+ reference:
36693
+ type: string
36694
+ metadata:
36695
+ type: object
36696
+ additionalProperties:
36697
+ type: string
36698
+ paidAt:
36699
+ type: string
36700
+ refundedAt:
36701
+ type: string
36702
+ dispute:
36703
+ type: object
36704
+ additionalProperties: true
36705
+ required:
36706
+ - paymentIntentId
36707
+ - amount
36708
+ - currency
36709
+ - amountRefunded
36710
+ - fee
36711
+ - email
36712
+ - reference
36713
+ - metadata
36714
+ - paidAt
36715
+ - refundedAt
36652
36716
  PaymentDomainResult:
36653
36717
  type: object
36654
36718
  properties:
@@ -36662,6 +36726,14 @@ components:
36662
36726
  - domain
36663
36727
  - applePay
36664
36728
  - googlePay
36729
+ AppPaymentStatus:
36730
+ type: string
36731
+ enum:
36732
+ - paid
36733
+ - partially_refunded
36734
+ - refunded
36735
+ - disputed
36736
+ - dispute_lost
36665
36737
  ProductKey:
36666
36738
  type: object
36667
36739
  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`). */
@@ -93,6 +93,49 @@ export interface PaymentList {
93
93
  hasMore: boolean;
94
94
  next: string | null;
95
95
  }
96
+ export interface PaymentSyncInput {
97
+ /** Only this app's payments. */
98
+ appId?: string;
99
+ /** Only payments made on or after this date (ISO). */
100
+ since?: string;
101
+ /** Where to carry on: the `next` of the last call. */
102
+ after?: string;
103
+ }
104
+ export interface PaymentSyncResult {
105
+ /** The app payments found on this page. */
106
+ checked: number;
107
+ /** Payment records written (new or brought up to date). */
108
+ saved: number;
109
+ hasMore: boolean;
110
+ next: string | null;
111
+ }
112
+ /** A payment record's status (`record.status`), kept by SmartLinks from Stripe. */
113
+ export type AppPaymentStatus = 'paid' | 'partially_refunded' | 'refunded' | 'disputed' | 'dispute_lost';
114
+ /**
115
+ * `data` of a payment record: an app record of type `payment` (visibility admin, customId = the Stripe
116
+ * payment id), one per in-page payment, written by SmartLinks from Stripe — never by the payer's browser.
117
+ * Amounts are in minor units (pence).
118
+ */
119
+ export interface AppPaymentRecordData {
120
+ paymentIntentId: string;
121
+ amount: number;
122
+ currency: string;
123
+ amountRefunded: number;
124
+ /** What SmartLinks took (the app's fee), minor units. */
125
+ fee: number;
126
+ email: string | null;
127
+ reference: string | null;
128
+ /** The app's own metadata from `createIntent`. */
129
+ metadata: Record<string, string>;
130
+ paidAt: string;
131
+ refundedAt: string | null;
132
+ dispute?: {
133
+ status: string;
134
+ reason: string | null;
135
+ amount: number | null;
136
+ at: string;
137
+ };
138
+ }
96
139
  export interface PaymentDomainResult {
97
140
  domain: string;
98
141
  /** 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.11";
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.11";
@@ -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.11 | Generated: 2026-12-05T10:45:08.620Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -11724,6 +11724,42 @@ interface PaymentList {
11724
11724
  }
11725
11725
  ```
11726
11726
 
11727
+ **PaymentSyncInput** (interface)
11728
+ ```typescript
11729
+ interface PaymentSyncInput {
11730
+ appId?: string
11731
+ since?: string
11732
+ after?: string
11733
+ }
11734
+ ```
11735
+
11736
+ **PaymentSyncResult** (interface)
11737
+ ```typescript
11738
+ interface PaymentSyncResult {
11739
+ checked: number
11740
+ saved: number
11741
+ hasMore: boolean
11742
+ next: string | null
11743
+ }
11744
+ ```
11745
+
11746
+ **AppPaymentRecordData** (interface)
11747
+ ```typescript
11748
+ interface AppPaymentRecordData {
11749
+ paymentIntentId: string
11750
+ amount: number
11751
+ currency: string
11752
+ amountRefunded: number
11753
+ fee: number
11754
+ email: string | null
11755
+ reference: string | null
11756
+ metadata: Record<string, string>
11757
+ paidAt: string
11758
+ refundedAt: string | null
11759
+ dispute?: { status: string; reason: string | null; amount: number | null; at: string }
11760
+ }
11761
+ ```
11762
+
11727
11763
  **PaymentDomainResult** (interface)
11728
11764
  ```typescript
11729
11765
  interface PaymentDomainResult {
@@ -11733,6 +11769,8 @@ interface PaymentDomainResult {
11733
11769
  }
11734
11770
  ```
11735
11771
 
11772
+ **AppPaymentStatus** = `'paid' | 'partially_refunded' | 'refunded' | 'disputed' | 'dispute_lost'`
11773
+
11736
11774
  ### product
11737
11775
 
11738
11776
  **ProductKey** (interface)
@@ -16434,6 +16472,9 @@ Stop using the business's Stripe account. SmartLinks forgets it (apps can no lon
16434
16472
  **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
16435
16473
  An app's in-page payments on the business's account, newest first (for reconciling).
16436
16474
 
16475
+ **sync**(collectionId: string, input: PaymentSyncInput = {}) → `Promise<PaymentSyncResult>`
16476
+ 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`.
16477
+
16437
16478
  **registerDomain**(collectionId: string, domain: string) → `Promise<PaymentDomainResult>`
16438
16479
  Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing).
16439
16480