@proveanything/smartlinks 2.2.7 → 2.2.8

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.
@@ -1,87 +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.
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
+ | `PAYMENTS_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/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.2.7";
1
+ export declare const SDK_VERSION = "2.2.8";
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.7";
2
+ export const SDK_VERSION = "2.2.8";
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.2.7 | Generated: 2026-12-04T13:31:00.283Z
3
+ Version: 2.2.8 | Generated: 2026-12-04T15:02:35.781Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
package/docs/i18n.md CHANGED
@@ -16,13 +16,17 @@ Forge's step 21 moves an app off it.
16
16
  3. **The host says which language.** Studio passes the person's own Studio language as `?lang=`, and later
17
17
  changes arrive live (`smartlinks:root-state` with `lang`). A key with no translation shows its English.
18
18
 
19
- **Where the other languages come from at run time.** Only `en.json` is in your source. The other
20
- languages are files the platform adds to the published bundle, and the SDK **downloads** the one in use
21
- (`GET <folder>/i18n/fr.json`) when the app starts or the language changes. It is a static file fetch, not
22
- an API call. `<folder>` is beside the page by default, or what you gave as `baseUrl` / `moduleUrl`. So when
23
- a key that has a translation still shows English, ask: **which `fr.json` was fetched, from where, and was it
24
- yours?** (In the browser's network list, filter on `i18n/`.) A local dev server or stand-in usually can't
25
- show this fault: there the page and the bundle are the same folder.
19
+ **Where the other languages come from at run time.** Once your app is translated, the other languages
20
+ are files beside `en.json` (`public/i18n/fr.json`, `de.json`…), in your source and in the published bundle.
21
+ They are not compiled into your code: the SDK **downloads** the one in use (`GET <folder>/i18n/fr.json`) when
22
+ the app starts or the language changes. It is a static file fetch, not an API call. `<folder>` is beside the
23
+ page by default, or what you gave as `baseUrl` / `moduleUrl`. So when a key still shows English:
24
+
25
+ 1. Look the key up in `public/i18n/<lang>.json`. Missing there: it isn't translated yet.
26
+ 2. There, but still English: the file isn't being read. Ask **which `fr.json` was fetched, from where, and
27
+ was it yours?** (In the browser's network list, filter on `i18n/`.) A local dev server or stand-in
28
+ usually can't show this fault: there the page and the bundle are the same folder. Inside Portal or Hub,
29
+ see the next section.
26
30
 
27
31
  ## Mounted inside another app's page: use `i18n.forApp`
28
32
 
@@ -54,8 +58,10 @@ export function useT() {
54
58
  instead when you know the folder exactly.
55
59
  - Don't call `i18n.init` from a container or widget: it changes the host's settings.
56
60
  - A container or widget runs on the **host's** SDK, not the one in your `package.json`. A host older than
57
- 2.2.5 has no `forApp`, and calling it there stops your whole panel. Check first and fall back to your
58
- bundled English: `typeof i18n.forApp === 'function' ? i18n.forApp(...) : <your English only>`.
61
+ 2.2.5 has no `forApp`, and one older than 2.2.1 has no `i18n` at all; calling either there stops your
62
+ whole panel. Check first and fall back to your bundled English:
63
+ `typeof i18n?.forApp === 'function' ? i18n.forApp(...) : <your English only>`, and use `i18n?.` for
64
+ anything else you read from the host's `i18n`.
59
65
  - `forApp` works for a standalone page too, so one `src/i18n.ts` can serve every way the app is shown.
60
66
 
61
67
  In an admin app, `lang` is the person's **Studio language** (buttons and labels). The site's content