@openrails/billing-ui 0.281.0 → 0.283.0
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.
- package/README.md +108 -364
- package/dist/account/format.d.ts +6 -2
- package/dist/admin/context.d.ts +38 -46
- package/dist/admin/lib/api/endpoints.d.ts +4 -4
- package/dist/admin/lib/api/index.d.ts +4 -4
- package/dist/admin/lib/api/metrics.d.ts +15 -6
- package/dist/admin/lib/capabilities.d.ts +2 -0
- package/dist/admin/lib/duration.d.ts +4 -0
- package/dist/admin/lib/format.d.ts +29 -1
- package/dist/admin/lib/mutations.d.ts +0 -10
- package/dist/admin/lib/queries.d.ts +16 -10
- package/dist/admin/messages.d.ts +61 -20
- package/dist/admin/pages/catalog/price-wizard-logic.d.ts +2 -0
- package/dist/admin/pages/catalog/price-wizard.d.ts +1 -3
- package/dist/admin/pages/customers/credits.d.ts +4 -1
- package/dist/admin/pages/dashboard/levels.d.ts +8 -0
- package/dist/admin/pages/dashboard/lib.d.ts +16 -7
- package/dist/admin/pages/dashboard/programs.d.ts +3 -0
- package/dist/admin/pages/dashboard/query-builder.d.ts +20 -0
- package/dist/admin/pages/dashboard/range.d.ts +8 -2
- package/dist/admin/pages/dashboard/registry.d.ts +14 -0
- package/dist/admin/pages/dashboard/reports-model.d.ts +8 -4
- package/dist/admin/pages/dashboard/reports.d.ts +1 -1
- package/dist/admin/pages/dashboard/units.d.ts +5 -0
- package/dist/admin/pages/dashboard/use-range.d.ts +5 -1
- package/dist/admin/pages/dashboard/widget-editor.d.ts +7 -2
- package/dist/admin/pages/dashboard/widget-tile.d.ts +10 -4
- package/dist/admin/pages/dashboard/widget-viz.d.ts +10 -5
- package/dist/admin/pages/ops/signals.d.ts +4 -0
- package/dist/admin/pages/payments/attempts.d.ts +2 -2
- package/dist/admin/pages/payments/health-model.d.ts +20 -20
- package/dist/admin/pages/subscriptions/views.d.ts +4 -0
- package/dist/admin-attempts-CRkxeVfQ.js +417 -0
- package/dist/admin-attempts-CRkxeVfQ.js.map +1 -0
- package/dist/{admin-auth-BUUdvmqC.js → admin-auth-C0pBH3kp.js} +2 -2
- package/dist/{admin-auth-BUUdvmqC.js.map → admin-auth-C0pBH3kp.js.map} +1 -1
- package/dist/{admin-badge-CAlUmS2s.js → admin-badge-C_-j7ANF.js} +2 -2
- package/dist/{admin-badge-CAlUmS2s.js.map → admin-badge-C_-j7ANF.js.map} +1 -1
- package/dist/{admin-button-Bn4otsuw.js → admin-button-BV5MAL2H.js} +2 -2
- package/dist/{admin-button-Bn4otsuw.js.map → admin-button-BV5MAL2H.js.map} +1 -1
- package/dist/{admin-capabilities-DS-X-__V.js → admin-capabilities-B3ZfkA49.js} +21 -13
- package/dist/admin-capabilities-B3ZfkA49.js.map +1 -0
- package/dist/{admin-card-BHKW1dfB.js → admin-card-DQ61c-kV.js} +2 -2
- package/dist/{admin-card-BHKW1dfB.js.map → admin-card-DQ61c-kV.js.map} +1 -1
- package/dist/admin-catalog-DAnsClai.js +867 -0
- package/dist/admin-catalog-DAnsClai.js.map +1 -0
- package/dist/{admin-cursor-pager-Qo9Sq6lN.js → admin-cursor-pager-dkNj-gb6.js} +22 -22
- package/dist/{admin-cursor-pager-Qo9Sq6lN.js.map → admin-cursor-pager-dkNj-gb6.js.map} +1 -1
- package/dist/admin-customer-search-DDMn_5Us.js +115 -0
- package/dist/admin-customer-search-DDMn_5Us.js.map +1 -0
- package/dist/{admin-customers-BZP6Jv-i.js → admin-customers-BMaugwpg.js} +24 -25
- package/dist/admin-customers-BMaugwpg.js.map +1 -0
- package/dist/admin-dashboard-DbbfrIOq.js +510 -0
- package/dist/admin-dashboard-DbbfrIOq.js.map +1 -0
- package/dist/{admin-data-table-BiFmcf0Z.js → admin-data-table-BjA8cBsr.js} +5 -5
- package/dist/{admin-data-table-BiFmcf0Z.js.map → admin-data-table-BjA8cBsr.js.map} +1 -1
- package/dist/admin-detail-BVJcnTO-.js +1361 -0
- package/dist/admin-detail-BVJcnTO-.js.map +1 -0
- package/dist/{admin-detail-cijme9Lc.js → admin-detail-DO9wd12I.js} +130 -107
- package/dist/admin-detail-DO9wd12I.js.map +1 -0
- package/dist/{admin-detail-CQws8363.js → admin-detail-M7YFYOGN.js} +211 -210
- package/dist/{admin-detail-CQws8363.js.map → admin-detail-M7YFYOGN.js.map} +1 -1
- package/dist/admin-detail-sOLj-K-Y.js +336 -0
- package/dist/{admin-detail-NApy5bio.js.map → admin-detail-sOLj-K-Y.js.map} +1 -1
- package/dist/admin-detail-uZ-eR2TT.js +292 -0
- package/dist/{admin-detail-C6VH3i2v.js.map → admin-detail-uZ-eR2TT.js.map} +1 -1
- package/dist/{admin-dialog-CgYGInHi.js → admin-dialog-BxRcYcQM.js} +3 -3
- package/dist/{admin-dialog-CgYGInHi.js.map → admin-dialog-BxRcYcQM.js.map} +1 -1
- package/dist/{admin-dropdown-menu-CU9RxoEJ.js → admin-dropdown-menu-DlyaKwyU.js} +2 -2
- package/dist/{admin-dropdown-menu-CU9RxoEJ.js.map → admin-dropdown-menu-DlyaKwyU.js.map} +1 -1
- package/dist/{admin-dunning-D8lAP7OA.js → admin-dunning-CDy6aMAj.js} +2 -2
- package/dist/{admin-dunning-D8lAP7OA.js.map → admin-dunning-CDy6aMAj.js.map} +1 -1
- package/dist/{admin-fact-card-lN-MsuSp.js → admin-fact-card-2DujC_r3.js} +2 -2
- package/dist/{admin-fact-card-lN-MsuSp.js.map → admin-fact-card-2DujC_r3.js.map} +1 -1
- package/dist/{admin-utils-CX097OR7.js → admin-format-Bc4NWK0F.js} +495 -328
- package/dist/admin-format-Bc4NWK0F.js.map +1 -0
- package/dist/{admin-health-CnagC763.js → admin-health-DePsyIlc.js} +217 -196
- package/dist/admin-health-DePsyIlc.js.map +1 -0
- package/dist/{admin-imports-SM_fKKgW.js → admin-imports-BrQH3u9M.js} +85 -86
- package/dist/{admin-imports-SM_fKKgW.js.map → admin-imports-BrQH3u9M.js.map} +1 -1
- package/dist/{admin-input-B_EUzCAE.js → admin-input-BZ2ExV_5.js} +2 -2
- package/dist/{admin-input-B_EUzCAE.js.map → admin-input-BZ2ExV_5.js.map} +1 -1
- package/dist/{admin-label-DQsOkp1p.js → admin-label-DecDO0oV.js} +2 -2
- package/dist/{admin-label-DQsOkp1p.js.map → admin-label-DecDO0oV.js.map} +1 -1
- package/dist/{admin-linked-table-row-BFsgc9tz.js → admin-linked-table-row-ChxhVptQ.js} +3 -3
- package/dist/{admin-linked-table-row-BFsgc9tz.js.map → admin-linked-table-row-ChxhVptQ.js.map} +1 -1
- package/dist/{admin-map-dialog-Dt3gTuTD.js → admin-map-dialog-CQmGOBMw.js} +12 -12
- package/dist/{admin-map-dialog-Dt3gTuTD.js.map → admin-map-dialog-CQmGOBMw.js.map} +1 -1
- package/dist/admin-metering-OXGOVQ7e.js +1716 -0
- package/dist/{admin-metering-DM4KhjOq.js.map → admin-metering-OXGOVQ7e.js.map} +1 -1
- package/dist/{admin-missing-record-G2Jz-VUn.js → admin-missing-record-B_9LpSIW.js} +4 -4
- package/dist/{admin-missing-record-G2Jz-VUn.js.map → admin-missing-record-B_9LpSIW.js.map} +1 -1
- package/dist/admin-ops-BTSunx1i.js +357 -0
- package/dist/{admin-ops-mwzj-jpg.js.map → admin-ops-BTSunx1i.js.map} +1 -1
- package/dist/{admin-orders-D_aqV66h.js → admin-orders-LqlpQVFo.js} +59 -60
- package/dist/{admin-orders-D_aqV66h.js.map → admin-orders-LqlpQVFo.js.map} +1 -1
- package/dist/{admin-parked-2FjIfyMg.js → admin-parked-Ch6mlS5f.js} +61 -62
- package/dist/{admin-parked-2FjIfyMg.js.map → admin-parked-Ch6mlS5f.js.map} +1 -1
- package/dist/{admin-payments-B4hh31PR.js → admin-payments-yNntF4i4.js} +42 -42
- package/dist/{admin-payments-B4hh31PR.js.map → admin-payments-yNntF4i4.js.map} +1 -1
- package/dist/{admin-price-detail--5Bovz20.js → admin-price-detail-DvmcYr8B.js} +131 -132
- package/dist/admin-price-detail-DvmcYr8B.js.map +1 -0
- package/dist/{admin-price-format-C-pus9FL.js → admin-price-format-Btdg11-J.js} +14 -5
- package/dist/admin-price-format-Btdg11-J.js.map +1 -0
- package/dist/admin-price-wizard-EFO3nBV8.js +376 -0
- package/dist/admin-price-wizard-EFO3nBV8.js.map +1 -0
- package/dist/{admin-proposals-DPRFoWel.js → admin-proposals-CO0LKHM8.js} +119 -120
- package/dist/{admin-proposals-DPRFoWel.js.map → admin-proposals-CO0LKHM8.js.map} +1 -1
- package/dist/admin-provider-prices-ZjQeEV1n.js +239 -0
- package/dist/{admin-provider-prices-B8Oc86dP.js.map → admin-provider-prices-ZjQeEV1n.js.map} +1 -1
- package/dist/admin-query-builder-DedekYUU.js +252 -0
- package/dist/admin-query-builder-DedekYUU.js.map +1 -0
- package/dist/{admin-range-picker-CSWcCYkg.js → admin-range-picker-1WGFlYYw.js} +46 -24
- package/dist/admin-range-picker-1WGFlYYw.js.map +1 -0
- package/dist/admin-records-A2R52prt.js +389 -0
- package/dist/{admin-records-CWbfqyT8.js.map → admin-records-A2R52prt.js.map} +1 -1
- package/dist/admin-reports-ySY9v463.js +420 -0
- package/dist/admin-reports-ySY9v463.js.map +1 -0
- package/dist/{admin-select-DSGCZFiZ.js → admin-select-CgZq2j0G.js} +2 -2
- package/dist/{admin-select-DSGCZFiZ.js.map → admin-select-CgZq2j0G.js.map} +1 -1
- package/dist/admin-settings-kOW1nPGB.js +1818 -0
- package/dist/admin-settings-kOW1nPGB.js.map +1 -0
- package/dist/{admin-shared-DdN2hyaR.js → admin-shared-DoBOSwkv.js} +33 -34
- package/dist/{admin-shared-DdN2hyaR.js.map → admin-shared-DoBOSwkv.js.map} +1 -1
- package/dist/admin-signals-D_iWk2r5.js +124 -0
- package/dist/admin-signals-D_iWk2r5.js.map +1 -0
- package/dist/{admin-skeleton-DOfsDIu0.js → admin-skeleton-DdqwXcr4.js} +2 -2
- package/dist/{admin-skeleton-DOfsDIu0.js.map → admin-skeleton-DdqwXcr4.js.map} +1 -1
- package/dist/{admin-status-badge-BLEGt2Fw.js → admin-status-badge-B8rjk6QR.js} +5 -3
- package/dist/admin-status-badge-B8rjk6QR.js.map +1 -0
- package/dist/{admin-subscriptions-PL5G3f0O.js → admin-subscriptions-CjYPSPs-.js} +43 -38
- package/dist/admin-subscriptions-CjYPSPs-.js.map +1 -0
- package/dist/{admin-switch-aOiQQzST.js → admin-switch-CyYmt8wi.js} +2 -2
- package/dist/{admin-switch-aOiQQzST.js.map → admin-switch-CyYmt8wi.js.map} +1 -1
- package/dist/{admin-table-DIKl2rpV.js → admin-table-ByPfWNq8.js} +2 -2
- package/dist/{admin-table-DIKl2rpV.js.map → admin-table-ByPfWNq8.js.map} +1 -1
- package/dist/admin-tabs-DKa6QljL.js +45 -0
- package/dist/admin-tabs-DKa6QljL.js.map +1 -0
- package/dist/{admin-textarea-W52-l_0n.js → admin-textarea-CQg__KGc.js} +2 -2
- package/dist/{admin-textarea-W52-l_0n.js.map → admin-textarea-CQg__KGc.js.map} +1 -1
- package/dist/{admin-typed-confirm-dialog-B_00EHlT.js → admin-typed-confirm-dialog-BvAYEh3H.js} +6 -6
- package/dist/{admin-typed-confirm-dialog-B_00EHlT.js.map → admin-typed-confirm-dialog-BvAYEh3H.js.map} +1 -1
- package/dist/admin-widget-tile-DDI3eaRy.js +290 -0
- package/dist/admin-widget-tile-DDI3eaRy.js.map +1 -0
- package/dist/admin-widget-viz-Db9CQ2Sx.js +1084 -0
- package/dist/admin-widget-viz-Db9CQ2Sx.js.map +1 -0
- package/dist/admin.css +1 -1
- package/dist/admin.js +660 -609
- package/dist/admin.js.map +1 -1
- package/dist/buy-button.d.ts +4 -2
- package/dist/cart.d.ts +4 -2
- package/dist/client/client.d.ts +16 -3
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +296 -181
- package/dist/client/generated/wire.d.ts +514 -277
- package/dist/client/index.d.ts +1 -1
- package/dist/client/types.d.ts +76 -8
- package/dist/{client-DwsFGm4M.js → client-D8qT6xjo.js} +86 -44
- package/dist/client-D8qT6xjo.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/components/billing-fields.d.ts +5 -3
- package/dist/components/platform-card-form.d.ts +3 -1
- package/dist/{hooks-C-MhXjQh.js → hooks-CX09fAJA.js} +86 -60
- package/dist/hooks-CX09fAJA.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +847 -779
- package/dist/index.js.map +1 -1
- package/dist/lib/billing-fields.d.ts +15 -0
- package/dist/lib/billing.d.ts +23 -5
- package/dist/lib/price-label.d.ts +1 -1
- package/dist/locales/en.d.ts +4 -0
- package/dist/locales/en.js +4 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/product-list.d.ts +4 -2
- package/dist/react/config.d.ts +10 -2
- package/dist/react/index.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tokenized-card-form.d.ts +10 -2
- package/docs/payment-form-contract.md +6 -15
- package/package.json +6 -6
- package/dist/admin/lib/api/copilot.d.ts +0 -6
- package/dist/admin/pages/catalog/copilot-panel.d.ts +0 -4
- package/dist/admin-attempts-DjgBAbx9.js +0 -418
- package/dist/admin-attempts-DjgBAbx9.js.map +0 -1
- package/dist/admin-capabilities-DS-X-__V.js.map +0 -1
- package/dist/admin-catalog-BdLDhr8R.js +0 -1096
- package/dist/admin-catalog-BdLDhr8R.js.map +0 -1
- package/dist/admin-customers-BZP6Jv-i.js.map +0 -1
- package/dist/admin-dashboard-BJSonknv.js +0 -461
- package/dist/admin-dashboard-BJSonknv.js.map +0 -1
- package/dist/admin-detail-C03O0R6e.js +0 -1351
- package/dist/admin-detail-C03O0R6e.js.map +0 -1
- package/dist/admin-detail-C6VH3i2v.js +0 -293
- package/dist/admin-detail-NApy5bio.js +0 -337
- package/dist/admin-detail-cijme9Lc.js.map +0 -1
- package/dist/admin-format-D9Ablh0P.js +0 -169
- package/dist/admin-format-D9Ablh0P.js.map +0 -1
- package/dist/admin-health-CnagC763.js.map +0 -1
- package/dist/admin-metering-DM4KhjOq.js +0 -1717
- package/dist/admin-ops-mwzj-jpg.js +0 -358
- package/dist/admin-price-detail--5Bovz20.js.map +0 -1
- package/dist/admin-price-format-C-pus9FL.js.map +0 -1
- package/dist/admin-price-wizard-Cj_Bgh-V.js +0 -354
- package/dist/admin-price-wizard-Cj_Bgh-V.js.map +0 -1
- package/dist/admin-provider-prices-B8Oc86dP.js +0 -240
- package/dist/admin-range-picker-CSWcCYkg.js.map +0 -1
- package/dist/admin-records-CWbfqyT8.js +0 -390
- package/dist/admin-reports-CAHWO_d6.js +0 -319
- package/dist/admin-reports-CAHWO_d6.js.map +0 -1
- package/dist/admin-settings-BrvNTJlM.js +0 -1818
- package/dist/admin-settings-BrvNTJlM.js.map +0 -1
- package/dist/admin-status-badge-BLEGt2Fw.js.map +0 -1
- package/dist/admin-subscriptions-PL5G3f0O.js.map +0 -1
- package/dist/admin-tabs-DR74xX0-.js +0 -156
- package/dist/admin-tabs-DR74xX0-.js.map +0 -1
- package/dist/admin-utils-CX097OR7.js.map +0 -1
- package/dist/admin-widget-viz-DVV9aTQp.js +0 -643
- package/dist/admin-widget-viz-DVV9aTQp.js.map +0 -1
- package/dist/client-DwsFGm4M.js.map +0 -1
- package/dist/hooks-C-MhXjQh.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,66 +1,28 @@
|
|
|
1
1
|
# @openrails/billing-ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
administration inside the
|
|
3
|
+
OpenRails billing in the browser: purchase, the customer's account billing,
|
|
4
|
+
and staff administration, inside your app. Card data is tokenized in the PSP's
|
|
5
|
+
own fields (Collect.js, Stripe Elements) and never enters your app. How it fits
|
|
6
|
+
an integration: the [client guide](https://github.com/open-rails/openrails/blob/master/docs/client.md#orders-and-checkout).
|
|
5
7
|
|
|
6
|
-
| Import
|
|
7
|
-
|
|
8
|
-
| `@openrails/billing-ui/client`
|
|
9
|
-
| `@openrails/billing-ui/react`
|
|
10
|
-
| `@openrails/billing-ui`
|
|
11
|
-
| `@openrails/billing-ui/locales/*` | `en de es ja ko zh`
|
|
12
|
-
| `@openrails/billing-ui/admin`
|
|
13
|
-
| `@openrails/billing-ui/admin.css` | Scoped staff administration styles |
|
|
8
|
+
| Import | Contents |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `@openrails/billing-ui/client` | the typed client for `/v1/me` and `BillingError`, framework-free |
|
|
11
|
+
| `@openrails/billing-ui/react` | `BillingProvider` and headless hooks, no styles |
|
|
12
|
+
| `@openrails/billing-ui` | the provider, styled purchase and account components, i18n |
|
|
13
|
+
| `@openrails/billing-ui/locales/*` | `en de es ja ko zh` |
|
|
14
|
+
| `@openrails/billing-ui/admin`, `/admin.css` | `AdminConsole`, `BillingAdmin`, `BillingCustomerSummary` and their helpers |
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
their own credential. Card data is tokenized in the PSP's own fields
|
|
18
|
-
(Collect.js, Stripe Elements) and never enters the host application.
|
|
16
|
+
Each OpenRails release `vX.Y.Z` publishes `@openrails/billing-ui@X.Y.Z` with
|
|
17
|
+
provenance; pin the exact version: `pnpm add @openrails/billing-ui@X.Y.Z`.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
billing fields, browser-autofill behavior and the payment request.
|
|
22
|
-
|
|
23
|
-
The package lives in the OpenRails repository and shares its version: each
|
|
24
|
-
OpenRails release `vX.Y.Z` publishes `@openrails/billing-ui@X.Y.Z` to npm, with
|
|
25
|
-
provenance.
|
|
26
|
-
|
|
27
|
-
```sh
|
|
28
|
-
pnpm add @openrails/billing-ui@X.Y.Z
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Account notification wording
|
|
32
|
-
|
|
33
|
-
AuthKit UI owns the notification bell, inbox and read/archive controls.
|
|
34
|
-
BillingUI supplies the billing-specific wording and action links through
|
|
35
|
-
`BillingNotification` and `isBillingNotification`; it owns no inbox or polling
|
|
36
|
-
client. Pass the component through AuthKit UI's optional `renderItem` callback
|
|
37
|
-
and supply your application's authorized billing destinations:
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
import { NotificationInbox } from "@openrails/auth-ui"
|
|
41
|
-
import { BillingNotification, isBillingNotification } from "@openrails/billing-ui"
|
|
42
|
-
|
|
43
|
-
<NotificationInbox renderItem={(item) =>
|
|
44
|
-
isBillingNotification(item)
|
|
45
|
-
? <BillingNotification item={item} actions={{ manage_billing: "/account/billing" }} />
|
|
46
|
-
: null
|
|
47
|
-
} />
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The formatter supports the six BillingUI locales. It inherits the current
|
|
51
|
-
locale/theme when rendered in a billing context, or accepts explicit `language`,
|
|
52
|
-
`messages` and `appearance` options for a global header. Unknown notification
|
|
53
|
-
kinds fall back to AuthKit UI's generic presentation.
|
|
54
|
-
|
|
55
|
-
## Buying
|
|
56
|
-
|
|
57
|
-
A React app imports from one place:
|
|
19
|
+
## The client
|
|
58
20
|
|
|
59
21
|
```tsx
|
|
60
|
-
import { BillingProvider,
|
|
22
|
+
import { BillingProvider, createBillingClient } from "@openrails/billing-ui"
|
|
61
23
|
|
|
62
|
-
//
|
|
63
|
-
//
|
|
24
|
+
// Embedded: your app's own mount, with your auth's fetch (auth-ui's authFetch
|
|
25
|
+
// attaches the bearer and retries once after a refresh).
|
|
64
26
|
const billing = createBillingClient({ baseUrl: "/billing/v1", fetch: auth.authFetch })
|
|
65
27
|
|
|
66
28
|
<BillingProvider client={billing} appearance={{ theme: "auto" }}>
|
|
@@ -68,353 +30,135 @@ const billing = createBillingClient({ baseUrl: "/billing/v1", fetch: auth.authFe
|
|
|
68
30
|
</BillingProvider>
|
|
69
31
|
```
|
|
70
32
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`credential_expired
|
|
33
|
+
Standalone or hosted, the browser calls the billing API with a short
|
|
34
|
+
`openrails:self` token your backend mints. `tokenSource` keeps it in memory
|
|
35
|
+
only, fetches the next one `skew` seconds (60) before expiry with one request
|
|
36
|
+
however many calls wait, and resends a call answered 401 `credential_expired` once:
|
|
75
37
|
|
|
76
38
|
```ts
|
|
77
|
-
import {
|
|
78
|
-
createBillingClient,
|
|
79
|
-
redeemAssertion,
|
|
80
|
-
tokenSource,
|
|
81
|
-
} from "@openrails/billing-ui"
|
|
82
|
-
|
|
83
39
|
const billing = createBillingClient({
|
|
84
40
|
baseUrl: "https://billing.example/v1",
|
|
85
41
|
getToken: tokenSource({
|
|
86
|
-
// { access_token, expires_in } from your backend, or its signed assertion redeemed here.
|
|
87
42
|
fetchToken: async () => {
|
|
88
|
-
const { assertion } = await (
|
|
89
|
-
|
|
90
|
-
).json()
|
|
91
|
-
return redeemAssertion({
|
|
92
|
-
tokenEndpoint: "https://billing.example/oauth2/token",
|
|
93
|
-
assertion,
|
|
94
|
-
})
|
|
43
|
+
const { assertion } = await (await fetch("/api/billing/assertion", { method: "POST" })).json()
|
|
44
|
+
return redeemAssertion({ tokenEndpoint: "https://billing.example/oauth2/token", assertion })
|
|
95
45
|
},
|
|
96
46
|
}),
|
|
97
47
|
})
|
|
98
48
|
```
|
|
99
49
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
or those granting an entitlement) and puts them in its own page's response,
|
|
103
|
-
their prices as a buyer sees them (`billing.BuyerPrices`). `<BuyButton price>`
|
|
104
|
-
buys one of those prices, `<ProductList products>` sells those products (a
|
|
105
|
-
course, its bundle and the membership that also unlocks it): a `BuyButton` per
|
|
106
|
-
price ("$4.99", "Rent for 3 days, $1.99", "$10.00 every 30 days").
|
|
107
|
-
|
|
108
|
-
The purchase is theirs from start to payment: a button creates the customer's
|
|
109
|
-
order (`POST /me/orders`) and pays it in a dialog. On a page of a site the
|
|
110
|
-
merchant registered to frame its pay URLs (`merchant.embed_origins` in
|
|
111
|
-
`GET /me/config`), it creates the order with its embedded pay URL in the same
|
|
112
|
-
call (`createOrder({ lines, payUrl: { embedded: true } })`) and frames
|
|
113
|
-
`order.pay_url` from the checkout origin (`<EmbeddedPayment>`); anywhere
|
|
114
|
-
else it pays on the page (`<OrderPayment>`). The embedded pay URL returns
|
|
115
|
-
nowhere: the frame says it is paid and tells the page (`onPaid`), and a
|
|
116
|
-
redirect PSP comes back inside it. Nothing is stored: OpenRails answers the
|
|
117
|
-
customer's open order of the same lines, so a second click, a reopened dialog
|
|
118
|
-
or a reload pays the same order (with a fresh URL), and a paid or expired one
|
|
119
|
-
is bought again as a new order. Signing in is the
|
|
120
|
-
host's: with `signedIn={false}`, or when OpenRails answers 401, they call
|
|
121
|
-
`onSignInRequired` instead. `onPaid` receives the completed order; it is a
|
|
122
|
-
hint, so confirm access from your own API (your gate) before granting
|
|
123
|
-
anything.
|
|
124
|
-
|
|
125
|
-
```tsx
|
|
126
|
-
<BuyButton
|
|
127
|
-
price={course.prices[0]} // from your server's page response
|
|
128
|
-
signedIn={signedIn}
|
|
129
|
-
onSignInRequired={() => openSignIn()}
|
|
130
|
-
onPaid={() => navigate("/courses/css-101")} // your gate now admits them
|
|
131
|
-
/>
|
|
132
|
-
|
|
133
|
-
<ProductList
|
|
134
|
-
products={products} // from your server's page response
|
|
135
|
-
signedIn={signedIn}
|
|
136
|
-
onSignInRequired={() => openSignIn()}
|
|
137
|
-
onPaid={() => navigate("/courses/css-101")}
|
|
138
|
-
/>
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
`returnUrl` returns the buyer from a redirect step (Stripe's hosted page); it
|
|
142
|
-
must be on one of your app's return origins.
|
|
143
|
-
|
|
144
|
-
`fallbacks` keeps a PSP back until the PSPs it stands in for are not offered,
|
|
145
|
-
or have failed `afterFailures` times on the order combined (each payment
|
|
146
|
-
option reports its `failed_attempts`); it then shows under "Card payment isn't
|
|
147
|
-
working?". CCBill after Mobius declines twice:
|
|
148
|
-
|
|
149
|
-
```tsx
|
|
150
|
-
<ProductList
|
|
151
|
-
products={products}
|
|
152
|
-
fallbacks={{ ccbill: { for: ["mobius"], afterFailures: 2 } }}
|
|
153
|
-
{...handlers}
|
|
154
|
-
/>
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`BuyButton`, `Cart`, `OrderPayment` and `EmbeddedPayment` take it too.
|
|
158
|
-
`EmbeddedPayment` passes it to the framed pay page in the URL fragment
|
|
159
|
-
(`withPaymentFallbacks(payUrl, fallbacks)` does the same for a hosted pay URL).
|
|
160
|
-
|
|
161
|
-
For prepaid credits, a fixed pack is another product/price. A
|
|
162
|
-
`customer_amount` price takes the buyer's `amount`: collect it on your product
|
|
163
|
-
page, and the purchase charges exactly that:
|
|
164
|
-
|
|
165
|
-
```tsx
|
|
166
|
-
import { decimalToAmount } from "@openrails/billing-ui/client"
|
|
167
|
-
|
|
168
|
-
// `depositPrice` is in a product your server sent; `currency` from getConfig().currencies.
|
|
169
|
-
// `enteredAmount` is the text from an <input inputMode="decimal">, e.g. "100".
|
|
170
|
-
const amount = decimalToAmount(enteredAmount, currency.decimals)
|
|
171
|
-
const bounds = depositPrice.customer_amount
|
|
172
|
-
const valid = amount && bounds && BigInt(amount) >= BigInt(bounds.min_amount) && BigInt(amount) <= BigInt(bounds.max_amount)
|
|
173
|
-
|
|
174
|
-
<BuyButton price={depositPrice} amount={valid ? amount : undefined} label="Add credits" {...handlers} />
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
OpenRails validates the bounds and whole currency minor units before accepting
|
|
178
|
-
payment. Fixed prices reject `amount`; their pack benefit can be greater than
|
|
179
|
-
the purchase price for a bulk discount. Customer-selected deposits currently
|
|
180
|
-
use NMI or Stripe.
|
|
50
|
+
A `fetch` that adds a DPoP proof (auth-ui's `dpopFetch`) binds the token to the
|
|
51
|
+
browser's key. Requests omit credentials; any origin may call.
|
|
181
52
|
|
|
182
|
-
|
|
183
|
-
https page, opened in the top window), `solana_pay` (a `solana:` link shown
|
|
184
|
-
as a QR code) or `authenticate` (the bank's challenge, run in the page).
|
|
185
|
-
|
|
186
|
-
### An order your server creates
|
|
53
|
+
## Buying
|
|
187
54
|
|
|
188
|
-
|
|
189
|
-
`Client.
|
|
190
|
-
|
|
55
|
+
The browser never reads the catalog: your server reads the products it sells
|
|
56
|
+
(Go `Client.ListProducts`) and puts them, priced as a buyer sees them
|
|
57
|
+
(`billing.BuyerPrices`), in its own page.
|
|
191
58
|
|
|
192
59
|
```tsx
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/>
|
|
60
|
+
<BuyButton price={course.prices[0]} signedIn={signedIn}
|
|
61
|
+
onSignInRequired={openSignIn} onPaid={() => navigate("/courses/css-101")} />
|
|
62
|
+
<ProductList products={products} signedIn={signedIn}
|
|
63
|
+
onSignInRequired={openSignIn} onPaid={() => navigate("/courses/css-101")} />
|
|
198
64
|
```
|
|
199
65
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
66
|
+
- A button creates the signed-in customer's order and pays it in a dialog. On
|
|
67
|
+
a site the merchant registered to frame its pay URLs, it frames the order's
|
|
68
|
+
`pay_url` instead (`<EmbeddedPayment>`). OpenRails answers the customer's open
|
|
69
|
+
order of the same lines, so a second click, a reopened dialog or a reload pays
|
|
70
|
+
one order.
|
|
71
|
+
- `onPaid` is a hint. Grant access from your server's own check, or from the
|
|
72
|
+
`order.completed` event, never from the browser.
|
|
73
|
+
- `<OrderPayment orderId>` pays an order your server created (`CreateOrder`):
|
|
74
|
+
saved cards, a new card, a hosted page, a Solana wallet, Apple and Google Pay
|
|
75
|
+
through Stripe. `onSettled` follows completion. `returnUrl` must be on one of
|
|
76
|
+
your app's return origins.
|
|
77
|
+
- A rail's own step is the order's `payment.next_action`: `redirect_to_url`
|
|
78
|
+
(top window), `solana_pay` (a QR code or wallet link) or `authenticate` (the
|
|
79
|
+
bank's challenge, in the page). In the EEA and UK a new card is kept only with
|
|
80
|
+
`reusable: true`, the customer's own opt-in.
|
|
81
|
+
- `fallbacks` keeps a PSP back until the PSPs it stands in for fail
|
|
82
|
+
(`{ ccbill: { for: ["nmi-main"], afterFailures: 2 } }`), then offers it under
|
|
83
|
+
"Card payment isn't working?". `BuyButton`, `ProductList`, `Cart`,
|
|
84
|
+
`OrderPayment` and `EmbeddedPayment` take it.
|
|
85
|
+
- A `customer_amount` price takes the buyer's `amount`: parse it with
|
|
86
|
+
`decimalToAmount(text, currency.decimals)` and check the price's bounds with
|
|
87
|
+
`BigInt`. `<Cart>` sells the customer's cart.
|
|
88
|
+
|
|
89
|
+
The form's fields, autofill and exact money rules: [payment form
|
|
90
|
+
contract](docs/payment-form-contract.md).
|
|
203
91
|
|
|
204
92
|
## Account billing
|
|
205
93
|
|
|
206
|
-
One `BillingProvider`, usually at the app's root, gives every component the
|
|
207
|
-
client, the appearance and the words. `@openrails/billing-ui/react` exports the
|
|
208
|
-
same provider for an app that uses only the hooks; it loads no stylesheet.
|
|
209
|
-
|
|
210
94
|
```tsx
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const billing = createBillingClient({ baseUrl: "/billing/v1", fetch: auth.authFetch })
|
|
215
|
-
|
|
216
|
-
<BillingProvider
|
|
217
|
-
client={billing}
|
|
218
|
-
appearance={{ theme: "auto" }}
|
|
219
|
-
messages={de}
|
|
220
|
-
locale="de"
|
|
221
|
-
navigate={navigate}
|
|
222
|
-
onChange={() => queryClient.invalidateQueries({ queryKey: ["billing"] })}
|
|
223
|
-
>
|
|
224
|
-
<AccountBilling
|
|
225
|
-
plansHref="/plans"
|
|
226
|
-
defaultCurrency="USD" // offers "Make default"
|
|
227
|
-
sendSolanaTransaction={(tx) => wallet.signAndSend(tx)} // optional on-chain cancellation
|
|
228
|
-
/>
|
|
229
|
-
</BillingProvider>
|
|
95
|
+
<AccountBilling plansHref="/plans" defaultCurrency="USD"
|
|
96
|
+
sendSolanaTransaction={(tx) => wallet.signAndSend(tx)} />
|
|
230
97
|
```
|
|
231
98
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
read
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
99
|
+
`AccountBilling` stacks `SubscriptionsPanel` (cancel, resume, change card,
|
|
100
|
+
change plan), `PaymentMethodsPanel` and `PaymentHistory`; `RenewalPrompt` invites
|
|
101
|
+
a customer whose subscriptions all ended back to `plansHref`. The hooks
|
|
102
|
+
(`useSubscriptions`, `useChangeOptions`, `usePaymentMethods`, `usePayments`)
|
|
103
|
+
resolve to `null` or a `BillingError`, never throwing.
|
|
104
|
+
|
|
105
|
+
- **Configuration.** The panels read `GET /v1/config` and `GET /v1/me/config`
|
|
106
|
+
once per provider (`useConfig()`, `useCustomerConfig()`). A page your server
|
|
107
|
+
renders can pass both as `config` and `customerConfig` (Go:
|
|
108
|
+
`Engine.PublicConfig`, `Engine.CustomerConfig`), so nothing is fetched to load.
|
|
109
|
+
- **Plan changes.** `changeSubscription(id, { priceId?, quantity?, idempotencyKey })`
|
|
110
|
+
is a money write: mint one key per attempt and reuse it until the change
|
|
111
|
+
resolves. More seats and upgrades charge now; fewer and downgrades apply at
|
|
112
|
+
the next renewal. `authenticateChange` runs a card challenge in the page;
|
|
113
|
+
Solana changes sign in the wallet (`signWalletAction`).
|
|
114
|
+
- **Money and periods** are exact: amounts are int64 native-unit strings scaled
|
|
115
|
+
by OpenRails' currency registry (`formatAmount`), and 720 hours reads "every
|
|
116
|
+
30 days", never "monthly".
|
|
117
|
+
- **Words and styles.** English is complete and the fallback; `messages` layers
|
|
118
|
+
bundles and `t` lets your i18n win. Styles are scoped under `.orck`;
|
|
119
|
+
`appearance.theme` is `light`, `dark`, `auto` or `inherit` (your shadcn tokens).
|
|
120
|
+
- **Notifications.** AuthKit UI owns the inbox; `BillingNotification` and
|
|
121
|
+
`isBillingNotification` render billing items through its `renderItem`.
|
|
254
122
|
|
|
255
123
|
## Staff administration
|
|
256
124
|
|
|
257
|
-
`AdminConsole` is the whole staff console, AuthKit's
|
|
258
|
-
|
|
125
|
+
Needs `@tanstack/react-query`. `AdminConsole` is the whole staff console, AuthKit's
|
|
126
|
+
account administration and billing together (needs `@openrails/auth-ui`):
|
|
259
127
|
|
|
260
128
|
```tsx
|
|
261
129
|
<AdminConsole authBaseUrl="/api/v1" billingBaseUrl="/billing/v1" merchant={merchant} basePath="/admin" />
|
|
262
130
|
```
|
|
263
131
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
Install the admin entry's optional peer with `pnpm add @tanstack/react-query`.
|
|
267
|
-
The host owns sign-in and passes its authenticated transport and router:
|
|
132
|
+
`BillingAdmin` is the billing pages alone, inside your own admin app:
|
|
268
133
|
|
|
269
134
|
```tsx
|
|
270
135
|
import { BillingAdmin } from "@openrails/billing-ui/admin"
|
|
271
136
|
import "@openrails/billing-ui/admin.css"
|
|
272
137
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
auth={auth}
|
|
276
|
-
basePath="/admin/billing"
|
|
277
|
-
navigation={{ pathname, search, navigate }}
|
|
278
|
-
appearance={{ theme: "inherit" }}
|
|
279
|
-
/>
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
`auth` implements `authFetch`; it can be an AuthKit client or a host transport.
|
|
283
|
-
Mount the component for the signed-in person and remount when that identity
|
|
284
|
-
changes. Omitting `navigation` uses browser history. Each instance owns its
|
|
285
|
-
transport, selected merchant, and query namespace, including when the host
|
|
286
|
-
supplies a shared `queryClient`.
|
|
287
|
-
|
|
288
|
-
`useBillingAdminAccess` reads the staff member's capabilities for the host's
|
|
289
|
-
navigation. `BillingCustomerSummary` supplies a bounded billing preview for a
|
|
290
|
-
host customer page. `settingsTabs`, `customerPanels`, and `userHref` compose
|
|
291
|
-
host content and links. The customer imports above do not load admin code or
|
|
292
|
-
styles. See the [BillingAdmin integration guide](https://github.com/open-rails/openrails/blob/master/docs/billing-admin.md)
|
|
293
|
-
for merchant selection, permissions, localization, and standalone console setup.
|
|
294
|
-
|
|
295
|
-
## Configuration and plan changes
|
|
296
|
-
|
|
297
|
-
The client also reads the configuration and changes a subscription's plan.
|
|
298
|
-
`GET /config` is a public route: the client sends it no bearer.
|
|
299
|
-
|
|
300
|
-
| Call | Route |
|
|
301
|
-
| --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
302
|
-
| `getConfig()` (capabilities, `currencies`, `captcha`; `client.currencies` is the pinned registry) | `GET /config` |
|
|
303
|
-
| `getCustomerConfig()` (the customer's merchant: `payment` with PSPs, `solana.network` and tokens, and `merchant`, its name) | `GET /me/config` |
|
|
304
|
-
| `listSubscriptionChangeOptions(id)` (the other tiers it can move to now, ranked, each with its preview) | `GET /me/subscriptions/{id}/change/options` |
|
|
305
|
-
| `previewSubscriptionChange(id, { priceId?, quantity? })` | `POST /me/subscriptions/{id}/change/preview` |
|
|
306
|
-
| `changeSubscription(id, { priceId?, quantity?, idempotencyKey, signature? })` | `POST /me/subscriptions/{id}/change` |
|
|
307
|
-
|
|
308
|
-
```ts
|
|
309
|
-
const preview = await billing.previewSubscriptionChange(sub.id, { quantity: 5 }) // amount_due_now, effective
|
|
310
|
-
const change = await billing.changeSubscription(sub.id, {
|
|
311
|
-
quantity: 5,
|
|
312
|
-
idempotencyKey,
|
|
313
|
-
})
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
- A change moves to another price of the tier group (`priceId`), to other
|
|
317
|
-
seats of a per-seat price (`quantity`), or both. More seats and an upgrade
|
|
318
|
-
charge now; fewer seats and a downgrade apply at the next renewal.
|
|
319
|
-
- `changeSubscription` is a money write. Mint one `idempotencyKey` per attempt and
|
|
320
|
-
reuse it until the change resolves (`status: "processing"`, a
|
|
321
|
-
`subscription_change_in_flight` refusal, a 5xx or a lost response), so
|
|
322
|
-
OpenRails replays the stored result instead of charging twice. A change the
|
|
323
|
-
card issuer challenges answers `requires_action` with an `authenticate`
|
|
324
|
-
`next_action`: `authenticateChange(client, id, change, psp)` runs it in the
|
|
325
|
-
page and confirms the change (`confirmSubscriptionChange`).
|
|
326
|
-
- A rail that needs the customer's own step answers `requires_action` with a
|
|
327
|
-
`next_action`. Solana's is `solana_sign_transactions`:
|
|
328
|
-
`signWalletAction(change.next_action, send)` signs and sends its
|
|
329
|
-
transactions and returns the signature; repeat `changeSubscription` with the same
|
|
330
|
-
key and `signature`. `cancelSubscription(id, { reason })` cancels at
|
|
331
|
-
period end without a wallet. Set `revokeOnChain: true` to also request an
|
|
332
|
-
optional wallet step; local cancellation has already taken effect. The
|
|
333
|
-
cancel hook signs this additional step when passed `sendTransaction` and
|
|
334
|
-
`revokeOnChain: true`.
|
|
335
|
-
|
|
336
|
-
## Provider-neutral flows
|
|
337
|
-
|
|
338
|
-
OpenRails's browser PSP configs (`GET /me/config`'s `payment.psps`) pick the
|
|
339
|
-
browser flow from each PSP's `flow` and public `config`
|
|
340
|
-
(Collect.js, native card inputs, Stripe Elements, redirect, wallet). Hosts never branch on a
|
|
341
|
-
provider:
|
|
342
|
-
|
|
343
|
-
- An order's `payment_options` are exactly the armed PSPs whose rail can make
|
|
344
|
-
this sale (Solana for one-time lines when it is configured, never CCBill),
|
|
345
|
-
each with what it `accepts`. `OrderPayment` renders one panel: the
|
|
346
|
-
customer's saved cards on them, newest first, an inline new card and one Pay
|
|
347
|
-
button. No provider chooser with one rail.
|
|
348
|
-
- A new card is charged and saved in one pay; an `authenticate` next action
|
|
349
|
-
runs 3-D Secure in the page, then `confirm`. A decline stays on the panel
|
|
350
|
-
with its message, so the buyer can pick another card under a new
|
|
351
|
-
idempotency key.
|
|
352
|
-
- Only PSPs with `routed !== false` (`routedPsps`) take new cards; others
|
|
353
|
-
stay listed so existing cards and subscriptions keep working.
|
|
354
|
-
- `<SavePaymentMethod psp={psp} onSaved={(id) => ...} />` saves a card in the
|
|
355
|
-
page (needs `BillingProvider`); `canSavePaymentMethod(psp)` filters PSPs
|
|
356
|
-
that support it. After an off-page verification the provider returns to
|
|
357
|
-
`returnURL(setupId)`; confirm with `client.confirmCardSetup(id)`.
|
|
358
|
-
- `defaultCountry` (SavePaymentMethod, AccountBilling)
|
|
359
|
-
preselects the billing country, else the browser locale's region.
|
|
360
|
-
|
|
361
|
-
- Panels: `SubscriptionsPanel` (cancel, resume, change card, change plan),
|
|
362
|
-
`PaymentMethodsPanel`, `PaymentHistory`, `BillingStatusBadge`,
|
|
363
|
-
`CancelSubscriptionDialog`; `AccountBilling` stacks them. A row offers
|
|
364
|
-
Change plan when OpenRails lists another tier for it; the dialog shows each
|
|
365
|
-
tier's charge and date and runs the change (wallet and issuer steps
|
|
366
|
-
included, one idempotency key until it resolves).
|
|
367
|
-
- `<RenewalPrompt plansHref="/plans" />` invites a customer whose
|
|
368
|
-
subscriptions all ended back to the plans page. A host that grants access
|
|
369
|
-
some other way leaves it out for customers who have that access.
|
|
370
|
-
- `renderSubscriptionFooter={(s) => ...}` adds host content under a
|
|
371
|
-
subscription row; `useBillingRefresh()` refetches after host-side changes.
|
|
372
|
-
- Hooks: `useSubscriptions` (`cancel`, `resume`, `setPaymentMethod`,
|
|
373
|
-
`changeSubscription`, per-row `pending`, `nextCursor`), `useChangeOptions`, `usePaymentMethods` (`add`,
|
|
374
|
-
`remove`, `setDefault`), `usePayments` (cursor pages).
|
|
375
|
-
Actions resolve to `null` or a `BillingError`; they never throw.
|
|
376
|
-
`changeSubscription` resolves to the `SubscriptionChange` instead of `null`. Cancel, resume
|
|
377
|
-
and the card change answer the subscription, which replaces the row.
|
|
378
|
-
- Money is exact: `/me` amounts are int64 native-unit strings, scaled by the
|
|
379
|
-
OpenRails currency registry (`currencies` option to extend it).
|
|
380
|
-
- Messages: English is complete and the fallback; `messages` layers bundles,
|
|
381
|
-
`t` lets the host's i18n win. `useMessages().error(err)` maps error codes.
|
|
382
|
-
Count-dependent messages are CLDR plural nodes (`{ one, other }`, plus an
|
|
383
|
-
exact `"1"` like ICU `=1`), selected with `locale`.
|
|
384
|
-
- Periods are exact: OpenRails windows are hours, so 720h reads "every 30
|
|
385
|
-
days", never "monthly"; only exact weeks, days or hours are named.
|
|
386
|
-
- Styles are scoped under `.orck`; `appearance.theme` is `light`, `dark`,
|
|
387
|
-
`auto` or `inherit`. `inherit` bundles no palette: the host page's shadcn
|
|
388
|
-
tokens (`--background`, `--primary`, ...) and its `.dark` class apply.
|
|
389
|
-
|
|
390
|
-
## UI primitives
|
|
391
|
-
|
|
392
|
-
`src/components/ui/*` is shadcn (`base-vega`, zinc; see `components.json`),
|
|
393
|
-
managed with `pnpm dlx shadcn@4.21.0 add <name> --overwrite`, importing `cn`
|
|
394
|
-
from the [`cn`](https://github.com/shadcn-ui/cn) package.
|
|
395
|
-
|
|
396
|
-
## Critical client contracts
|
|
397
|
-
|
|
398
|
-
`critical/` exercises the built client in Chromium against real AuthKit,
|
|
399
|
-
OpenRails, PostgreSQL, and the actual Stripe adapter. The Go critical suite
|
|
400
|
-
owns isolated schemas, credentials, external provider fixtures, and network
|
|
401
|
-
faults. Set `OPENRAILS_CRITICAL_DSN` to an owned disposable PostgreSQL database;
|
|
402
|
-
no missing service is accepted as a skipped critical case.
|
|
403
|
-
|
|
404
|
-
```sh
|
|
405
|
-
pnpm critical:build # build the SDK, browser bundle, and check driver types
|
|
406
|
-
pnpm critical:static # reuse dist: type/lint and packed-artifact checks
|
|
407
|
-
pnpm test:e2e # local SDK subset, hosted by the real Go fixtures
|
|
408
|
-
pnpm contract # regenerate OpenRails' contract files, src/client/generated among them
|
|
409
|
-
pnpm contract:check # fail if a generated contract file is stale
|
|
138
|
+
<BillingAdmin baseUrl="/billing/v1" auth={auth} basePath="/admin/billing"
|
|
139
|
+
navigation={{ pathname, search, navigate }} appearance={{ theme: "inherit" }} />
|
|
410
140
|
```
|
|
411
141
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
142
|
+
- `auth` supplies `authFetch`; the component stores no tokens. Mount it for the
|
|
143
|
+
signed-in person and remount when that changes. Each tab shows only to whoever
|
|
144
|
+
holds its permission (`GET /v1/admin/access`); the API checks every request.
|
|
145
|
+
- `merchant` fixes the merchant (`merchants` and `onMerchantChange` add a
|
|
146
|
+
switcher); `settingsTabs`, `customerPanels` and `userHref` add your content.
|
|
147
|
+
- `useBillingAdminAccess` reads the staff member's access for your navigation;
|
|
148
|
+
`BillingCustomerSummary` previews a customer's billing on your page;
|
|
149
|
+
`billingConfirmWarnings` words a ban or deletion warning (neither cancels
|
|
150
|
+
subscriptions).
|
|
151
|
+
- The customer imports load no admin code or styles.
|
|
152
|
+
|
|
153
|
+
## Developing
|
|
154
|
+
|
|
155
|
+
`pnpm critical:build` builds the package and checks the browser driver types;
|
|
156
|
+
`pnpm critical:static` runs type, lint and packed-artifact checks;
|
|
157
|
+
`pnpm contract:check` fails when the generated wire types under
|
|
158
|
+
`src/client/generated` are stale (`pnpm contract` regenerates them with
|
|
159
|
+
OpenRails' contracts). Browser behaviour runs in OpenRails' critical suite.
|
|
160
|
+
`src/components/ui` is shadcn (`base-vega`, zinc; see `components.json`).
|
|
417
161
|
|
|
418
162
|
## License
|
|
419
163
|
|
|
420
|
-
MIT; see [LICENSE](LICENSE). Only this package is MIT: the rest of the OpenRails repository is under the
|
|
164
|
+
MIT; see [LICENSE](LICENSE). Only this package is MIT: the rest of the OpenRails repository is under the Elastic License 2.0 (ELv2).
|
package/dist/account/format.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function formatDate(value: string | null | undefined, locale?: st
|
|
|
4
4
|
/** Exact money, or null while the currency's scale is unknown. */
|
|
5
5
|
export declare function formatMoney(amount: string | null | undefined, currency: string, scales: CurrencyScales, locale?: string): string | null;
|
|
6
6
|
/** "every 30 days", "30 days of access" or "one-time". */
|
|
7
|
-
export declare function intervalLabel(price: Pick<Price, "access_duration_hours" | "billing_interval_hours"> | null | undefined, m: Translator): string | null;
|
|
7
|
+
export declare function intervalLabel(price: Pick<Price, "access_duration_hours" | "billing_interval_hours" | "billing_interval_months"> | null | undefined, m: Translator): string | null;
|
|
8
8
|
export declare function subscriptionName(s: Subscription, { t }: Translator): string;
|
|
9
9
|
/**
|
|
10
10
|
* What a payment bought, from the frozen lines of the order it settles: their
|
|
@@ -19,7 +19,11 @@ export declare function brandName(brand: string | null | undefined, fallback: st
|
|
|
19
19
|
export declare function cardText(card: CardSummary | null | undefined, m: Translator): string;
|
|
20
20
|
export declare function expiry(card: CardSummary | null | undefined): string | null;
|
|
21
21
|
export declare const LIVE_STATUSES: Set<string>;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A current subscription, or a canceled subscription retaining paid access:
|
|
24
|
+
* `access` is the window the server found live when it answered, so the
|
|
25
|
+
* device's clock decides nothing.
|
|
26
|
+
*/
|
|
23
27
|
export declare const isLive: (s: Subscription) => boolean;
|
|
24
28
|
/** Future billing has stopped or cancellation is scheduled. */
|
|
25
29
|
export declare const isEnding: (s: Subscription) => boolean;
|