@flopay/react 1.14.5 → 1.14.7
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/dist/automatic-payment-button.d.ts +81 -0
- package/dist/buyer-identity-fallback.d.ts +43 -0
- package/dist/card-button-content.d.ts +11 -0
- package/dist/card-setup-entry.d.ts +10 -104
- package/dist/card-setup-surface.d.ts +12 -0
- package/dist/card-setup-theme.d.ts +32 -0
- package/dist/checkout-utils.d.ts +163 -0
- package/dist/context.d.ts +46 -0
- package/dist/direct-paypal-button.d.ts +155 -0
- package/dist/error-banner.d.ts +21 -0
- package/dist/external-method-recovery.d.ts +1 -0
- package/dist/external-method-telemetry.d.ts +17 -0
- package/dist/{card-setup-entry.d.cts → flopay-card-setup.d.ts} +19 -11
- package/dist/flopay-checkout.d.ts +239 -0
- package/dist/flopay-payment-method-setup-main.d.ts +10 -0
- package/dist/flopay-payment-method-setup.d.ts +11 -0
- package/dist/hooks.d.ts +36 -0
- package/dist/in-app-browser.d.ts +5 -0
- package/dist/index.d.ts +20 -921
- package/dist/inline-session-cache.d.ts +1 -0
- package/dist/instruments.d.ts +5 -0
- package/dist/merchant-callback.d.ts +1 -0
- package/dist/payment-logos.generated.d.ts +1 -0
- package/dist/payment-method-setup-advertisement.d.ts +36 -0
- package/dist/payment-method-setup-entry.d.ts +12 -14
- package/dist/payment-method-setup-paypal.d.ts +25 -0
- package/dist/payment-method-setup-stripe.d.ts +31 -0
- package/dist/{payment-method-setup-surface-DWGNLM0I.d.cts → payment-method-setup-surface.d.ts} +27 -9
- package/dist/popup-capability.d.ts +12 -0
- package/dist/processing-overlay.d.ts +33 -0
- package/dist/provider.d.ts +40 -0
- package/dist/recent-completion.d.ts +1 -0
- package/dist/run-latest-abortable-action.d.ts +5 -0
- package/dist/saved-payment-flow.d.ts +124 -0
- package/dist/split-card-form.d.ts +319 -0
- package/dist/stripe-method-presentation.d.ts +115 -0
- package/dist/telemetry-bridge.d.ts +41 -0
- package/dist/use-external-attempt-reconciliation.d.ts +27 -0
- package/dist/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/vault-card-fields.d.ts +95 -0
- package/dist/vault-theme.d.ts +1 -0
- package/package.json +5 -5
- package/dist/index.d.cts +0 -921
- package/dist/payment-method-setup-entry.d.cts +0 -16
- package/dist/payment-method-setup-surface-B9TI-00C.d.ts +0 -72
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ButtonsLayoutStyles, ButtonsLayoutTheme, CheckoutButtonMethod, CheckoutItem, CheckoutProduct, CheckoutSession, CheckoutSubscription, DeclineEvent, FloPayAppearance, InlineSessionDraft, PaymentResult, ThemeId } from '@flopay/shared';
|
|
2
|
+
import { FloPayError } from '@flopay/shared';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
export interface FloPayAutomaticPaymentSuccessEvent {
|
|
5
|
+
result: PaymentResult;
|
|
6
|
+
session: CheckoutSession | null;
|
|
7
|
+
sessionId: string | null;
|
|
8
|
+
autoCompleted: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onError'> {
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Session-bound checkout token for a consumer-supplied {@link sessionId}
|
|
14
|
+
* (the `nonce` returned when that session was created). Post-#640 backends
|
|
15
|
+
* require it as `x-checkout-session-token` to read the session and to
|
|
16
|
+
* `/process` it; without it the existing-session path 401s with
|
|
17
|
+
* "Missing checkout session token.". Ignored on the create-session path,
|
|
18
|
+
* where the SDK mints and threads the nonce itself.
|
|
19
|
+
*/
|
|
20
|
+
nonce?: string;
|
|
21
|
+
createSession?: InlineSessionDraft;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Ignored. The backend now picks the customer's most recent
|
|
24
|
+
* vaulted payment method via `getLatestByUserId` and rebinds the session's
|
|
25
|
+
* gateway to match it (see `apps/api`'s `createSingle` auto-checkout
|
|
26
|
+
* branch). Passing this prop has no effect — it is retained only to avoid
|
|
27
|
+
* breaking existing integrations.
|
|
28
|
+
*/
|
|
29
|
+
paymentMethodId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Ignored. The backend orchestrates gateway routing — clients
|
|
32
|
+
* no longer choose between card and PayPal at the SDK boundary. Passing
|
|
33
|
+
* this prop has no effect.
|
|
34
|
+
*/
|
|
35
|
+
checkoutMethod?: CheckoutButtonMethod;
|
|
36
|
+
clientId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Unified products array (TeamFloPay/backend#760). When supplied,
|
|
39
|
+
* `items`/`subscriptions` are ignored. The SDK folds the legacy fields
|
|
40
|
+
* into this shape internally.
|
|
41
|
+
*/
|
|
42
|
+
products?: CheckoutProduct[];
|
|
43
|
+
items?: CheckoutItem[];
|
|
44
|
+
subscriptions?: CheckoutSubscription[];
|
|
45
|
+
account?: InlineSessionDraft['account'];
|
|
46
|
+
successUrl?: string;
|
|
47
|
+
cancelUrl?: string;
|
|
48
|
+
couponCodes?: string[];
|
|
49
|
+
tagsData?: InlineSessionDraft['tagsData'];
|
|
50
|
+
utmMetadata?: InlineSessionDraft['utmMetadata'];
|
|
51
|
+
billingApiUrl?: string;
|
|
52
|
+
locale?: string;
|
|
53
|
+
/**
|
|
54
|
+
* High-level theme bundle that styles the button (and the fallback
|
|
55
|
+
* `FloPayCheckout` modal that opens when the saved-payment charge needs
|
|
56
|
+
* user interaction). One of: `'classic'`, `'modern-light'`, `'modern-dark'`,
|
|
57
|
+
* `'bold-light'`, `'bold-dark'`, `'glass-light'`, `'glass-dark'`. Explicit
|
|
58
|
+
* `buttonsStyles` still wins for fine-grained overrides.
|
|
59
|
+
*/
|
|
60
|
+
theme?: ThemeId;
|
|
61
|
+
/**
|
|
62
|
+
* Per-checkout appearance overrides layered on top of the chosen `theme`
|
|
63
|
+
* (same shape as {@link FloPayCheckout}'s `appearance`). Its `colorPrimary` /
|
|
64
|
+
* `colorPrimaryHover` / `borderRadius` re-skin the button — and the fallback
|
|
65
|
+
* `FloPayCheckout` modal — so the auto-pay button matches the rest of the
|
|
66
|
+
* themed checkout. Without this the button only saw the bundle's defaults.
|
|
67
|
+
*/
|
|
68
|
+
appearance?: FloPayAppearance;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `theme` instead. Legacy buttons-layout preset
|
|
71
|
+
* (`'default' | 'minimal' | 'rounded' | 'dark'`). Still honored for
|
|
72
|
+
* back-compat.
|
|
73
|
+
*/
|
|
74
|
+
buttonsTheme?: ButtonsLayoutTheme;
|
|
75
|
+
buttonsStyles?: ButtonsLayoutStyles;
|
|
76
|
+
onSuccess?: (event: FloPayAutomaticPaymentSuccessEvent) => void;
|
|
77
|
+
onError?: (error: FloPayError) => void;
|
|
78
|
+
onDecline?: (decline: DeclineEvent) => void;
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
}
|
|
81
|
+
export declare function FloPayAutomaticPaymentButton({ sessionId, nonce, createSession, paymentMethodId: _deprecatedPaymentMethodId, checkoutMethod: _deprecatedCheckoutMethod, clientId, products, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, theme, appearance, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { InlineSessionPatch } from '@flopay/shared';
|
|
2
|
+
export { compactBuyerIdentity } from '@flopay/shared';
|
|
3
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
4
|
+
export type BuyerIdentity = NonNullable<InlineSessionPatch['account']>;
|
|
5
|
+
export type BuyerIdentityReadyHandler = (identity: BuyerIdentity) => MaybePromise<void>;
|
|
6
|
+
export type BuyerIdentityFallbackRequest = {
|
|
7
|
+
id: number;
|
|
8
|
+
methodLabel: string;
|
|
9
|
+
identity: BuyerIdentity;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Single-request identity collector shared by the express (wallet/PayPal)
|
|
13
|
+
* surfaces. `collect(methodLabel, identity)` opens a panel seeded with whatever
|
|
14
|
+
* the provider returned and resolves with the buyer's edited identity, or
|
|
15
|
+
* `null` if they cancel (or the component unmounts). A new request supersedes
|
|
16
|
+
* any pending one.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useBuyerIdentityFallback(): {
|
|
19
|
+
request: BuyerIdentityFallbackRequest | null;
|
|
20
|
+
collect: (methodLabel: string, identity: BuyerIdentity) => Promise<BuyerIdentity | null>;
|
|
21
|
+
finish: (identity: BuyerIdentity | null) => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Buyer-identity collection panel shared by every express surface that has to
|
|
25
|
+
* gather a missing email before it can continue (wallets, the ECE PayPal
|
|
26
|
+
* button, and the direct PayPal button). Provider- or merchant-supplied names
|
|
27
|
+
* are preserved, but the SDK never asks the buyer for a name itself.
|
|
28
|
+
*
|
|
29
|
+
* - `methodLabel` drives both the heading and the submit copy
|
|
30
|
+
* ("Continue with {methodLabel}").
|
|
31
|
+
* - `submitting` disables the submit while a continuation is in flight (used by
|
|
32
|
+
* the direct-PayPal preflight path).
|
|
33
|
+
* - `onCancel` renders a Cancel button only when provided.
|
|
34
|
+
* - `testId` overrides the container test id for surface-specific assertions.
|
|
35
|
+
*/
|
|
36
|
+
export declare function BuyerIdentityFallbackPanel({ identity, methodLabel, onComplete, onCancel, submitting, testId, }: {
|
|
37
|
+
identity: BuyerIdentity;
|
|
38
|
+
methodLabel: string;
|
|
39
|
+
onComplete: (identity: BuyerIdentity) => void;
|
|
40
|
+
onCancel?: () => void;
|
|
41
|
+
submitting?: boolean;
|
|
42
|
+
testId?: string;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export declare function isEmptySlotContent(content: React.ReactNode | undefined): boolean;
|
|
3
|
+
export declare function CardButtonContentSlot({ content, }: {
|
|
4
|
+
content?: React.ReactNode;
|
|
5
|
+
}): React.ReactElement;
|
|
6
|
+
export declare function BackButtonContentSlot({ content, }: {
|
|
7
|
+
content?: React.ReactNode;
|
|
8
|
+
}): React.ReactElement;
|
|
9
|
+
export declare function TitleContentSlot({ content }: {
|
|
10
|
+
content?: React.ReactNode;
|
|
11
|
+
}): React.ReactElement;
|
|
@@ -1,106 +1,12 @@
|
|
|
1
|
-
import { ThemeId, VaultCardThemeColors, FloPayAppearance, ButtonsLayoutStyles, SavedCardDisplay, FloPayError, FloPayErrorType } from '@flopay/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
/** Verified terminal result from a no-charge card setup. */
|
|
5
|
-
interface FloPayCardSetupCompleteEvent {
|
|
6
|
-
status: 'succeeded';
|
|
7
|
-
sessionId: string;
|
|
8
|
-
/** Present when the backend terminal message includes the saved-card display DTO. */
|
|
9
|
-
paymentMethod?: SavedCardDisplay;
|
|
10
|
-
}
|
|
11
|
-
/** Provider-neutral terminal decline from card verification. */
|
|
12
|
-
interface FloPayCardSetupDeclineEvent {
|
|
13
|
-
status: 'declined';
|
|
14
|
-
sessionId: string;
|
|
15
|
-
reason?: string;
|
|
16
|
-
message?: string;
|
|
17
|
-
}
|
|
18
|
-
/** Abandoned setup result emitted when the component unmounts pre-terminally. */
|
|
19
|
-
interface FloPayCardSetupCancelEvent {
|
|
20
|
-
status: 'cancelled';
|
|
21
|
-
sessionId: string;
|
|
22
|
-
}
|
|
23
|
-
/** Structured technical/validation failure from the card-setup surface. */
|
|
24
|
-
declare class FloPayCardSetupError extends FloPayError {
|
|
25
|
-
readonly retryable: boolean;
|
|
26
|
-
constructor(message: string, type: FloPayErrorType, options: {
|
|
27
|
-
code: string;
|
|
28
|
-
retryable: boolean;
|
|
29
|
-
param?: string;
|
|
30
|
-
statusCode?: number;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/** Props for the browser-only secure card-setup surface. */
|
|
34
|
-
interface FloPayCardSetupProps {
|
|
35
|
-
/** Opaque id returned by the merchant-authenticated setup-session endpoint. */
|
|
36
|
-
sessionId: string;
|
|
37
|
-
/** Session-bound token returned alongside {@link FloPayCardSetupProps.sessionId}. */
|
|
38
|
-
nonce: string;
|
|
39
|
-
/** Billing API base URL. Defaults to the configured FloPay environment URL. */
|
|
40
|
-
billingApiUrl?: string;
|
|
41
|
-
/** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
|
|
42
|
-
telemetry?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Theme for FloPay's hosted, PCI-compliant card widget. Accepts the same
|
|
45
|
-
* high-level {@link ThemeId} as `FloPayCheckout` (resolved through the same
|
|
46
|
-
* bundle, so one value styles both surfaces identically) or raw
|
|
47
|
-
* {@link VaultCardThemeColors} for full manual control. Defaults to
|
|
48
|
-
* `'modern-light'`, which an unrecognized preset id also falls back to; pass
|
|
49
|
-
* `'classic'` for the historic FloPay look.
|
|
50
|
-
*/
|
|
51
|
-
theme?: ThemeId | VaultCardThemeColors;
|
|
52
|
-
/**
|
|
53
|
-
* Inline styles for the hosted-widget container. A named preset first gives
|
|
54
|
-
* that container the same complete surface as the checkout's credit-card
|
|
55
|
-
* pane (background, border, radius, shadow, padding), with any stored
|
|
56
|
-
* `buttonsStyles.cardFormContainer` merged over it; each `containerStyle`
|
|
57
|
-
* property then wins over that surface for the same property, a longhand
|
|
58
|
-
* refines a surface shorthand (`borderColor` recolors the preset border), and
|
|
59
|
-
* any `background*` member replaces the surface background entirely.
|
|
60
|
-
* Raw colors add no surface. `'classic'` adds one only from a stored
|
|
61
|
-
* `buttonsStyles.cardFormContainer`, merged beneath `containerStyle` the same
|
|
62
|
-
* way; otherwise `containerStyle` applies alone.
|
|
63
|
-
*/
|
|
64
|
-
containerStyle?: React.CSSProperties;
|
|
65
|
-
/**
|
|
66
|
-
* Appearance override, the same prop and type as `FloPayCheckout`'s (for
|
|
67
|
-
* example a client's saved embed theme `appearance`). It replaces the preset's
|
|
68
|
-
* appearance outright, as checkout does: its variables (primary color, text,
|
|
69
|
-
* font, radius, …) drive the hosted card fields, the hosted submit button
|
|
70
|
-
* and the outcome overlay. Ignored with raw {@link VaultCardThemeColors}; an
|
|
71
|
-
* empty `{}` is the same as omitting it. Changes restyle in place.
|
|
72
|
-
*/
|
|
73
|
-
appearance?: FloPayAppearance;
|
|
74
|
-
/**
|
|
75
|
-
* Buttons-layout style overrides, the same prop and type as
|
|
76
|
-
* `FloPayCheckout`'s (for example a client's saved embed theme
|
|
77
|
-
* `buttonsStyles`), merged over the preset's buttons layout the way checkout
|
|
78
|
-
* merges them. `submitButton` and the `cardInput*` members style the hosted
|
|
79
|
-
* card form, and `cardFormContainer` the pane around it and the outcome
|
|
80
|
-
* overlay's panel. Ignored with raw {@link VaultCardThemeColors}; an empty
|
|
81
|
-
* `{}` is the same as omitting it. Changes restyle in place.
|
|
82
|
-
*/
|
|
83
|
-
buttonsStyles?: ButtonsLayoutStyles;
|
|
84
|
-
/** Optional content shown while the session and hosted widget are loading. */
|
|
85
|
-
loading?: React.ReactNode;
|
|
86
|
-
/** Fired once the hosted widget has mounted and can accept card input. */
|
|
87
|
-
onReady?: () => void;
|
|
88
|
-
/** Fired only after the backend reports that the card is verified and usable. */
|
|
89
|
-
onComplete?: (event: FloPayCardSetupCompleteEvent) => void;
|
|
90
|
-
/** Fired when verification terminally declines; never paired with `onComplete`. */
|
|
91
|
-
onDecline?: (event: FloPayCardSetupDeclineEvent) => void;
|
|
92
|
-
/** Fired exactly once if the setup surface unmounts before a terminal outcome. */
|
|
93
|
-
onCancel?: (event: FloPayCardSetupCancelEvent) => void;
|
|
94
|
-
/** Live hosted-field validation message, or `null` when validation clears. */
|
|
95
|
-
onValidation?: (message: string | null) => void;
|
|
96
|
-
/** Fired for setup-session validation, transport, or hosted-widget failures. */
|
|
97
|
-
onError?: (error: FloPayCardSetupError) => void;
|
|
98
|
-
}
|
|
99
1
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
2
|
+
* Stripe-free entry for card-setup surfaces (`@flopay/react/card-setup`).
|
|
3
|
+
*
|
|
4
|
+
* The main entry's module graph reaches `@flopay/js`'s Stripe adapter, whose
|
|
5
|
+
* eager `@stripe/stripe-js` import starts downloading the js.stripe.com
|
|
6
|
+
* script at evaluation time — deliberate for checkout, wrong for pages that
|
|
7
|
+
* only manage saved cards. Import `FloPayCardSetup` from here to keep such
|
|
8
|
+
* pages free of Stripe network activity by construction. The main entry still
|
|
9
|
+
* re-exports the component for back-compat, but bundlers that evaluate the
|
|
10
|
+
* whole main entry will pull Stripe with it.
|
|
103
11
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export { FloPayCardSetup, type FloPayCardSetupCancelEvent, type FloPayCardSetupCompleteEvent, type FloPayCardSetupDeclineEvent, FloPayCardSetupError, type FloPayCardSetupProps };
|
|
12
|
+
export { FloPayCardSetup, type FloPayCardSetupCancelEvent, type FloPayCardSetupCompleteEvent, type FloPayCardSetupDeclineEvent, FloPayCardSetupError, type FloPayCardSetupProps, } from './flopay-card-setup.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export { mergeCardSetupSurface } from '@flopay/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Apply a `React.CSSProperties` object to an element in declaration order,
|
|
5
|
+
* replacing whatever inline style it had. Rewriting the whole declaration list
|
|
6
|
+
* on every change (rather than diffing property by property, as a React
|
|
7
|
+
* `style` prop does) is what keeps the shorthand/longhand precedence above
|
|
8
|
+
* deterministic across live theme switches: a preset `border` that changes
|
|
9
|
+
* underneath a merchant `borderColor` is re-cascaded, not silently reset.
|
|
10
|
+
* Values are serialized exactly as React would serialize a `style` prop.
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyInlineStyle(element: HTMLElement, style: React.CSSProperties | undefined): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ButtonsLayoutStyles, CardSetupOverlaySource, CardSetupThemeSource, FloPayAppearance, VaultCardThemeColors } from '@flopay/shared';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import type { ProcessingOverlayTheme } from './processing-overlay.js';
|
|
4
|
+
export { mergeButtonsStyles } from '@flopay/shared';
|
|
5
|
+
/**
|
|
6
|
+
* The card-setup processing / success / error modal for a named preset (or a
|
|
7
|
+
* stored theme resolved over one), from `@flopay/shared`; this only types its
|
|
8
|
+
* framework-free panel style as React's.
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeCardSetupOverlayTheme(source: CardSetupOverlaySource): ProcessingOverlayTheme;
|
|
11
|
+
/** Everything the card-setup surface paints, resolved from one stored theme. */
|
|
12
|
+
interface CardSetupThemeResolution {
|
|
13
|
+
/**
|
|
14
|
+
* The hosted-widget directive: computed colors, raw colors passed through
|
|
15
|
+
* untouched, or `null` — the explicit classic reset.
|
|
16
|
+
*/
|
|
17
|
+
vaultTheme: VaultCardThemeColors | null;
|
|
18
|
+
/** The pane surface laid beneath the merchant's `containerStyle`, if any. */
|
|
19
|
+
surface: React.CSSProperties | undefined;
|
|
20
|
+
/** The outcome overlay's theme; `undefined` keeps the neutral modal. */
|
|
21
|
+
overlayTheme: ProcessingOverlayTheme | undefined;
|
|
22
|
+
/** The effective appearance, for the Stripe Elements and method tiles beside the hosted form. */
|
|
23
|
+
appearance: FloPayAppearance | undefined;
|
|
24
|
+
/** The effective buttons layout, for the wallet, PayPal and APM buttons and tiles. */
|
|
25
|
+
buttonsLayout: ButtonsLayoutStyles | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the `FloPayCardSetup` theming props the way `FloPayCheckout`
|
|
29
|
+
* resolves its own (`resolveCardSetupTheme` in `@flopay/shared`), typing the
|
|
30
|
+
* surface and overlay as React's.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveCardSetupTheme(source: CardSetupThemeSource): CardSetupThemeResolution;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { PaymentAPI } from '@flopay/js';
|
|
2
|
+
import type { CaptureMethod, CardSetupFutureUse, CheckoutAccount, CheckoutButtonMethod, CheckoutMode, CheckoutSession, DeclineEvent, FutureUseSessionFields, InlineSessionDraft, InlineSessionPatch, NormalizedCheckoutSession, PaymentResult, TelemetryErrorCode, TelemetryFailureCategory, TelemetryProvider, TelemetryRequestCategory, TelemetryStatusClass, TokenizedBody } from '@flopay/shared';
|
|
3
|
+
import { FloPayError } from '@flopay/shared';
|
|
4
|
+
export interface CheckoutMountFailureResolution {
|
|
5
|
+
errorCode: TelemetryErrorCode;
|
|
6
|
+
stage: 'checkout_mount' | 'provider_load' | 'session_read';
|
|
7
|
+
failureCategory?: TelemetryFailureCategory;
|
|
8
|
+
provider?: TelemetryProvider;
|
|
9
|
+
requestCategory?: TelemetryRequestCategory;
|
|
10
|
+
statusClass?: TelemetryStatusClass;
|
|
11
|
+
}
|
|
12
|
+
export interface CheckoutProviderFailureTelemetry {
|
|
13
|
+
errorCode: 'PROVIDER_LOAD_FAILED';
|
|
14
|
+
stage: 'provider_load';
|
|
15
|
+
failureCategory: 'invalid_response' | 'provider_runtime';
|
|
16
|
+
provider: 'stripe';
|
|
17
|
+
requestCategory: 'provider_sdk';
|
|
18
|
+
}
|
|
19
|
+
/** Resolve the fixed Stripe provider-load tuple without inspecting free-form data. */
|
|
20
|
+
export declare function resolveCheckoutProviderFailureTelemetry(error: unknown): CheckoutProviderFailureTelemetry;
|
|
21
|
+
export declare function checkoutInitializationError(): FloPayError;
|
|
22
|
+
export { canRecoverHostedCardForm, hasServerSideCardGateway } from '@flopay/shared';
|
|
23
|
+
export declare function canRenderWithoutStripe(unified: NormalizedCheckoutSession | null, showPayPal: boolean, showStripe: boolean): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Classify an existing-session mount failure only from SDK-owned control-flow
|
|
26
|
+
* state and closed error discriminants. Free-form messages are never inspected
|
|
27
|
+
* or forwarded. UI fallback decisions remain separate so this helper only
|
|
28
|
+
* carries telemetry fields into the reporter.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveCheckoutMountFailure(error: unknown, sessionReadCompleted: boolean): CheckoutMountFailureResolution | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Single-flight buyer-only claim for a still-anonymous checkout session.
|
|
33
|
+
* Resolves with the identified session once `PATCH /claim` lands; every call
|
|
34
|
+
* after the first returns the same promise (a claim cannot change the bound
|
|
35
|
+
* buyer, so re-firing would only desync it from the submit-time snapshot).
|
|
36
|
+
*/
|
|
37
|
+
export type BuyerClaim = (account?: Partial<NonNullable<InlineSessionPatch['account']>>) => Promise<NormalizedCheckoutSession>;
|
|
38
|
+
/**
|
|
39
|
+
* Build the single-flight buyer-only claim for an anonymous session that has
|
|
40
|
+
* no detached-create closure to hand: a session restored from sessionStorage
|
|
41
|
+
* after a remount, a one-shot (`deferDataAttachment: false`) create without an
|
|
42
|
+
* email, an existing session loaded by `sessionId` + `nonce` that the billing
|
|
43
|
+
* API returned as `buyerIdentified: false`, or a standalone `SplitCardForm`
|
|
44
|
+
* composed by the merchant. Everything the replay-safe backend operation needs
|
|
45
|
+
* is still available — session id, nonce, and whatever account draft the
|
|
46
|
+
* merchant supplied (none for a session loaded by id).
|
|
47
|
+
*
|
|
48
|
+
* Without this closure the card form's collected email never reaches
|
|
49
|
+
* `PATCH /claim`, only the best-effort submit-time `PATCH /account` snapshot —
|
|
50
|
+
* which writes the email but does not bind a buyer, so the hosted vault charge
|
|
51
|
+
* is refused server-side and the widget times out waiting for an outcome.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createBuyerClaim(api: Pick<PaymentAPI, 'claimCheckoutSession'>, sessionId: string, nonce: string, baseAccount?: Partial<InlineSessionDraft['account']>): BuyerClaim;
|
|
54
|
+
export declare function mergeInlineSessionPatches(base: InlineSessionPatch | undefined, patch: InlineSessionPatch | undefined): InlineSessionPatch | undefined;
|
|
55
|
+
export declare function mergeInlineSessionPatch(params: InlineSessionDraft, patch: InlineSessionPatch | undefined): InlineSessionDraft;
|
|
56
|
+
export declare function buildSyntheticSession(params: InlineSessionDraft, checkoutModeOverride?: CheckoutMode): CheckoutSession;
|
|
57
|
+
export { splitFullName } from '@flopay/shared';
|
|
58
|
+
export declare function mergeAccountPatch<T extends {
|
|
59
|
+
userId?: string;
|
|
60
|
+
email?: string;
|
|
61
|
+
firstName?: string;
|
|
62
|
+
lastName?: string;
|
|
63
|
+
country?: string | null;
|
|
64
|
+
zip?: string | null;
|
|
65
|
+
}>(base: T, patch: Partial<CheckoutAccount> | undefined): T;
|
|
66
|
+
export declare function buildDeclineEvent(method: CheckoutButtonMethod, input: string | FloPayError, overrides?: {
|
|
67
|
+
code?: string;
|
|
68
|
+
declineCode?: string;
|
|
69
|
+
}): DeclineEvent;
|
|
70
|
+
/**
|
|
71
|
+
* Record which checkout session a failure belongs to (sdk#396), so the error
|
|
72
|
+
* and any decline event built from it carry the id. Returns the same error;
|
|
73
|
+
* an empty id or one already set is left alone. Never pass the session nonce.
|
|
74
|
+
*/
|
|
75
|
+
export declare function withCheckoutSessionId<T extends FloPayError>(error: T, sessionId: string | null | undefined): T;
|
|
76
|
+
export { applyFriendlyMessageOverride } from '@flopay/shared';
|
|
77
|
+
/** Build the merchant-facing terminal result from a completed checkout session. */
|
|
78
|
+
export declare function buildAuthorizedOrSucceededResult(session: Pick<CheckoutSession, 'status' | 'id' | 'paymentId' | 'authorizationExpiresAt'>, fallbackSessionId?: string | null): PaymentResult;
|
|
79
|
+
/** Whether the checkout reached a buyer-success terminal state. */
|
|
80
|
+
export declare function isCheckoutSessionTerminalSuccess(session: CheckoutSession | null | undefined): session is CheckoutSession & {
|
|
81
|
+
status: 'authorized' | 'complete';
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Reconcile a status-only hard-cap outcome with the complete session a React flow already holds.
|
|
85
|
+
* The status endpoint omits amount and currency, so those fields must come from the prior session
|
|
86
|
+
* rather than placeholder values in a public merchant callback.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveCheckoutCompletionSession(completion: NormalizedCheckoutSession, priorSession: CheckoutSession): CheckoutSession | undefined;
|
|
89
|
+
/** Preserve the public error contract for an expired checkout session. */
|
|
90
|
+
export declare function createExpiredCheckoutSessionError(session: CheckoutSession): FloPayError;
|
|
91
|
+
/** Read a `code` off a thrown value: FloPayError's own, or a plain `{ code }` shape. */
|
|
92
|
+
export declare function readErrorCode(err: unknown): string | undefined;
|
|
93
|
+
/** Preserve the public error contract when automatic checkout polling does not succeed. */
|
|
94
|
+
export declare function createAutomaticPaymentSessionError(session: CheckoutSession | null | undefined): FloPayError;
|
|
95
|
+
/**
|
|
96
|
+
* The Stripe PaymentIntent statuses the checkout can advance from.
|
|
97
|
+
* `requires_capture` remains accepted for legacy automatic/PayPal sessions,
|
|
98
|
+
* but is not a settled payment for an explicit manual-capture session.
|
|
99
|
+
*/
|
|
100
|
+
export declare function isSuccessfulPaymentIntentStatus(status: string | null | undefined, captureMethod?: CaptureMethod): boolean;
|
|
101
|
+
export declare function mapPayPalIntentStatusToPaymentResult(status: string | null | undefined): PaymentResult['status'];
|
|
102
|
+
export type StripePaymentIntentLike = {
|
|
103
|
+
id?: string;
|
|
104
|
+
status?: string;
|
|
105
|
+
payment_method?: string | {
|
|
106
|
+
id?: string | null;
|
|
107
|
+
} | null;
|
|
108
|
+
};
|
|
109
|
+
export declare function retrievePaymentIntentFromProvider(provider: unknown, clientSecret: string): Promise<StripePaymentIntentLike | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Deferred Stripe Elements mode for the wallet / Express Checkout row
|
|
112
|
+
* (Apple Pay, Google Pay).
|
|
113
|
+
*
|
|
114
|
+
* The mode, amount and capture method come from the shared
|
|
115
|
+
* {@link resolveWalletModeOptions} (setup mode for a $0-today cart, so the
|
|
116
|
+
* wallet sheet never shows a placeholder charge), which `@flopay/vue` uses too.
|
|
117
|
+
*
|
|
118
|
+
* The usage comes from {@link resolveSetupFutureUsage} (future use is platform
|
|
119
|
+
* policy): the read's `futureUse` when it carries one, none when Apple Pay or
|
|
120
|
+
* Google Pay is listed in `futureUseUnsupported`, and the historic
|
|
121
|
+
* `off_session` on a legacy read.
|
|
122
|
+
*
|
|
123
|
+
* @param amountInMinorUnits cart total due today, in the smallest currency unit.
|
|
124
|
+
* @param captureMethod capture contract used by the subsequently created intent.
|
|
125
|
+
* @param session the session read's future-use fields.
|
|
126
|
+
*/
|
|
127
|
+
export declare function resolveWalletElementsMode(amountInMinorUnits: number | undefined, captureMethod?: CaptureMethod, session?: FutureUseSessionFields | null): {
|
|
128
|
+
mode: 'setup';
|
|
129
|
+
paymentMethodTypes: ['card'];
|
|
130
|
+
setupFutureUsage?: CardSetupFutureUse;
|
|
131
|
+
} | {
|
|
132
|
+
mode: 'payment';
|
|
133
|
+
amount: number;
|
|
134
|
+
captureMethod: 'automatic_async' | 'manual';
|
|
135
|
+
paymentMethodTypes: ['card'];
|
|
136
|
+
setupFutureUsage?: CardSetupFutureUse;
|
|
137
|
+
};
|
|
138
|
+
/** Bounded cause of a wallet confirmation the provider rejected as invalid. */
|
|
139
|
+
type WalletConfirmationRejectionReason = 'deferred_contract_mismatch' | 'intent_unexpected_state' | 'invalid_request';
|
|
140
|
+
export type WalletConfirmationRejection = {
|
|
141
|
+
errorCode: 'CONFIGURATION_INVALID';
|
|
142
|
+
failureCategory: 'invalid_response';
|
|
143
|
+
reason: WalletConfirmationRejectionReason;
|
|
144
|
+
} | {
|
|
145
|
+
errorCode: 'PROVIDER_RUNTIME_FAILED';
|
|
146
|
+
failureCategory: 'provider_runtime';
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Reduce a rejected Stripe confirmation to Flo's closed telemetry taxonomy.
|
|
150
|
+
* Provider strings are inspected only for an allowlisted classification and
|
|
151
|
+
* are never forwarded to telemetry.
|
|
152
|
+
*
|
|
153
|
+
* Invalid confirmations carry a bounded `reason`, in precedence order:
|
|
154
|
+
* - `deferred_contract_mismatch`: the deferred Elements options disagree with
|
|
155
|
+
* the intent (Stripe.js `IntegrationError` or `elements_intent_mismatch`).
|
|
156
|
+
* - `intent_unexpected_state`: the intent was already confirmed, cancelled or
|
|
157
|
+
* changed when confirmation landed.
|
|
158
|
+
* - `invalid_request`: any other `invalid_request_error`.
|
|
159
|
+
*
|
|
160
|
+
* Runtime failures stay reason-less.
|
|
161
|
+
*/
|
|
162
|
+
export declare function classifyWalletConfirmationRejection(error: unknown): WalletConfirmationRejection;
|
|
163
|
+
export declare function resolveTokenizedPaymentMethodId(tokenizedBody: TokenizedBody | null | undefined): string | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FloPay } from '@flopay/js';
|
|
2
|
+
import type { CheckoutMode, CheckoutSession, FloPayError, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
|
|
3
|
+
import type { EmitFloInstrument } from './instruments.js';
|
|
4
|
+
/** Internal context value for the FloPay provider. */
|
|
5
|
+
export interface FloPayContextValue {
|
|
6
|
+
flopay: FloPay | null;
|
|
7
|
+
/**
|
|
8
|
+
* Stripe FloPay instance used for the Stripe-rendered PayPal fallback. When
|
|
9
|
+
* direct PayPal (`gateways.paypal`) is configured this isn't used for
|
|
10
|
+
* rendering — DirectPayPalButton talks to PayPal directly — but the
|
|
11
|
+
* Stripe-PayPal saved-PM redirect leg still relies on it.
|
|
12
|
+
* `null` or absent means the Stripe-rendered PayPal fallback is unavailable.
|
|
13
|
+
*/
|
|
14
|
+
paypalFlopay?: FloPay | null;
|
|
15
|
+
billingApiUrl: string;
|
|
16
|
+
/** Emit the privacy-safe merchant instrument projection. */
|
|
17
|
+
emitInstrument?: EmitFloInstrument;
|
|
18
|
+
}
|
|
19
|
+
/** Internal context value for checkout state. */
|
|
20
|
+
export interface CheckoutContextValue {
|
|
21
|
+
session: CheckoutSession | null;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
error: FloPayError | null;
|
|
24
|
+
checkoutMode?: CheckoutMode;
|
|
25
|
+
inlineSessionDraft?: InlineSessionDraft;
|
|
26
|
+
applyInlineSessionPatch?: (patch: InlineSessionPatch) => Promise<{
|
|
27
|
+
sessionId: string;
|
|
28
|
+
session: CheckoutSession | null;
|
|
29
|
+
}>;
|
|
30
|
+
inlineSessionPatchProcessing?: boolean;
|
|
31
|
+
/** True while catalog data is being attached to a detached shell. */
|
|
32
|
+
claimPending?: boolean;
|
|
33
|
+
/** @deprecated Catalog attachment no longer waits for buyer identity; always false/absent. */
|
|
34
|
+
claimRequiresIdentity?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Attach late buyer identity to a still-anonymous session
|
|
37
|
+
* (`buyerIdentified: false`) via `PATCH /claim`. A no-op once the session is
|
|
38
|
+
* identified. `SplitCardForm` falls back to this when the merchant composes
|
|
39
|
+
* it as a custom-layout child without wiring `onBuyerIdentityReady`.
|
|
40
|
+
*/
|
|
41
|
+
claimBuyerIdentity?: (identity: NonNullable<InlineSessionPatch['account']>) => Promise<void>;
|
|
42
|
+
/** Resolves once the detached shell has its cart/catalog attached and is safe to charge. */
|
|
43
|
+
waitForDataAttachment?: () => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export declare const FloPayContext: import("react").Context<FloPayContextValue>;
|
|
46
|
+
export declare const CheckoutContext: import("react").Context<CheckoutContextValue>;
|