@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CheckoutAppearance } from './appearance';
|
|
2
|
+
import { BillingClient } from './client/client';
|
|
3
|
+
import { Order } from './client/types';
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export interface OrderCheckoutProps {
|
|
6
|
+
orderId: string;
|
|
7
|
+
/** The client to pay through; default: the provider's. */
|
|
8
|
+
client?: BillingClient;
|
|
9
|
+
/** Where a redirect PSP will return to; card PSPs need none. */
|
|
10
|
+
returnUrl?: string;
|
|
11
|
+
/** Offer the customer's saved cards (GET /me/payment-methods). Default true. */
|
|
12
|
+
savedPaymentMethods?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Offer a PSP whose card entry is server. Default true; orders take
|
|
15
|
+
* tokens only, so such a PSP is offered for saved cards alone.
|
|
16
|
+
*/
|
|
17
|
+
serverCardEntry?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Offer Apple Pay and Google Pay through a Stripe PSP's Express Checkout
|
|
20
|
+
* Element. The page's host must be a payment-method domain registered on
|
|
21
|
+
* that Stripe account. Default false.
|
|
22
|
+
*/
|
|
23
|
+
wallets?: boolean;
|
|
24
|
+
/** Once the order is complete, or processing on an asynchronous rail. */
|
|
25
|
+
onSettled?: (order: Order) => void;
|
|
26
|
+
appearance?: CheckoutAppearance;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Pays one order. Requires `BillingProvider`. */
|
|
30
|
+
export declare function OrderCheckout({ orderId, client: given, returnUrl, savedPaymentMethods, serverCardEntry, wallets, onSettled, appearance, className, }: OrderCheckoutProps): React.JSX.Element;
|
package/dist/psp.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { PaymentMethod } from './client/types';
|
|
3
|
-
import { PaymentOption, SavedPaymentMethod } from './types';
|
|
4
2
|
export declare const pspConfigSchema: z.ZodObject<{
|
|
5
3
|
psp_id: z.ZodString;
|
|
6
4
|
key: z.ZodString;
|
|
@@ -14,8 +12,6 @@ export declare const pspConfigSchema: z.ZodObject<{
|
|
|
14
12
|
retry_after: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
15
13
|
}, z.core.$strip>;
|
|
16
14
|
export type PspConfig = z.infer<typeof pspConfigSchema>;
|
|
17
|
-
/** Whether a rail takes a card in the page (saved or new). */
|
|
18
|
-
export declare const isCardRail: (rail: PaymentOption) => boolean;
|
|
19
15
|
/** PSPs that take new purchases and new cards. */
|
|
20
16
|
export declare const checkoutPsps: (psps: readonly PspConfig[]) => PspConfig[];
|
|
21
17
|
/**
|
|
@@ -23,13 +19,9 @@ export declare const checkoutPsps: (psps: readonly PspConfig[]) => PspConfig[];
|
|
|
23
19
|
* for again; null when none is.
|
|
24
20
|
*/
|
|
25
21
|
export declare function cardRetryAfter(psps: readonly PspConfig[]): number | null;
|
|
26
|
-
/** Saved cards the checkout can charge in place, for the given rails, newest first. */
|
|
27
|
-
export declare function savedMethodsFor(methods: readonly PaymentMethod[], rails: readonly PaymentOption[]): SavedPaymentMethod[];
|
|
28
22
|
export type CardSetupDriver = "collect_js" | "card" | "stripe_elements";
|
|
29
23
|
/** How a card is saved with this PSP in the page, or null when it cannot be. */
|
|
30
24
|
export declare function cardSetupDriver(psp: PspConfig): CardSetupDriver | null;
|
|
31
25
|
export declare const canSavePaymentMethod: (psp: PspConfig) => boolean;
|
|
32
26
|
/** Whether a pending payment on this PSP can be authenticated in the page. */
|
|
33
27
|
export declare const canAuthenticatePayment: (psp: PspConfig) => boolean;
|
|
34
|
-
/** The PSP config behind a checkout rail, for card setup and authentication. */
|
|
35
|
-
export declare function railPsp(rail: PaymentOption): PspConfig;
|
package/dist/react/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SendSolanaTransaction, SubscriptionChangeInput } from '../client/client';
|
|
1
|
+
import { ProductListOptions, SendSolanaTransaction, SubscriptionChangeInput } from '../client/client';
|
|
2
2
|
import { BillingError } from '../client/errors';
|
|
3
3
|
import { NewCard, Payment, PaymentMethod, Product, Subscription, SubscriptionChange } from '../client/types';
|
|
4
4
|
export type ActionResult = Promise<BillingError | null>;
|
|
@@ -39,16 +39,17 @@ export interface SubscriptionsState {
|
|
|
39
39
|
export declare function useSubscriptions(options?: SubscriptionsOptions): SubscriptionsState;
|
|
40
40
|
export interface ProductsState {
|
|
41
41
|
products: Product[] | null;
|
|
42
|
-
/** The cursor of the next page; null on the last. */
|
|
43
|
-
nextCursor: string | null;
|
|
44
42
|
loading: boolean;
|
|
45
43
|
error: BillingError | null;
|
|
46
44
|
refetch: () => void;
|
|
47
45
|
}
|
|
48
|
-
/** The
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
/** The product keys to look up: `ProductListOptions`. */
|
|
47
|
+
export type ProductsOptions = Pick<ProductListOptions, "keys">;
|
|
48
|
+
/**
|
|
49
|
+
* The products on sale named by `keys`, each with its active prices: a
|
|
50
|
+
* public catalog lookup.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useProducts({ keys }: ProductsOptions): ProductsState;
|
|
52
53
|
export type PaymentMethodAction = "remove" | "default";
|
|
53
54
|
export interface PaymentMethodsState {
|
|
54
55
|
methods: PaymentMethod[] | null;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BillingProvider, type BillingProviderProps } from './provider';
|
|
2
2
|
export { useBillingClient, useBillingRefresh, useOptionalBillingContext, type BillingChange, type BillingContextValue, } from './context';
|
|
3
3
|
export { useConfig, useCurrencyScales, type ConfigState, type ConfigStore, } from './config';
|
|
4
|
-
export { usePaymentMethods, usePayments, useProducts, useSubscriptions, type ActionResult, type PaymentMethodAction, type PaymentMethodsState, type PaymentsOptions, type PaymentsState, type ProductsState, type SubscriptionAction, type SubscriptionsOptions, type SubscriptionsState, } from './hooks';
|
|
4
|
+
export { usePaymentMethods, usePayments, useProducts, useSubscriptions, type ActionResult, type PaymentMethodAction, type PaymentMethodsState, type PaymentsOptions, type PaymentsState, type ProductsOptions, type ProductsState, type SubscriptionAction, type SubscriptionsOptions, type SubscriptionsState, } from './hooks';
|
package/dist/react/provider.d.ts
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { CheckoutAppearance } from '../appearance';
|
|
2
3
|
import { BillingClient } from '../client/client';
|
|
4
|
+
import { BillingUiMessageBundle, BillingUiTranslate } from '../i18n/messages';
|
|
5
|
+
import { Navigate } from '../scope-context';
|
|
3
6
|
import { BillingChange } from './context';
|
|
4
7
|
export interface BillingProviderProps {
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The customer's client: hooks and the account panels read it, and a
|
|
10
|
+
* checkout saves a new card to the customer first. Leave it out where no
|
|
11
|
+
* customer is signed in, such as the shared payment page.
|
|
12
|
+
*/
|
|
13
|
+
client?: BillingClient;
|
|
6
14
|
/** Fires after each successful mutation: the host's cache-invalidation hook. */
|
|
7
15
|
onChange?: (change: BillingChange) => void;
|
|
16
|
+
appearance?: CheckoutAppearance;
|
|
17
|
+
/** Locale bundle(s) layered over English; later entries win. */
|
|
18
|
+
messages?: BillingUiMessageBundle | readonly BillingUiMessageBundle[];
|
|
19
|
+
/** Host translation hook, consulted before the bundles. */
|
|
20
|
+
t?: BillingUiTranslate;
|
|
21
|
+
/** BCP 47 tag for dates, money and plurals; defaults to the browser's. */
|
|
22
|
+
locale?: string;
|
|
23
|
+
/** Host router for in-app links (e.g. the plans page). */
|
|
24
|
+
navigate?: Navigate;
|
|
8
25
|
children?: ReactNode;
|
|
9
26
|
}
|
|
10
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The one billing-ui provider: the client, and the appearance and words of
|
|
29
|
+
* the styled components. Renders no DOM; surfaces create their own styling
|
|
30
|
+
* roots, and no stylesheet loads until a styled component is imported.
|
|
31
|
+
*/
|
|
32
|
+
export declare function BillingProvider({ client, onChange, appearance, messages, t, locale, navigate, children, }: BillingProviderProps): import("react").JSX.Element;
|
package/dist/react.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, d as n,
|
|
2
|
-
|
|
3
|
-
import { jsx as g } from "react/jsx-runtime";
|
|
4
|
-
//#region src/react/provider.tsx
|
|
5
|
-
function _({ client: e, onChange: n, children: r }) {
|
|
6
|
-
let [i, a] = h(0), o = m(n);
|
|
7
|
-
f(() => {
|
|
8
|
-
o.current = n;
|
|
9
|
-
});
|
|
10
|
-
let s = d((e) => {
|
|
11
|
-
a((e) => e + 1), o.current?.(e);
|
|
12
|
-
}, []), c = d(() => a((e) => e + 1), []), l = p(() => u(e), [e]), _ = p(() => ({
|
|
13
|
-
client: e,
|
|
14
|
-
version: i,
|
|
15
|
-
notify: s,
|
|
16
|
-
refresh: c,
|
|
17
|
-
config: l
|
|
18
|
-
}), [
|
|
19
|
-
e,
|
|
20
|
-
i,
|
|
21
|
-
s,
|
|
22
|
-
c,
|
|
23
|
-
l
|
|
24
|
-
]);
|
|
25
|
-
return /* @__PURE__ */ g(t.Provider, {
|
|
26
|
-
value: _,
|
|
27
|
-
children: r
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { _ as BillingProvider, a as useBillingClient, n as useBillingRefresh, o as useConfig, c as useCurrencyScales, r as useOptionalBillingContext, i as usePaymentMethods, e as usePayments, s as useProducts, l as useSubscriptions };
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=react.js.map
|
|
1
|
+
import { a as e, c as t, d as n, i as r, n as i, o as a, r as o, s, t as c, u as l } from "./hooks-DYepYVMX.js";
|
|
2
|
+
export { e as BillingProvider, t as useBillingClient, l as useBillingRefresh, a as useConfig, s as useCurrencyScales, n as useOptionalBillingContext, c as usePaymentMethods, i as usePayments, o as useProducts, r as useSubscriptions };
|
|
@@ -5,12 +5,6 @@ export interface SavePaymentMethodProps {
|
|
|
5
5
|
/** The PSP to save the card with, from OpenRails's payment config. */
|
|
6
6
|
psp: PspConfig;
|
|
7
7
|
onSaved: (paymentMethodId: string) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Where the provider returns after an off-page verification (3-D Secure),
|
|
10
|
-
* given the setup id to confirm with `client.confirmCardSetup`. Default:
|
|
11
|
-
* the current page with `?setup_id=`.
|
|
12
|
-
*/
|
|
13
|
-
returnURL?: (setupId: string) => string;
|
|
14
8
|
/** Billing country to preselect; default: the browser locale's region. */
|
|
15
9
|
defaultCountry?: string;
|
|
16
10
|
submitLabel?: string;
|