@flopay/react 1.14.5 → 1.14.6

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 (45) hide show
  1. package/dist/automatic-payment-button.d.ts +81 -0
  2. package/dist/buyer-identity-fallback.d.ts +43 -0
  3. package/dist/card-button-content.d.ts +11 -0
  4. package/dist/card-setup-entry.d.ts +10 -104
  5. package/dist/card-setup-surface.d.ts +12 -0
  6. package/dist/card-setup-theme.d.ts +32 -0
  7. package/dist/checkout-utils.d.ts +163 -0
  8. package/dist/context.d.ts +46 -0
  9. package/dist/direct-paypal-button.d.ts +155 -0
  10. package/dist/error-banner.d.ts +21 -0
  11. package/dist/external-method-recovery.d.ts +1 -0
  12. package/dist/external-method-telemetry.d.ts +17 -0
  13. package/dist/{card-setup-entry.d.cts → flopay-card-setup.d.ts} +19 -11
  14. package/dist/flopay-checkout.d.ts +239 -0
  15. package/dist/flopay-payment-method-setup-main.d.ts +10 -0
  16. package/dist/flopay-payment-method-setup.d.ts +11 -0
  17. package/dist/hooks.d.ts +36 -0
  18. package/dist/in-app-browser.d.ts +5 -0
  19. package/dist/index.d.ts +20 -921
  20. package/dist/inline-session-cache.d.ts +1 -0
  21. package/dist/instruments.d.ts +5 -0
  22. package/dist/merchant-callback.d.ts +1 -0
  23. package/dist/payment-logos.generated.d.ts +1 -0
  24. package/dist/payment-method-setup-advertisement.d.ts +36 -0
  25. package/dist/payment-method-setup-entry.d.ts +12 -14
  26. package/dist/payment-method-setup-paypal.d.ts +25 -0
  27. package/dist/payment-method-setup-stripe.d.ts +31 -0
  28. package/dist/{payment-method-setup-surface-DWGNLM0I.d.cts → payment-method-setup-surface.d.ts} +27 -9
  29. package/dist/popup-capability.d.ts +12 -0
  30. package/dist/processing-overlay.d.ts +33 -0
  31. package/dist/provider.d.ts +40 -0
  32. package/dist/recent-completion.d.ts +1 -0
  33. package/dist/run-latest-abortable-action.d.ts +5 -0
  34. package/dist/saved-payment-flow.d.ts +124 -0
  35. package/dist/split-card-form.d.ts +319 -0
  36. package/dist/stripe-method-presentation.d.ts +115 -0
  37. package/dist/telemetry-bridge.d.ts +41 -0
  38. package/dist/use-external-attempt-reconciliation.d.ts +27 -0
  39. package/dist/use-isomorphic-layout-effect.d.ts +3 -0
  40. package/dist/vault-card-fields.d.ts +95 -0
  41. package/dist/vault-theme.d.ts +1 -0
  42. package/package.json +5 -5
  43. package/dist/index.d.cts +0 -921
  44. package/dist/payment-method-setup-entry.d.cts +0 -16
  45. package/dist/payment-method-setup-surface-B9TI-00C.d.ts +0 -72
