@flopay/shared 1.14.4 → 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 (49) hide show
  1. package/dist/before-button-click.d.ts +11 -0
  2. package/dist/card-setup-overlay-theme.d.ts +34 -0
  3. package/dist/card-setup-surface.d.ts +24 -0
  4. package/dist/card-setup-theme.d.ts +62 -0
  5. package/dist/card-setup.d.ts +7 -0
  6. package/dist/checkout-gateway-rules.d.ts +50 -0
  7. package/dist/checkout-outcomes.d.ts +14 -0
  8. package/dist/checkout-payload.d.ts +86 -0
  9. package/dist/checkout-process-request.d.ts +57 -0
  10. package/dist/config.d.ts +29 -0
  11. package/dist/constants.d.ts +452 -0
  12. package/dist/display.d.ts +64 -0
  13. package/dist/email-validation.d.ts +2 -0
  14. package/dist/errors.d.ts +53 -0
  15. package/dist/external-method-recovery.d.ts +24 -0
  16. package/dist/friendly-message.d.ts +5 -0
  17. package/dist/future-use.d.ts +24 -0
  18. package/dist/idempotency.d.ts +55 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.ts +67 -3739
  21. package/dist/index.mjs +1 -1
  22. package/dist/inline-session-cache.d.ts +20 -0
  23. package/dist/instrument-dispatch.d.ts +28 -0
  24. package/dist/instruments.d.ts +51 -0
  25. package/dist/payment-logos.generated.d.ts +1 -0
  26. package/dist/payment-method-setup-advertisement.d.ts +67 -0
  27. package/dist/paypal-buyer-identity.d.ts +46 -0
  28. package/dist/paypal-channel.d.ts +77 -0
  29. package/dist/paypal-environment.d.ts +14 -0
  30. package/dist/postal-code-lookup.d.ts +19 -0
  31. package/dist/postal-code-validation.d.ts +46 -0
  32. package/dist/primary-tile-style.d.ts +46 -0
  33. package/dist/recent-completion.d.ts +2 -0
  34. package/dist/saved-payment-methods.d.ts +96 -0
  35. package/dist/sentry-filter.d.ts +21 -0
  36. package/dist/stripe-appearance.d.ts +19 -0
  37. package/dist/stripe-paypal-presentation.d.ts +42 -0
  38. package/dist/telemetry-failure.d.ts +14 -0
  39. package/dist/telemetry.d.ts +161 -0
  40. package/dist/types.d.ts +1747 -0
  41. package/dist/uuid.d.ts +19 -0
  42. package/dist/validation.d.ts +19 -0
  43. package/dist/vault-submit-theme.d.ts +22 -0
  44. package/dist/vault-theme.d.ts +28 -0
  45. package/dist/vault-verification.d.ts +45 -0
  46. package/dist/wallet-elements-mode.d.ts +27 -0
  47. package/dist/wallet-sheet-window.d.ts +44 -0
  48. package/package.json +4 -3
  49. package/dist/index.d.cts +0 -3739
