@openrails/billing-ui 0.236.0 → 0.237.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +37 -67
  3. package/dist/account/account-billing.d.ts +1 -1
  4. package/dist/account/payment-methods-panel.d.ts +1 -1
  5. package/dist/buy-button.d.ts +14 -9
  6. package/dist/client/client.d.ts +25 -13
  7. package/dist/client/generated/error-codes.d.ts +1 -1
  8. package/dist/client/generated/routes.d.ts +1 -199
  9. package/dist/client/generated/wire.d.ts +34 -185
  10. package/dist/client/index.d.ts +1 -1
  11. package/dist/client/types.d.ts +72 -141
  12. package/dist/client-D9G1Tgox.js +888 -0
  13. package/dist/client-D9G1Tgox.js.map +1 -0
  14. package/dist/client.js +2 -2
  15. package/dist/components/eyebrow.d.ts +5 -0
  16. package/dist/embedded-checkout.d.ts +22 -0
  17. package/dist/{hooks-2d-XjpuI.js → hooks-DYepYVMX.js} +2 -2
  18. package/dist/{hooks-2d-XjpuI.js.map → hooks-DYepYVMX.js.map} +1 -1
  19. package/dist/index.d.ts +3 -7
  20. package/dist/index.js +1131 -2150
  21. package/dist/index.js.map +1 -1
  22. package/dist/modal.d.ts +3 -9
  23. package/dist/offers.d.ts +4 -5
  24. package/dist/psp.d.ts +0 -8
  25. package/dist/react.js +1 -1
  26. package/dist/styles.css +1 -1
  27. package/dist/tokenized-card-form.d.ts +5 -1
  28. package/dist/types.d.ts +12 -250
  29. package/docs/payment-form-contract.md +31 -74
  30. package/package.json +1 -2
  31. package/dist/checkout-frame.d.ts +0 -17
  32. package/dist/checkout-page.d.ts +0 -21
  33. package/dist/checkout.d.ts +0 -22
  34. package/dist/client/checkout.d.ts +0 -28
  35. package/dist/client-BuvolBPT.js +0 -1092
  36. package/dist/client-BuvolBPT.js.map +0 -1
  37. package/dist/components/ccbill-fields.d.ts +0 -8
  38. package/dist/components/methods.d.ts +0 -13
  39. package/dist/components/summary.d.ts +0 -12
  40. package/dist/fixtures.d.ts +0 -9
  41. package/dist/frame.d.ts +0 -47
  42. package/dist/lib/rail-meta.d.ts +0 -15
  43. package/dist/lib/redirect.d.ts +0 -2
  44. package/dist/source.d.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## Running charges
