@openrails/billing-ui 0.235.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.
- package/CHANGELOG.md +155 -0
- package/README.md +103 -103
- package/dist/account/account-billing.d.ts +2 -4
- package/dist/account/payment-methods-panel.d.ts +2 -4
- package/dist/buy-button.d.ts +40 -0
- package/dist/cart.d.ts +18 -0
- package/dist/client/client.d.ts +95 -59
- package/dist/client/errors.d.ts +4 -0
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +103 -272
- package/dist/client/generated/wire.d.ts +117 -246
- package/dist/client/index.d.ts +2 -2
- package/dist/client/types.d.ts +286 -142
- package/dist/client-D9G1Tgox.js +888 -0
- package/dist/client-D9G1Tgox.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/components/eyebrow.d.ts +5 -0
- package/dist/components/stripe-card.d.ts +8 -2
- package/dist/components/stripe-wallets.d.ts +12 -0
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/embedded-checkout.d.ts +22 -0
- package/dist/hooks-DYepYVMX.js +526 -0
- package/dist/hooks-DYepYVMX.js.map +1 -0
- package/dist/i18n/context.d.ts +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.js +1470 -2178
- package/dist/index.js.map +1 -1
- package/dist/lib/money.d.ts +1 -0
- package/dist/lib/offer-label.d.ts +4 -0
- package/dist/locales/de.js +20 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +20 -0
- package/dist/locales/en.js +20 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +20 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/ja.js +11 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +11 -0
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/zh.js +11 -0
- package/dist/locales/zh.js.map +1 -1
- package/dist/modal.d.ts +3 -9
- package/dist/offers.d.ts +32 -0
- package/dist/order-checkout.d.ts +30 -0
- package/dist/psp.d.ts +0 -8
- package/dist/react/hooks.d.ts +8 -7
- package/dist/react/index.d.ts +1 -1
- package/dist/react/provider.d.ts +24 -2
- package/dist/react.js +2 -33
- package/dist/save-payment-method.d.ts +0 -6
- package/dist/styles.css +1 -1
- package/dist/tokenized-card-form.d.ts +5 -1
- package/dist/types.d.ts +12 -250
- package/docs/payment-form-contract.md +31 -74
- package/package.json +1 -2
- package/dist/checkout-frame.d.ts +0 -17
- package/dist/checkout-page.d.ts +0 -21
- package/dist/checkout.d.ts +0 -24
- package/dist/client-BpzCZes3.js +0 -931
- package/dist/client-BpzCZes3.js.map +0 -1
- package/dist/components/ccbill-fields.d.ts +0 -8
- package/dist/components/methods.d.ts +0 -13
- package/dist/components/summary.d.ts +0 -12
- package/dist/config-qLcHvK0Q.js +0 -341
- package/dist/config-qLcHvK0Q.js.map +0 -1
- package/dist/fixtures.d.ts +0 -9
- package/dist/frame.d.ts +0 -47
- package/dist/lib/rail-meta.d.ts +0 -15
- package/dist/lib/redirect.d.ts +0 -2
- package/dist/provider.d.ts +0 -18
- package/dist/react.js.map +0 -1
- package/dist/source.d.ts +0 -5
package/dist/client/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Account,
|
|
1
|
+
import { BillingError } from './errors';
|
|
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;
|
|
@@ -18,15 +18,13 @@ export interface BillingClientOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
currencies?: CurrencyScales;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
customerBase?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A public catalog lookup: the products named by `keys` (at most 100 product
|
|
23
|
+
* keys), in one page.
|
|
24
|
+
*/
|
|
25
|
+
export interface ProductListOptions {
|
|
26
|
+
keys: string[];
|
|
27
|
+
signal?: AbortSignal;
|
|
30
28
|
}
|
|
31
29
|
export interface ListOptions {
|
|
32
30
|
limit?: number;
|
|
@@ -69,6 +67,14 @@ export declare const isWalletAction: (next: NextAction | null | undefined) => bo
|
|
|
69
67
|
export declare function signWalletAction(next: NextAction, sendTransaction: SendSolanaTransaction): Promise<string>;
|
|
70
68
|
/** Total wait a GET may spend on its one retry. */
|
|
71
69
|
export declare const RETRY_BUDGET_MS = 2000;
|
|
70
|
+
/**
|
|
71
|
+
* An order request's answer. `error` is set when the payment failed: the
|
|
72
|
+
* order is open again and its `payment.last_payment_error` says why.
|
|
73
|
+
*/
|
|
74
|
+
export interface OrderResult {
|
|
75
|
+
order: Order;
|
|
76
|
+
error?: BillingError;
|
|
77
|
+
}
|
|
72
78
|
export declare function createBillingClient(options?: BillingClientOptions): {
|
|
73
79
|
baseUrl: string;
|
|
74
80
|
/** One page of the customer's subscriptions, newest first. */
|
|
@@ -108,21 +114,72 @@ export declare function createBillingClient(options?: BillingClientOptions): {
|
|
|
108
114
|
}): Promise<SubscriptionChange>;
|
|
109
115
|
listPaymentMethods(opts?: CursorOptions): Promise<ListPage<PaymentMethod>>;
|
|
110
116
|
/**
|
|
111
|
-
*
|
|
112
|
-
* token
|
|
117
|
+
* Saves a card entered in the page with the PSP `psp_id` in one call: the
|
|
118
|
+
* token of its own fields, or the card itself ("card"). A Stripe card the
|
|
119
|
+
* bank wants authenticated answers `requires_action`.
|
|
113
120
|
*/
|
|
114
121
|
addPaymentMethod(card: NewCard): Promise<PaymentMethod>;
|
|
122
|
+
/** The customer's cart, priced now. */
|
|
123
|
+
getCart(signal?: AbortSignal): Promise<Cart>;
|
|
124
|
+
/**
|
|
125
|
+
* Puts a price in the cart or changes its line, and answers the cart.
|
|
126
|
+
* `quantity` 0 removes the line; omitted, the price's default. `amount`
|
|
127
|
+
* is the customer's choice on a price that takes one.
|
|
128
|
+
*/
|
|
129
|
+
setCartLine(priceId: string, input?: {
|
|
130
|
+
quantity?: number;
|
|
131
|
+
amount?: string;
|
|
132
|
+
}): Promise<Cart>;
|
|
133
|
+
/** Empties the cart. */
|
|
134
|
+
clearCart(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Creates an order from `lines` or the cart (`cart: true`), and with
|
|
137
|
+
* `payment` pays it in the same call; `expectedTotal` is the total the
|
|
138
|
+
* customer saw. A failed payment resolves as payOrder's does.
|
|
139
|
+
*/
|
|
140
|
+
createOrder(input: {
|
|
141
|
+
lines?: {
|
|
142
|
+
price_id: string;
|
|
143
|
+
quantity?: number;
|
|
144
|
+
amount?: string;
|
|
145
|
+
}[];
|
|
146
|
+
cart?: boolean;
|
|
147
|
+
expectedTotal?: string;
|
|
148
|
+
payment?: OrderPaymentInput;
|
|
149
|
+
reusable?: boolean;
|
|
150
|
+
idempotencyKey: string;
|
|
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>>;
|
|
162
|
+
/** One of the customer's orders: the resumable handle of a purchase. */
|
|
163
|
+
getOrder(orderId: string, signal?: AbortSignal): Promise<Order>;
|
|
115
164
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
165
|
+
* Pays an open order. A failed payment resolves with the order (open,
|
|
166
|
+
* `payment.last_payment_error` saying why) and `error`, the 402.
|
|
167
|
+
* `idempotencyKey` is minted when the pay button renders: a retry with it
|
|
168
|
+
* answers what the first request answered.
|
|
118
169
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
170
|
+
payOrder(orderId: string, input: {
|
|
171
|
+
payment: OrderPaymentInput;
|
|
172
|
+
expectedTotal: string;
|
|
173
|
+
reusable?: boolean;
|
|
121
174
|
idempotencyKey: string;
|
|
122
|
-
}): Promise<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
175
|
+
}): Promise<OrderResult>;
|
|
176
|
+
/** Reads the provider after the customer completed `next_action`. */
|
|
177
|
+
confirmOrder(orderId: string): Promise<OrderResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Finishes saving a card the bank asked to authenticate, after the PSP's
|
|
180
|
+
* script answered its `next_action`.
|
|
181
|
+
*/
|
|
182
|
+
confirmPaymentMethod(paymentMethodId: string): Promise<PaymentMethod>;
|
|
126
183
|
/** The provider challenge a pending payment operation is waiting on. */
|
|
127
184
|
getPaymentAuthentication(operationId: string): Promise<PaymentAuthentication>;
|
|
128
185
|
confirmPaymentAuthentication(operationId: string): Promise<void>;
|
|
@@ -130,7 +187,7 @@ export declare function createBillingClient(options?: BillingClientOptions): {
|
|
|
130
187
|
removePaymentMethod(paymentMethodId: string): Promise<"removed" | "pending">;
|
|
131
188
|
/**
|
|
132
189
|
* Makes the card the default for one currency: it pays the currency's
|
|
133
|
-
*
|
|
190
|
+
* usage orders and every subscription in it without its own card.
|
|
134
191
|
*/
|
|
135
192
|
setDefaultPaymentMethod(input: {
|
|
136
193
|
currency: string;
|
|
@@ -140,56 +197,35 @@ export declare function createBillingClient(options?: BillingClientOptions): {
|
|
|
140
197
|
listPayments(opts?: CursorOptions & {
|
|
141
198
|
rail?: string;
|
|
142
199
|
}): Promise<ListPage<Payment>>;
|
|
143
|
-
listInvoices(opts?: CursorOptions): Promise<ListPage<Invoice>>;
|
|
144
200
|
/**
|
|
145
201
|
* The customer's summary: balance and amount owed per currency, the card
|
|
146
202
|
* that pays each currency, and unread notices.
|
|
147
203
|
*/
|
|
148
204
|
getAccount(signal?: AbortSignal): Promise<Account>;
|
|
149
|
-
getInvoice(invoiceId: string, signal?: AbortSignal): Promise<Invoice>;
|
|
150
|
-
/** Products on sale, each with its current prices. */
|
|
151
|
-
listProducts(opts?: ListOptions): Promise<Page<Product>>;
|
|
152
|
-
/**
|
|
153
|
-
* Mints a hosted checkout session for the signed-in customer and one
|
|
154
|
-
* price. Render it with `<CheckoutFrame url>` when the session has a
|
|
155
|
-
* `url`, else with `<Checkout source={client.checkoutSource(id)}>`.
|
|
156
|
-
* Select a price by `priceId`, or by both `productKey` and `priceKey`.
|
|
157
|
-
* `successUrl` brings the buyer back from a redirect rail; it must be on
|
|
158
|
-
* one of this app's return origins.
|
|
159
|
-
*/
|
|
160
|
-
createCheckoutSession(input: {
|
|
161
|
-
priceKey?: string;
|
|
162
|
-
productKey?: string;
|
|
163
|
-
priceId?: string;
|
|
164
|
-
/** Customer-selected deposit in the price currency’s native units. */
|
|
165
|
-
amount?: string;
|
|
166
|
-
/** Defaults to true for recurring prices; false buys the initial term only. */
|
|
167
|
-
autoRenew?: boolean;
|
|
168
|
-
successUrl?: string;
|
|
169
|
-
}): Promise<CheckoutSessionLink>;
|
|
170
205
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* customer reads and pays it on that customer surface, signed in. A
|
|
174
|
-
* refusal the buyer can answer (an invalid card form, too many attempts)
|
|
175
|
-
* resolves as `failed`; an expired or unknown session as `expired`.
|
|
206
|
+
* The products on sale named by `keys`, each with its current prices.
|
|
207
|
+
* No keys name no products: nothing is fetched.
|
|
176
208
|
*/
|
|
177
|
-
|
|
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>;
|
|
178
223
|
/**
|
|
179
224
|
* The deployment's public configuration: what the mount serves, the
|
|
180
225
|
* currency registry and the merchant's payment setup. React components
|
|
181
226
|
* share one copy through `useConfig()`.
|
|
182
227
|
*/
|
|
183
228
|
getConfig(signal?: AbortSignal): Promise<PublicConfig>;
|
|
184
|
-
/**
|
|
185
|
-
* Accepted tokens with live prices. `priceId` adds each token's `quote`;
|
|
186
|
-
* `wallet` adds its `balance`.
|
|
187
|
-
*/
|
|
188
|
-
listSolanaTokens(opts?: {
|
|
189
|
-
priceId?: string;
|
|
190
|
-
wallet?: string;
|
|
191
|
-
signal?: AbortSignal;
|
|
192
|
-
}): Promise<SolanaToken[]>;
|
|
193
229
|
/** Currency code (upper case) to native-unit decimals. */
|
|
194
230
|
currencies: Readonly<Record<string, number>>;
|
|
195
231
|
};
|
package/dist/client/errors.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface BillingErrorBody {
|
|
|
5
5
|
request_id?: string;
|
|
6
6
|
param?: string;
|
|
7
7
|
metadata?: Record<string, unknown>;
|
|
8
|
+
/** The order a failed payment left open (402 card_error). */
|
|
9
|
+
order?: unknown;
|
|
8
10
|
}
|
|
9
11
|
export declare class BillingError extends Error {
|
|
10
12
|
readonly status: number;
|
|
@@ -13,6 +15,8 @@ export declare class BillingError extends Error {
|
|
|
13
15
|
readonly param?: string;
|
|
14
16
|
readonly requestId?: string;
|
|
15
17
|
readonly metadata: Record<string, unknown>;
|
|
18
|
+
/** The order a failed payment left open, unvalidated. */
|
|
19
|
+
readonly order?: unknown;
|
|
16
20
|
constructor(status: number, body: BillingErrorBody);
|
|
17
21
|
}
|
|
18
22
|
export declare const isBillingError: (value: unknown) => value is BillingError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type OpenRailsErrorCode = "
|
|
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;
|