@openrails/billing-ui 0.235.0 → 0.236.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 (60) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +103 -73
  3. package/dist/account/account-billing.d.ts +1 -3
  4. package/dist/account/payment-methods-panel.d.ts +1 -3
  5. package/dist/buy-button.d.ts +35 -0
  6. package/dist/cart.d.ts +18 -0
  7. package/dist/checkout.d.ts +1 -3
  8. package/dist/client/checkout.d.ts +28 -0
  9. package/dist/client/client.d.ts +71 -47
  10. package/dist/client/errors.d.ts +4 -0
  11. package/dist/client/generated/error-codes.d.ts +1 -1
  12. package/dist/client/generated/routes.d.ts +117 -88
  13. package/dist/client/generated/wire.d.ts +88 -66
  14. package/dist/client/index.d.ts +2 -2
  15. package/dist/client/types.d.ts +230 -17
  16. package/dist/{client-BpzCZes3.js → client-BuvolBPT.js} +477 -316
  17. package/dist/client-BuvolBPT.js.map +1 -0
  18. package/dist/client.js +2 -2
  19. package/dist/components/stripe-card.d.ts +8 -2
  20. package/dist/components/stripe-wallets.d.ts +12 -0
  21. package/dist/components/ui/badge.d.ts +1 -1
  22. package/dist/components/ui/button.d.ts +1 -1
  23. package/dist/frame.d.ts +5 -5
  24. package/dist/hooks-2d-XjpuI.js +526 -0
  25. package/dist/hooks-2d-XjpuI.js.map +1 -0
  26. package/dist/i18n/context.d.ts +1 -1
  27. package/dist/index.d.ts +7 -5
  28. package/dist/index.js +1966 -1655
  29. package/dist/index.js.map +1 -1
  30. package/dist/lib/money.d.ts +1 -0
  31. package/dist/lib/offer-label.d.ts +4 -0
  32. package/dist/locales/de.js +20 -0
  33. package/dist/locales/de.js.map +1 -1
  34. package/dist/locales/en.d.ts +20 -0
  35. package/dist/locales/en.js +20 -0
  36. package/dist/locales/en.js.map +1 -1
  37. package/dist/locales/es.js +20 -0
  38. package/dist/locales/es.js.map +1 -1
  39. package/dist/locales/ja.js +11 -0
  40. package/dist/locales/ja.js.map +1 -1
  41. package/dist/locales/ko.js +11 -0
  42. package/dist/locales/ko.js.map +1 -1
  43. package/dist/locales/zh.js +11 -0
  44. package/dist/locales/zh.js.map +1 -1
  45. package/dist/offers.d.ts +33 -0
  46. package/dist/order-checkout.d.ts +30 -0
  47. package/dist/react/hooks.d.ts +8 -7
  48. package/dist/react/index.d.ts +1 -1
  49. package/dist/react/provider.d.ts +24 -2
  50. package/dist/react.js +2 -33
  51. package/dist/save-payment-method.d.ts +0 -6
  52. package/dist/styles.css +1 -1
  53. package/dist/types.d.ts +16 -16
  54. package/docs/payment-form-contract.md +6 -6
  55. package/package.json +1 -1
  56. package/dist/client-BpzCZes3.js.map +0 -1
  57. package/dist/config-qLcHvK0Q.js +0 -341
  58. package/dist/config-qLcHvK0Q.js.map +0 -1
  59. package/dist/provider.d.ts +0 -18
  60. package/dist/react.js.map +0 -1
@@ -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;
@@ -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 catalog: active products with their active prices. */
49
- export declare function useProducts(options?: {
50
- limit?: number;
51
- }): ProductsState;
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;
@@ -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';
@@ -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
- client: BillingClient;
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
- export declare function BillingProvider({ client, onChange, children, }: BillingProviderProps): import("react").JSX.Element;
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, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u } from "./config-qLcHvK0Q.js";
2
- import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
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-2d-XjpuI.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;