@flopay/shared 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +367 -317
- package/dist/index.d.ts +367 -317
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1576,163 +1576,100 @@ interface CountryOption {
|
|
|
1576
1576
|
*/
|
|
1577
1577
|
declare function isCardSetupCheckoutSession(session: CheckoutSession): boolean;
|
|
1578
1578
|
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
module?: string;
|
|
1584
|
-
}
|
|
1585
|
-
interface SentryEventLike {
|
|
1586
|
-
exception?: {
|
|
1587
|
-
values?: Array<{
|
|
1588
|
-
stacktrace?: {
|
|
1589
|
-
frames?: SentryStackFrameLike[];
|
|
1590
|
-
};
|
|
1591
|
-
}>;
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1579
|
+
/** Returns whether a checkout deliberately stops after placing an authorization hold. */
|
|
1580
|
+
declare function isAuthorizationOnlySession(session?: {
|
|
1581
|
+
captureMethod?: CaptureMethod;
|
|
1582
|
+
} | null): boolean;
|
|
1594
1583
|
/**
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1584
|
+
* Returns whether an outcome represents money settled for the active checkout.
|
|
1585
|
+
*
|
|
1586
|
+
* `requires_capture` remains successful for legacy automatic/PayPal flows, but
|
|
1587
|
+
* can never be treated as settled for a manual-capture session.
|
|
1598
1588
|
*/
|
|
1599
|
-
declare function
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
declare const TELEMETRY_SCHEMA_VERSION: 1;
|
|
1603
|
-
declare const TELEMETRY_SDK_PACKAGES: readonly ["@flopay/shared", "@flopay/js", "@flopay/react"];
|
|
1604
|
-
type TelemetrySdkPackage = (typeof TELEMETRY_SDK_PACKAGES)[number];
|
|
1605
|
-
declare const TELEMETRY_MAX_BATCH_BYTES: number;
|
|
1606
|
-
declare const TELEMETRY_MAX_BATCH_EVENTS = 20;
|
|
1607
|
-
type TelemetryEventClass = 'technical_error' | 'lifecycle' | 'expected_outcome' | 'performance';
|
|
1608
|
-
declare const TELEMETRY_PROVIDERS: readonly ["stripe", "paypal"];
|
|
1609
|
-
type TelemetryProvider = (typeof TELEMETRY_PROVIDERS)[number];
|
|
1610
|
-
type TelemetryProviderInput = TelemetryProvider | 'flo' | 'pcivault' | 'other' | 'unknown';
|
|
1611
|
-
declare const TELEMETRY_PAYMENT_METHOD_CATEGORIES: readonly ["card", "wallet", "paypal", "apm", "saved", "unknown"];
|
|
1612
|
-
type TelemetryPaymentMethodCategory = (typeof TELEMETRY_PAYMENT_METHOD_CATEGORIES)[number];
|
|
1613
|
-
declare const TELEMETRY_STAGES: readonly ["callback", "sdk_initialize", "checkout_mount", "session_create", "session_shell", "session_claim", "session_read", "session_first_byte", "session_complete", "checkout_data_ready", "checkout_render", "checkout_interactive", "provider_load", "provider_ready", "overlay_open", "overlay_return", "redirect", "redirect_resume", "vault_request", "vault_mount", "vault_ready", "vault_submit", "tokenization", "three_ds_handoff", "three_ds_return", "processing", "recovery", "completion", "unmount", "total_journey"];
|
|
1614
|
-
type TelemetryStage = (typeof TELEMETRY_STAGES)[number];
|
|
1615
|
-
declare const TELEMETRY_ERROR_CODES: readonly ["CALLBACK_FAILED", "CHECKOUT_SESSION_CREATE_FAILED", "CONFIGURATION_INVALID", "INTERNAL_SDK_ERROR", "NETWORK_REQUEST_FAILED", "PAYMENT_PROCESSING_FAILED", "POPUP_BLOCKED", "PROVIDER_LOAD_FAILED", "PROVIDER_RUNTIME_FAILED", "RECOVERY_FAILED", "REDIRECT_RESUME_FAILED", "REQUEST_TIMEOUT", "SDK_INITIALIZATION_FAILED", "THREE_DS_FAILED", "TOKENIZATION_FAILED", "VAULT_LOAD_FAILED", "VAULT_SUBMIT_FAILED"];
|
|
1616
|
-
type TelemetryErrorCode = (typeof TELEMETRY_ERROR_CODES)[number];
|
|
1617
|
-
declare const TELEMETRY_FAILURE_CATEGORIES: readonly ["server_error", "transport_error", "invalid_response", "provider_runtime"];
|
|
1618
|
-
type TelemetryFailureCategory = (typeof TELEMETRY_FAILURE_CATEGORIES)[number];
|
|
1619
|
-
/** Closed catalog of SDK-authored lifecycle and operational log names. */
|
|
1620
|
-
declare const TELEMETRY_LOG_NAMES: readonly ["sdk.initialize.started", "sdk.initialize.ready", "sdk.cache.hit", "sdk.cache.miss", "checkout.mount", "session.create.started", "session.shell.ready", "session.claim.started", "session.claim.completed", "session.read.started", "session.request.first_byte", "session.request.completed", "checkout.data.ready", "checkout.rendered", "checkout.interactive", "checkout.recovery.started", "checkout.recovery.completed", "checkout.unmount", "provider.load.started", "provider.eligibility.checked", "provider.availability.checked", "provider.ready", "provider.popup.opened", "provider.overlay.opened", "provider.overlay.returned", "provider.redirect.started", "provider.redirect.resumed", "vault.capture.requested", "vault.widget.mounted", "vault.widget.ready", "vault.submission.started", "vault.action.required", "vault.three_ds.handoff", "vault.three_ds.returned", "vault.terminal", "payment.method.selected", "payment.intent.started", "payment.intent.completed", "payment.tokenization.started", "payment.tokenization.completed", "payment.processing.started", "payment.processing.completed", "payment.three_ds.handoff", "payment.three_ds.returned", "operation.retry", "operation.deduplicated", "operation.fallback", "operation.cache.hit", "operation.cache.miss", "operation.recovery.started", "operation.recovery.completed", "operation.state_transition"];
|
|
1621
|
-
type TelemetryLogName = (typeof TELEMETRY_LOG_NAMES)[number];
|
|
1622
|
-
declare const TELEMETRY_REQUEST_CATEGORIES: readonly ["session_create", "session_claim", "session_read", "intent_create", "process_payment", "vault_capture", "account_snapshot", "provider_sdk", "other"];
|
|
1623
|
-
type TelemetryRequestCategory = (typeof TELEMETRY_REQUEST_CATEGORIES)[number];
|
|
1624
|
-
declare const TELEMETRY_STATUS_CLASSES: readonly ["2xx", "3xx", "4xx", "5xx", "network_error", "timeout", "unknown"];
|
|
1625
|
-
type TelemetryStatusClass = (typeof TELEMETRY_STATUS_CLASSES)[number];
|
|
1626
|
-
declare const TELEMETRY_CHECKOUT_MODES: readonly ["full", "auto", "confirm", "setup", "unknown"];
|
|
1627
|
-
type TelemetryCheckoutMode = (typeof TELEMETRY_CHECKOUT_MODES)[number];
|
|
1628
|
-
declare const TELEMETRY_LAYOUTS: readonly ["embedded", "buttons", "automatic", "unknown"];
|
|
1629
|
-
type TelemetryLayout = (typeof TELEMETRY_LAYOUTS)[number];
|
|
1630
|
-
declare const TELEMETRY_DURATION_MODES: readonly ["machine", "buyer", "total"];
|
|
1631
|
-
type TelemetryDurationMode = (typeof TELEMETRY_DURATION_MODES)[number];
|
|
1632
|
-
declare const TELEMETRY_EXPECTED_OUTCOMES: readonly ["action_required", "card_setup_declined", "card_setup_succeeded", "customer_abandoned", "payment_cancelled", "payment_declined", "payment_authorized", "payment_succeeded", "validation_rejected"];
|
|
1633
|
-
type TelemetryExpectedOutcome = (typeof TELEMETRY_EXPECTED_OUTCOMES)[number];
|
|
1634
|
-
interface TelemetryCommonFields {
|
|
1635
|
-
eventId: string;
|
|
1636
|
-
stage: TelemetryStage;
|
|
1637
|
-
sequence: number;
|
|
1638
|
-
provider?: TelemetryProvider;
|
|
1639
|
-
attempt?: number;
|
|
1640
|
-
statusClass?: TelemetryStatusClass;
|
|
1641
|
-
requestCategory?: TelemetryRequestCategory;
|
|
1642
|
-
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
1643
|
-
checkoutMode?: TelemetryCheckoutMode;
|
|
1644
|
-
layout?: TelemetryLayout;
|
|
1645
|
-
}
|
|
1646
|
-
interface BuildTelemetryCommonInput {
|
|
1647
|
-
eventId: string;
|
|
1648
|
-
stage: TelemetryStage;
|
|
1649
|
-
sequence: number;
|
|
1650
|
-
provider?: TelemetryProviderInput;
|
|
1651
|
-
attempt?: number;
|
|
1652
|
-
statusClass?: TelemetryStatusClass;
|
|
1653
|
-
requestCategory?: TelemetryRequestCategory;
|
|
1654
|
-
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
1655
|
-
checkoutMode?: TelemetryCheckoutMode;
|
|
1656
|
-
layout?: TelemetryLayout;
|
|
1657
|
-
}
|
|
1658
|
-
interface TelemetryErrorEvent extends TelemetryCommonFields {
|
|
1659
|
-
class: 'technical_error';
|
|
1660
|
-
code: TelemetryErrorCode;
|
|
1661
|
-
failureCategory?: TelemetryFailureCategory;
|
|
1662
|
-
}
|
|
1663
|
-
interface BuildTelemetryErrorEventInput extends BuildTelemetryCommonInput {
|
|
1664
|
-
errorCode: TelemetryErrorCode;
|
|
1665
|
-
failureCategory?: TelemetryFailureCategory;
|
|
1666
|
-
}
|
|
1667
|
-
interface TelemetryLogEvent extends TelemetryCommonFields {
|
|
1668
|
-
class: 'lifecycle';
|
|
1669
|
-
name: TelemetryLogName;
|
|
1670
|
-
}
|
|
1671
|
-
interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
|
|
1672
|
-
name: TelemetryLogName;
|
|
1673
|
-
}
|
|
1674
|
-
interface TelemetryExpectedOutcomeEvent extends TelemetryCommonFields {
|
|
1675
|
-
class: 'expected_outcome';
|
|
1676
|
-
outcome: TelemetryExpectedOutcome;
|
|
1677
|
-
}
|
|
1678
|
-
interface BuildTelemetryTerminalEventInput extends Omit<BuildTelemetryCommonInput, 'stage'> {
|
|
1679
|
-
outcome: TelemetryExpectedOutcome;
|
|
1680
|
-
stage?: TelemetryStage;
|
|
1681
|
-
}
|
|
1682
|
-
interface TelemetryPerformanceEvent extends TelemetryCommonFields {
|
|
1683
|
-
class: 'performance';
|
|
1684
|
-
durationMs: number;
|
|
1685
|
-
/** True when the measured duration exceeded the bounded wire value. */
|
|
1686
|
-
durationTruncated?: true;
|
|
1687
|
-
durationMode: TelemetryDurationMode;
|
|
1688
|
-
}
|
|
1689
|
-
interface BuildTelemetryPerformanceEventInput extends BuildTelemetryCommonInput {
|
|
1690
|
-
durationMs: number;
|
|
1691
|
-
/** Preserves a previously sanitized truncation marker during serialization. */
|
|
1692
|
-
durationTruncated?: boolean;
|
|
1693
|
-
durationMode: TelemetryDurationMode;
|
|
1694
|
-
}
|
|
1695
|
-
type TelemetryEvent = TelemetryErrorEvent | TelemetryLogEvent | TelemetryExpectedOutcomeEvent | TelemetryPerformanceEvent;
|
|
1696
|
-
interface SerializeTelemetryBatchOptions {
|
|
1697
|
-
correlationId: string;
|
|
1698
|
-
sdkPackage: TelemetrySdkPackage;
|
|
1699
|
-
sdkVersion: string;
|
|
1700
|
-
batchId?: string;
|
|
1701
|
-
}
|
|
1702
|
-
interface TelemetryBatchEnvelope {
|
|
1703
|
-
schemaVersion: typeof TELEMETRY_SCHEMA_VERSION;
|
|
1704
|
-
batchId: string;
|
|
1705
|
-
correlationId: string;
|
|
1706
|
-
sdk: {
|
|
1707
|
-
package: TelemetrySdkPackage;
|
|
1708
|
-
version: string;
|
|
1709
|
-
};
|
|
1710
|
-
events: TelemetryEvent[];
|
|
1711
|
-
}
|
|
1712
|
-
/** Build a closed SDK technical-error event. */
|
|
1713
|
-
declare function buildTelemetryErrorEvent(input: BuildTelemetryErrorEventInput): TelemetryErrorEvent;
|
|
1714
|
-
/** Build a typed SDK lifecycle event; arbitrary text is never accepted. */
|
|
1715
|
-
declare function buildTelemetryLogEvent(input: BuildTelemetryLogEventInput): TelemetryLogEvent;
|
|
1716
|
-
/** Build a non-error expected checkout outcome. */
|
|
1717
|
-
declare function buildTelemetryTerminalEvent(input: BuildTelemetryTerminalEventInput): TelemetryExpectedOutcomeEvent;
|
|
1718
|
-
/** Build a monotonic SDK-owned duration measurement. */
|
|
1719
|
-
declare function buildTelemetryPerformanceEvent(input: BuildTelemetryPerformanceEventInput): TelemetryPerformanceEvent;
|
|
1720
|
-
/** Serialize one closed backend-owned v1 telemetry envelope. */
|
|
1721
|
-
declare function serializeTelemetryBatch(events: readonly TelemetryEvent[], options: SerializeTelemetryBatchOptions): string;
|
|
1589
|
+
declare function isMoneySettledOutcome(outcome?: string | null, captureMethod?: CaptureMethod): boolean;
|
|
1590
|
+
/** Collapses provider/backend reason strings into the SDK's closed failure vocabulary. */
|
|
1591
|
+
declare function normalizeCheckoutFailureOutcome(value: unknown): CheckoutFailureOutcome | undefined;
|
|
1722
1592
|
|
|
1723
|
-
interface
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1593
|
+
interface CaptureMethodEligibilityParams {
|
|
1594
|
+
captureMethod?: CaptureMethod;
|
|
1595
|
+
products?: readonly CheckoutProduct[];
|
|
1596
|
+
items?: readonly CheckoutItem[];
|
|
1597
|
+
subscriptions?: readonly CheckoutSubscription[];
|
|
1727
1598
|
}
|
|
1728
1599
|
/**
|
|
1729
|
-
*
|
|
1730
|
-
*
|
|
1600
|
+
* Reject authorisation-only checkout carts that contain a subscription.
|
|
1601
|
+
*
|
|
1602
|
+
* The backend remains authoritative; this shared preflight keeps every SDK
|
|
1603
|
+
* creation style from mounting or redirecting to a checkout that cannot
|
|
1604
|
+
* support manual capture.
|
|
1605
|
+
*
|
|
1606
|
+
* Subscription detection in the unified `products` shape is best-effort:
|
|
1607
|
+
* `CheckoutProduct.type` is optional, so catalog-backed subscriptions that
|
|
1608
|
+
* omit it are resolved and rejected by the authoritative backend validation.
|
|
1731
1609
|
*/
|
|
1732
|
-
declare function
|
|
1733
|
-
/**
|
|
1734
|
-
|
|
1735
|
-
|
|
1610
|
+
declare function assertCaptureMethodEligible(params: CaptureMethodEligibilityParams): void;
|
|
1611
|
+
/**
|
|
1612
|
+
* Whether a session may be created through the **detached** shell + claim flow
|
|
1613
|
+
* (TeamFloPay/backend#1099).
|
|
1614
|
+
*
|
|
1615
|
+
* Detached creation is the default, but it is not universally available:
|
|
1616
|
+
*
|
|
1617
|
+
* - The billing API accepts `deferDataAttachment` only for Full checkouts
|
|
1618
|
+
* (`IsDeferredCheckoutMode`), so `auto` and `confirm` are excluded.
|
|
1619
|
+
* - A saved-payment session (`tokenizedData`) can be charged the moment it
|
|
1620
|
+
* exists, so it must carry its cart from the start.
|
|
1621
|
+
* - `deferDataAttachment: false` is the caller's explicit opt-out.
|
|
1622
|
+
*/
|
|
1623
|
+
declare function isDetachedSessionEligible(params: InlineSessionDraft): boolean;
|
|
1624
|
+
/**
|
|
1625
|
+
* Resolve the session-level currency, honoring the documented fallback:
|
|
1626
|
+
* `session.currency ?? items[*].currency ?? subscriptions[*].currency ?? products[*].currency`.
|
|
1627
|
+
*
|
|
1628
|
+
* Returns the first non-blank currency found, or `null` when nothing is set.
|
|
1629
|
+
* Empty and whitespace-only strings are treated as unset so they do not
|
|
1630
|
+
* bypass the fallback chain.
|
|
1631
|
+
*
|
|
1632
|
+
* Post-#760 backends reject session-create requests without a session-level
|
|
1633
|
+
* currency (`@IsNotEmpty`); callers should throw a validation error when
|
|
1634
|
+
* this returns `null` rather than silently defaulting.
|
|
1635
|
+
*/
|
|
1636
|
+
declare function resolveSessionCurrency(sessionCurrency: string | undefined, items?: ReadonlyArray<{
|
|
1637
|
+
currency?: string;
|
|
1638
|
+
}> | undefined, subscriptions?: ReadonlyArray<{
|
|
1639
|
+
currency?: string;
|
|
1640
|
+
}> | undefined, products?: ReadonlyArray<{
|
|
1641
|
+
currency?: string;
|
|
1642
|
+
}> | undefined): string | null;
|
|
1643
|
+
/**
|
|
1644
|
+
* Fold legacy `items` + `subscriptions` arrays into the unified `products[]`
|
|
1645
|
+
* shape introduced by backend #760. Items become `type: 'item'`,
|
|
1646
|
+
* subscriptions become `type: 'subscription'`. The relative order is
|
|
1647
|
+
* subscriptions-first then items, matching the order the previous payload
|
|
1648
|
+
* builders emitted on the wire.
|
|
1649
|
+
*/
|
|
1650
|
+
declare function foldIntoProducts(items: readonly CheckoutItem[] | undefined, subscriptions: readonly CheckoutSubscription[] | undefined): CheckoutProduct[];
|
|
1651
|
+
/**
|
|
1652
|
+
* Build the request payload for a single product in the unified shape
|
|
1653
|
+
* introduced by backend #760. Emits `type`, `code`, `name`, `quantity`,
|
|
1654
|
+
* `totalAmount`, `overrideAmount`, `currency`, and optional `metadata`.
|
|
1655
|
+
*/
|
|
1656
|
+
declare function buildProductPayload(product: CheckoutProduct, sessionCurrency: string): Record<string, unknown>;
|
|
1657
|
+
/**
|
|
1658
|
+
* Build the request payload for a single item.
|
|
1659
|
+
*
|
|
1660
|
+
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
1661
|
+
* Retained until the next major so external callers building the legacy
|
|
1662
|
+
* `items[]` payload manually keep working.
|
|
1663
|
+
*/
|
|
1664
|
+
declare function buildItemPayload(item: CheckoutItem, sessionCurrency: string): Record<string, unknown>;
|
|
1665
|
+
/**
|
|
1666
|
+
* Build the request payload for a single subscription.
|
|
1667
|
+
*
|
|
1668
|
+
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
1669
|
+
* Retained until the next major so external callers building the legacy
|
|
1670
|
+
* `subscriptions[]` payload manually keep working.
|
|
1671
|
+
*/
|
|
1672
|
+
declare function buildSubscriptionPayload(subscription: CheckoutSubscription, sessionCurrency: string): Record<string, unknown>;
|
|
1736
1673
|
|
|
1737
1674
|
/** FloPay environment — determines which billing API URL is used. */
|
|
1738
1675
|
type FloPayEnvironment = 'staging' | 'production' | 'local';
|
|
@@ -1765,7 +1702,7 @@ declare function getConfiguredBillingApiUrl(): string;
|
|
|
1765
1702
|
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
1766
1703
|
|
|
1767
1704
|
/** Current SDK version. */
|
|
1768
|
-
declare const SDK_VERSION = "1.
|
|
1705
|
+
declare const SDK_VERSION = "1.7.0";
|
|
1769
1706
|
/**
|
|
1770
1707
|
* HTTP header the SDK sends on checkout-session create/read requests so the
|
|
1771
1708
|
* backend can observe compatibility. Version 1.4.9 is the first release that
|
|
@@ -2194,58 +2131,6 @@ declare function getStateOptions(country: string): StateOption[] | null;
|
|
|
2194
2131
|
/** Returns the appropriate label for the state/province field based on country. */
|
|
2195
2132
|
declare function getStateLabel(countryCode: string): string;
|
|
2196
2133
|
|
|
2197
|
-
/**
|
|
2198
|
-
* Postal-code → state derivation for AVS.
|
|
2199
|
-
*
|
|
2200
|
-
* Used when the form configuration shows `address_line_1` but hides the
|
|
2201
|
-
* `state` input — we still want to populate `billing_details.address.state`
|
|
2202
|
-
* so Stripe Radar gets a richer address signal. Currently supports US and CA;
|
|
2203
|
-
* other countries return `null` (caller should fall back to omitting state).
|
|
2204
|
-
*/
|
|
2205
|
-
/**
|
|
2206
|
-
* Resolve a state / province code from a postal code for the given country.
|
|
2207
|
-
*
|
|
2208
|
-
* - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
|
|
2209
|
-
* - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
|
|
2210
|
-
* - All other countries: `null`.
|
|
2211
|
-
*
|
|
2212
|
-
* Returns `null` when the postal code is malformed or falls in an unmapped
|
|
2213
|
-
* range. Callers should treat `null` as "skip — don't derive".
|
|
2214
|
-
*/
|
|
2215
|
-
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
2216
|
-
|
|
2217
|
-
/**
|
|
2218
|
-
* True when `validator` has an authoritative postcode pattern for the country
|
|
2219
|
-
* (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
|
|
2220
|
-
* Supported countries validate the postcode format; unsupported / no-postcode /
|
|
2221
|
-
* unresolvable countries fail open. Note the 2-letter passthrough means `UK`
|
|
2222
|
-
* (an unsupported `validator` locale) returns `false` here — matching the
|
|
2223
|
-
* backend; use the full name `United Kingdom` for `GB` semantics.
|
|
2224
|
-
*/
|
|
2225
|
-
declare function isPostalCodeSupported(country: string): boolean;
|
|
2226
|
-
/**
|
|
2227
|
-
* Validate a postcode against the country's expected format. A faithful mirror
|
|
2228
|
-
* of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
|
|
2229
|
-
* value the server would accept, nor opens the submit gate on one it would
|
|
2230
|
-
* reject. Fail-open (returns `true`) in exactly the backend's three cases:
|
|
2231
|
-
*
|
|
2232
|
-
* - `postalCode` is blank / whitespace-only;
|
|
2233
|
-
* - the country can't be normalized to an ISO-2 locale;
|
|
2234
|
-
* - the ISO-2 locale isn't one `validator` recognises.
|
|
2235
|
-
*
|
|
2236
|
-
* Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
|
|
2237
|
-
* that distinguish "required" (empty) from "malformed" (bad format) must check
|
|
2238
|
-
* emptiness themselves — an empty value fails open here, as it does server-side.
|
|
2239
|
-
*/
|
|
2240
|
-
declare function isValidPostalCode(country: string, postalCode: string): boolean;
|
|
2241
|
-
/**
|
|
2242
|
-
* The example postcode the backend would embed in its 400 message for the
|
|
2243
|
-
* country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
|
|
2244
|
-
* `undefined` when there is none (unresolvable country, or a supported country
|
|
2245
|
-
* absent from {@link POSTAL_CODE_EXAMPLES}).
|
|
2246
|
-
*/
|
|
2247
|
-
declare function getPostalCodeExample(country: string): string | undefined;
|
|
2248
|
-
|
|
2249
2134
|
/** A single line item formatted for display in the checkout UI. */
|
|
2250
2135
|
interface DisplayLineItem {
|
|
2251
2136
|
name: string;
|
|
@@ -2310,118 +2195,6 @@ interface BuildCheckoutDisplayDataOptions {
|
|
|
2310
2195
|
*/
|
|
2311
2196
|
declare function buildCheckoutDisplayData(session: CheckoutSession, options?: BuildCheckoutDisplayDataOptions): CheckoutDisplayData;
|
|
2312
2197
|
|
|
2313
|
-
interface CaptureMethodEligibilityParams {
|
|
2314
|
-
captureMethod?: CaptureMethod;
|
|
2315
|
-
products?: readonly CheckoutProduct[];
|
|
2316
|
-
items?: readonly CheckoutItem[];
|
|
2317
|
-
subscriptions?: readonly CheckoutSubscription[];
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* Reject authorisation-only checkout carts that contain a subscription.
|
|
2321
|
-
*
|
|
2322
|
-
* The backend remains authoritative; this shared preflight keeps every SDK
|
|
2323
|
-
* creation style from mounting or redirecting to a checkout that cannot
|
|
2324
|
-
* support manual capture.
|
|
2325
|
-
*
|
|
2326
|
-
* Subscription detection in the unified `products` shape is best-effort:
|
|
2327
|
-
* `CheckoutProduct.type` is optional, so catalog-backed subscriptions that
|
|
2328
|
-
* omit it are resolved and rejected by the authoritative backend validation.
|
|
2329
|
-
*/
|
|
2330
|
-
declare function assertCaptureMethodEligible(params: CaptureMethodEligibilityParams): void;
|
|
2331
|
-
/**
|
|
2332
|
-
* Whether a session may be created through the **detached** shell + claim flow
|
|
2333
|
-
* (TeamFloPay/backend#1099).
|
|
2334
|
-
*
|
|
2335
|
-
* Detached creation is the default, but it is not universally available:
|
|
2336
|
-
*
|
|
2337
|
-
* - The billing API accepts `deferDataAttachment` only for Full checkouts
|
|
2338
|
-
* (`IsDeferredCheckoutMode`), so `auto` and `confirm` are excluded.
|
|
2339
|
-
* - A saved-payment session (`tokenizedData`) can be charged the moment it
|
|
2340
|
-
* exists, so it must carry its cart from the start.
|
|
2341
|
-
* - `deferDataAttachment: false` is the caller's explicit opt-out.
|
|
2342
|
-
*/
|
|
2343
|
-
declare function isDetachedSessionEligible(params: InlineSessionDraft): boolean;
|
|
2344
|
-
/**
|
|
2345
|
-
* Resolve the session-level currency, honoring the documented fallback:
|
|
2346
|
-
* `session.currency ?? items[*].currency ?? subscriptions[*].currency ?? products[*].currency`.
|
|
2347
|
-
*
|
|
2348
|
-
* Returns the first non-blank currency found, or `null` when nothing is set.
|
|
2349
|
-
* Empty and whitespace-only strings are treated as unset so they do not
|
|
2350
|
-
* bypass the fallback chain.
|
|
2351
|
-
*
|
|
2352
|
-
* Post-#760 backends reject session-create requests without a session-level
|
|
2353
|
-
* currency (`@IsNotEmpty`); callers should throw a validation error when
|
|
2354
|
-
* this returns `null` rather than silently defaulting.
|
|
2355
|
-
*/
|
|
2356
|
-
declare function resolveSessionCurrency(sessionCurrency: string | undefined, items?: ReadonlyArray<{
|
|
2357
|
-
currency?: string;
|
|
2358
|
-
}> | undefined, subscriptions?: ReadonlyArray<{
|
|
2359
|
-
currency?: string;
|
|
2360
|
-
}> | undefined, products?: ReadonlyArray<{
|
|
2361
|
-
currency?: string;
|
|
2362
|
-
}> | undefined): string | null;
|
|
2363
|
-
/**
|
|
2364
|
-
* Fold legacy `items` + `subscriptions` arrays into the unified `products[]`
|
|
2365
|
-
* shape introduced by backend #760. Items become `type: 'item'`,
|
|
2366
|
-
* subscriptions become `type: 'subscription'`. The relative order is
|
|
2367
|
-
* subscriptions-first then items, matching the order the previous payload
|
|
2368
|
-
* builders emitted on the wire.
|
|
2369
|
-
*/
|
|
2370
|
-
declare function foldIntoProducts(items: readonly CheckoutItem[] | undefined, subscriptions: readonly CheckoutSubscription[] | undefined): CheckoutProduct[];
|
|
2371
|
-
/**
|
|
2372
|
-
* Build the request payload for a single product in the unified shape
|
|
2373
|
-
* introduced by backend #760. Emits `type`, `code`, `name`, `quantity`,
|
|
2374
|
-
* `totalAmount`, `overrideAmount`, `currency`, and optional `metadata`.
|
|
2375
|
-
*/
|
|
2376
|
-
declare function buildProductPayload(product: CheckoutProduct, sessionCurrency: string): Record<string, unknown>;
|
|
2377
|
-
/**
|
|
2378
|
-
* Build the request payload for a single item.
|
|
2379
|
-
*
|
|
2380
|
-
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
2381
|
-
* Retained until the next major so external callers building the legacy
|
|
2382
|
-
* `items[]` payload manually keep working.
|
|
2383
|
-
*/
|
|
2384
|
-
declare function buildItemPayload(item: CheckoutItem, sessionCurrency: string): Record<string, unknown>;
|
|
2385
|
-
/**
|
|
2386
|
-
* Build the request payload for a single subscription.
|
|
2387
|
-
*
|
|
2388
|
-
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
2389
|
-
* Retained until the next major so external callers building the legacy
|
|
2390
|
-
* `subscriptions[]` payload manually keep working.
|
|
2391
|
-
*/
|
|
2392
|
-
declare function buildSubscriptionPayload(subscription: CheckoutSubscription, sessionCurrency: string): Record<string, unknown>;
|
|
2393
|
-
|
|
2394
|
-
/** Returns whether a checkout deliberately stops after placing an authorization hold. */
|
|
2395
|
-
declare function isAuthorizationOnlySession(session?: {
|
|
2396
|
-
captureMethod?: CaptureMethod;
|
|
2397
|
-
} | null): boolean;
|
|
2398
|
-
/**
|
|
2399
|
-
* Returns whether an outcome represents money settled for the active checkout.
|
|
2400
|
-
*
|
|
2401
|
-
* `requires_capture` remains successful for legacy automatic/PayPal flows, but
|
|
2402
|
-
* can never be treated as settled for a manual-capture session.
|
|
2403
|
-
*/
|
|
2404
|
-
declare function isMoneySettledOutcome(outcome?: string | null, captureMethod?: CaptureMethod): boolean;
|
|
2405
|
-
/** Collapses provider/backend reason strings into the SDK's closed failure vocabulary. */
|
|
2406
|
-
declare function normalizeCheckoutFailureOutcome(value: unknown): CheckoutFailureOutcome | undefined;
|
|
2407
|
-
|
|
2408
|
-
/**
|
|
2409
|
-
* Look up currency information by ISO 3166-1 alpha-2 country code.
|
|
2410
|
-
* Falls back to USD when the country is not in the map.
|
|
2411
|
-
*/
|
|
2412
|
-
declare function getCurrencyByCountry(countryCode: string): CurrencyInfo;
|
|
2413
|
-
/** Returns `true` if the string looks like a Stripe publishable key. */
|
|
2414
|
-
declare function isValidPublishableKey(key: string): boolean;
|
|
2415
|
-
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
2416
|
-
declare function isValidSecretKey(key: string): boolean;
|
|
2417
|
-
/**
|
|
2418
|
-
* Returns `true` when the client secret belongs to a SetupIntent (`seti_…`).
|
|
2419
|
-
* Trial-only / $0 checkouts confirm and retrieve a SetupIntent instead of a
|
|
2420
|
-
* PaymentIntent, so callers must route those to `confirmCardSetup` /
|
|
2421
|
-
* `retrieveSetupIntent` rather than the PaymentIntent equivalents.
|
|
2422
|
-
*/
|
|
2423
|
-
declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
|
|
2424
|
-
|
|
2425
2198
|
/**
|
|
2426
2199
|
* HTTP header the SDK sends to make checkout-session creation idempotent
|
|
2427
2200
|
* (TeamFloPay/backend#972, paired SDK issue TeamFloPay/sdk#133).
|
|
@@ -2478,6 +2251,266 @@ declare function generateIdempotencyKey(): string | undefined;
|
|
|
2478
2251
|
*/
|
|
2479
2252
|
declare function resolveIdempotencyKey(supplied?: string): string | undefined;
|
|
2480
2253
|
|
|
2254
|
+
/** Schema version for the privacy-safe instrument callback contract. */
|
|
2255
|
+
declare const FLO_INSTRUMENT_SCHEMA_VERSION: 1;
|
|
2256
|
+
/**
|
|
2257
|
+
* Complete catalog of checkout signals exposed to merchant applications.
|
|
2258
|
+
* Error phases are separate catalog entries so consumers can verify parity
|
|
2259
|
+
* with each arm of their checkout analytics funnel.
|
|
2260
|
+
*/
|
|
2261
|
+
declare const FLO_INSTRUMENT_CATALOG: readonly [{
|
|
2262
|
+
readonly name: "checkout_mount";
|
|
2263
|
+
}, {
|
|
2264
|
+
readonly name: "sdk_loaded";
|
|
2265
|
+
}, {
|
|
2266
|
+
readonly name: "form_rendered";
|
|
2267
|
+
}, {
|
|
2268
|
+
readonly name: "card_expanded";
|
|
2269
|
+
}, {
|
|
2270
|
+
readonly name: "tokenize";
|
|
2271
|
+
}, {
|
|
2272
|
+
readonly name: "process_attempt";
|
|
2273
|
+
}, {
|
|
2274
|
+
readonly name: "3ds_challenge";
|
|
2275
|
+
}, {
|
|
2276
|
+
readonly name: "checkout_error";
|
|
2277
|
+
readonly phase: "session_create";
|
|
2278
|
+
}, {
|
|
2279
|
+
readonly name: "checkout_error";
|
|
2280
|
+
readonly phase: "sdk_load";
|
|
2281
|
+
}, {
|
|
2282
|
+
readonly name: "checkout_error";
|
|
2283
|
+
readonly phase: "process";
|
|
2284
|
+
}, {
|
|
2285
|
+
readonly name: "checkout_error";
|
|
2286
|
+
readonly phase: "wallets";
|
|
2287
|
+
}];
|
|
2288
|
+
type FloInstrumentLifecycleName = Exclude<(typeof FLO_INSTRUMENT_CATALOG)[number]['name'], 'checkout_error'>;
|
|
2289
|
+
type FloInstrumentErrorPhase = Extract<(typeof FLO_INSTRUMENT_CATALOG)[number], {
|
|
2290
|
+
name: 'checkout_error';
|
|
2291
|
+
}>['phase'];
|
|
2292
|
+
interface FloInstrumentCommonFields {
|
|
2293
|
+
schemaVersion: typeof FLO_INSTRUMENT_SCHEMA_VERSION;
|
|
2294
|
+
/** Gateway selected for this transition, when the checkout has selected one. */
|
|
2295
|
+
gateway?: BillingProvider;
|
|
2296
|
+
}
|
|
2297
|
+
type FloInstrumentEvent = (FloInstrumentCommonFields & {
|
|
2298
|
+
name: FloInstrumentLifecycleName;
|
|
2299
|
+
}) | (FloInstrumentCommonFields & {
|
|
2300
|
+
name: 'checkout_error';
|
|
2301
|
+
phase: FloInstrumentErrorPhase;
|
|
2302
|
+
});
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* Postal-code → state derivation for AVS.
|
|
2306
|
+
*
|
|
2307
|
+
* Used when the form configuration shows `address_line_1` but hides the
|
|
2308
|
+
* `state` input — we still want to populate `billing_details.address.state`
|
|
2309
|
+
* so Stripe Radar gets a richer address signal. Currently supports US and CA;
|
|
2310
|
+
* other countries return `null` (caller should fall back to omitting state).
|
|
2311
|
+
*/
|
|
2312
|
+
/**
|
|
2313
|
+
* Resolve a state / province code from a postal code for the given country.
|
|
2314
|
+
*
|
|
2315
|
+
* - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
|
|
2316
|
+
* - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
|
|
2317
|
+
* - All other countries: `null`.
|
|
2318
|
+
*
|
|
2319
|
+
* Returns `null` when the postal code is malformed or falls in an unmapped
|
|
2320
|
+
* range. Callers should treat `null` as "skip — don't derive".
|
|
2321
|
+
*/
|
|
2322
|
+
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* True when `validator` has an authoritative postcode pattern for the country
|
|
2326
|
+
* (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
|
|
2327
|
+
* Supported countries validate the postcode format; unsupported / no-postcode /
|
|
2328
|
+
* unresolvable countries fail open. Note the 2-letter passthrough means `UK`
|
|
2329
|
+
* (an unsupported `validator` locale) returns `false` here — matching the
|
|
2330
|
+
* backend; use the full name `United Kingdom` for `GB` semantics.
|
|
2331
|
+
*/
|
|
2332
|
+
declare function isPostalCodeSupported(country: string): boolean;
|
|
2333
|
+
/**
|
|
2334
|
+
* Validate a postcode against the country's expected format. A faithful mirror
|
|
2335
|
+
* of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
|
|
2336
|
+
* value the server would accept, nor opens the submit gate on one it would
|
|
2337
|
+
* reject. Fail-open (returns `true`) in exactly the backend's three cases:
|
|
2338
|
+
*
|
|
2339
|
+
* - `postalCode` is blank / whitespace-only;
|
|
2340
|
+
* - the country can't be normalized to an ISO-2 locale;
|
|
2341
|
+
* - the ISO-2 locale isn't one `validator` recognises.
|
|
2342
|
+
*
|
|
2343
|
+
* Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
|
|
2344
|
+
* that distinguish "required" (empty) from "malformed" (bad format) must check
|
|
2345
|
+
* emptiness themselves — an empty value fails open here, as it does server-side.
|
|
2346
|
+
*/
|
|
2347
|
+
declare function isValidPostalCode(country: string, postalCode: string): boolean;
|
|
2348
|
+
/**
|
|
2349
|
+
* The example postcode the backend would embed in its 400 message for the
|
|
2350
|
+
* country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
|
|
2351
|
+
* `undefined` when there is none (unresolvable country, or a supported country
|
|
2352
|
+
* absent from {@link POSTAL_CODE_EXAMPLES}).
|
|
2353
|
+
*/
|
|
2354
|
+
declare function getPostalCodeExample(country: string): string | undefined;
|
|
2355
|
+
|
|
2356
|
+
interface SentryStackFrameLike {
|
|
2357
|
+
in_app?: boolean;
|
|
2358
|
+
filename?: string;
|
|
2359
|
+
abs_path?: string;
|
|
2360
|
+
module?: string;
|
|
2361
|
+
}
|
|
2362
|
+
interface SentryEventLike {
|
|
2363
|
+
exception?: {
|
|
2364
|
+
values?: Array<{
|
|
2365
|
+
stacktrace?: {
|
|
2366
|
+
frames?: SentryStackFrameLike[];
|
|
2367
|
+
};
|
|
2368
|
+
}>;
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Drops errors whose complete exception stack contains recognized hosted
|
|
2373
|
+
* third-party code and no resolvable first-party frame. All other events are
|
|
2374
|
+
* returned by identity.
|
|
2375
|
+
*/
|
|
2376
|
+
declare function dropThirdPartyOnlyError<T extends SentryEventLike>(event: T): T | null;
|
|
2377
|
+
|
|
2378
|
+
/** Wire schema version shared with the Flo telemetry ingestion service. */
|
|
2379
|
+
declare const TELEMETRY_SCHEMA_VERSION: 1;
|
|
2380
|
+
declare const TELEMETRY_SDK_PACKAGES: readonly ["@flopay/shared", "@flopay/js", "@flopay/react"];
|
|
2381
|
+
type TelemetrySdkPackage = (typeof TELEMETRY_SDK_PACKAGES)[number];
|
|
2382
|
+
declare const TELEMETRY_MAX_BATCH_BYTES: number;
|
|
2383
|
+
declare const TELEMETRY_MAX_BATCH_EVENTS = 20;
|
|
2384
|
+
type TelemetryEventClass = 'technical_error' | 'lifecycle' | 'expected_outcome' | 'performance';
|
|
2385
|
+
declare const TELEMETRY_PROVIDERS: readonly ["stripe", "paypal"];
|
|
2386
|
+
type TelemetryProvider = (typeof TELEMETRY_PROVIDERS)[number];
|
|
2387
|
+
type TelemetryProviderInput = TelemetryProvider | 'flo' | 'pcivault' | 'other' | 'unknown';
|
|
2388
|
+
declare const TELEMETRY_PAYMENT_METHOD_CATEGORIES: readonly ["card", "wallet", "paypal", "apm", "saved", "unknown"];
|
|
2389
|
+
type TelemetryPaymentMethodCategory = (typeof TELEMETRY_PAYMENT_METHOD_CATEGORIES)[number];
|
|
2390
|
+
declare const TELEMETRY_STAGES: readonly ["callback", "sdk_initialize", "checkout_mount", "session_create", "session_shell", "session_claim", "session_read", "session_first_byte", "session_complete", "checkout_data_ready", "checkout_render", "checkout_interactive", "provider_load", "provider_ready", "overlay_open", "overlay_return", "redirect", "redirect_resume", "vault_request", "vault_mount", "vault_ready", "vault_submit", "tokenization", "three_ds_handoff", "three_ds_return", "processing", "recovery", "completion", "unmount", "total_journey"];
|
|
2391
|
+
type TelemetryStage = (typeof TELEMETRY_STAGES)[number];
|
|
2392
|
+
declare const TELEMETRY_ERROR_CODES: readonly ["CALLBACK_FAILED", "CHECKOUT_SESSION_CREATE_FAILED", "CONFIGURATION_INVALID", "INTERNAL_SDK_ERROR", "NETWORK_REQUEST_FAILED", "PAYMENT_PROCESSING_FAILED", "POPUP_BLOCKED", "PROVIDER_LOAD_FAILED", "PROVIDER_RUNTIME_FAILED", "RECOVERY_FAILED", "REDIRECT_RESUME_FAILED", "REQUEST_TIMEOUT", "SDK_INITIALIZATION_FAILED", "THREE_DS_FAILED", "TOKENIZATION_FAILED", "VAULT_LOAD_FAILED", "VAULT_SUBMIT_FAILED"];
|
|
2393
|
+
type TelemetryErrorCode = (typeof TELEMETRY_ERROR_CODES)[number];
|
|
2394
|
+
declare const TELEMETRY_FAILURE_CATEGORIES: readonly ["server_error", "transport_error", "invalid_response", "provider_runtime"];
|
|
2395
|
+
type TelemetryFailureCategory = (typeof TELEMETRY_FAILURE_CATEGORIES)[number];
|
|
2396
|
+
/** Closed catalog of SDK-authored lifecycle and operational log names. */
|
|
2397
|
+
declare const TELEMETRY_LOG_NAMES: readonly ["sdk.initialize.started", "sdk.initialize.ready", "sdk.cache.hit", "sdk.cache.miss", "checkout.mount", "session.create.started", "session.shell.ready", "session.claim.started", "session.claim.completed", "session.read.started", "session.request.first_byte", "session.request.completed", "checkout.data.ready", "checkout.rendered", "checkout.interactive", "checkout.recovery.started", "checkout.recovery.completed", "checkout.unmount", "provider.load.started", "provider.eligibility.checked", "provider.availability.checked", "provider.ready", "provider.popup.opened", "provider.overlay.opened", "provider.overlay.returned", "provider.redirect.started", "provider.redirect.resumed", "vault.capture.requested", "vault.widget.mounted", "vault.widget.ready", "vault.submission.started", "vault.action.required", "vault.three_ds.handoff", "vault.three_ds.returned", "vault.terminal", "payment.method.selected", "payment.intent.started", "payment.intent.completed", "payment.tokenization.started", "payment.tokenization.completed", "payment.processing.started", "payment.processing.completed", "payment.three_ds.handoff", "payment.three_ds.returned", "operation.retry", "operation.deduplicated", "operation.fallback", "operation.cache.hit", "operation.cache.miss", "operation.recovery.started", "operation.recovery.completed", "operation.state_transition"];
|
|
2398
|
+
type TelemetryLogName = (typeof TELEMETRY_LOG_NAMES)[number];
|
|
2399
|
+
declare const TELEMETRY_REQUEST_CATEGORIES: readonly ["session_create", "session_claim", "session_read", "intent_create", "process_payment", "vault_capture", "account_snapshot", "provider_sdk", "other"];
|
|
2400
|
+
type TelemetryRequestCategory = (typeof TELEMETRY_REQUEST_CATEGORIES)[number];
|
|
2401
|
+
declare const TELEMETRY_STATUS_CLASSES: readonly ["2xx", "3xx", "4xx", "5xx", "network_error", "timeout", "unknown"];
|
|
2402
|
+
type TelemetryStatusClass = (typeof TELEMETRY_STATUS_CLASSES)[number];
|
|
2403
|
+
declare const TELEMETRY_CHECKOUT_MODES: readonly ["full", "auto", "confirm", "setup", "unknown"];
|
|
2404
|
+
type TelemetryCheckoutMode = (typeof TELEMETRY_CHECKOUT_MODES)[number];
|
|
2405
|
+
declare const TELEMETRY_LAYOUTS: readonly ["embedded", "buttons", "automatic", "unknown"];
|
|
2406
|
+
type TelemetryLayout = (typeof TELEMETRY_LAYOUTS)[number];
|
|
2407
|
+
declare const TELEMETRY_DURATION_MODES: readonly ["machine", "buyer", "total"];
|
|
2408
|
+
type TelemetryDurationMode = (typeof TELEMETRY_DURATION_MODES)[number];
|
|
2409
|
+
declare const TELEMETRY_EXPECTED_OUTCOMES: readonly ["action_required", "card_setup_declined", "card_setup_succeeded", "customer_abandoned", "payment_cancelled", "payment_declined", "payment_authorized", "payment_succeeded", "validation_rejected"];
|
|
2410
|
+
type TelemetryExpectedOutcome = (typeof TELEMETRY_EXPECTED_OUTCOMES)[number];
|
|
2411
|
+
interface TelemetryCommonFields {
|
|
2412
|
+
eventId: string;
|
|
2413
|
+
stage: TelemetryStage;
|
|
2414
|
+
sequence: number;
|
|
2415
|
+
provider?: TelemetryProvider;
|
|
2416
|
+
attempt?: number;
|
|
2417
|
+
statusClass?: TelemetryStatusClass;
|
|
2418
|
+
requestCategory?: TelemetryRequestCategory;
|
|
2419
|
+
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
2420
|
+
checkoutMode?: TelemetryCheckoutMode;
|
|
2421
|
+
layout?: TelemetryLayout;
|
|
2422
|
+
}
|
|
2423
|
+
interface BuildTelemetryCommonInput {
|
|
2424
|
+
eventId: string;
|
|
2425
|
+
stage: TelemetryStage;
|
|
2426
|
+
sequence: number;
|
|
2427
|
+
provider?: TelemetryProviderInput;
|
|
2428
|
+
attempt?: number;
|
|
2429
|
+
statusClass?: TelemetryStatusClass;
|
|
2430
|
+
requestCategory?: TelemetryRequestCategory;
|
|
2431
|
+
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
2432
|
+
checkoutMode?: TelemetryCheckoutMode;
|
|
2433
|
+
layout?: TelemetryLayout;
|
|
2434
|
+
}
|
|
2435
|
+
interface TelemetryErrorEvent extends TelemetryCommonFields {
|
|
2436
|
+
class: 'technical_error';
|
|
2437
|
+
code: TelemetryErrorCode;
|
|
2438
|
+
failureCategory?: TelemetryFailureCategory;
|
|
2439
|
+
}
|
|
2440
|
+
interface BuildTelemetryErrorEventInput extends BuildTelemetryCommonInput {
|
|
2441
|
+
errorCode: TelemetryErrorCode;
|
|
2442
|
+
failureCategory?: TelemetryFailureCategory;
|
|
2443
|
+
}
|
|
2444
|
+
interface TelemetryLogEvent extends TelemetryCommonFields {
|
|
2445
|
+
class: 'lifecycle';
|
|
2446
|
+
name: TelemetryLogName;
|
|
2447
|
+
}
|
|
2448
|
+
interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
|
|
2449
|
+
name: TelemetryLogName;
|
|
2450
|
+
}
|
|
2451
|
+
interface TelemetryExpectedOutcomeEvent extends TelemetryCommonFields {
|
|
2452
|
+
class: 'expected_outcome';
|
|
2453
|
+
outcome: TelemetryExpectedOutcome;
|
|
2454
|
+
}
|
|
2455
|
+
interface BuildTelemetryTerminalEventInput extends Omit<BuildTelemetryCommonInput, 'stage'> {
|
|
2456
|
+
outcome: TelemetryExpectedOutcome;
|
|
2457
|
+
stage?: TelemetryStage;
|
|
2458
|
+
}
|
|
2459
|
+
interface TelemetryPerformanceEvent extends TelemetryCommonFields {
|
|
2460
|
+
class: 'performance';
|
|
2461
|
+
durationMs: number;
|
|
2462
|
+
/** True when the measured duration exceeded the bounded wire value. */
|
|
2463
|
+
durationTruncated?: true;
|
|
2464
|
+
durationMode: TelemetryDurationMode;
|
|
2465
|
+
}
|
|
2466
|
+
interface BuildTelemetryPerformanceEventInput extends BuildTelemetryCommonInput {
|
|
2467
|
+
durationMs: number;
|
|
2468
|
+
/** Preserves a previously sanitized truncation marker during serialization. */
|
|
2469
|
+
durationTruncated?: boolean;
|
|
2470
|
+
durationMode: TelemetryDurationMode;
|
|
2471
|
+
}
|
|
2472
|
+
type TelemetryEvent = TelemetryErrorEvent | TelemetryLogEvent | TelemetryExpectedOutcomeEvent | TelemetryPerformanceEvent;
|
|
2473
|
+
interface SerializeTelemetryBatchOptions {
|
|
2474
|
+
correlationId: string;
|
|
2475
|
+
sdkPackage: TelemetrySdkPackage;
|
|
2476
|
+
sdkVersion: string;
|
|
2477
|
+
batchId?: string;
|
|
2478
|
+
}
|
|
2479
|
+
interface TelemetryBatchEnvelope {
|
|
2480
|
+
schemaVersion: typeof TELEMETRY_SCHEMA_VERSION;
|
|
2481
|
+
batchId: string;
|
|
2482
|
+
correlationId: string;
|
|
2483
|
+
sdk: {
|
|
2484
|
+
package: TelemetrySdkPackage;
|
|
2485
|
+
version: string;
|
|
2486
|
+
};
|
|
2487
|
+
events: TelemetryEvent[];
|
|
2488
|
+
}
|
|
2489
|
+
/** Build a closed SDK technical-error event. */
|
|
2490
|
+
declare function buildTelemetryErrorEvent(input: BuildTelemetryErrorEventInput): TelemetryErrorEvent;
|
|
2491
|
+
/** Build a typed SDK lifecycle event; arbitrary text is never accepted. */
|
|
2492
|
+
declare function buildTelemetryLogEvent(input: BuildTelemetryLogEventInput): TelemetryLogEvent;
|
|
2493
|
+
/** Build a non-error expected checkout outcome. */
|
|
2494
|
+
declare function buildTelemetryTerminalEvent(input: BuildTelemetryTerminalEventInput): TelemetryExpectedOutcomeEvent;
|
|
2495
|
+
/** Build a monotonic SDK-owned duration measurement. */
|
|
2496
|
+
declare function buildTelemetryPerformanceEvent(input: BuildTelemetryPerformanceEventInput): TelemetryPerformanceEvent;
|
|
2497
|
+
/** Serialize one closed backend-owned v1 telemetry envelope. */
|
|
2498
|
+
declare function serializeTelemetryBatch(events: readonly TelemetryEvent[], options: SerializeTelemetryBatchOptions): string;
|
|
2499
|
+
|
|
2500
|
+
interface ClassifiedTelemetryFailure {
|
|
2501
|
+
errorCode: TelemetryErrorCode;
|
|
2502
|
+
statusClass: TelemetryStatusClass;
|
|
2503
|
+
failureCategory?: TelemetryFailureCategory;
|
|
2504
|
+
}
|
|
2505
|
+
/**
|
|
2506
|
+
* Classify the bounded billing response contract without reading free-form
|
|
2507
|
+
* messages, error codes, or provider payloads.
|
|
2508
|
+
*/
|
|
2509
|
+
declare function classifyPaymentRejection(status: number, payload: unknown): Extract<TelemetryExpectedOutcome, 'payment_declined' | 'validation_rejected'> | undefined;
|
|
2510
|
+
/** Classify only SDK-owned error structure; never inspect messages or payloads. */
|
|
2511
|
+
declare function classifyTelemetryFailure(error: unknown, fallbackCode: TelemetryErrorCode, fallbackStatusClass?: TelemetryStatusClass): ClassifiedTelemetryFailure;
|
|
2512
|
+
declare function telemetryStatusClass(status: number | undefined, fallbackStatusClass?: TelemetryStatusClass): TelemetryStatusClass;
|
|
2513
|
+
|
|
2481
2514
|
/**
|
|
2482
2515
|
* RFC 4122 v4 UUID shape (case-insensitive). Mirrors the backend's `@IsUUID()`
|
|
2483
2516
|
* acceptance for the fields the SDK fills, e.g. the session-intent
|
|
@@ -2498,4 +2531,21 @@ declare function isUuidV4(value: unknown): value is string;
|
|
|
2498
2531
|
*/
|
|
2499
2532
|
declare function randomUuidV4(): string;
|
|
2500
2533
|
|
|
2501
|
-
|
|
2534
|
+
/**
|
|
2535
|
+
* Look up currency information by ISO 3166-1 alpha-2 country code.
|
|
2536
|
+
* Falls back to USD when the country is not in the map.
|
|
2537
|
+
*/
|
|
2538
|
+
declare function getCurrencyByCountry(countryCode: string): CurrencyInfo;
|
|
2539
|
+
/** Returns `true` if the string looks like a Stripe publishable key. */
|
|
2540
|
+
declare function isValidPublishableKey(key: string): boolean;
|
|
2541
|
+
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
2542
|
+
declare function isValidSecretKey(key: string): boolean;
|
|
2543
|
+
/**
|
|
2544
|
+
* Returns `true` when the client secret belongs to a SetupIntent (`seti_…`).
|
|
2545
|
+
* Trial-only / $0 checkouts confirm and retrieve a SetupIntent instead of a
|
|
2546
|
+
* PaymentIntent, so callers must route those to `confirmCardSetup` /
|
|
2547
|
+
* `retrieveSetupIntent` rather than the PaymentIntent equivalents.
|
|
2548
|
+
*/
|
|
2549
|
+
declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
|
|
2550
|
+
|
|
2551
|
+
export { type AVSFieldConfig, BILLING_API_URL, BILLING_API_URL_PRODUCTION, BILLING_API_URL_STAGING, BOLD_DARK_APPEARANCE, BOLD_LIGHT_APPEARANCE, BUTTONS_LAYOUT_BOLD_DARK, BUTTONS_LAYOUT_BOLD_LIGHT, BUTTONS_LAYOUT_DARK, BUTTONS_LAYOUT_DEFAULT, BUTTONS_LAYOUT_GLASS_DARK, BUTTONS_LAYOUT_GLASS_LIGHT, BUTTONS_LAYOUT_MINIMAL, BUTTONS_LAYOUT_MODERN_DARK, BUTTONS_LAYOUT_MODERN_LIGHT, BUTTONS_LAYOUT_ROUNDED, type BeforeButtonClickEvent, type BillingDetails, type BillingProvider, type BuildCheckoutDisplayDataOptions, type BuildTelemetryErrorEventInput, type BuildTelemetryLogEventInput, type BuildTelemetryPerformanceEventInput, type BuildTelemetryTerminalEventInput, type ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CaptureMethod, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutFailureOutcome, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionMode, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ClassifiedTelemetryFailure, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreateSessionIntentRequest, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DetachedCheckoutSession, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_INSTRUMENT_CATALOG, FLO_INSTRUMENT_SCHEMA_VERSION, FLO_SDK_VERSION_HEADER, type FloInstrumentErrorPhase, type FloInstrumentEvent, type FloInstrumentLifecycleName, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, IDEMPOTENCY_IN_PROGRESS_CODE, IDEMPOTENCY_KEY_HEADER, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MAX_IDEMPOTENCY_KEY_LENGTH, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NonCardPaymentMethodCategory, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, PAYPAL_VAULTED_PAYMENT_METHOD_TYPE, type PayPalPaymentResult, type PayPalProviderObjectType, type PayPalSessionIntent, type PayPalSessionIntentRequest, type PaymentMethodRemovalConflictCode, type PaymentMethodRemovalConflictError, type PaymentMethodRemovalError, type PaymentMethodRemovalFailureReason, type PaymentMethodRemovalNotFoundError, type PaymentMethodRemovalRetryableError, type PaymentProviderAdapter, type PaymentResult, type PriceData, type ProcessPaymentParams, type RecurringInterval, SDK_VERSION, STRIPE_EXPRESS_METHODS, STRIPE_METHOD_AMOUNT_LIMITS, STRIPE_METHOD_COUNTRIES, STRIPE_METHOD_CURRENCIES, STRIPE_METHOD_MATRIX, SUPPORTED_CARD_BRANDS, type SavedCardDisplay, type SavedPaymentMethodStatus, type SentryEventLike, type SentryStackFrameLike, type SerializeTelemetryBatchOptions, type SessionIntent, type SessionIntentDeclineRequest, type StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, type StripeSessionIntent, type StripeSessionIntentRequest, TELEMETRY_ERROR_CODES, TELEMETRY_FAILURE_CATEGORIES, TELEMETRY_LOG_NAMES, TELEMETRY_MAX_BATCH_BYTES, TELEMETRY_MAX_BATCH_EVENTS, TELEMETRY_SCHEMA_VERSION, TELEMETRY_SDK_PACKAGES, THEMES, type TagsData, type TelemetryBatchEnvelope, type TelemetryCheckoutMode, type TelemetryDurationMode, type TelemetryErrorCode, type TelemetryErrorEvent, type TelemetryEvent, type TelemetryEventClass, type TelemetryExpectedOutcome, type TelemetryExpectedOutcomeEvent, type TelemetryFailureCategory, type TelemetryLayout, type TelemetryLogEvent, type TelemetryLogName, type TelemetryPaymentMethodCategory, type TelemetryPerformanceEvent, type TelemetryProvider, type TelemetryProviderInput, type TelemetryRequestCategory, type TelemetrySdkPackage, type TelemetryStage, type TelemetryStatusClass, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, UUID_V4, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, assertCaptureMethodEligible, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, buildTelemetryErrorEvent, buildTelemetryLogEvent, buildTelemetryPerformanceEvent, buildTelemetryTerminalEvent, classifyPaymentRejection, classifyTelemetryFailure, configureFlopay, dropThirdPartyOnlyError, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, generateIdempotencyKey, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeExample, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isAuthorizationOnlySession, isCardSetupCheckoutSession, isDetachedSessionEligible, isMoneySettledOutcome, isPostalCodeSupported, isSetupIntentClientSecret, isUuidV4, isValidPostalCode, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeCheckoutFailureOutcome, normalizeGatewayEnvironment, partitionStripeMethods, randomUuidV4, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveIdempotencyKey, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, serializeTelemetryBatch, stripeExpressMethodToOptionKey, telemetryStatusClass, validationError };
|