@@ -0,0 +1,319 @@
1
+ import type { AVSFieldConfig, BeforeButtonClickEvent, CheckoutButtonMethod, CheckoutSession, DeclineEvent, FloPayPaymentCancelEvent, GatewayEnvironment, InlineSessionPatch, PaymentResult, PayPalProviderObjectType, TokenizedBody, WalletPresentation } from '@flopay/shared';
2
+ import { FloPayError } from '@flopay/shared';
3
+ import React from 'react';
4
+ import { type MaybePromise } from './buyer-identity-fallback.js';
5
+ export { darkenHex } from '@flopay/shared';
6
+ export declare const CARD_VIEW_TRANSITION_MS = 180;
7
+ /**
8
+ * Shared "primary button" base style for the two buyer-action buttons in the
9
+ * buttons-layout (the "Credit / Debit Card" button + `FloPayAutomaticPaymentButton`).
10
+ *
11
+ * - `'classic'` / no theme: white background, grey border — historic look
12
+ * that lines up with the wallet ECE row's flat tiles.
13
+ * - Any theme bundle (`modern-*`, `bold-*`, `glass-*`): `colorPrimary`
14
+ * (`resolvedPrimaryColor` — already merged with any `appearance` override)
15
+ * drives the `backgroundColor`, exactly like the "Confirm Payment" submit
16
+ * CTA, so all three flo buttons (submit, card, auto-pay) share one fill and
17
+ * a per-checkout `colorPrimary` override re-skins every one of them. The
18
+ * bundle's `submitButton` still supplies `color` / `border` / `borderRadius`
19
+ * / `boxShadow` so typography + shape stay on-theme. Hover (`colorPrimaryHover`)
20
+ * is applied by each button's `onMouseEnter`/`onMouseLeave` at the call site.
21
+ */
22
+ export declare function derivePrimaryTileStyle(opts: {
23
+ themeBundle: import('@flopay/shared').ThemeBundle | null | undefined;
24
+ resolvedPrimaryColor: string;
25
+ resolvedBorderRadius: string;
26
+ submitButtonStyle?: React.CSSProperties;
27
+ /**
28
+ * Raw `appearance.colorPrimary` (undefined when the merchant didn't set one).
29
+ * When present it forces a primary-filled tile even with no theme bundle
30
+ * (the `classic` preset), so an explicit `colorPrimary` override always wins
31
+ * over the historic white tile.
32
+ */
33
+ explicitPrimaryColor?: string;
34
+ }): React.CSSProperties;
35
+ export interface SplitCardFormProps {
36
+ /** The checkout session ID (UUID from billing API). */
37
+ sessionId: string;
38
+ /**
39
+ * Session-bound checkout token returned by session creation
40
+ * (`CheckoutSessionResult.nonce` or `session.clientSecret`). Forwarded as
41
+ * `x-checkout-session-token` on every continuation request — required by
42
+ * post-#640 backends. `FloPayCheckout` plumbs this prop automatically.
43
+ */
44
+ nonce?: string;
45
+ /** Billing API base URL. Optional — defaults to the value from FloPayProvider or the shared constant. */
46
+ billingApiUrl?: string;
47
+ /** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
48
+ telemetry?: boolean;
49
+ /** User's email (required for creating payment intents). */
50
+ email?: string;
51
+ /** User ID (required for processing payments). */
52
+ userId?: string;
53
+ /** Called when the full payment flow completes successfully. */
54
+ onComplete?: (result: PaymentResult) => void;
55
+ /** Called when a payment error occurs. */
56
+ onError?: (error: FloPayError) => void;
57
+ /** Called when a payment is declined or the authentication step fails. */
58
+ onDecline?: (decline: DeclineEvent) => void;
59
+ /**
60
+ * Called once when the buyer closes or leaves the direct PayPal button's
61
+ * PayPal window without approving. Not called for Stripe-rendered PayPal.
62
+ */
63
+ onCancel?: (event: FloPayPaymentCancelEvent) => void;
64
+ /**
65
+ * **Override**: If provided, delegates backend submission to the caller.
66
+ * When omitted, processes internally (calls processPayment + handles 3DS).
67
+ */
68
+ onTokenizedBody?: (tokenizedBody: TokenizedBody) => void;
69
+ /** First name for billing. */
70
+ firstName?: string;
71
+ /** Last name for billing. */
72
+ lastName?: string;
73
+ /** Checkout version for A/B tracking. */
74
+ chv?: string;
75
+ /** Additional CSS class for the form wrapper. */
76
+ className?: string;
77
+ /**
78
+ * Final wording for the hosted card form's submit button — the control that
79
+ * starts the card payment — e.g. `'Pay $10'` (billing API v1.9.35+). Pass
80
+ * the final, already-localized plain text from your own order summary; the
81
+ * SDK does not format amounts or translate.
82
+ *
83
+ * Changes apply live without remounting the card form, so buyer-entered
84
+ * card details, focus, and caret are kept. Omitting it, passing `null`, or
85
+ * clearing it after a label was shown restores the hosted default
86
+ * (`CONFIRM PAYMENT`); blank, oversized, or invalid text also shows the
87
+ * default. It does not change wallet, PayPal, processing, or retry wording,
88
+ * the buttons-layout card tile (`cardButtonContent`), or the saved-payment
89
+ * confirm button (`FloPayCheckout`'s `confirmLabel`).
90
+ */
91
+ submitLabel?: string | null;
92
+ /** External processing state. */
93
+ isProcessing?: boolean;
94
+ /** External error message. */
95
+ error?: string | null;
96
+ /** Called when internal error state changes. */
97
+ onErrorChange?: (error: string | null) => void;
98
+ /**
99
+ * Show the PayPal payment surface above the hosted vault card surface. Defaults to `true`.
100
+ * The renderer is chosen from `session.gateways.paypal`: when that gateway
101
+ * is configured, `DirectPayPalButton` (PayPal JS SDK) takes over and Stripe
102
+ * drops `paypal` from its express row to avoid double-rendering; otherwise
103
+ * PayPal renders inside `ExpressCheckoutElement` (using either a dedicated
104
+ * `gateways.stripe.paypalPublishableKey` sub-account or the main Stripe
105
+ * account when the enabled-methods list includes `paypal`).
106
+ */
107
+ showPayPal?: boolean;
108
+ /**
109
+ * Show Stripe-rendered wallets and APMs (ExpressCheckoutElement +
110
+ * PaymentElement). Defaults to `true`. When `false`, every Stripe surface
111
+ * is hidden — only `DirectPayPalButton` can render. Setting both
112
+ * `showStripe={false}` and `showPayPal={false}` (with no PayPal gateway
113
+ * configured) throws a bootstrap-time validation error.
114
+ */
115
+ showStripe?: boolean;
116
+ /**
117
+ * Preferred approval presentation for supported wallets. Defaults to
118
+ * `'auto'`. Safety signals and provider capability remain authoritative.
119
+ */
120
+ walletPresentation?: WalletPresentation;
121
+ /**
122
+ * Per-session list of Stripe payment method type identifiers (as returned
123
+ * by the billing API on `gateways.stripe.enabledPaymentMethods`). When
124
+ * supplied, drives the contents of the `ExpressCheckoutElement` row and the
125
+ * accordion `PaymentElement` instead of the historic hardcoded
126
+ * Apple/Google/PayPal set. `card` is reserved for the hosted card path: it
127
+ * advertises that `/vault/capture` recovery is available when the session
128
+ * has no embedded vault block. When omitted, the SDK falls back to the
129
+ * legacy `showApplePay`/`showGooglePay`/`showPayPal` toggles.
130
+ */
131
+ enabledPaymentMethods?: string[];
132
+ /**
133
+ * Per-method buyer-country gate from `gateways.stripe.enabledPaymentMethodCountries`
134
+ * (method → allowed ISO-3166-1 alpha-2 countries; a method absent here has no
135
+ * country gate). The SDK filters the rendered tile row by the buyer's *live*
136
+ * country against this map, so per-method country eligibility comes from the
137
+ * backend rather than a hardcoded SDK table. When omitted (legacy backend),
138
+ * the SDK falls back to its built-in {@link STRIPE_METHOD_COUNTRIES} table.
139
+ */
140
+ enabledPaymentMethodCountries?: Record<string, string[]>;
141
+ /**
142
+ * @deprecated The Apple Pay / Google Pay surface is now driven by the
143
+ * `gateways.stripe.enabledPaymentMethods` list returned per-session by the
144
+ * billing API. Pass {@link SplitCardFormProps.enabledPaymentMethods} (or
145
+ * upgrade the backend so `FloPayCheckout` threads it through automatically).
146
+ * Setting this prop emits a one-time deprecation warning and is otherwise
147
+ * ignored when `enabledPaymentMethods` is supplied.
148
+ */
149
+ showApplePay?: boolean;
150
+ /**
151
+ * @deprecated See {@link SplitCardFormProps.showApplePay}.
152
+ */
153
+ showGooglePay?: boolean;
154
+ /**
155
+ * Layout mode for the payment form.
156
+ * - `'default'` — all payment methods + card form shown together (current behavior)
157
+ * - `'buttons'` — PayPal, wallets, and a "Credit / Debit Card" button; clicking the card
158
+ * button expands the card form with a back button to return to the button view
159
+ */
160
+ layout?: 'default' | 'buttons';
161
+ /**
162
+ * High-level theme bundle that styles non-card Stripe Elements, the FloPay
163
+ * wrapper / AVS inputs, and the hosted vault widget. One of:
164
+ * `'classic'` (historic FloPay look, no bundle applied), `'modern-light'`,
165
+ * `'modern-dark'`, `'bold-light'`, `'bold-dark'`, `'glass-light'`,
166
+ * `'glass-dark'`. Explicit `appearance` / `buttonsStyles` props still
167
+ * override their respective halves when provided.
168
+ */
169
+ theme?: import('@flopay/shared').ThemeId;
170
+ /**
171
+ * @deprecated Use `theme` instead. Legacy buttons-layout preset
172
+ * (`'default' | 'minimal' | 'rounded' | 'dark'`). Still honored for
173
+ * back-compat — the new union accepts the bundle ids too but you should
174
+ * migrate to the `theme` prop.
175
+ */
176
+ buttonsTheme?: import('@flopay/shared').ButtonsLayoutTheme;
177
+ /** Style overrides merged on top of the resolved theme bundle / buttonsTheme preset. */
178
+ buttonsStyles?: import('@flopay/shared').ButtonsLayoutStyles;
179
+ /**
180
+ * Appearance from `FloPayProvider` / `FloPayCheckout`. Threaded through so
181
+ * the React-rendered wrapper, AVS inputs, title, and hosted vault widget can
182
+ * derive colors from `appearance.variables` when no explicit `buttonsStyles`
183
+ * is supplied. Bundle consumers (`THEMES[id]`) get a coherent look without
184
+ * having to forward both halves manually.
185
+ */
186
+ appearance?: import('@flopay/shared').FloPayAppearance;
187
+ /** Custom React content rendered inside the card button when `layout="buttons"`. */
188
+ cardButtonContent?: React.ReactNode;
189
+ /** Custom React content rendered for the buttons-layout card back button label. */
190
+ cardBackButtonContent?: React.ReactNode;
191
+ /** Custom React content rendered for the card-form title. */
192
+ cardTitleContent?: React.ReactNode;
193
+ /**
194
+ * @deprecated No longer rendered — the default-layout security footer was
195
+ * removed alongside the theme-bundle refactor. Retained as an optional
196
+ * prop so existing integrations type-check without changes.
197
+ */
198
+ showSecurityFooter?: boolean;
199
+ /**
200
+ * Called when a payment method button is clicked.
201
+ * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
202
+ */
203
+ onButtonClick?: (method: CheckoutButtonMethod) => void;
204
+ /**
205
+ * Called before a payment button continues in `layout="buttons"`.
206
+ * Runs for card, PayPal, Apple Pay, and Google Pay.
207
+ */
208
+ onBeforeButtonClick?: (event: BeforeButtonClickEvent) => MaybePromise<undefined | false | InlineSessionPatch>;
209
+ /**
210
+ * Called after checkout collects a missing buyer email/name. FloPayCheckout
211
+ * uses this to claim an email-less detached session before payment continues.
212
+ */
213
+ onBuyerIdentityReady?: (identity: NonNullable<InlineSessionPatch['account']>) => MaybePromise<void>;
214
+ /**
215
+ * Enable AVS (Address Verification).
216
+ * - `true` — show country + postal code (backward compatible default)
217
+ * - `AVSFieldConfig` — granular per-field control, optionally scoped to country codes
218
+ * - `false` / omitted — AVS disabled
219
+ */
220
+ enableAVS?: boolean | AVSFieldConfig;
221
+ /**
222
+ * Per-merchant order of the hosted vault card rows — a permutation of
223
+ * `['name','number','expiry']` (`'expiry'` is the combined expiry+CVV row;
224
+ * the submit button stays last). Drives both the visual order and the tab
225
+ * order inside the widget. Omit for the default (`name`, `number`, `expiry`).
226
+ * Only applies on the vault card path.
227
+ */
228
+ cardFieldOrder?: import('@flopay/shared').VaultCardFieldKey[];
229
+ /** Content rendered above the hosted vault card widget (below the wallet divider). */
230
+ cardPreFormSlot?: React.ReactNode;
231
+ /** Layout for AVS fields: 'row' (side-by-side, default) or 'column' (stacked). */
232
+ avsLayout?: 'row' | 'column';
233
+ /** Pre-filled country code (ISO 3166-1 alpha-2) for AVS. */
234
+ country?: string;
235
+ /** Pre-filled ZIP/postal code for AVS. */
236
+ zip?: string;
237
+ /** Pre-filled street address (line 1) for AVS. Typically from a partner GeoIP / profile lookup. */
238
+ addressLine1?: string;
239
+ /** Pre-filled apt/suite/unit (line 2) for AVS. */
240
+ addressLine2?: string;
241
+ /** Pre-filled city for AVS. Typically from a partner GeoIP / profile lookup. */
242
+ city?: string;
243
+ /** Pre-filled state/province for AVS. Typically from a partner GeoIP / profile lookup. */
244
+ state?: string;
245
+ /** Callback when AVS country changes. */
246
+ onCountryChange?: (country: string) => void;
247
+ /** Callback when AVS ZIP/postal code changes. */
248
+ onZipChange?: (zip: string) => void;
249
+ /** Whether AVS was enabled (sent to backend for analytics). */
250
+ avsCheck?: boolean;
251
+ /** Checkout type: 'standard_checkout' or 'embedded_checkout'. */
252
+ checkoutType?: string;
253
+ /** Checkout layout: 'default_layout', 'buttons_layout', or 'custom_layout'. */
254
+ checkoutLayout?: string;
255
+ /** Total amount in cents (smallest currency unit). Used for wallet/PayPal Elements config. */
256
+ totalAmount?: number;
257
+ /** Currency code (used for PayPal Elements config). */
258
+ currency?: string;
259
+ /** Render the card form expanded on first paint when `layout="buttons"`. */
260
+ initialCardOpen?: boolean;
261
+ /**
262
+ * Direct PayPal gateway configuration. When provided, PayPal renders via
263
+ * the official PayPal JS SDK (in-app browser compliant) instead of via
264
+ * Stripe's ExpressCheckoutElement. Selection is mutually exclusive:
265
+ * setting this disables the Stripe-rendered PayPal path automatically.
266
+ */
267
+ directPaypal?: {
268
+ clientId: string;
269
+ environment?: GatewayEnvironment;
270
+ /**
271
+ * @deprecated The active session's
272
+ * `gateways.paypal.providerObjectType` advertisement is authoritative.
273
+ * Retained as a fallback for integrations that do not supply a session.
274
+ */
275
+ providerObjectType?: PayPalProviderObjectType;
276
+ /** Backend-advertised non-popup presentation for one-time PayPal Orders. */
277
+ approvalPresentation?: import('@flopay/shared').PayPalApprovalPresentation;
278
+ /** Backend-created PayPal object to resume without creating a replacement. */
279
+ existingOrderId?: string;
280
+ };
281
+ /** Whether the active session represents a subscription (drives direct PayPal intent). */
282
+ isSubscription?: boolean;
283
+ /** Backing session — forwarded to direct-PayPal so it can populate accountData. */
284
+ session?: CheckoutSession | null;
285
+ /**
286
+ * True while a **detached** session's claim is waiting for buyer identity or
287
+ * is still in flight (TeamFloPay/backend#1099).
288
+ *
289
+ * The hosted card widget is already mounted and the buyer can fill it in, but
290
+ * the session has no cart attached yet, so nothing may be submitted: the
291
+ * billing API rejects process / intent calls on an unclaimed session with
292
+ * `409 checkout_session_data_attachment_required`, and holds an unclaimed
293
+ * vault charge with a retryable `503`. While true, card submit stays gated.
294
+ * Non-card surfaces also stay hidden unless they are needed to collect the
295
+ * missing identity; all payment continuations enable when the claim lands.
296
+ * `FloPayCheckout` plumbs this prop automatically.
297
+ */
298
+ dataAttachmentPending?: boolean;
299
+ /**
300
+ * True when the pending detached claim is waiting for this form to collect
301
+ * buyer identity. Non-card collection surfaces remain available, while all
302
+ * payment continuations still await `onBuyerIdentityReady`.
303
+ */
304
+ dataAttachmentRequiresIdentity?: boolean;
305
+ /**
306
+ * Enables on-screen diagnostic panels for the PayPal/wallet gating decision
307
+ * and the `DirectPayPalButton` lifecycle. Intended for debugging in-app
308
+ * browsers where remote console access is impractical. Off by default.
309
+ */
310
+ debug?: boolean;
311
+ }
312
+ /**
313
+ * Checkout surface combining hosted vault card capture with wallets, APMs,
314
+ * and PayPal. Card entry is hosted-vault-only.
315
+ *
316
+ * Stripe-hosted PayPal uses its own Elements instance; direct PayPal uses the
317
+ * official PayPal SDK when the session advertises that gateway.
318
+ */
319
+ export declare function SplitCardForm(props: SplitCardFormProps): React.JSX.Element;
@@ -0,0 +1,115 @@
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;
@@ -0,0 +1,41 @@
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 {};
@@ -0,0 +1,27 @@
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 {};
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,95 @@
1
+ import type { CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
2
+ import type React from 'react';
3
+ /** Props for {@link VaultCardFields}. */
4
+ export interface VaultCardFieldsProps {
5
+ /**
6
+ * The card-capture adapter (typically `useFloPay().cardCapture()`). Owns
7
+ * injecting + bootstrapping the hosted vault widget. Changing this instance
8
+ * (or {@link VaultCardFieldsProps.html}) remounts the widget.
9
+ */
10
+ capture: CardCaptureAdapter;
11
+ /**
12
+ * Server-rendered hosted vault widget HTML (the session's
13
+ * {@link CheckoutSession.vault} block `html`, or one fetched from
14
+ * `POST /vault/capture`). The widget owns the card fields, submit button,
15
+ * tokenization, charge, and 3DS; this component only injects it.
16
+ */
17
+ html: string;
18
+ /**
19
+ * Per-session integrity token (the vault block's `messageToken`). Forwarded
20
+ * to the adapter so it can reject forged terminal `postMessage` outcomes that
21
+ * omit/mismatch it. Omitted when the backend does not (yet) mint one.
22
+ */
23
+ messageToken?: string;
24
+ /**
25
+ * Exact origin expected for the widget's terminal `postMessage` outcomes
26
+ * (the vault block's `expectedOrigin`). Forwarded to the adapter's origin
27
+ * gate; omitted to skip it.
28
+ */
29
+ expectedOrigin?: string;
30
+ /**
31
+ * The form sits behind the backend's production human check (the vault
32
+ * block's `verification.required`). Forwarded to the adapter so a pre-submit
33
+ * frame `error` (check failed, expired or unavailable) is not reported as a
34
+ * vault load failure; it still reaches {@link VaultCardFieldsProps.onError}.
35
+ */
36
+ verificationRequired?: boolean;
37
+ /**
38
+ * Merchant theme colors pushed into the hosted widget so the card form
39
+ * matches the surrounding checkout. Applied live on change (no remount).
40
+ * `null` is the explicit classic reset: after a theme was applied it tells
41
+ * the hosted form to restore every historical neutral value. Omitted (or
42
+ * `null` from the start) leaves the widget's own defaults untouched.
43
+ */
44
+ theme?: VaultCardThemeColors | null;
45
+ /**
46
+ * Final, already-localized wording for the hosted card form's submit button
47
+ * (e.g. `'Pay $10'`), billing API v1.9.35+. Applied live on change (no
48
+ * remount, buyer-entered card data kept). `null` is the same as omitting it:
49
+ * omitting or clearing it after a label was shown restores the session
50
+ * default (`CONFIRM PAYMENT`, or `ADD CARD` for card setup); blank text also
51
+ * shows the default.
52
+ */
53
+ submitLabel?: string | null;
54
+ /**
55
+ * Inline styles for the container the widget mounts into. Applied as a
56
+ * whole declaration list in key order on every change (not diffed property
57
+ * by property), so a shorthand and a longhand of the same family cascade
58
+ * deterministically across live updates — the surface the card-setup preset
59
+ * treatment and a merchant `containerStyle` share.
60
+ */
61
+ containerStyle?: React.CSSProperties;
62
+ /** Fired once the widget is injected and bootstrapping. */
63
+ onReady?: () => void;
64
+ /**
65
+ * Fired with a load/runtime error message from the widget, or `null` when it
66
+ * clears. Wired to the card form's shared error banner. Terminal payment
67
+ * outcomes (`complete` / `decline`) are observed by the parent form directly
68
+ * off the same adapter and are not surfaced here.
69
+ */
70
+ onError?: (message: string | null) => void;
71
+ /**
72
+ * Fired with the widget's inline field-validation message (live, debounced by
73
+ * the widget to changes), or `null` when validation clears. Surfaced in the
74
+ * card form's error banner and the merchant `onError`.
75
+ */
76
+ onValidation?: (message: string | null) => void;
77
+ }
78
+ /**
79
+ * Renders the backend-served vault PCI card widget
80
+ * (TeamFloPay/backend#823, Model A). The hosted widget
81
+ * is a self-contained form: PAN / CVC, the submit button, the charge, and 3DS
82
+ * all live inside it. This component only injects the widget HTML through the
83
+ * {@link CardCaptureAdapter} and bridges its `ready` / `error` lifecycle events
84
+ * back to the surrounding card form.
85
+ */
86
+ export declare function VaultCardFields({ capture, html, messageToken, expectedOrigin, verificationRequired, theme, submitLabel, containerStyle, onReady, onError, onValidation, }: VaultCardFieldsProps): React.ReactElement;
87
+ /**
88
+ * The rule drawn above the hosted card fields when other payment methods are
89
+ * offered first ("or pay with card"). Checkout and payment-method setup draw
90
+ * the same one. It lives beside the card fields because every surface that
91
+ * draws it already imports them, so it costs no surface a module of its own.
92
+ */
93
+ export declare function MethodsDivider({ label }: {
94
+ label: string;
95
+ }): React.ReactElement;
@@ -0,0 +1 @@
1
+ export { computeVaultCardThemeColors } from '@flopay/shared';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/react",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -36,8 +36,8 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@flopay/js": "1.14.5",
40
- "@flopay/shared": "1.14.5",
39
+ "@flopay/js": "1.14.6",
40
+ "@flopay/shared": "1.14.6",
41
41
  "@paypal/paypal-js": "^10.1.0",
42
42
  "@stripe/react-stripe-js": "^6.12.0",
43
43
  "@stripe/stripe-js": "^9.17.0"
@@ -55,11 +55,11 @@
55
55
  "react": "^19.3.1",
56
56
  "react-dom": "^19.3.1",
57
57
  "tsup": "^8.3.0",
58
- "typescript": "^6.0.3",
58
+ "typescript": "^7.0.2",
59
59
  "vitest": "4.1.12"
60
60
  },
61
61
  "scripts": {
62
- "build": "tsup",
62
+ "build": "tsup && tsc -p tsconfig.build.json",
63
63
  "dev": "tsup --watch",
64
64
  "typecheck": "tsc --noEmit",
65
65
  "test": "vitest run",