4
+
5
+ - `Balance` gains `accrued_amount`, `accrual_rate_per_hour`, `as_of` and
6
+ `depletes_at`: what the customer's running charges have charged and not yet
7
+ posted, the rate they draw the balance at, and when it runs out.
8
+ `available_amount` is net of the accrual.
9
+
10
+ ## Orders replace checkout sessions
11
+
12
+ - Breaking: `<BuyButton>` and `<Offers>` create the customer's order and pay
13
+ it in `<OrderCheckout>`; `onPaid` receives the completed `Order`.
14
+ `returnUrl` replaces `successUrl`, and `autoRenew` is gone.
15
+ - Breaking: `<CheckoutPage>`, `<CheckoutFrame>` and the shared payment page
16
+ are removed with checkout sessions; so are `CheckoutLayout`,
17
+ `CheckoutFrameTheme`, `CheckoutSession`, `CheckoutSessionStatus`,
18
+ `CheckoutPlan`, `CheckoutLineItem`, `CheckoutPhase`, `PaymentOption`,
19
+ `PayRequest`, `PayResult`, their schemas, `amountSchema`,
20
+ `unitDecimalsSchema`, `isCardRail`, `savedMethodsFor` and the client's
21
+ `CheckoutSessionLink`. `NextAction` and `PaymentFailure` are the order's,
22
+ from `@openrails/billing-ui/client`.
23
+ - A page that paid a server-minted session pays the server's order instead:
24
+ the Go `Client.CreateOrder` creates it, and `<OrderCheckout orderId>` pays
25
+ it, a subscription line included.
26
+ - `SavedPaymentMethod` names its `psp_id` (was `option_id`).
27
+
28
+ ## Usage orders
29
+
30
+ - Breaking: `listInvoices`, `getInvoice` and `Invoice` are removed. Usage
31
+ billed in arrears is an order (`origin: usage`): `listOrders({ origin:
32
+ "usage" })` lists them, and `<OrderCheckout>` pays one with a saved card.
33
+ - `Order` gains `usage` (its period, `due_at`, `amount_paid`, `amount_due`,
34
+ collection and `delinquent`) and `uncollectible_at`; `status` may be
35
+ `uncollectible`. A usage line names its `source`; its `price_id` and
36
+ `product_id` are null.
37
+ - `Order.checkout.expires_at` is read again.
38
+
39
+ ## Embedded checkout
40
+
41
+ - `<EmbeddedCheckout url onComplete?>` frames a merchant order's embedded
42
+ checkout (`checkout.ui_mode: embedded`): it follows the page's height and
43
+ hears its completion only from its own frame on the checkout host's origin;
44
+ without `onComplete` it goes to the checkout's `success_url`.
45
+ - `Order.checkout.ui_mode`; `PublicMerchant.embed_origins`;
46
+ `PublicConfig.network` (the checkout page's sign-in to the customer network).
47
+ - `createNetworkLinkChallenge()` and `createNetworkLink({challengeId, idToken})`
48
+ link the customer to a customer-network account.
49
+
50
+ ## No Solana token list
51
+
52
+ - `listSolanaTokens` and `SolanaToken` are gone with `GET /v1/solana/tokens`:
53
+ the accepted tokens are `getConfig()`'s `payment.solana.tokens`.
54
+
3
55
  ## Apple Pay and Google Pay
4
56
 
5
57
  - `<OrderCheckout wallets>` offers Apple Pay and Google Pay through a Stripe
package/README.md CHANGED
@@ -10,15 +10,13 @@ billing (subscriptions, saved cards, payment history).
10
10
  | `@openrails/billing-ui` | `BillingProvider`, styled checkout and account components, i18n |
11
11
  | `@openrails/billing-ui/locales/*` | `en de es ja ko zh` message bundles |
12
12
 
13
- The checkout owns the browser payment flow, behind `<BuyButton>` and
14
- `<Offers>`. OpenRails holds the checkout session: the signed-in customer mints
15
- one for a price, and its `ocs_` id alone reads and pays it. Card data is tokenized in NMI-hosted Collect.js iframes and
16
- never enters the host application, unless the PSP takes cards on OpenRails
17
- itself (`card_entry: server`, driver `card`).
13
+ The checkout owns the browser payment flow, behind `<BuyButton>`, `<Offers>`
14
+ and `<OrderCheckout>`: the signed-in customer's order, read and paid with
15
+ their own credential. Card data is tokenized in the PSP's own fields
16
+ (Collect.js, Stripe Elements) and never enters the host application.
18
17
 
19
- See [Payment form contract](docs/payment-form-contract.md) for the exact-money
20
- session document, billing fields, browser-autofill behavior, and the checkout
21
- request schema.
18
+ See [Payment form contract](docs/payment-form-contract.md) for exact money,
19
+ billing fields, browser-autofill behavior and the payment request.
22
20
 
23
21
  The package lives in the OpenRails repository and shares its version: each
24
22
  OpenRails release `vX.Y.Z` publishes `@openrails/billing-ui@X.Y.Z` to npm, with
@@ -48,13 +46,13 @@ const billing = createBillingClient({ baseUrl: "/billing/v1", fetch: auth.authFe
48
46
  key (a course, its bundle and the membership that also unlocks it; the Go
49
47
  `Client.ListOffers` finds the products granting an entitlement): a
50
48
  `BuyButton` per price ("$4.99", "Rent for 3 days, $1.99",
51
- "$10.00 every 30 days"). The purchase is theirs from start to payment, so the
52
- app never handles a checkout session: today a button opens one in a checkout
53
- dialog; when orders take a new card it will create an order instead,
54
- and apps won't change. Signing in is the host's: with `signedIn={false}`, or
55
- when OpenRails answers 401, they call `onSignInRequired` instead. `onPaid`
56
- follows a successful payment only; it is a hint, so confirm access from your
57
- own API (your gate) before granting anything.
49
+ "$10.00 every 30 days"). The purchase is theirs from start to payment: a
50
+ button creates the customer's order and pays it in a dialog
51
+ (`<OrderCheckout>`); a second click before it is paid opens the same order.
52
+ Signing in is the host's: with `signedIn={false}`, or when OpenRails answers
53
+ 401, they call `onSignInRequired` instead. `onPaid` receives the completed
54
+ order; it is a hint, so confirm access from your own API (your gate) before
55
+ granting anything.
58
56
 
59
57
  ```tsx
60
58
  <BuyButton
@@ -73,9 +71,8 @@ own API (your gate) before granting anything.
73
71
  />
74
72
  ```
75
73
 
76
- `successUrl` returns the buyer from a redirect step (Stripe's hosted page); it
77
- must be on one of your app's return origins. `autoRenew={false}` buys a
78
- recurring price's first term only.
74
+ `returnUrl` returns the buyer from a redirect step (Stripe's hosted page); it
75
+ must be on one of your app's return origins.
79
76
 
80
77
  For prepaid credits, a fixed pack is another product/price. A
81
78
  `customer_amount` price takes the buyer's `amount`: collect it on your product
@@ -98,44 +95,22 @@ payment. Fixed prices reject `amount`; their pack benefit can be greater than
98
95
  the purchase price for a bulk discount. Customer-selected deposits currently
99
96
  use NMI or Stripe.
100
97
 
101
- A rail's own step is the pay result's `next_action`: `redirect_to_url` (an
102
- https page, opened in the top window) or `solana_pay` (a `solana:` link shown
103
- as a QR code). A card challenge is its `operation`, authenticated in the page.
98
+ A rail's own step is the order's `payment.next_action`: `redirect_to_url` (an
99
+ https page, opened in the top window), `solana_pay` (a `solana:` link shown
100
+ as a QR code) or `authenticate` (the bank's challenge, run in the page).
104
101
 
105
- ### A shared payment page
102
+ ### An order your server creates
106
103
 
107
- Several sites selling for one merchant can share one payment page
108
- (`Config.Checkout.PageURL`). A server mints the session with the Go
109
- `Client.CreateCheckoutSession` and hands the browser its `url`, which the site
110
- frames:
104
+ A server that decides what its customer buys creates the order with the Go
105
+ `Client.CreateOrder` (`POST /v1/app/orders`) and hands its id to the
106
+ customer's browser, which pays it signed in:
111
107
 
112
108
  ```tsx
113
- <CheckoutFrame url={session.url} theme="dark" onComplete={() => refetchAccess()} />
109
+ <OrderCheckout orderId={orderId} returnUrl={returnUrl} onSettled={(order) => refetchAccess(order)} />
114
110
  ```
115
111
 
116
- Stripe Elements needs the buyer's own client, so the shared page offers token
117
- rails only.
118
-
119
- The payment host serves `<CheckoutPage>` from one HTML entry at `PageURL`,
120
- behind its adapter's `CheckoutFramePolicy` (only the sites in
121
- `Config.Checkout.EmbedOrigins` may frame it). No customer signs in there, so
122
- its `BillingProvider` has no client:
123
-
124
- ```tsx
125
- import { BillingProvider, CheckoutPage } from "@openrails/billing-ui"
126
-
127
- createRoot(root).render(
128
- <BillingProvider>
129
- <CheckoutPage appearance={{ variables: brand }} />
130
- </BillingProvider>
131
- )
132
- ```
133
-
134
- The page reads the session id from its URL fragment and talks to its frame
135
- with `postMessage`, origin-checked both ways: page to app `ready`,
136
- `resize {height}`, `complete {status}` and `redirect {url}` (a nested frame
137
- cannot navigate the top window, so the app does); app to page
138
- `init {theme}`. The page messages only the app origin recorded on its session.
112
+ `onSettled` follows a complete order, or one processing on an asynchronous
113
+ rail. A subscription line names its subscription once paid.
139
114
 
140
115
  ## Account billing
141
116
 
@@ -175,8 +150,8 @@ for host components.
175
150
  ## Catalog and plan changes
176
151
 
177
152
  The client also reads the public catalog and changes a subscription's plan.
178
- The catalog and Solana reads are public routes, served only when the host
179
- mounts OpenRails' checkout routes; `GET /config` is always served.
153
+ The catalog read is a public route, served only when the host mounts
154
+ OpenRails' checkout routes; `GET /config` is always served.
180
155
 
181
156
  | Call | Route |
182
157
  | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
@@ -184,7 +159,6 @@ mounts OpenRails' checkout routes; `GET /config` is always served.
184
159
  | `getConfig()` (capabilities, `currencies`, `payment` with PSPs, `solana.network` and tokens; `client.currencies` is the pinned registry) | `GET /config` |
185
160
  | `previewSubscriptionChange(id, { priceId?, quantity? })` | `POST /me/subscriptions/{id}/change/preview` |
186
161
  | `changeSubscription(id, { priceId?, quantity?, idempotencyKey, signature? })` | `POST /me/subscriptions/{id}/change` |
187
- | `listSolanaTokens({ priceId, wallet })` | `GET /solana/tokens` |
188
162
 
189
163
  ```ts
190
164
  const preview = await billing.previewSubscriptionChange(sub.id, { quantity: 5 }) // amount_due_now, effective
@@ -219,19 +193,15 @@ browser flow from each PSP's `flow` and public `config`
219
193
  (Collect.js, native card inputs, Stripe Elements, redirect, wallet). Hosts never branch on a
220
194
  provider:
221
195
 
222
- - A session's `options` are exactly the armed PSPs whose rail can make this
223
- sale (Solana when it is configured, never CCBill),
224
- each with its `driver` and `public_config`; `saved_methods` are the buyer's
225
- cards on them, newest first (paying sends the chosen card's id explicitly).
226
- Card rails (`collect_js`, `card`, `stripe_elements`) render one panel: saved cards,
227
- an inline new card and one Pay/Subscribe button, which is the customer's
228
- confirmation of the displayed terms. No provider chooser with one rail.
229
- - Inside a `BillingProvider` with a client, a new card is always saved to the
230
- account first and the session is paid with `payment_method_id` on the
231
- customer surface; `requires_action` results
232
- carrying an `operation` run 3-D Secure in the page. A `failed` result stays
233
- on the panel with `failure.message` next to its `field`, so the buyer can
234
- pick another card; the host gives each new attempt a new idempotency key.
196
+ - An order's `payment_options` are exactly the armed PSPs whose rail can make
197
+ this sale (Solana for one-time lines when it is configured, never CCBill),
198
+ each with what it `accepts`. `OrderCheckout` renders one panel: the
199
+ customer's saved cards on them, newest first, an inline new card and one Pay
200
+ button. No provider chooser with one rail.
201
+ - A new card is charged and saved in one pay; an `authenticate` next action
202
+ runs 3-D Secure in the page, then `confirm`. A decline stays on the panel
203
+ with its message, so the buyer can pick another card under a new
204
+ idempotency key.
235
205
  - Only PSPs with `checkout !== false` (`checkoutPsps`) take new cards; others
236
206
  stay listed so existing cards and subscriptions keep working.
237
207
  - `<SavePaymentMethod psp={psp} onSaved={(id) => ...} />` saves a card in the
@@ -240,7 +210,7 @@ provider:
240
210
  `returnURL(setupId)`; confirm with `client.confirmCardSetup(id)`.
241
211
  - `authenticatePayment(client, operationId, psp)` completes a pending
242
212
  payment's 3-D Secure challenge when `canAuthenticatePayment(psp)`.
243
- - `defaultCountry` (CheckoutPage, SavePaymentMethod, AccountBilling)
213
+ - `defaultCountry` (SavePaymentMethod, AccountBilling)
244
214
  preselects the billing country, else the browser locale's region.
245
215
 
246
216
  - Panels: `SubscriptionsPanel` (cancel, resume, change card),
@@ -4,7 +4,7 @@ import { SubscriptionsPanelProps } from './subscriptions-panel';
4
4
  export interface AccountBillingProps {
5
5
  /**
6
6
  * Offers to make a card the default for this currency: it pays the
7
- * currency's invoices and every subscription in it without its own card.
7
+ * currency's usage orders and every subscription in it without its own card.
8
8
  */
9
9
  defaultCurrency?: string;
10
10
  /** Billing country to preselect when adding a card. */
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  export interface PaymentMethodsPanelProps {
4
4
  /**
5
5
  * Offers to make a card the default for this currency: it pays the
6
- * currency's invoices and every subscription in it without its own card.
6
+ * currency's usage orders and every subscription in it without its own card.
7
7
  */
8
8
  defaultCurrency?: string;
9
9
  /** Billing country to preselect when adding a card. */
@@ -1,5 +1,5 @@
1
1
  import { CheckoutAppearance } from './appearance';
2
- import { PayResult } from './types';
2
+ import { Order } from './client/types';
3
3
  import * as React from "react";
4
4
  export interface BuyButtonProps {
5
5
  /** The product's catalog key. */
@@ -10,18 +10,16 @@ export interface BuyButtonProps {
10
10
  label?: string;
11
11
  /**
12
12
  * A customer-chosen deposit, in the price currency's native units, for a
13
- * price with `customer_amount`; the checkout charges exactly this.
13
+ * price with `customer_amount`; the order charges exactly this.
14
14
  */
15
15
  amount?: string;
16
- /** false buys a recurring price's first term only; default: renews. */
17
- autoRenew?: boolean;
18
- /** Where a redirect rail (Stripe's hosted page) returns the buyer: one of the app's return origins. */
19
- successUrl?: string;
16
+ /** Where a redirect PSP (Stripe's hosted page) returns the buyer: one of the app's return origins. */
17
+ returnUrl?: string;
20
18
  /**
21
- * The purchase succeeded. A hint: the host's own gate decides access, so
22
- * send the buyer to the content it guards.
19
+ * The order is paid. A hint: the host's own gate decides access, so send
20
+ * the buyer to the content it guards.
23
21
  */
24
- onPaid: (result: PayResult) => void;
22
+ onPaid: (order: Order) => void;
25
23
  /**
26
24
  * Buying needs a signed-in customer: called instead of the checkout when
27
25
  * `signedIn` is false or OpenRails answers 401.
@@ -33,3 +31,10 @@ export interface BuyButtonProps {
33
31
  className?: string;
34
32
  }
35
33
  export declare function BuyButton(props: BuyButtonProps): React.JSX.Element;
34
+ export type PurchaseProps = Omit<BuyButtonProps, "product" | "price"> & {
35
+ /** The price to buy; the button waits while it is unknown. */
36
+ priceId?: string;
37
+ label: string;
38
+ };
39
+ /** One price's button and its order. Requires `BillingProvider`. */
40
+ export declare function Purchase({ priceId, label, amount, returnUrl, onPaid, onSignInRequired, signedIn, appearance, className, }: PurchaseProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { BillingError } from './errors';
2
- import { Account, PublicConfig, PaymentAuthentication, CurrencyScales, Invoice, ListPage, NewCard, NextAction, Cart, Order, OrderPaymentInput, Page, Payment, PaymentMethod, Product, SolanaToken, Subscription, SubscriptionChange, SubscriptionChangePreview } from './types';
2
+ import { Account, CustomerLink, NetworkLinkChallenge, PublicConfig, PaymentAuthentication, CurrencyScales, ListPage, NewCard, NextAction, Cart, Order, OrderPaymentInput, Page, Payment, PaymentMethod, Product, Subscription, SubscriptionChange, SubscriptionChangePreview } from './types';
3
3
  export interface BillingClientOptions {
4
4
  /** OpenRails embedded mount. Default "/billing/v1". */
5
5
  baseUrl?: string;
@@ -149,6 +149,16 @@ export declare function createBillingClient(options?: BillingClientOptions): {
149
149
  reusable?: boolean;
150
150
  idempotencyKey: string;
151
151
  }): Promise<OrderResult>;
152
+ /**
153
+ * The customer's orders, newest first: `origin: "usage"` their usage
154
+ * orders, `overdue` those still owed past their due date.
155
+ */
156
+ listOrders(opts?: CursorOptions & {
157
+ origin?: string;
158
+ status?: string;
159
+ subscriptionId?: string;
160
+ overdue?: boolean;
161
+ }): Promise<ListPage<Order>>;
152
162
  /** One of the customer's orders: the resumable handle of a purchase. */
153
163
  getOrder(orderId: string, signal?: AbortSignal): Promise<Order>;
154
164
  /**
@@ -177,7 +187,7 @@ export declare function createBillingClient(options?: BillingClientOptions): {
177
187
  removePaymentMethod(paymentMethodId: string): Promise<"removed" | "pending">;
178
188
  /**
179
189
  * Makes the card the default for one currency: it pays the currency's
180
- * invoices and every subscription in it without its own card.
190
+ * usage orders and every subscription in it without its own card.
181
191
  */
182
192
  setDefaultPaymentMethod(input: {
183
193
  currency: string;
@@ -187,33 +197,35 @@ export declare function createBillingClient(options?: BillingClientOptions): {
187
197
  listPayments(opts?: CursorOptions & {
188
198
  rail?: string;
189
199
  }): Promise<ListPage<Payment>>;
190
- listInvoices(opts?: CursorOptions): Promise<ListPage<Invoice>>;
191
200
  /**
192
201
  * The customer's summary: balance and amount owed per currency, the card
193
202
  * that pays each currency, and unread notices.
194
203
  */
195
204
  getAccount(signal?: AbortSignal): Promise<Account>;
196
- getInvoice(invoiceId: string, signal?: AbortSignal): Promise<Invoice>;
197
205
  /**
198
206
  * The products on sale named by `keys`, each with its current prices.
199
207
  * No keys name no products: nothing is fetched.
200
208
  */
201
209
  listProducts(opts: ProductListOptions): Promise<Page<Product>>;
210
+ /**
211
+ * A challenge to link the customer to an openrails.dev account: its
212
+ * `nonce` goes in the network sign-in's authorization request.
213
+ */
214
+ createNetworkLinkChallenge(): Promise<NetworkLinkChallenge>;
215
+ /**
216
+ * Links the customer to the openrails.dev account whose fresh sign-in
217
+ * answered the challenge (its ID token).
218
+ */
219
+ createNetworkLink(params: {
220
+ challengeId: string;
221
+ idToken: string;
222
+ }): Promise<CustomerLink>;
202
223
  /**
203
224
  * The deployment's public configuration: what the mount serves, the
204
225
  * currency registry and the merchant's payment setup. React components
205
226
  * share one copy through `useConfig()`.
206
227
  */
207
228
  getConfig(signal?: AbortSignal): Promise<PublicConfig>;
208
- /**
209
- * Accepted tokens with live prices. `priceId` adds each token's `quote`;
210
- * `wallet` adds its `balance`.
211
- */
212
- listSolanaTokens(opts?: {
213
- priceId?: string;
214
- wallet?: string;
215
- signal?: AbortSignal;
216
- }): Promise<SolanaToken[]>;
217
229
  /** Currency code (upper case) to native-unit decimals. */
218
230
  currencies: Readonly<Record<string, number>>;
219
231
  };
@@ -1,4 +1,4 @@
1
- export type OpenRailsErrorCode = "admission_captured" | "admission_not_found" | "allowance_meter_not_found" | "allowance_source_in_use" | "allowance_source_invalid" | "already_owned" | "application_required" | "as_of_required" | "authentication_required" | "authentication_unavailable" | "authorization_unavailable" | "billing_archive_integrity" | "billing_archive_invalid_artifact" | "billing_archive_merchant_mismatch" | "billing_archive_not_empty" | "billing_archive_unavailable" | "billing_archive_unsupported_state" | "billing_policy_not_found" | "cancel_unsupported_on_rail" | "captcha_invalid" | "captcha_required" | "card_attempts_blocked" | "card_declined" | "card_not_saved" | "card_requires_https" | "catalog_benefit_overlap" | "catalog_revision_conflict" | "checkout_attempt_closed" | "checkout_attempt_expired" | "checkout_attempts_exhausted" | "checkout_expired" | "checkout_not_found" | "checkout_offer_unavailable" | "checkout_payment_in_progress" | "checkout_request_invalid" | "checkout_session_expired" | "checkout_session_not_found" | "checkout_session_unavailable" | "credential_expired" | "credential_revoked" | "credit_grant_held" | "credit_grant_not_found" | "credit_grant_unavailable" | "csrf_origin_denied" | "currency_unsupported" | "custodian_capture_unavailable" | "customer_action_required" | "customer_email_required" | "customer_not_found" | "customer_payment_unsupported" | "customer_proof_required" | "customer_session_required" | "dashboard_invalid" | "database_busy" | "default_payment_method_invalid" | "default_payment_method_required" | "default_rate_card_not_found" | "default_rate_card_required" | "finding_action_failed" | "finding_not_actionable" | "hold_not_found" | "host_event_not_found" | "host_principal_invalid" | "hosted_checkout_unavailable" | "idempotency_key_in_progress" | "idempotency_key_in_use" | "idempotency_key_required" | "idempotency_key_reused" | "insufficient_credits" | "insufficient_funds" | "internal_error" | "invalid_cursor" | "invalid_customer_id" | "invalid_host_event_request" | "invalid_param" | "invalid_payment_method" | "invalid_psp_reference" | "invalid_query" | "invalid_request_body" | "invalid_settlement_status_request" | "invoice_action_not_allowed" | "invoice_not_retryable" | "invoice_retry_idempotency_conflict" | "invoice_retry_in_progress" | "invoice_retry_outcome_unknown" | "invoker_scoped_principal" | "merchant_binding_mismatch" | "merchant_config_read_only" | "merchant_directory_unavailable" | "merchant_not_found" | "merchant_selector_invalid" | "merchant_unresolved" | "meter_in_use" | "meter_rate_card_conflict" | "method_not_allowed" | "metrics_query_invalid" | "model_unavailable" | "network_account_linked" | "network_link_challenge_invalid" | "network_link_conflict" | "network_link_in_use" | "network_terms_required" | "order_has_recurring_line" | "order_line_unavailable" | "order_not_cancelable" | "order_not_payable" | "order_payment_in_progress" | "order_total_changed" | "payment_duplicate_refused" | "payment_exceeds_due" | "payment_failed" | "payment_idempotency_conflict" | "payment_in_progress" | "payment_method_delete_failed" | "payment_method_delete_unsupported" | "payment_method_not_psp_vaulted" | "payment_method_not_usable" | "payment_method_psp_mismatch" | "payment_method_required" | "payment_method_same_vault" | "payment_method_stale" | "payment_method_update_failed" | "payment_method_update_retry_required" | "payment_method_update_unsupported" | "payment_not_found" | "payment_not_refundable" | "payment_not_retryable" | "payment_option_unavailable" | "payment_provider_rejected" | "permission_required" | "price_change_currency_mismatch" | "price_change_target_archived" | "price_increase_notice_too_short" | "price_key_cadence_conflict" | "price_key_not_found" | "price_migration_not_found" | "price_not_found" | "price_not_sellable" | "product_not_found" | "product_tier_group_conflict" | "product_tier_group_in_use" | "provider_billing_observation_conflict" | "provider_cancel_held" | "provider_operation_conflict" | "provider_operation_has_billing_evidence" | "provider_operation_not_found" | "provider_operation_not_open" | "provider_operation_not_refused" | "provider_operation_refused" | "provider_outcome_unknown" | "psp_claim_requires_proof" | "psp_credentials_rejected" | "psp_exists" | "psp_key_taken" | "psp_last_active" | "psp_not_found" | "purchase_review_resolved" | "quantity_not_allowed" | "rate_card_currency_mismatch" | "rate_card_has_overrides" | "rate_card_product_not_found" | "rate_limit_exceeded" | "rebill_terms_committed" | "refund_failed" | "refund_rail_unavailable" | "refund_unsupported" | "request_body_too_large" | "resource_access_denied" | "resource_conflict" | "resource_not_found" | "revision_mismatch" | "route_not_found" | "scheduled_change_exists" | "service_credential_customer_scope_denied" | "service_unavailable" | "solana_rpc_unavailable" | "solana_transaction_refused" | "step_up_required" | "step_up_unavailable" | "stored_credential_required" | "subscription_change_already_scheduled" | "subscription_change_cadence_unsupported" | "subscription_change_credit_exceeds_price" | "subscription_change_cycle_unknown" | "subscription_change_idempotency_conflict" | "subscription_change_idempotency_key_required" | "subscription_change_in_flight" | "subscription_change_period_unknown" | "subscription_change_provider_conflict" | "subscription_change_refused" | "subscription_change_renewal_due" | "subscription_change_requires_linked_plan" | "subscription_change_target_inactive" | "subscription_change_unsupported_on_rail" | "subscription_not_active" | "subscription_not_found" | "subscription_paid_through" | "subscription_resumable" | "trial_unsupported_on_rail" | "unknown_field" | "unsupported_media_type" | "usage_meter_invalid" | "usage_meter_not_found" | "usage_rate_card_invalid" | "webhook_account_mismatch" | "webhook_invalid" | "widget_generation_invalid";
1
+ export type OpenRailsErrorCode = "admission_captured" | "admission_not_found" | "allowance_meter_not_found" | "allowance_source_in_use" | "allowance_source_invalid" | "already_owned" | "application_required" | "as_of_required" | "authentication_required" | "authentication_unavailable" | "authorization_unavailable" | "billing_archive_integrity" | "billing_archive_invalid_artifact" | "billing_archive_merchant_mismatch" | "billing_archive_not_empty" | "billing_archive_unavailable" | "billing_archive_unsupported_state" | "billing_policy_not_found" | "cancel_unsupported_on_rail" | "captcha_invalid" | "captcha_required" | "card_attempts_blocked" | "card_declined" | "card_not_saved" | "card_requires_https" | "catalog_benefit_overlap" | "catalog_revision_conflict" | "checkout_attempt_closed" | "checkout_attempt_expired" | "checkout_attempts_exhausted" | "checkout_embed_origins_required" | "checkout_expired" | "checkout_not_found" | "credential_expired" | "credential_revoked" | "credit_grant_held" | "credit_grant_not_found" | "credit_grant_unavailable" | "csrf_origin_denied" | "currency_unsupported" | "custodian_capture_unavailable" | "customer_action_required" | "customer_email_required" | "customer_not_found" | "customer_payment_unsupported" | "customer_session_required" | "dashboard_invalid" | "database_busy" | "default_payment_method_invalid" | "default_payment_method_required" | "default_rate_card_not_found" | "default_rate_card_required" | "finding_action_failed" | "finding_not_actionable" | "hold_not_found" | "host_event_not_found" | "host_principal_invalid" | "hosted_checkout_unavailable" | "idempotency_key_in_progress" | "idempotency_key_in_use" | "idempotency_key_required" | "idempotency_key_reused" | "insufficient_credits" | "insufficient_funds" | "internal_error" | "invalid_cursor" | "invalid_customer_id" | "invalid_host_event_request" | "invalid_param" | "invalid_payment_method" | "invalid_psp_reference" | "invalid_query" | "invalid_request_body" | "invalid_settlement_status_request" | "invoker_scoped_principal" | "merchant_binding_mismatch" | "merchant_config_read_only" | "merchant_directory_unavailable" | "merchant_not_found" | "merchant_selector_invalid" | "merchant_unresolved" | "meter_in_use" | "meter_rate_card_conflict" | "method_not_allowed" | "metrics_query_invalid" | "model_unavailable" | "network_account_linked" | "network_link_challenge_invalid" | "network_link_conflict" | "network_link_in_use" | "network_terms_required" | "order_action_not_allowed" | "order_has_recurring_line" | "order_line_unavailable" | "order_not_cancelable" | "order_not_payable" | "order_payment_in_progress" | "order_total_changed" | "payment_duplicate_refused" | "payment_exceeds_due" | "payment_failed" | "payment_idempotency_conflict" | "payment_in_progress" | "payment_method_delete_failed" | "payment_method_delete_unsupported" | "payment_method_not_psp_vaulted" | "payment_method_not_usable" | "payment_method_psp_mismatch" | "payment_method_required" | "payment_method_same_vault" | "payment_method_stale" | "payment_method_update_failed" | "payment_method_update_unsupported" | "payment_not_found" | "payment_not_refundable" | "payment_not_retryable" | "payment_option_unavailable" | "payment_provider_rejected" | "permission_required" | "price_change_currency_mismatch" | "price_change_target_archived" | "price_increase_notice_too_short" | "price_key_cadence_conflict" | "price_key_not_found" | "price_migration_not_found" | "price_not_found" | "price_not_sellable" | "product_not_found" | "product_tier_group_conflict" | "product_tier_group_in_use" | "provider_billing_observation_conflict" | "provider_cancel_held" | "provider_operation_conflict" | "provider_operation_has_billing_evidence" | "provider_operation_not_found" | "provider_operation_not_open" | "provider_operation_not_refused" | "provider_operation_refused" | "provider_outcome_unknown" | "psp_claim_requires_proof" | "psp_credentials_rejected" | "psp_exists" | "psp_key_taken" | "psp_last_active" | "psp_not_found" | "purchase_review_resolved" | "quantity_not_allowed" | "rate_card_currency_mismatch" | "rate_card_has_overrides" | "rate_card_product_not_found" | "rate_limit_exceeded" | "rebill_terms_committed" | "refund_failed" | "refund_rail_unavailable" | "refund_unsupported" | "request_body_too_large" | "resource_access_denied" | "resource_conflict" | "resource_not_found" | "revision_mismatch" | "route_not_found" | "running_charge_not_found" | "scheduled_change_exists" | "service_credential_customer_scope_denied" | "service_unavailable" | "solana_rpc_unavailable" | "solana_transaction_refused" | "step_up_required" | "step_up_unavailable" | "stored_credential_required" | "subscription_change_already_scheduled" | "subscription_change_cadence_unsupported" | "subscription_change_credit_exceeds_price" | "subscription_change_cycle_unknown" | "subscription_change_idempotency_conflict" | "subscription_change_idempotency_key_required" | "subscription_change_in_flight" | "subscription_change_period_unknown" | "subscription_change_provider_conflict" | "subscription_change_refused" | "subscription_change_renewal_due" | "subscription_change_requires_linked_plan" | "subscription_change_target_inactive" | "subscription_change_unsupported_on_rail" | "subscription_not_active" | "subscription_not_found" | "subscription_paid_through" | "subscription_resumable" | "trial_unsupported_on_rail" | "unknown_field" | "unsupported_media_type" | "usage_meter_invalid" | "usage_meter_not_found" | "usage_rate_card_invalid" | "webhook_account_mismatch" | "webhook_invalid" | "widget_generation_invalid";
2
2
  export type OpenRailsErrorType = "api_error" | "authentication_error" | "authorization_error" | "card_error" | "invalid_request_error" | "rate_limit_error";
3
3
  export declare const OPENRAILS_ERROR_CODES: Readonly<Record<OpenRailsErrorCode, {
4
4
  status: number;
@@ -53,146 +53,6 @@ export declare const OPENRAILS_ROUTES: readonly [{
53
53
  };
54
54
  readonly errors: readonly [];
55
55
  readonly errorSets: readonly ["tier:public"];
56
- }, {
57
- readonly method: "GET";
58
- readonly path: "/v1/solana/tokens";
59
- readonly group: "checkout";
60
- readonly auth: "public";
61
- readonly permission: null;
62
- readonly sensitive: false;
63
- readonly mountedWhen: "solana";
64
- readonly request: null;
65
- readonly responses: {
66
- readonly 200: "SupportedTokensResponse";
67
- };
68
- readonly errors: readonly ["resource_conflict"];
69
- readonly errorSets: readonly ["tier:public", "request"];
70
- }, {
71
- readonly method: "GET";
72
- readonly path: "/v1/checkout-sessions/{id}";
73
- readonly group: "checkout";
74
- readonly auth: "checkout_session";
75
- readonly permission: null;
76
- readonly sensitive: false;
77
- readonly mountedWhen: null;
78
- readonly request: null;
79
- readonly responses: {
80
- readonly 200: "CheckoutSession";
81
- };
82
- readonly errors: readonly ["card_attempts_blocked", "card_declined", "card_not_saved", "checkout_session_not_found", "checkout_session_unavailable", "idempotency_key_reused", "insufficient_funds", "invalid_param", "payment_method_required", "payment_method_stale", "payment_provider_rejected", "resource_access_denied", "resource_conflict", "resource_not_found", "service_unavailable", "subscription_paid_through", "subscription_resumable"];
83
- readonly errorSets: readonly ["tier:checkout_session"];
84
- }, {
85
- readonly method: "POST";
86
- readonly path: "/v1/checkout-sessions/{id}/pay";
87
- readonly group: "checkout";
88
- readonly auth: "checkout_session";
89
- readonly permission: null;
90
- readonly sensitive: false;
91
- readonly mountedWhen: null;
92
- readonly request: "PayCheckoutSessionParams";
93
- readonly responses: {
94
- readonly 200: "CheckoutSessionPayResult";
95
- };
96
- readonly errors: readonly ["card_attempts_blocked", "card_declined", "card_not_saved", "card_requires_https", "checkout_offer_unavailable", "checkout_payment_in_progress", "checkout_request_invalid", "checkout_session_expired", "checkout_session_not_found", "checkout_session_unavailable", "customer_proof_required", "idempotency_key_reused", "insufficient_funds", "invalid_param", "payment_method_required", "payment_method_stale", "payment_provider_rejected", "resource_access_denied", "resource_conflict", "resource_not_found", "service_unavailable", "subscription_paid_through", "subscription_resumable"];
97
- readonly errorSets: readonly ["tier:checkout_session", "request"];
98
- }, {
99
- readonly method: "GET";
100
- readonly path: "/v1/checkout-attempts/{id}/solana-pay";
101
- readonly group: "checkout";
102
- readonly auth: "session_id";
103
- readonly permission: null;
104
- readonly sensitive: false;
105
- readonly mountedWhen: "solana";
106
- readonly request: null;
107
- readonly responses: {
108
- readonly 200: "SolanaPayGetResponse";
109
- };
110
- readonly errors: readonly ["checkout_attempt_expired", "invalid_param", "resource_conflict", "resource_not_found"];
111
- readonly errorSets: readonly ["tier:session_id"];
112
- }, {
113
- readonly method: "POST";
114
- readonly path: "/v1/checkout-attempts/{id}/solana-pay";
115
- readonly group: "checkout";
116
- readonly auth: "session_id";
117
- readonly permission: null;
118
- readonly sensitive: false;
119
- readonly mountedWhen: "solana";
120
- readonly request: "SolanaPayPostRequest";
121
- readonly responses: {
122
- readonly 200: "SolanaPayPostResponse";
123
- };
124
- readonly errors: readonly ["checkout_attempt_expired", "invalid_param", "resource_conflict", "resource_not_found"];
125
- readonly errorSets: readonly ["tier:session_id", "request"];
126
- }, {
127
- readonly method: "POST";
128
- readonly path: "/v1/me/checkout-sessions";
129
- readonly group: "customer";
130
- readonly auth: "customer";
131
- readonly permission: null;
132
- readonly sensitive: false;
133
- readonly mountedWhen: null;
134
- readonly request: "MintCheckoutSessionParams";
135
- readonly responses: {
136
- readonly 201: "CheckoutSessionLink";
137
- };
138
- readonly errors: readonly ["authentication_required", "checkout_offer_unavailable", "checkout_session_unavailable", "customer_action_required", "invalid_param", "resource_conflict", "resource_not_found", "service_unavailable"];
139
- readonly errorSets: readonly ["tier:customer", "request"];
140
- }, {
141
- readonly method: "GET";
142
- readonly path: "/v1/me/checkout-sessions/{id}";
143
- readonly group: "customer";
144
- readonly auth: "customer";
145
- readonly permission: null;
146
- readonly sensitive: false;
147
- readonly mountedWhen: null;
148
- readonly request: null;
149
- readonly responses: {
150
- readonly 200: "CheckoutSession";
151
- };
152
- readonly errors: readonly ["card_attempts_blocked", "card_declined", "card_not_saved", "checkout_session_not_found", "checkout_session_unavailable", "idempotency_key_reused", "insufficient_funds", "invalid_param", "payment_method_required", "payment_method_stale", "payment_provider_rejected", "resource_access_denied", "resource_conflict", "resource_not_found", "service_unavailable", "subscription_paid_through", "subscription_resumable"];
153
- readonly errorSets: readonly ["tier:customer"];
154
- }, {
155
- readonly method: "POST";
156
- readonly path: "/v1/me/checkout-sessions/{id}/pay";
157
- readonly group: "customer";
158
- readonly auth: "customer";
159
- readonly permission: null;
160
- readonly sensitive: false;
161
- readonly mountedWhen: null;
162
- readonly request: "PayCheckoutSessionParams";
163
- readonly responses: {
164
- readonly 200: "CheckoutSessionPayResult";
165
- };
166
- readonly errors: readonly ["card_attempts_blocked", "card_declined", "card_not_saved", "card_requires_https", "checkout_offer_unavailable", "checkout_payment_in_progress", "checkout_request_invalid", "checkout_session_expired", "checkout_session_not_found", "checkout_session_unavailable", "customer_action_required", "customer_proof_required", "idempotency_key_reused", "insufficient_funds", "invalid_param", "payment_method_required", "payment_method_stale", "payment_provider_rejected", "resource_access_denied", "resource_conflict", "resource_not_found", "service_unavailable", "subscription_paid_through", "subscription_resumable"];
167
- readonly errorSets: readonly ["tier:customer", "request"];
168
- }, {
169
- readonly method: "GET";
170
- readonly path: "/v1/captcha/status";
171
- readonly group: "checkout";
172
- readonly auth: "public";
173
- readonly permission: null;
174
- readonly sensitive: false;
175
- readonly mountedWhen: null;
176
- readonly request: null;
177
- readonly responses: {
178
- readonly 200: "CaptchaStatus";
179
- };
180
- readonly errors: readonly [];
181
- readonly errorSets: readonly ["tier:public"];
182
- }, {
183
- readonly method: "GET";
184
- readonly path: "/v1/captcha/client.js";
185
- readonly group: "checkout";
186
- readonly auth: "public";
187
- readonly permission: null;
188
- readonly sensitive: false;
189
- readonly mountedWhen: null;
190
- readonly request: null;
191
- readonly responses: {
192
- readonly 200: "application/javascript";
193
- };
194
- readonly errors: readonly [];
195
- readonly errorSets: readonly ["tier:public"];
196
56
  }, {
197
57
  readonly method: "POST";
198
58
  readonly path: "/v1/me/orders/preview";
@@ -276,7 +136,7 @@ export declare const OPENRAILS_ROUTES: readonly [{
276
136
  readonly responses: {
277
137
  readonly 200: "Order";
278
138
  };
279
- readonly errors: readonly ["card_declined", "customer_action_required", "customer_session_required", "payment_failed", "resource_conflict", "resource_not_found", "service_unavailable"];
139
+ readonly errors: readonly ["card_declined", "customer_action_required", "customer_session_required", "invalid_param", "payment_failed", "resource_conflict", "resource_not_found", "service_unavailable"];
280
140
  readonly errorSets: readonly ["tier:customer"];
281
141
  }, {
282
142
  readonly method: "POST";
@@ -546,49 +406,6 @@ export declare const OPENRAILS_ROUTES: readonly [{
546
406
  };
547
407
  readonly errors: readonly ["currency_unsupported"];
548
408
  readonly errorSets: readonly ["tier:customer", "request"];
549
- }, {
550
- readonly method: "GET";
551
- readonly path: "/v1/me/invoices";
552
- readonly group: "customer";
553
- readonly auth: "customer";
554
- readonly permission: null;
555
- readonly sensitive: false;
556
- readonly mountedWhen: null;
557
- readonly request: null;
558
- readonly responses: {
559
- readonly 200: "ListPage<Invoice>";
560
- };
561
- readonly errors: readonly ["invalid_cursor"];
562
- readonly errorSets: readonly ["tier:customer", "request"];
563
- }, {
564
- readonly method: "GET";
565
- readonly path: "/v1/me/invoices/{id}";
566
- readonly group: "customer";
567
- readonly auth: "customer";
568
- readonly permission: null;
569
- readonly sensitive: false;
570
- readonly mountedWhen: null;
571
- readonly request: null;
572
- readonly responses: {
573
- readonly 200: "Invoice";
574
- };
575
- readonly errors: readonly ["invalid_param", "resource_not_found"];
576
- readonly errorSets: readonly ["tier:customer"];
577
- }, {
578
- readonly method: "POST";
579
- readonly path: "/v1/me/invoices/{id}/pay-now";
580
- readonly group: "customer";
581
- readonly auth: "customer";
582
- readonly permission: null;
583
- readonly sensitive: false;
584
- readonly mountedWhen: null;
585
- readonly request: "PayInvoiceParams";
586
- readonly responses: {
587
- readonly 200: "InvoicePayNow";
588
- readonly 202: "InvoicePayNow";
589
- };
590
- readonly errors: readonly ["card_declined", "customer_action_required", "customer_payment_unsupported", "invalid_param", "invalid_payment_method", "payment_idempotency_conflict", "payment_in_progress", "payment_method_required", "payment_not_retryable", "payment_provider_rejected", "rebill_terms_committed", "resource_conflict", "resource_not_found", "service_unavailable"];
591
- readonly errorSets: readonly ["tier:customer", "request"];
592
409
  }, {
593
410
  readonly method: "GET";
594
411
  readonly path: "/v1/me/payment-operations/{id}/authentication";
@@ -673,21 +490,6 @@ export declare const OPENRAILS_ROUTES: readonly [{
673
490
  };
674
491
  readonly errors: readonly ["card_attempts_blocked", "card_declined", "card_not_saved", "card_requires_https", "invalid_param", "payment_duplicate_refused", "payment_method_stale", "payment_provider_rejected", "provider_outcome_unknown", "service_unavailable"];
675
492
  readonly errorSets: readonly ["tier:customer", "request"];
676
- }, {
677
- readonly method: "PUT";
678
- readonly path: "/v1/me/payment-methods/{id}";
679
- readonly group: "customer";
680
- readonly auth: "customer";
681
- readonly permission: null;
682
- readonly sensitive: false;
683
- readonly mountedWhen: null;
684
- readonly request: "ReplacePaymentMethodCardParams";
685
- readonly responses: {
686
- readonly 200: "PaymentMethod";
687
- readonly 202: null;
688
- };
689
- readonly errors: readonly ["card_declined", "card_not_saved", "card_requires_https", "invalid_param", "payment_method_update_failed", "payment_method_update_retry_required", "payment_method_update_unsupported", "payment_provider_rejected", "resource_conflict", "resource_not_found", "service_unavailable"];
690
- readonly errorSets: readonly ["tier:customer", "request"];
691
493
  }, {
692
494
  readonly method: "PATCH";
693
495
  readonly path: "/v1/me/payment-methods/{id}";