@flopay/react 1.20.15 → 2.0.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 (67) hide show
  1. package/README.md +107 -390
  2. package/dist/card-setup-entry.cjs +1 -6
  3. package/dist/card-setup-entry.d.ts +4 -10
  4. package/dist/card-setup-entry.mjs +1 -1
  5. package/dist/chunk-KPRDVWZP.mjs +1 -0
  6. package/dist/chunk-XRYDC367.mjs +1 -0
  7. package/dist/flopay-runtime-card-setup.d.ts +4 -5
  8. package/dist/flopay-runtime-checkout.d.ts +2 -0
  9. package/dist/hosted-runtime-components.d.ts +75 -0
  10. package/dist/index.cjs +1 -47
  11. package/dist/index.d.ts +3 -21
  12. package/dist/index.mjs +1 -21
  13. package/dist/payment-method-setup-entry.cjs +1 -27
  14. package/dist/payment-method-setup-entry.d.ts +5 -12
  15. package/dist/payment-method-setup-entry.mjs +1 -1
  16. package/dist/runtime-context.d.ts +10 -0
  17. package/package.json +3 -6
  18. package/dist/account-bound-elements.d.ts +0 -31
  19. package/dist/automatic-payment-button.d.ts +0 -88
  20. package/dist/buyer-identity-fallback.d.ts +0 -43
  21. package/dist/card-button-content.d.ts +0 -11
  22. package/dist/card-setup-surface.d.ts +0 -12
  23. package/dist/card-setup-theme.d.ts +0 -32
  24. package/dist/checkout-utils.d.ts +0 -172
  25. package/dist/chunk-BU7THP6H.mjs +0 -1
  26. package/dist/chunk-FGCZOMML.mjs +0 -22
  27. package/dist/chunk-ITRFSHZP.mjs +0 -6
  28. package/dist/chunk-PCIHQY3X.mjs +0 -1
  29. package/dist/chunk-VK67324N.mjs +0 -1
  30. package/dist/context.d.ts +0 -46
  31. package/dist/direct-paypal-button.d.ts +0 -155
  32. package/dist/error-banner.d.ts +0 -21
  33. package/dist/external-method-recovery.d.ts +0 -1
  34. package/dist/external-method-telemetry.d.ts +0 -17
  35. package/dist/flopay-card-setup.d.ts +0 -114
  36. package/dist/flopay-checkout.d.ts +0 -292
  37. package/dist/flopay-payment-method-setup-main.d.ts +0 -10
  38. package/dist/flopay-payment-method-setup.d.ts +0 -11
  39. package/dist/hooks.d.ts +0 -36
  40. package/dist/in-app-browser.d.ts +0 -5
  41. package/dist/inline-session-cache.d.ts +0 -1
  42. package/dist/instruments.d.ts +0 -5
  43. package/dist/more-payment-options.d.ts +0 -19
  44. package/dist/one-click-warnings.d.ts +0 -12
  45. package/dist/payment-logos.generated.d.ts +0 -1
  46. package/dist/payment-method-layout-placeholder.d.ts +0 -10
  47. package/dist/payment-method-setup-advertisement.d.ts +0 -36
  48. package/dist/payment-method-setup-paypal-CLV7JDJH.mjs +0 -1
  49. package/dist/payment-method-setup-paypal.d.ts +0 -25
  50. package/dist/payment-method-setup-stripe-526L4P5X.mjs +0 -1
  51. package/dist/payment-method-setup-stripe.d.ts +0 -31
  52. package/dist/payment-method-setup-surface.d.ts +0 -90
  53. package/dist/popup-capability.d.ts +0 -12
  54. package/dist/processing-overlay.d.ts +0 -33
  55. package/dist/provider-callback-ignored.d.ts +0 -8
  56. package/dist/provider.d.ts +0 -40
  57. package/dist/recent-completion.d.ts +0 -1
  58. package/dist/run-latest-abortable-action.d.ts +0 -5
  59. package/dist/saved-payment-flow.d.ts +0 -140
  60. package/dist/split-card-form.d.ts +0 -393
  61. package/dist/stripe-method-presentation.d.ts +0 -115
  62. package/dist/telemetry-bridge.d.ts +0 -41
  63. package/dist/use-external-attempt-reconciliation.d.ts +0 -27
  64. package/dist/use-isomorphic-layout-effect.d.ts +0 -3
  65. package/dist/use-payment-method-layout.d.ts +0 -27
  66. package/dist/vault-card-fields.d.ts +0 -97
  67. package/dist/vault-theme.d.ts +0 -1
