@openrails/billing-ui 0.0.0-stage → 0.230.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/CHANGELOG.md +257 -0
- package/LICENSE +21 -0
- package/README.md +211 -2
- package/dist/account/account-billing.d.ts +19 -0
- package/dist/account/cancel-dialog.d.ts +18 -0
- package/dist/account/change-card-dialog.d.ts +14 -0
- package/dist/account/format.d.ts +25 -0
- package/dist/account/notice.d.ts +3 -0
- package/dist/account/payment-history.d.ts +8 -0
- package/dist/account/payment-methods-panel.d.ts +19 -0
- package/dist/account/section.d.ts +25 -0
- package/dist/account/status-badge.d.ts +8 -0
- package/dist/account/subscriptions-panel.d.ts +19 -0
- package/dist/appearance.d.ts +23 -0
- package/dist/authenticate.d.ts +8 -0
- package/dist/checkout-frame.d.ts +17 -0
- package/dist/checkout-page.d.ts +16 -0
- package/dist/checkout.d.ts +24 -0
- package/dist/client/client.d.ts +167 -0
- package/dist/client/errors.d.ts +26 -0
- package/dist/client/generated/openrails-routes.d.ts +2 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/types.d.ts +754 -0
- package/dist/client-DhG2jv34.js +771 -0
- package/dist/client-DhG2jv34.js.map +1 -0
- package/dist/client.js +3 -0
- package/dist/components/billing-fields.d.ts +39 -0
- package/dist/components/card-brands.d.ts +6 -0
- package/dist/components/card-fields.d.ts +29 -0
- package/dist/components/ccbill-fields.d.ts +8 -0
- package/dist/components/methods.d.ts +13 -0
- package/dist/components/pay-button.d.ts +6 -0
- package/dist/components/qr.d.ts +6 -0
- package/dist/components/saved-methods.d.ts +9 -0
- package/dist/components/states.d.ts +10 -0
- package/dist/components/stripe-card.d.ts +17 -0
- package/dist/components/summary.d.ts +12 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/spinner.d.ts +3 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/dist-CslWupfi.js +3311 -0
- package/dist/dist-CslWupfi.js.map +1 -0
- package/dist/errors-T-PRm3vV.js +54 -0
- package/dist/errors-T-PRm3vV.js.map +1 -0
- package/dist/fixtures.d.ts +9 -0
- package/dist/frame.d.ts +47 -0
- package/dist/hooks-DLFF-zx5.js +285 -0
- package/dist/hooks-DLFF-zx5.js.map +1 -0
- package/dist/i18n/context.d.ts +4 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/messages.d.ts +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +4182 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/billing.d.ts +25 -0
- package/dist/lib/card-brands.d.ts +2 -0
- package/dist/lib/card-entry.d.ts +46 -0
- package/dist/lib/ccbill.d.ts +8 -0
- package/dist/lib/collect.d.ts +51 -0
- package/dist/lib/money.d.ts +9 -0
- package/dist/lib/period.d.ts +15 -0
- package/dist/lib/rail-meta.d.ts +15 -0
- package/dist/lib/redirect.d.ts +2 -0
- package/dist/lib/stripe-appearance.d.ts +2 -0
- package/dist/lib/stripe.d.ts +2 -0
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/de.js +204 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/en.d.ts +201 -0
- package/dist/locales/en.js +204 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es.d.ts +2 -0
- package/dist/locales/es.js +204 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/ja.d.ts +2 -0
- package/dist/locales/ja.js +195 -0
- package/dist/locales/ja.js.map +1 -0
- package/dist/locales/ko.d.ts +2 -0
- package/dist/locales/ko.js +195 -0
- package/dist/locales/ko.js.map +1 -0
- package/dist/locales/zh.d.ts +2 -0
- package/dist/locales/zh.js +195 -0
- package/dist/locales/zh.js.map +1 -0
- package/dist/modal.d.ts +12 -0
- package/dist/provider.d.ts +18 -0
- package/dist/psp.d.ts +46 -0
- package/dist/react/context.d.ts +38 -0
- package/dist/react/hooks.d.ts +76 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/provider.d.ts +18 -0
- package/dist/react/remote.d.ts +11 -0
- package/dist/react.js +37 -0
- package/dist/react.js.map +1 -0
- package/dist/save-payment-method.d.ts +26 -0
- package/dist/scope-context.d.ts +17 -0
- package/dist/scope.d.ts +6 -0
- package/dist/source.d.ts +14 -0
- package/dist/styles.css +3 -0
- package/dist/tokenized-card-form.d.ts +24 -0
- package/dist/types.d.ts +191 -0
- package/docs/1055-nmi-host-integration.md +28 -0
- package/docs/payment-form-contract.md +153 -0
- package/package.json +112 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CheckoutAppearance } from '../appearance';
|
|
2
|
+
import { SendSolanaTransaction } from '../client/client';
|
|
3
|
+
import { Subscription } from '../client/types';
|
|
4
|
+
import { SubscriptionsOptions } from '../react/hooks';
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
export interface SubscriptionsPanelProps extends SubscriptionsOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Wallet for Solana-rail subscriptions. Without it their cancel action is
|
|
9
|
+
* hidden.
|
|
10
|
+
*/
|
|
11
|
+
sendSolanaTransaction?: SendSolanaTransaction;
|
|
12
|
+
/** Empty-state link to the host's plans page (uses `navigate` if set). */
|
|
13
|
+
plansHref?: string;
|
|
14
|
+
/** Host content under a row, e.g. a plan-change control. */
|
|
15
|
+
renderSubscriptionFooter?: (subscription: Subscription) => React.ReactNode;
|
|
16
|
+
appearance?: CheckoutAppearance;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function SubscriptionsPanel({ sendSolanaTransaction, plansHref, renderSubscriptionFooter, appearance, className, ...options }: SubscriptionsPanelProps): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export type CheckoutTheme = "light" | "dark" | "auto" | "inherit";
|
|
3
|
+
export interface CheckoutVariables {
|
|
4
|
+
background?: string;
|
|
5
|
+
foreground?: string;
|
|
6
|
+
card?: string;
|
|
7
|
+
mutedForeground?: string;
|
|
8
|
+
faintForeground?: string;
|
|
9
|
+
border?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
primary?: string;
|
|
12
|
+
primaryForeground?: string;
|
|
13
|
+
destructive?: string;
|
|
14
|
+
ring?: string;
|
|
15
|
+
radius?: string;
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckoutAppearance {
|
|
19
|
+
theme?: CheckoutTheme;
|
|
20
|
+
variables?: CheckoutVariables;
|
|
21
|
+
}
|
|
22
|
+
export declare function appearanceStyle(appearance: CheckoutAppearance | undefined): CSSProperties | undefined;
|
|
23
|
+
export declare function appearanceTheme(appearance: CheckoutAppearance | undefined): CheckoutTheme;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BillingClient } from './client/client';
|
|
2
|
+
import { PspConfig } from './psp';
|
|
3
|
+
/**
|
|
4
|
+
* Completes the provider challenge (3-D Secure) a pending payment operation
|
|
5
|
+
* waits on. "not_required" when the provider has none outstanding; the
|
|
6
|
+
* operation's own status remains the result.
|
|
7
|
+
*/
|
|
8
|
+
export declare function authenticatePayment(client: BillingClient, operationId: string, psp: PspConfig): Promise<"authenticated" | "not_required">;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CheckoutFrameTheme } from './frame';
|
|
2
|
+
import { CheckoutSessionStatus } from './types';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export interface CheckoutFrameProps {
|
|
5
|
+
/** The minted session's `url` (createCheckoutSession). */
|
|
6
|
+
url: string;
|
|
7
|
+
onComplete?: (status: CheckoutSessionStatus) => void;
|
|
8
|
+
/** Default "auto": the buyer's system preference. */
|
|
9
|
+
theme?: CheckoutFrameTheme;
|
|
10
|
+
/** Accessible name of the frame. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Height before the page reports its own, in pixels. Default 480. */
|
|
13
|
+
minHeight?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare function CheckoutFrame({ url, onComplete, theme, title, minHeight, className, style, }: CheckoutFrameProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CheckoutAppearance } from './appearance';
|
|
2
|
+
import { CheckoutLayout } from './checkout';
|
|
3
|
+
import { BillingClient } from './client/client';
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export interface CheckoutPageProps {
|
|
6
|
+
/** OpenRails mount on this host. Default "/billing/v1". */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Replaces the client built from `baseUrl`. */
|
|
9
|
+
client?: BillingClient;
|
|
10
|
+
/** This host's branding; the framing app chooses the theme. */
|
|
11
|
+
appearance?: CheckoutAppearance;
|
|
12
|
+
layout?: CheckoutLayout;
|
|
13
|
+
defaultCountry?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function CheckoutPage({ baseUrl, client, appearance, layout, defaultCountry, className, }: CheckoutPageProps): React.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CheckoutAppearance } from './appearance';
|
|
2
|
+
import { CheckoutSource } from './source';
|
|
3
|
+
import { CheckoutPhase, PayResult } from './types';
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export type CheckoutLayout = "auto" | "wide" | "compact";
|
|
6
|
+
export interface CheckoutProps {
|
|
7
|
+
source: CheckoutSource;
|
|
8
|
+
appearance?: CheckoutAppearance;
|
|
9
|
+
layout?: CheckoutLayout;
|
|
10
|
+
/** Billing country to preselect; default: the browser locale's region. */
|
|
11
|
+
defaultCountry?: string;
|
|
12
|
+
/** Return target after an off-page card verification (Stripe setup). */
|
|
13
|
+
cardSetupReturnURL?: (setupId: string) => string;
|
|
14
|
+
onComplete?: (result: PayResult) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Leaves for a redirect rail's page. Default: navigate the top window,
|
|
17
|
+
* which a nested frame may not do; <CheckoutPage> asks its app instead.
|
|
18
|
+
*/
|
|
19
|
+
onRedirect?: (url: string) => void;
|
|
20
|
+
onPhaseChange?: (phase: CheckoutPhase) => void;
|
|
21
|
+
completionMode?: "embedded" | "redirect";
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function Checkout({ source, appearance, layout, defaultCountry, cardSetupReturnURL, onComplete, onRedirect, onPhaseChange, completionMode, className, }: CheckoutProps): React.JSX.Element;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { CheckoutSource } from '../source';
|
|
2
|
+
import { BillingStatus, CardSetup, Currency, HostedCheckoutLink, PaymentAuthentication, CurrencyScales, Invoice, NewCard, Page, Payment, PaymentMethod, Price, Product, SolanaConfig, SolanaTierChange, SolanaTierChangeTx, SolanaToken, Subscription, TierChange, TierChangePreview } from './types';
|
|
3
|
+
export interface BillingClientOptions {
|
|
4
|
+
/** OpenRails embedded mount. Default "/billing/v1". */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Transport. Pass an authenticating fetch (auth-ui's `client.authFetch`)
|
|
8
|
+
* or combine the default with `getToken`.
|
|
9
|
+
*/
|
|
10
|
+
fetch?: (input: string, init: RequestInit) => Promise<Response>;
|
|
11
|
+
/** Bearer for each request; omit when `fetch` authenticates. */
|
|
12
|
+
getToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
13
|
+
/** Sent as Accept-Language. */
|
|
14
|
+
language?: () => string | null | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Extra or overriding currency scales (code -> native-unit decimals). The
|
|
17
|
+
* pinned OpenRails registry is built in; `/me` amounts carry no scale.
|
|
18
|
+
*/
|
|
19
|
+
currencies?: CurrencyScales;
|
|
20
|
+
}
|
|
21
|
+
export interface ListOptions {
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export type SolanaCancelStage = "preparing" | "signing" | "confirming";
|
|
27
|
+
/**
|
|
28
|
+
* Signs and submits a base64 transaction with the customer's wallet and
|
|
29
|
+
* returns its signature. Throw `WalletRejectedError` when the user declines.
|
|
30
|
+
*/
|
|
31
|
+
export type SendSolanaTransaction = (transactionBase64: string) => Promise<string>;
|
|
32
|
+
export declare class WalletRejectedError extends Error {
|
|
33
|
+
constructor(message?: string);
|
|
34
|
+
}
|
|
35
|
+
export declare const CANCEL_FEEDBACK_MIN = 4;
|
|
36
|
+
export declare const CANCEL_FEEDBACK_MAX = 500;
|
|
37
|
+
/** Total wait a GET may spend on its one retry. */
|
|
38
|
+
export declare const RETRY_BUDGET_MS = 2000;
|
|
39
|
+
export declare function createBillingClient(options?: BillingClientOptions): {
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
listSubscriptions(opts?: ListOptions & {
|
|
42
|
+
status?: string;
|
|
43
|
+
}): Promise<Page<Subscription>>;
|
|
44
|
+
/** Includes `recovery` (list rows do not). */
|
|
45
|
+
getSubscription(subscriptionId: string, signal?: AbortSignal): Promise<Subscription>;
|
|
46
|
+
/**
|
|
47
|
+
* Queues the cancellation (202). Access and resumability follow the
|
|
48
|
+
* rail's cancel mode; re-read the subscription to observe the result.
|
|
49
|
+
*/
|
|
50
|
+
cancelSubscription(subscriptionId: string, input: {
|
|
51
|
+
feedback: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/** Queues the resumption (202). */
|
|
54
|
+
resumeSubscription(subscriptionId: string): Promise<void>;
|
|
55
|
+
setSubscriptionPaymentMethod(subscriptionId: string, paymentMethodId: string): Promise<void>;
|
|
56
|
+
/** What `changeTier` would charge now and at the next renewal. */
|
|
57
|
+
previewTierChange(subscriptionId: string, priceId: string, signal?: AbortSignal): Promise<TierChangePreview>;
|
|
58
|
+
/**
|
|
59
|
+
* Moves the subscription to another price of its tier group: an upgrade
|
|
60
|
+
* charges the saved card now, a downgrade applies at period end.
|
|
61
|
+
* `idempotencyKey` identifies this attempt; reuse it until the change
|
|
62
|
+
* resolves (`processing`, a `tier_change_in_flight` refusal or a lost
|
|
63
|
+
* response) so the stored result replays instead of charging twice.
|
|
64
|
+
*/
|
|
65
|
+
changeTier(subscriptionId: string, input: {
|
|
66
|
+
priceId: string;
|
|
67
|
+
idempotencyKey: string;
|
|
68
|
+
}): Promise<TierChange>;
|
|
69
|
+
/**
|
|
70
|
+
* Solana rail: the tier-change transaction for the wallet to sign and
|
|
71
|
+
* send. Pass the resulting signature to `confirmSolanaTierChange`.
|
|
72
|
+
*/
|
|
73
|
+
prepareSolanaTierChange(subscriptionId: string, newPriceId: string): Promise<SolanaTierChangeTx>;
|
|
74
|
+
/**
|
|
75
|
+
* Records the landed transaction. Keep the signature until this succeeds:
|
|
76
|
+
* confirming it again replays the result (`already_confirmed`).
|
|
77
|
+
*/
|
|
78
|
+
confirmSolanaTierChange(subscriptionId: string, input: {
|
|
79
|
+
signature: string;
|
|
80
|
+
newPriceId: string;
|
|
81
|
+
}): Promise<SolanaTierChange>;
|
|
82
|
+
/**
|
|
83
|
+
* On-chain cancellation for the solana rail: the server prepares an
|
|
84
|
+
* unsigned transaction, the wallet signs and submits it, the server
|
|
85
|
+
* verifies the signature and records the cancel.
|
|
86
|
+
*/
|
|
87
|
+
cancelSubscriptionOnChain(subscriptionId: string, sendTransaction: SendSolanaTransaction, onStage?: (stage: SolanaCancelStage) => void): Promise<void>;
|
|
88
|
+
listPaymentMethods(opts?: ListOptions): Promise<Page<PaymentMethod>>;
|
|
89
|
+
/**
|
|
90
|
+
* Stores a card entered in the page: a Collect.js token
|
|
91
|
+
* (`cardSetupDriver` "collect_js") or the card itself ("card").
|
|
92
|
+
*/
|
|
93
|
+
addPaymentMethod(card: NewCard): Promise<PaymentMethod>;
|
|
94
|
+
/**
|
|
95
|
+
* Starts an in-page card setup with a PSP whose browser SDK collects the
|
|
96
|
+
* card (see `cardSetupDriver`). `idempotencyKey` identifies this attempt.
|
|
97
|
+
*/
|
|
98
|
+
createCardSetup(input: {
|
|
99
|
+
pspId: string;
|
|
100
|
+
idempotencyKey: string;
|
|
101
|
+
}): Promise<CardSetup>;
|
|
102
|
+
getCardSetup(setupId: string, signal?: AbortSignal): Promise<CardSetup>;
|
|
103
|
+
/** Verifies the setup with the provider; `payment_method_id` once saved. */
|
|
104
|
+
confirmCardSetup(setupId: string): Promise<CardSetup>;
|
|
105
|
+
/** The provider challenge a pending payment operation is waiting on. */
|
|
106
|
+
getPaymentAuthentication(operationId: string): Promise<PaymentAuthentication>;
|
|
107
|
+
confirmPaymentAuthentication(operationId: string): Promise<void>;
|
|
108
|
+
/** `pending` when the provider is still converging (202). */
|
|
109
|
+
removePaymentMethod(paymentMethodId: string): Promise<"removed" | "pending">;
|
|
110
|
+
/** Makes the method the default collector for one currency's invoices. */
|
|
111
|
+
setDefaultPaymentMethod(input: {
|
|
112
|
+
currency: string;
|
|
113
|
+
paymentMethodId: string;
|
|
114
|
+
}): Promise<void>;
|
|
115
|
+
/** Charges and refunds, newest first. `rail` filters by rail. */
|
|
116
|
+
listPayments(opts?: ListOptions & {
|
|
117
|
+
rail?: string;
|
|
118
|
+
}): Promise<Page<Payment>>;
|
|
119
|
+
listInvoices(opts?: ListOptions): Promise<Page<Invoice>>;
|
|
120
|
+
getInvoice(invoiceId: string, signal?: AbortSignal): Promise<Invoice>;
|
|
121
|
+
getStatus(signal?: AbortSignal): Promise<BillingStatus>;
|
|
122
|
+
/** Active products with their active prices. */
|
|
123
|
+
listProducts(opts?: ListOptions): Promise<Page<Product>>;
|
|
124
|
+
/** Active prices. `product` is a `prod_` id; `type` is `recurring | one_time`. */
|
|
125
|
+
listPrices(opts?: ListOptions & {
|
|
126
|
+
currency?: string;
|
|
127
|
+
product?: string;
|
|
128
|
+
type?: string;
|
|
129
|
+
}): Promise<Page<Price>>;
|
|
130
|
+
/** The server's currency registry; `currencies` is the pinned copy. */
|
|
131
|
+
listCurrencies(signal?: AbortSignal): Promise<Currency[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Mints a hosted checkout session for the signed-in customer and one
|
|
134
|
+
* price. Render it with `<CheckoutFrame url>` when the session has a
|
|
135
|
+
* `url`, else with `<Checkout source={client.checkoutSource(id)}>`.
|
|
136
|
+
* `successUrl` brings the buyer back from a redirect rail; it must be on
|
|
137
|
+
* one of this app's return origins.
|
|
138
|
+
*/
|
|
139
|
+
createCheckoutSession(input: {
|
|
140
|
+
priceKey?: string;
|
|
141
|
+
priceId?: string;
|
|
142
|
+
successUrl?: string;
|
|
143
|
+
}): Promise<HostedCheckoutLink>;
|
|
144
|
+
/**
|
|
145
|
+
* Reads and pays one hosted checkout session. The id is the only
|
|
146
|
+
* credential: no bearer is sent. A refusal the buyer can answer (an
|
|
147
|
+
* invalid card form, too many attempts) resolves as `failed`; an expired
|
|
148
|
+
* or unknown session as `expired`.
|
|
149
|
+
*/
|
|
150
|
+
checkoutSource(sessionId: string): CheckoutSource;
|
|
151
|
+
/** Network and accepted tokens; served only with a Solana PSP. */
|
|
152
|
+
getSolanaConfig(signal?: AbortSignal): Promise<SolanaConfig>;
|
|
153
|
+
/**
|
|
154
|
+
* Accepted tokens with live prices. `priceId` or `checkoutSessionId` adds
|
|
155
|
+
* each token's `quote`; `wallet` adds its `balance`.
|
|
156
|
+
*/
|
|
157
|
+
listSolanaTokens(opts?: {
|
|
158
|
+
priceId?: string;
|
|
159
|
+
checkoutSessionId?: string;
|
|
160
|
+
wallet?: string;
|
|
161
|
+
signal?: AbortSignal;
|
|
162
|
+
}): Promise<SolanaToken[]>;
|
|
163
|
+
/** Currency code (upper case) to native-unit decimals. */
|
|
164
|
+
currencies: Readonly<Record<string, number>>;
|
|
165
|
+
};
|
|
166
|
+
export type BillingClient = ReturnType<typeof createBillingClient>;
|
|
167
|
+
export declare const isWalletRejection: (error: unknown) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface BillingErrorBody {
|
|
2
|
+
type: string;
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
request_id?: string;
|
|
6
|
+
param?: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare class BillingError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly type: string;
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly param?: string;
|
|
14
|
+
readonly requestId?: string;
|
|
15
|
+
readonly metadata: Record<string, unknown>;
|
|
16
|
+
constructor(status: number, body: BillingErrorBody);
|
|
17
|
+
}
|
|
18
|
+
export declare const isBillingError: (value: unknown) => value is BillingError;
|
|
19
|
+
/**
|
|
20
|
+
* A server failure (HTTP 5xx) from any client or host source that carries a
|
|
21
|
+
* numeric `status`. It is surfaced at once, never retried behind the caller.
|
|
22
|
+
*/
|
|
23
|
+
export declare const isServerError: (value: unknown) => boolean;
|
|
24
|
+
export declare function localError(code: string, message: string): BillingError;
|
|
25
|
+
export declare function readBillingError(res: Response): Promise<BillingError>;
|
|
26
|
+
export declare function toBillingError(error: unknown): BillingError;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type OpenRailsCustomerRoute = "GET /billing/v1/me/balance" | "POST /billing/v1/me/billing-portal" | "POST /billing/v1/me/checkout" | "POST /billing/v1/me/checkout/sessions" | "GET /billing/v1/me/checkout/{id}" | "POST /billing/v1/me/checkout/{id}/confirm" | "PUT /billing/v1/me/collection-payment-method" | "PUT /billing/v1/me/default-payment-method" | "GET /billing/v1/me/entitlements/active" | "GET /billing/v1/me/invoices" | "GET /billing/v1/me/invoices/{id}" | "POST /billing/v1/me/invoices/{id}/pay-now" | "GET /billing/v1/me/notifications" | "GET /billing/v1/me/notifications/unread-count" | "POST /billing/v1/me/notifications/{id}/read" | "GET /billing/v1/me/payment-methods" | "POST /billing/v1/me/payment-methods" | "POST /billing/v1/me/payment-methods/stripe-setup" | "GET /billing/v1/me/payment-methods/stripe-setup/{id}" | "POST /billing/v1/me/payment-methods/stripe-setup/{id}/confirm" | "DELETE /billing/v1/me/payment-methods/{id}" | "PUT /billing/v1/me/payment-methods/{id}" | "GET /billing/v1/me/payment-operations/{id}/authentication" | "POST /billing/v1/me/payment-operations/{id}/authentication/confirm" | "GET /billing/v1/me/payments" | "GET /billing/v1/me/products" | "GET /billing/v1/me/products/{product_id}/access" | "GET /billing/v1/me/spend-limits" | "GET /billing/v1/me/status" | "GET /billing/v1/me/subscriptions" | "GET /billing/v1/me/subscriptions/{id}" | "POST /billing/v1/me/subscriptions/{id}/cancel" | "POST /billing/v1/me/subscriptions/{id}/change-tier" | "POST /billing/v1/me/subscriptions/{id}/change-tier/preview" | "PUT /billing/v1/me/subscriptions/{id}/payment-method" | "GET /billing/v1/me/subscriptions/{id}/provider-cutover" | "POST /billing/v1/me/subscriptions/{id}/provider-cutover" | "POST /billing/v1/me/subscriptions/{id}/provider-cutover/preview" | "POST /billing/v1/me/subscriptions/{id}/resume" | "POST /billing/v1/me/subscriptions/{id}/retry-now" | "POST /billing/v1/me/subscriptions/{id}/solana-cancel" | "POST /billing/v1/me/subscriptions/{id}/solana-cancel-tx" | "POST /billing/v1/me/subscriptions/{id}/solana-tier-change" | "POST /billing/v1/me/subscriptions/{id}/solana-tier-change/confirm" | "GET /billing/v1/me/tier" | "GET /billing/v1/me/transactions" | "GET /billing/v1/me/usage";
|
|
2
|
+
export declare const OPENRAILS_CURRENCY_SCALES: Readonly<Record<string, number>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CANCEL_FEEDBACK_MAX, CANCEL_FEEDBACK_MIN, createBillingClient, isWalletRejection, RETRY_BUDGET_MS, WalletRejectedError, type BillingClient, type BillingClientOptions, type ListOptions, type SendSolanaTransaction, type SolanaCancelStage, } from './client';
|
|
2
|
+
export { BillingError, isBillingError, isServerError, readBillingError, toBillingError, type BillingErrorBody, } from './errors';
|
|
3
|
+
export type { BillingStatus, CardSetup, CardSummary, Currency, CurrencyScales, HostedCheckoutLink, Invoice, NewCard, Page, Payment, PaymentAuthentication, PaymentMethod, PaymentOperation, PaymentRecovery, Price, Product, SolanaConfig, SolanaTierChange, SolanaTierChangeTx, SolanaToken, Subscription, SubscriptionPrice, SubscriptionProduct, SubscriptionStatus, TierChange, TierChangePreview, } from './types';
|
|
4
|
+
export { amountToDecimal, formatAmount, type Amount } from '../lib/money';
|