@@ -0,0 +1,67 @@
1
+ import type { NormalizedCheckoutSession } from './types.js';
2
+ /** One advertised Stripe wallet/APM, with the account the backend chose for it. */
3
+ interface StripeSetupAdvertisement {
4
+ /** The Stripe payment method type (`apple_pay`, `sepa_debit`, ...). */
5
+ method: string;
6
+ /** This entry's own publishable key: the backend can pick an account per method. */
7
+ publishableKey: string;
8
+ /** The setup session's own currency, from the read. Never guessed. */
9
+ currency: string;
10
+ }
11
+ /** Direct PayPal vault flow a setup session advertises. */
12
+ interface PayPalSetupAdvertisement {
13
+ clientId: string;
14
+ environment?: string;
15
+ }
16
+ /**
17
+ * The methods a setup session advertises. The SDK renders exactly these: no
18
+ * gateway selection, filtering or inference happens on the client.
19
+ */
20
+ export interface PaymentMethodSetupAdvertisement {
21
+ /** The hosted vault card widget (a `card` entry, or no advertisement at all). */
22
+ card: boolean;
23
+ /** Stripe wallets/APMs in advertised order. */
24
+ stripe: StripeSetupAdvertisement[];
25
+ paypal: PayPalSetupAdvertisement | null;
26
+ /** The setup session's own currency from the read, or `null` when it carries none. */
27
+ currency: string | null;
28
+ /**
29
+ * Stripe wallets/APMs the session advertises that are not rendered only
30
+ * because the read carries no currency, so a session that offers nothing
31
+ * else can say why instead of claiming it advertises nothing.
32
+ */
33
+ skippedForMissingCurrency: string[];
34
+ }
35
+ /**
36
+ * Read the advertisement from a normalized setup session. Only the session's
37
+ * `advertisedPaymentMethods` decides it (backend docs/card-setup.md,
38
+ * "Advertised payment methods"); the purchase-checkout gateway block is never
39
+ * read, since it lists nothing on a setup session.
40
+ *
41
+ * - Field absent (an older backend): the card only, exactly as `FloPayCardSetup`.
42
+ * - `family: "card"`: the hosted vault card widget.
43
+ * - `family: "wallet"` / `"apm"` with `providerType: "stripe"`: that Stripe
44
+ * method, with the entry's own publishable key. Skipped when the read carries
45
+ * no currency, and listed in `skippedForMissingCurrency`.
46
+ * - `family: "paypal"` (`paypal_vaulted`): the PayPal vault flow, with the
47
+ * entry's key as the client id and its environment. It owns `paypal`, so a
48
+ * Stripe-rendered `paypal` entry is not drawn a second time.
49
+ * - Anything else is skipped, never thrown on. The first entry for a
50
+ * `paymentMethodType` wins.
51
+ */
52
+ export declare function readSetupAdvertisement(normalized: NormalizedCheckoutSession): PaymentMethodSetupAdvertisement;
53
+ /** The marker of every method the advertisement renders, card first. */
54
+ export declare function advertisedMethodKeys(advertisement: PaymentMethodSetupAdvertisement): string[];
55
+ /** Whether the advertisement offers anything to render. */
56
+ export declare function advertisesAnyMethod(advertisement: PaymentMethodSetupAdvertisement): boolean;
57
+ /** The session-intent category for an advertised Stripe method. */
58
+ export declare function stripeMethodCategory(method: string): 'wallet' | 'apm';
59
+ /** Which wording the outcome overlay uses: card wording only for the card widget. */
60
+ export type SetupOverlayWording = 'card' | 'payment_method';
61
+ /** Processing / success / failure overlay labels for a setup outcome. */
62
+ export declare function setupOverlayLabels(wording: SetupOverlayWording): {
63
+ processingLabel: string;
64
+ successLabel: string;
65
+ errorLabel: string;
66
+ };
67
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { CheckoutSession, InlineSessionPatch, PayPalBrowserEnvironment, PayPalProviderObjectType, TelemetryPresentationMode } from './index.js';
2
+ /**
3
+ * The buyer identity an express surface attaches to the checkout: the
4
+ * session-patch `account` shape (email and names, plus any other account
5
+ * fields the click-time patch carried).
6
+ */
7
+ export type PayPalBuyerIdentity = NonNullable<InlineSessionPatch['account']>;
8
+ /**
9
+ * Trims the names and drops empty ones. Express continuations use empty name
10
+ * markers to clear hydrated fallbacks through JSON checkpoints
11
+ * (`preserveMissingNames`); the final process payload strips them again.
12
+ */
13
+ export declare function compactBuyerIdentity(identity: PayPalBuyerIdentity, preserveMissingNames?: boolean): PayPalBuyerIdentity;
14
+ /** Splits a full name at the first whitespace run; a card-holder placeholder is no name. */
15
+ export declare function splitFullName(name: string | null | undefined): {
16
+ firstName?: string;
17
+ lastName?: string;
18
+ };
19
+ /** The payer PayPal reports for an approved order (`actions.order.get()`). */
20
+ export declare function readPayPalPayerIdentity(details: unknown): PayPalBuyerIdentity;
21
+ /**
22
+ * The buyer identity a PayPal approval starts from: the click-time account
23
+ * patch wins, then the host's `email` and `billingName`, then the session's
24
+ * customer.
25
+ */
26
+ export declare function resolvePayPalApprovalIdentity(input: {
27
+ accountPatch?: InlineSessionPatch['account'] | null;
28
+ email?: string | null;
29
+ billingName?: string | null;
30
+ session?: CheckoutSession | null;
31
+ }): PayPalBuyerIdentity;
32
+ /** Whether the approval still lacks a valid email or any name, so PayPal's payer is read. */
33
+ export declare function needsPayPalPayerDetails(identity: PayPalBuyerIdentity): boolean;
34
+ /** Fills the approval identity's gaps from PayPal's order details; PayPal's payer wins per field. */
35
+ export declare function mergePayPalPayerIdentity(identity: PayPalBuyerIdentity, details: unknown): PayPalBuyerIdentity;
36
+ /**
37
+ * Whether a PayPal approval must collect the buyer's email itself: no valid
38
+ * email is known from the host or the session.
39
+ */
40
+ export declare function paypalProviderIdentityRequired(email: string | null | undefined, session: CheckoutSession | null | undefined): boolean;
41
+ /**
42
+ * Chooses a PayPal presentation without ever hiding PayPal. Deterministic
43
+ * non-popup modes are limited to one-time Orders in an in-app browser and
44
+ * require the backend's advertisement.
45
+ */
46
+ export declare function resolvePayPalPresentationMode(environment: PayPalBrowserEnvironment, advertisedCapability: TelemetryPresentationMode | undefined, providerObjectType: PayPalProviderObjectType): TelemetryPresentationMode;
@@ -0,0 +1,77 @@
1
+ import type { CheckoutSession, FloPayPaymentCancelEvent, InlineSessionPatch, PayPalProviderObjectType, PayPalSessionIntentRequest, ProcessPaymentParams, TokenizedBody } from './types.js';
2
+ /**
3
+ * Whether the configured PayPal object rides the Flo-owned `paypal_vaulted`
4
+ * channel. An explicitly configured `order` or `setup_token` (the session's
5
+ * advertisement, or the deprecated prop as a fallback) does. A legacy session
6
+ * with neither, and an advertised provider-managed `subscription`, keep the
7
+ * released `paypal` requests byte-identical.
8
+ */
9
+ export declare function usesPayPalVaultedChannel(configuredObjectType: PayPalProviderObjectType | undefined): boolean;
10
+ /**
11
+ * The `/intents` request body for a direct PayPal button. The payment-method
12
+ * type is the in-band channel selector: the Flo-owned channel asks for
13
+ * `paypal_vaulted` (with `intentKind: 'setup'` for a vault setup token); the
14
+ * legacy channel asks for `paypal` with `intentKind: 'payment'`.
15
+ */
16
+ export declare function buildPayPalSessionIntentRequest(configuredObjectType: PayPalProviderObjectType | undefined): PayPalSessionIntentRequest;
17
+ /**
18
+ * The tokenized body for PayPal's approval token. A vault setup token and an
19
+ * advertised order carry the Flo-owned channel so the backend can continue on
20
+ * it; the legacy fallback keeps the released body byte-identical.
21
+ */
22
+ export declare function buildPayPalTokenizedBody(token: string, configuredObjectType: PayPalProviderObjectType | undefined): TokenizedBody;
23
+ /**
24
+ * The merchant-facing event for a buyer who closed or left PayPal without
25
+ * approving. The session is the attempt's (the click-time patch's, else the
26
+ * button's) and the payment-method type follows the same channel rule as the
27
+ * attempt's `/intents` request.
28
+ */
29
+ export declare function buildPayPalCancelEvent(sessionId: string, configuredObjectType: PayPalProviderObjectType | undefined): FloPayPaymentCancelEvent;
30
+ /** What a direct PayPal button knows when it completes an approval itself. */
31
+ export interface PayPalProcessPaymentInput {
32
+ /** The approval's tokenized body ({@link buildPayPalTokenizedBody}). */
33
+ body: TokenizedBody;
34
+ /** The session the attempt runs on (the click-time patch's, else the button's). */
35
+ sessionId: string;
36
+ /** The checkout session token for the attempt. */
37
+ nonce: string | undefined;
38
+ /** The click-time account patch from `runBeforeButtonClick`. */
39
+ accountPatch?: InlineSessionPatch['account'];
40
+ /** The checkout session, for the buyer's identity and address. */
41
+ session?: CheckoutSession | null;
42
+ /** The button's `email` prop. */
43
+ email?: string;
44
+ }
45
+ /**
46
+ * The `/process` call a direct PayPal button makes when no host takes the
47
+ * tokenized body: the click-time account patch wins, then the session's
48
+ * customer, then its account data. Returns the (vestigial) user id argument
49
+ * and the request, in the field order the released button sends.
50
+ */
51
+ export declare function buildPayPalProcessPaymentRequest(input: PayPalProcessPaymentInput): {
52
+ userId: string;
53
+ params: ProcessPaymentParams;
54
+ };
55
+ /**
56
+ * The buyer-facing message for a failed PayPal payment: the raw message (or
57
+ * the generic fallback) through the shared friendly-message override.
58
+ */
59
+ export declare function friendlyPayPalFailureMessage(rawMessage: string | undefined): string;
60
+ /** A rejected PayPal `/process` response body, read for the buyer message and the decline codes. */
61
+ export declare function describePayPalProcessFailure(json: Record<string, unknown> | null): {
62
+ message: string;
63
+ code: string | undefined;
64
+ declineCode: string | undefined;
65
+ };
66
+ /**
67
+ * The `providerDeclineReason` a PayPal decline reports to `/intents/decline`:
68
+ * the provider's decline code, then its error code, then the generic reason.
69
+ */
70
+ export declare function resolvePayPalDeclineReason(error: unknown): string;
71
+ /**
72
+ * Zoid (PayPal's iframe framework) reports its own teardown through `onError`:
73
+ * "zoid destroyed all components", a closed window, a removed container. Those
74
+ * are page navigation or unmounting, not payment errors, so no binding shows
75
+ * them to the buyer.
76
+ */
77
+ export declare function isPayPalTeardownMessage(message: string | undefined): boolean;
@@ -0,0 +1,14 @@
1
+ import type { TelemetryAppFamily, TelemetryPopupCapability } from './telemetry.js';
2
+ /** Privacy-bounded browser context shared by PayPal presentation and telemetry. */
3
+ export interface PayPalBrowserEnvironment {
4
+ inAppBrowser: boolean;
5
+ appFamily: TelemetryAppFamily;
6
+ popupCapability: TelemetryPopupCapability;
7
+ }
8
+ /**
9
+ * Classifies an in-app browser without retaining or returning its user agent.
10
+ *
11
+ * Static UA evidence cannot prove that a popup will open, so capability stays
12
+ * `unknown`; runtime lifecycle evidence is reported separately.
13
+ */
14
+ export declare function detectPayPalEnvironment(userAgent?: string): PayPalBrowserEnvironment;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Postal-code → state derivation for AVS.
3
+ *
4
+ * Used when the form configuration shows `address_line_1` but hides the
5
+ * `state` input — we still want to populate `billing_details.address.state`
6
+ * so Stripe Radar gets a richer address signal. Currently supports US and CA;
7
+ * other countries return `null` (caller should fall back to omitting state).
8
+ */
9
+ /**
10
+ * Resolve a state / province code from a postal code for the given country.
11
+ *
12
+ * - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
13
+ * - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
14
+ * - All other countries: `null`.
15
+ *
16
+ * Returns `null` when the postal code is malformed or falls in an unmapped
17
+ * range. Callers should treat `null` as "skip — don't derive".
18
+ */
19
+ export declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ISO 3166-1 alpha-2 → example postcode map, surfaced in the field hint / inline
3
+ * error so the buyer sees the expected shape. Replicated **verbatim** from the
4
+ * backend validator's `POSTAL_CODE_EXAMPLES` (backend#895) so the SDK's own
5
+ * client-side hint shows the *same* example the backend embeds in its 400
6
+ * message ("Expected format: e.g. {example}") — the two can never contradict.
7
+ * Every example is verified against `validator`'s own pattern (see the package
8
+ * tests). A supported country absent from this map still validates — the hint,
9
+ * like the backend message, simply omits the example.
10
+ *
11
+ * Exported (module-level, not via the package barrel) so the drift-guard test
12
+ * can derive its country list from this single source of truth instead of
13
+ * hardcoding a subset that silently falls out of sync as entries are added.
14
+ */
15
+ export declare const POSTAL_CODE_EXAMPLES: Readonly<Record<string, string>>;
16
+ /**
17
+ * True when `validator` has an authoritative postcode pattern for the country
18
+ * (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
19
+ * Supported countries validate the postcode format; unsupported / no-postcode /
20
+ * unresolvable countries fail open. Note the 2-letter passthrough means `UK`
21
+ * (an unsupported `validator` locale) returns `false` here — matching the
22
+ * backend; use the full name `United Kingdom` for `GB` semantics.
23
+ */
24
+ export declare function isPostalCodeSupported(country: string): boolean;
25
+ /**
26
+ * Validate a postcode against the country's expected format. A faithful mirror
27
+ * of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
28
+ * value the server would accept, nor opens the submit gate on one it would
29
+ * reject. Fail-open (returns `true`) in exactly the backend's three cases:
30
+ *
31
+ * - `postalCode` is blank / whitespace-only;
32
+ * - the country can't be normalized to an ISO-2 locale;
33
+ * - the ISO-2 locale isn't one `validator` recognises.
34
+ *
35
+ * Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
36
+ * that distinguish "required" (empty) from "malformed" (bad format) must check
37
+ * emptiness themselves — an empty value fails open here, as it does server-side.
38
+ */
39
+ export declare function isValidPostalCode(country: string, postalCode: string): boolean;
40
+ /**
41
+ * The example postcode the backend would embed in its 400 message for the
42
+ * country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
43
+ * `undefined` when there is none (unresolvable country, or a supported country
44
+ * absent from {@link POSTAL_CODE_EXAMPLES}).
45
+ */
46
+ export declare function getPostalCodeExample(country: string): string | undefined;
@@ -0,0 +1,46 @@
1
+ import type { ThemeBundle } from './types.js';
2
+ /** The submit-button style fields a themed tile copies (any CSS-like record). */
3
+ export interface PrimaryTileSubmitStyle {
4
+ color?: unknown;
5
+ border?: unknown;
6
+ borderRadius?: unknown;
7
+ boxShadow?: unknown;
8
+ }
9
+ /** Inputs for {@link derivePrimaryTileStyle}. */
10
+ export interface PrimaryTileStyleSource {
11
+ themeBundle: ThemeBundle | null | undefined;
12
+ resolvedPrimaryColor: string;
13
+ resolvedBorderRadius: string;
14
+ submitButtonStyle?: PrimaryTileSubmitStyle | undefined;
15
+ /**
16
+ * Raw `appearance.colorPrimary` (undefined when the merchant didn't set one).
17
+ * When present it forces a primary-filled tile even with no theme bundle
18
+ * (the `classic` preset), so an explicit `colorPrimary` override always wins
19
+ * over the historic white tile.
20
+ */
21
+ explicitPrimaryColor?: string | undefined;
22
+ }
23
+ /** The colour and shape of a primary tile. */
24
+ export interface PrimaryTileStyle {
25
+ backgroundColor: string;
26
+ color: string;
27
+ border: string;
28
+ borderRadius: string | number;
29
+ boxShadow?: string | undefined;
30
+ }
31
+ /**
32
+ * Base colours for a primary tile (the buttons-layout card tile and the
33
+ * one-click button):
34
+ *
35
+ * - `'classic'` / no theme: white background, grey border — historic look
36
+ * that lines up with the wallet ECE row's flat tiles.
37
+ * - Any theme bundle (`modern-*`, `bold-*`, `glass-*`): `colorPrimary`
38
+ * (`resolvedPrimaryColor` — already merged with any `appearance` override)
39
+ * drives the `backgroundColor`, exactly like the "Confirm Payment" submit
40
+ * CTA, so all three flo buttons (submit, card, auto-pay) share one fill and
41
+ * a per-checkout `colorPrimary` override re-skins every one of them. The
42
+ * bundle's `submitButton` still supplies `color` / `border` / `borderRadius`
43
+ * / `boxShadow` so typography + shape stay on-theme. Hover (`colorPrimaryHover`)
44
+ * is applied by each button's mouse-enter / mouse-leave at the call site.
45
+ */
46
+ export declare function derivePrimaryTileStyle(opts: PrimaryTileStyleSource): PrimaryTileStyle;
@@ -0,0 +1,2 @@
1
+ export declare function markSessionRecentlyCompleted(sessionId: string | null | undefined): void;
2
+ export declare function wasSessionRecentlyCompleted(sessionId: string | null | undefined): boolean;
@@ -0,0 +1,96 @@
1
+ import type { CheckoutSession, SavedCardDisplay, SavedPaymentMethodStatus } from './types.js';
2
+ /**
3
+ * The family a saved payment method belongs to: the same grouping as
4
+ * {@link AdvertisedPaymentMethod.family}. It discriminates {@link SavedPaymentMethodDisplay} by
5
+ * `type`. The billing API's list request takes a method type instead, typed as
6
+ * {@link SavedPaymentMethodListType}.
7
+ */
8
+ export type SavedPaymentMethodFamily = 'card' | 'wallet' | 'paypal' | 'apm';
9
+ /**
10
+ * Every {@link SavedPaymentMethodFamily}, for exhaustive handling and grouping.
11
+ * A plain readonly literal like the other shared constants: a module-scope `Object.freeze` call
12
+ * cannot be tree-shaken, so every checkout bundle would carry it.
13
+ */
14
+ export declare const SAVED_PAYMENT_METHOD_FAMILIES: readonly SavedPaymentMethodFamily[];
15
+ /**
16
+ * The family a saved payment method belongs to.
17
+ * @deprecated Use {@link SavedPaymentMethodFamily}, the same type. For the list request's `type`,
18
+ * use {@link SavedPaymentMethodListType}: the billing API does not accept `wallet` or `apm` there.
19
+ */
20
+ export type SavedPaymentMethodType = SavedPaymentMethodFamily;
21
+ /**
22
+ * Every saved payment method family, the same values in the same order as
23
+ * {@link SAVED_PAYMENT_METHOD_FAMILIES}. Its own plain readonly literal, so it tree-shakes too.
24
+ * @deprecated Use {@link SAVED_PAYMENT_METHOD_FAMILIES}. For the list request's `type`, use
25
+ * {@link SAVED_PAYMENT_METHOD_LIST_TYPES}.
26
+ */
27
+ export declare const SAVED_PAYMENT_METHOD_TYPES: readonly SavedPaymentMethodType[];
28
+ /**
29
+ * A method type the billing API's saved payment method list (`GET /v1/payment-methods`) accepts as
30
+ * its `type` filter: `card`, `paypal`, or a saved wallet or APM method type. It is a method type,
31
+ * never a family, so `wallet` and `apm` are not values; nor is the setup flow's `paypal_vaulted`.
32
+ */
33
+ export type SavedPaymentMethodListType = 'card' | 'paypal' | 'apple_pay' | 'google_pay' | 'sepa_debit' | 'us_bank_account';
34
+ /**
35
+ * Every {@link SavedPaymentMethodListType}: exactly the values the billing API accepts for the list
36
+ * `type` filter. A plain readonly literal that tree-shakes, like {@link SAVED_PAYMENT_METHOD_FAMILIES}.
37
+ */
38
+ export declare const SAVED_PAYMENT_METHOD_LIST_TYPES: readonly SavedPaymentMethodListType[];
39
+ /** Saved card in the generalised display type; `type` stays optional for card-only consumers. */
40
+ export interface SavedCardPaymentMethodDisplay extends SavedCardDisplay {
41
+ type?: 'card';
42
+ /** The row's method type as the billing API returns it: always `card` for a card. */
43
+ methodType?: 'card';
44
+ label?: string;
45
+ /** The billing API's display label for the row; `null` for a card, so build one from `brand`. */
46
+ displayLabel?: string | null;
47
+ }
48
+ /** Saved non-card method: only safe, display-only label fields. */
49
+ export interface SavedOtherPaymentMethodDisplay {
50
+ id: string;
51
+ /** The method's family, for grouping. */
52
+ type: 'wallet' | 'paypal' | 'apm';
53
+ /**
54
+ * The row's method type as the billing API returns it, such as `apple_pay`, `google_pay`,
55
+ * `sepa_debit`, `us_bank_account` or `paypal`. It tells methods of one family apart. An open
56
+ * string: a newer billing API may return a type this SDK does not name yet.
57
+ */
58
+ methodType?: string;
59
+ /** @deprecated Use {@link SavedOtherPaymentMethodDisplay.displayLabel}, which holds the same value. */
60
+ label: string;
61
+ /** The billing API's safe display label for the row. */
62
+ displayLabel?: string;
63
+ status: SavedPaymentMethodStatus;
64
+ }
65
+ /** Display-only saved payment method of any type. */
66
+ export type SavedPaymentMethodDisplay = SavedCardPaymentMethodDisplay | SavedOtherPaymentMethodDisplay;
67
+ /** Optional filter for listing saved payment methods. */
68
+ export interface ListSavedPaymentMethodsQuery {
69
+ /** List only methods of this method type. Leave it out to list every saved method. */
70
+ type?: SavedPaymentMethodListType;
71
+ }
72
+ /**
73
+ * Whether a read session is a no-charge setup session, whatever methods it advertises.
74
+ * Only the explicit setup mode, a zero amount and an empty cart decide it: the billing API
75
+ * alone chooses which methods (and gateways) a setup session offers, so
76
+ * `advertisedPaymentMethods` is never consulted here.
77
+ */
78
+ export declare function isSetupCheckoutSession(session: CheckoutSession): boolean;
79
+ /**
80
+ * One payment method a setup session advertises, exactly as the billing API sends it
81
+ * (backend docs/card-setup.md, "Advertised payment methods"). The values are open:
82
+ * a client skips a `family` or `paymentMethodType` it does not know.
83
+ */
84
+ export interface AdvertisedPaymentMethod {
85
+ /** `card`, `wallet`, `apm` or `paypal` today. */
86
+ family: string;
87
+ /** The method itself: `card`, `apple_pay`, `sepa_debit`, `paypal_vaulted`, ... */
88
+ paymentMethodType: string;
89
+ /** The gateway the backend chose for this method. */
90
+ gatewayId: string;
91
+ /** That gateway's provider: `stripe` or `paypal` today. */
92
+ providerType: string;
93
+ /** This method's own publishable key (the client id for PayPal). */
94
+ publishableKey: string;
95
+ environment: string;
96
+ }
@@ -0,0 +1,21 @@
1
+ export interface SentryStackFrameLike {
2
+ in_app?: boolean;
3
+ filename?: string;
4
+ abs_path?: string;
5
+ module?: string;
6
+ }
7
+ export interface SentryEventLike {
8
+ exception?: {
9
+ values?: Array<{
10
+ stacktrace?: {
11
+ frames?: SentryStackFrameLike[];
12
+ };
13
+ }>;
14
+ };
15
+ }
16
+ /**
17
+ * Drops errors whose complete exception stack contains recognized hosted
18
+ * third-party code and no resolvable first-party frame. All other events are
19
+ * returned by identity.
20
+ */
21
+ export declare function dropThirdPartyOnlyError<T extends SentryEventLike>(event: T): T | null;
@@ -0,0 +1,19 @@
1
+ import type { FloPayAppearance, FloPayThemeVariables } from './types.js';
2
+ /**
3
+ * A `FloPayAppearance` whose `theme` has been normalized to the set Stripe's
4
+ * Appearance API accepts, so it can be handed straight to Stripe Elements
5
+ * without tripping Stripe.js's `Invalid value … provided to "theme"` warning.
6
+ */
7
+ export interface StripeSafeAppearance {
8
+ theme: 'stripe' | 'night' | 'flat';
9
+ variables?: FloPayThemeVariables;
10
+ rules?: Record<string, Record<string, string>>;
11
+ }
12
+ /** Maps FloPay's public appearance token to Stripe's accepted theme set. */
13
+ export declare function toStripeAppearanceTheme(theme: 'default' | 'flat' | 'night' | 'none' | undefined): 'stripe' | 'night' | 'flat';
14
+ /**
15
+ * Normalizes a FloPay appearance before a UI binding passes it to Stripe
16
+ * Elements. Lives here, free of Stripe.js, so the Stripe-free entries and
17
+ * every UI binding share one mapping (TeamFloPay/sdk#410, CTO decision 1).
18
+ */
19
+ export declare function toStripeAppearance(appearance: FloPayAppearance): StripeSafeAppearance;
@@ -0,0 +1,42 @@
1
+ import type { PayPalBrowserEnvironment, TelemetryPopupCapability, WalletPresentation } from './index.js';
2
+ /**
3
+ * Selects the safe Stripe-routed PayPal surface for the active checkout mount
4
+ * from the merchant's `walletPresentation` preference. An in-app browser, a
5
+ * pop-up the browser blocked, or `prefer_redirect` gives the full-page
6
+ * redirect; anything else keeps the pop-up. Moved from @flopay/react's
7
+ * `in-app-browser.ts` so @flopay/vue resolves `walletPresentation` the same way.
8
+ */
9
+ export declare function resolveStripePayPalPresentation(environment: PayPalBrowserEnvironment, preference: WalletPresentation, popupCapability?: TelemetryPopupCapability): 'popup' | 'redirect';
10
+ /**
11
+ * Storage key carrying the effective session / nonce / account patch across a
12
+ * Stripe-routed PayPal redirect, so the return can `/process` against the same
13
+ * session PayPal authorized (an inline-session bootstrap inside the click gate
14
+ * would otherwise be lost when the page reloads after the PayPal round-trip).
15
+ */
16
+ export declare const STRIPE_PAYPAL_RESUME_KEY = "flopay_paypal_resume";
17
+ /** The query parameters Stripe appends to the return URL after a redirect. */
18
+ export declare const STRIPE_REDIRECT_PARAMS: readonly ['payment_intent', 'payment_intent_client_secret', 'redirect_status'];
19
+ export interface StripePayPalResumeContinuation<TAccount = unknown> {
20
+ clientSecret?: string;
21
+ sessionId?: string;
22
+ nonce?: string;
23
+ accountPatch?: TAccount;
24
+ }
25
+ /** `[payment_intent, payment_intent_client_secret, redirect_status]` from the current URL. */
26
+ export declare function readStripeRedirectParams(): [string | null, string | null, string | null];
27
+ /** The current URL without Stripe's redirect parameters (the PayPal `return_url`). */
28
+ export declare function stripeRedirectReturnUrl(): string;
29
+ /**
30
+ * The saved continuation, only when it belongs to `clientSecret`, so a stale
31
+ * payload from a prior attempt can't replay against a different PaymentIntent.
32
+ */
33
+ export declare function readMatchingStripePayPalContinuation<TAccount = unknown>(clientSecret: string | null): StripePayPalResumeContinuation<TAccount> | null;
34
+ /** Whether this page load is the return of a Stripe-routed PayPal redirect this browser started. */
35
+ export declare function hasMatchingStripePayPalReturn(): boolean;
36
+ /**
37
+ * Saves the continuation, or removes it when called without one. Returns
38
+ * whether storage accepted the change (a redirect must not start without it).
39
+ */
40
+ export declare function writeStripePayPalContinuation(continuation?: StripePayPalResumeContinuation): boolean;
41
+ /** Consumes the continuation and strips Stripe's redirect parameters from the URL. */
42
+ export declare function clearStripePayPalReturn(): void;
@@ -0,0 +1,14 @@
1
+ import type { TelemetryErrorCode, TelemetryExpectedOutcome, TelemetryFailureCategory, TelemetryStatusClass } from './telemetry.js';
2
+ export interface ClassifiedTelemetryFailure {
3
+ errorCode: TelemetryErrorCode;
4
+ statusClass: TelemetryStatusClass;
5
+ failureCategory?: TelemetryFailureCategory;
6
+ }
7
+ /**
8
+ * Classify the bounded billing response contract without reading free-form
9
+ * messages, error codes, or provider payloads.
10
+ */
11
+ export declare function classifyPaymentRejection(status: number, payload: unknown): Extract<TelemetryExpectedOutcome, 'payment_declined' | 'validation_rejected'> | undefined;
12
+ /** Classify only SDK-owned error structure; never inspect messages or payloads. */
13
+ export declare function classifyTelemetryFailure(error: unknown, fallbackCode: TelemetryErrorCode, fallbackStatusClass?: TelemetryStatusClass): ClassifiedTelemetryFailure;
14
+ export declare function telemetryStatusClass(status: number | undefined, fallbackStatusClass?: TelemetryStatusClass): TelemetryStatusClass;