@@ -1,115 +0,0 @@
1
- import type { ThemeId } from '@flopay/shared';
2
- import type { StripeExpressCheckoutElementReadyEvent } from '@stripe/stripe-js';
3
- import type React from 'react';
4
- export declare const DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT = 44;
5
- export declare function FloPayKeyframes(): React.JSX.Element;
6
- /**
7
- * Express-checkout element load states.
8
- *
9
- * - `loading`: initial — waiting for ExpressCheckoutElement's `ready` event.
10
- * - `ready`: at least one of the requested methods is available on this
11
- * device. Element renders.
12
- * - `unavailable`: the element initialized fine but `availablePaymentMethods`
13
- * reported none of the requested methods. The row collapses so buyers can
14
- * continue with another payment method.
15
- * - `load_error`: Stripe's `onLoadError` fired — the element couldn't
16
- * initialize at all (script blocked, network failure).
17
- */
18
- export type ExpressCheckoutLoadState = 'loading' | 'ready' | 'unavailable' | 'load_error';
19
- export declare function resolveExpressCheckoutLoadState(event: StripeExpressCheckoutElementReadyEvent, methods: string[]): ExpressCheckoutLoadState;
20
- export declare function ExpressCheckoutReadySwap({ state, placeholderTestId, borderRadius, children, }: {
21
- state: ExpressCheckoutLoadState;
22
- placeholderTestId?: string;
23
- /**
24
- * Border radius for the pulse-skeleton placeholder. Defaults to `8` for
25
- * the classic look; consumers pass the theme's `borderRadius` (or the
26
- * theme bundle's `cardButton.borderRadius`) so the skeleton matches the
27
- * eventual button's corners — otherwise the placeholder reads as
28
- * visually unrelated to the wallet tile that replaces it.
29
- */
30
- borderRadius?: string | number;
31
- children: React.ReactNode;
32
- }): React.JSX.Element | null;
33
- export declare function isExpressCheckoutRowVisible(state: ExpressCheckoutLoadState): boolean;
34
- /**
35
- * Reusable method-tile button — same 44px contract as the wallet ECE row.
36
- * Lifted out so both the unselected list and the expanded-method header
37
- * reuse the same shape and theming. The pressed state (`submitting`)
38
- * replaces the label with a spinner so the buyer sees feedback during the
39
- * session-scoped intent creation → `stripe.confirmPayment` round-trip on
40
- * auto-confirm methods.
41
- */
42
- export declare function StripeMethodButton({ method, themeId, submitting, disabled, highlighted, hasNextStep, onClick, backgroundColor, borderColor, textColor, borderRadius, fontFamily, }: {
43
- method: string;
44
- /**
45
- * Active FloPay theme id — drives which `STRIPE_METHOD_MATRIX[method]
46
- * .theme.{light,dark}` variant the button picks up its brand colors
47
- * (and eventually logo) from. `null`/`undefined`/`classic` falls back
48
- * to the matrix's `light` variant; any `*-dark` theme picks the `dark`
49
- * variant.
50
- */
51
- themeId?: ThemeId | null;
52
- submitting?: boolean;
53
- disabled?: boolean;
54
- highlighted?: boolean;
55
- /**
56
- * Render a right-chevron at the trailing edge of the button label,
57
- * signalling that clicking the tile drills into a second page (the
58
- * inline form for input-requiring APMs like SEPA Debit / EPS / iDEAL).
59
- * Auto-confirm methods (Cash App, Affirm) leave this off — their click
60
- * goes straight to Stripe's authorization UI with no intermediate page.
61
- */
62
- hasNextStep?: boolean;
63
- onClick: () => void;
64
- backgroundColor?: string;
65
- borderColor?: string;
66
- textColor?: string;
67
- borderRadius?: string | number;
68
- fontFamily?: string;
69
- }): React.JSX.Element;
70
- /**
71
- * The `paymentMethods` map for one ExpressCheckoutElement: the wallets in
72
- * `expressMethods` are shown and every other key is explicitly `'never'`, so
73
- * Stripe collapses it instead of falling back to its own defaults.
74
- *
75
- * Every enabled wallet, Apple Pay and Google Pay included, is requested as
76
- * `'auto'`: Stripe then runs its own device and wallet-setup checks and
77
- * advertises only the wallets this buyer can actually use (its `ready` event's
78
- * `availablePaymentMethods`). `'always'` would override those checks and can
79
- * draw a wallet button that does nothing when tapped, so it is never sent. The
80
- * checkout row, the setup surface and the Vue port all use this same map, so a
81
- * buyer gets the same answer on every surface.
82
- */
83
- export declare function buildExpressMethodMap(expressMethods: readonly string[]): Record<string, 'auto' | 'never'>;
84
- /** How every wallet row is drawn: plain wallet marks, one 44px button per row. */
85
- export declare const EXPRESS_CHECKOUT_PRESENTATION: {
86
- readonly buttonType: Record<string, string>;
87
- readonly layout: {
88
- readonly maxColumns: 1;
89
- readonly overflow: 'never';
90
- };
91
- };
92
- /**
93
- * PaymentElement layout for one method's inline form. Single-method group: only
94
- * this method's accordion item renders, default-expanded so its input (IBAN,
95
- * bank picker) is immediately visible.
96
- */
97
- export declare const STRIPE_METHOD_INLINE_FORM_LAYOUT: {
98
- readonly type: 'accordion';
99
- readonly defaultCollapsed: false;
100
- readonly radios: 'never';
101
- };
102
- /** The full-width action button under a method's inline form ("Pay with X", "Save X"). */
103
- export declare function StripeMethodSubmitButton({ testId, attributes, disabled, onClick, color, borderRadius, style, children, }: {
104
- testId: string;
105
- /** Extra `data-*` attributes a surface already exposes on its action button. */
106
- attributes?: Record<`data-${string}`, string>;
107
- disabled: boolean;
108
- onClick: () => void;
109
- /** Background: the surface's resolved primary colour. */
110
- color: string;
111
- borderRadius: string | number;
112
- /** The theme bundle's `submitButton` overrides, merged last. */
113
- style?: React.CSSProperties;
114
- children: React.ReactNode;
115
- }): React.JSX.Element;
@@ -1,41 +0,0 @@
1
- import type { FloPay } from '@flopay/js';
2
- import type { BuildTelemetryErrorEventInput, BuildTelemetryLogEventInput, BuildTelemetryPerformanceEventInput, BuildTelemetryTerminalEventInput, TelemetryCheckoutMode, TelemetryLayout, TelemetrySdkPackage } from '@flopay/shared';
3
- type TelemetryErrorInput = Omit<BuildTelemetryErrorEventInput, 'eventId' | 'sequence'>;
4
- type TelemetryLogInput = Omit<BuildTelemetryLogEventInput, 'eventId' | 'sequence'>;
5
- type TelemetryPerformanceInput = Omit<BuildTelemetryPerformanceEventInput, 'eventId' | 'sequence'>;
6
- type TelemetryTerminalInput = Omit<BuildTelemetryTerminalEventInput, 'eventId' | 'sequence'>;
7
- type TelemetryObservation = ({
8
- class: 'lifecycle';
9
- } & TelemetryLogInput) | ({
10
- class: 'technical_error';
11
- } & TelemetryErrorInput);
12
- export interface TelemetryCheckoutContext {
13
- checkoutMode?: TelemetryCheckoutMode;
14
- layout?: TelemetryLayout;
15
- }
16
- export interface TelemetryBridge {
17
- error(input: TelemetryErrorInput): void;
18
- log(input: TelemetryLogInput): void;
19
- performance(input: TelemetryPerformanceInput): void;
20
- terminal(input: TelemetryTerminalInput): void;
21
- now(): number;
22
- elapsed(startedAt: number): number;
23
- setCheckoutContext(context: TelemetryCheckoutContext): void;
24
- beginCheckout(context?: TelemetryCheckoutContext): number;
25
- disable(): void;
26
- subscribe(observer: (event: TelemetryObservation) => void): () => void;
27
- flush(): Promise<void>;
28
- destroy(): void;
29
- }
30
- interface ReporterFactoryOptions {
31
- billingApiUrl: string;
32
- sdkPackage?: TelemetrySdkPackage;
33
- sdkVersion: string;
34
- enabled?: boolean;
35
- clock?: () => number;
36
- }
37
- export declare function createTelemetryBridge(options: ReporterFactoryOptions): TelemetryBridge;
38
- export declare function getFloPayTelemetryBridge(floPay: FloPay | null | undefined): TelemetryBridge | undefined;
39
- /** Test helper for attaching the same hidden bridge shape to a fake FloPay. */
40
- export declare function attachTelemetryBridgeForTest(floPay: object, bridge: Partial<TelemetryBridge>): void;
41
- export {};
@@ -1,27 +0,0 @@
1
- type MissingTerminalHandler = (method: string, error: Error, options: {
2
- code: string;
3
- popupBlocked?: boolean;
4
- }) => void;
5
- type MissingTerminalDeferredHandler = (method: string, generation: number) => void;
6
- export interface ExternalAttemptReconciliationOptions {
7
- onHandoffObserved?: (method: string) => void;
8
- /**
9
- * Methods whose provider UI can still be open, and still own a live callback, after
10
- * the page regains focus (native wallet sheets). For these the grace timer is only
11
- * an observation: it never invalidates the attempt or runs `onMissingTerminal`, and
12
- * the attempt stays armed until confirm, cancel, an explicit failure or unmount.
13
- * Elapsed time alone is never evidence that such a sheet failed to open.
14
- */
15
- defersMissingTerminal?: (method: string) => boolean;
16
- /** Called each time the grace timer expires for a deferred method. */
17
- onMissingTerminalDeferred?: MissingTerminalDeferredHandler;
18
- }
19
- export declare function useExternalAttemptReconciliation(onMissingTerminal: MissingTerminalHandler, options?: ExternalAttemptReconciliationOptions): {
20
- startAttempt: (method: string) => number;
21
- finishAttempt: (generation?: number) => boolean;
22
- invalidateAttempt: (generation?: number) => void;
23
- isAttemptInvalidated: (generation?: number) => boolean;
24
- isAttemptCurrent: (generation: number) => boolean;
25
- generationRef: import("react").RefObject<number>;
26
- };
27
- export {};
@@ -1,3 +0,0 @@
1
- import { useLayoutEffect } from 'react';
2
- /** Commit-sensitive effect that remains safe when React renders on the server. */
3
- export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
@@ -1,27 +0,0 @@
1
- import { type PaymentMethodGroupLayout, type PaymentMethodLayoutRules } from '@flopay/shared';
2
- /**
3
- * How long the checkout waits for the billing API's layout before it shows
4
- * the merchant's default order instead. A later answer is then ignored, so
5
- * nothing moves once it is on screen.
6
- */
7
- export declare const PAYMENT_METHOD_LAYOUT_TIMEOUT_MS = 1500;
8
- /**
9
- * The order to render the payment method groups in, and the groups behind
10
- * "More payment options". Without rules it is the default order with no
11
- * link, straight away and without a request. With rules, the billing API
12
- * resolves it for this buyer, and `null` means the first answer is still
13
- * pending: render placeholders, not methods that might move. A slow, failed
14
- * or older billing API gives the merchant's default rule. When the rules
15
- * change, the previous layout stays until the new one is known.
16
- *
17
- * `waitForSession` holds the request while an inline session's details are
18
- * still being attached (the background claim): the buyer's country arrives
19
- * with them, so asking earlier would pick the rule without it.
20
- */
21
- export declare function usePaymentMethodLayout({ rules, sessionId, nonce, billingApiUrl, waitForSession, }: {
22
- rules: PaymentMethodLayoutRules | undefined;
23
- sessionId: string;
24
- nonce: string | undefined;
25
- billingApiUrl: string | undefined;
26
- waitForSession: boolean;
27
- }): PaymentMethodGroupLayout | null;
@@ -1,97 +0,0 @@
1
- import type { CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
2
- import type React from 'react';
3
- /** Props for {@link VaultCardFields}. */
4
- export interface VaultCardFieldsProps {
5
- /** The vault block expiry, forwarded to the adapter mount. */
6
- expiresAt?: string | null;
7
- /**
8
- * The card-capture adapter (typically `useFloPay().cardCapture()`). Owns
9
- * injecting + bootstrapping the hosted vault widget. Changing this instance
10
- * (or {@link VaultCardFieldsProps.html}) remounts the widget.
11
- */
12
- capture: CardCaptureAdapter;
13
- /**
14
- * Server-rendered hosted vault widget HTML (the session's
15
- * {@link CheckoutSession.vault} block `html`, or one fetched from
16
- * `POST /vault/capture`). The widget owns the card fields, submit button,
17
- * tokenization, charge, and 3DS; this component only injects it.
18
- */
19
- html: string;
20
- /**
21
- * Per-session integrity token (the vault block's `messageToken`). Forwarded
22
- * to the adapter so it can reject forged terminal `postMessage` outcomes that
23
- * omit/mismatch it. Omitted when the backend does not (yet) mint one.
24
- */
25
- messageToken?: string;
26
- /**
27
- * Exact origin expected for the widget's terminal `postMessage` outcomes
28
- * (the vault block's `expectedOrigin`). Forwarded to the adapter's origin
29
- * gate; omitted to skip it.
30
- */
31
- expectedOrigin?: string;
32
- /**
33
- * The form sits behind the backend's production human check (the vault
34
- * block's `verification.required`). Forwarded to the adapter so a pre-submit
35
- * frame `error` (check failed, expired or unavailable) is not reported as a
36
- * vault load failure; it still reaches {@link VaultCardFieldsProps.onError}.
37
- */
38
- verificationRequired?: boolean;
39
- /**
40
- * Merchant theme colors pushed into the hosted widget so the card form
41
- * matches the surrounding checkout. Applied live on change (no remount).
42
- * `null` is the explicit classic reset: after a theme was applied it tells
43
- * the hosted form to restore every historical neutral value. Omitted (or
44
- * `null` from the start) leaves the widget's own defaults untouched.
45
- */
46
- theme?: VaultCardThemeColors | null;
47
- /**
48
- * Final, already-localized wording for the hosted card form's submit button
49
- * (e.g. `'Pay $10'`), billing API v1.9.35+. Applied live on change (no
50
- * remount, buyer-entered card data kept). `null` is the same as omitting it:
51
- * omitting or clearing it after a label was shown restores the session
52
- * default (`CONFIRM PAYMENT`, or `ADD CARD` for card setup); blank text also
53
- * shows the default.
54
- */
55
- submitLabel?: string | null;
56
- /**
57
- * Inline styles for the container the widget mounts into. Applied as a
58
- * whole declaration list in key order on every change (not diffed property
59
- * by property), so a shorthand and a longhand of the same family cascade
60
- * deterministically across live updates — the surface the card-setup preset
61
- * treatment and a merchant `containerStyle` share.
62
- */
63
- containerStyle?: React.CSSProperties;
64
- /** Fired once the widget is injected and bootstrapping. */
65
- onReady?: () => void;
66
- /**
67
- * Fired with a load/runtime error message from the widget, or `null` when it
68
- * clears. Wired to the card form's shared error banner. Terminal payment
69
- * outcomes (`complete` / `decline`) are observed by the parent form directly
70
- * off the same adapter and are not surfaced here.
71
- */
72
- onError?: (message: string | null) => void;
73
- /**
74
- * Fired with the widget's inline field-validation message (live, debounced by
75
- * the widget to changes), or `null` when validation clears. Surfaced in the
76
- * card form's error banner and the merchant `onError`.
77
- */
78
- onValidation?: (message: string | null) => void;
79
- }
80
- /**
81
- * Renders the backend-served vault PCI card widget
82
- * (TeamFloPay/backend#823, Model A). The hosted widget
83
- * is a self-contained form: PAN / CVC, the submit button, the charge, and 3DS
84
- * all live inside it. This component only injects the widget HTML through the
85
- * {@link CardCaptureAdapter} and bridges its `ready` / `error` lifecycle events
86
- * back to the surrounding card form.
87
- */
88
- export declare function VaultCardFields({ capture, html, messageToken, expectedOrigin, expiresAt, verificationRequired, theme, submitLabel, containerStyle, onReady, onError, onValidation, }: VaultCardFieldsProps): React.ReactElement;
89
- /**
90
- * The rule drawn above the hosted card fields when other payment methods are
91
- * offered first ("or pay with card"). Checkout and payment-method setup draw
92
- * the same one. It lives beside the card fields because every surface that
93
- * draws it already imports them, so it costs no surface a module of its own.
94
- */
95
- export declare function MethodsDivider({ label }: {
96
- label: string;
97
- }): React.ReactElement;
@@ -1 +0,0 @@
1
- export { computeVaultCardThemeColors } from '@flopay/shared';