@flopay/shared 1.5.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/README.md +6 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +505 -377
- package/dist/index.d.ts +505 -377
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -344,6 +344,20 @@ interface CheckoutGateway {
|
|
|
344
344
|
* backends (the SDK then falls back to its built-in table).
|
|
345
345
|
*/
|
|
346
346
|
enabledPaymentMethodCountries?: Record<string, string[]>;
|
|
347
|
+
/**
|
|
348
|
+
* PayPal object the backend selected for this checkout continuation — which
|
|
349
|
+
* PayPal JS flow the session needs. New backends advertise `'order'` or
|
|
350
|
+
* `'setup_token'` (legacy provider-managed subscriptions are expressed by
|
|
351
|
+
* omission, though `'subscription'` remains accepted for robustness). Absent
|
|
352
|
+
* → released fallback: `isSubscription ? 'subscription' : 'order'`. The
|
|
353
|
+
* backend suppresses this advertisement for `x-flo-sdk-version` readers
|
|
354
|
+
* older than 1.6.0 (header-less direct integrations always see it);
|
|
355
|
+
* advertisement only — routing follows the payment-method type the client
|
|
356
|
+
* requests. On `gateways.paypal`, {@link enabledPaymentMethods} may also
|
|
357
|
+
* carry an informational `'paypal_vaulted'` entry when the Flo-owned
|
|
358
|
+
* channel is available.
|
|
359
|
+
*/
|
|
360
|
+
providerObjectType?: PayPalProviderObjectType;
|
|
347
361
|
}
|
|
348
362
|
/**
|
|
349
363
|
* Map of gateways attached to a session, keyed by gateway code. A session can
|
|
@@ -507,30 +521,72 @@ interface StripeSessionIntentRequest extends SessionIntentAuthorizationAttempt {
|
|
|
507
521
|
paymentMethodId: string | null;
|
|
508
522
|
intentKind: 'payment' | 'setup';
|
|
509
523
|
}
|
|
510
|
-
/**
|
|
511
|
-
|
|
512
|
-
* derives order vs subscription from the session's products and returns that as
|
|
513
|
-
* the response `providerObjectType`. PayPal setup intents are unsupported —
|
|
514
|
-
* PayPal vaults during a successful Order capture, not via standalone setups.
|
|
515
|
-
*/
|
|
516
|
-
interface PayPalSessionIntentRequest extends SessionIntentAuthorizationAttempt {
|
|
524
|
+
/** Fields shared by every direct PayPal intent request channel. */
|
|
525
|
+
interface PayPalSessionIntentRequestBase extends SessionIntentAuthorizationAttempt {
|
|
517
526
|
provider: 'paypal';
|
|
518
527
|
paymentMethodCategory: 'wallet';
|
|
519
|
-
paymentMethodType: 'paypal';
|
|
520
528
|
paymentMethodId: null;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Legacy provider-managed channel. `paymentMethodType: 'paypal'` keeps the
|
|
532
|
+
* released contract byte-identical: always `intentKind: 'payment'`, and the
|
|
533
|
+
* backend derives Order vs provider-managed Subscription from the session.
|
|
534
|
+
*/
|
|
535
|
+
interface PayPalLegacySessionIntentRequest extends PayPalSessionIntentRequestBase {
|
|
536
|
+
paymentMethodType: 'paypal';
|
|
537
|
+
intentKind: 'payment';
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Flo-owned channel, payment continuation. `paymentMethodType:
|
|
541
|
+
* 'paypal_vaulted'` with `intentKind: 'payment'` requests a Flo-owned PayPal
|
|
542
|
+
* Order (advertised as `providerObjectType: 'order'`).
|
|
543
|
+
*/
|
|
544
|
+
interface PayPalVaultedPaymentSessionIntentRequest extends PayPalSessionIntentRequestBase {
|
|
545
|
+
paymentMethodType: 'paypal_vaulted';
|
|
521
546
|
intentKind: 'payment';
|
|
522
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Flo-owned channel, setup continuation. `paymentMethodType: 'paypal_vaulted'`
|
|
550
|
+
* with `intentKind: 'setup'` requests a PayPal vault setup token for an
|
|
551
|
+
* item-free deferred Flo-owned start (advertised as `providerObjectType:
|
|
552
|
+
* 'setup_token'`).
|
|
553
|
+
*/
|
|
554
|
+
interface PayPalVaultedSetupSessionIntentRequest extends PayPalSessionIntentRequestBase {
|
|
555
|
+
paymentMethodType: 'paypal_vaulted';
|
|
556
|
+
intentKind: 'setup';
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Direct PayPal intent request. The payment-method type is the in-band channel
|
|
560
|
+
* selector: `'paypal'` keeps provider-managed semantics, `'paypal_vaulted'`
|
|
561
|
+
* opts the request into the Flo-owned channel. The union makes the invalid
|
|
562
|
+
* combination (`'paypal'` with `intentKind: 'setup'`) unrepresentable.
|
|
563
|
+
*/
|
|
564
|
+
type PayPalSessionIntentRequest = PayPalLegacySessionIntentRequest | PayPalVaultedPaymentSessionIntentRequest | PayPalVaultedSetupSessionIntentRequest;
|
|
523
565
|
type CreateSessionIntentRequest = StripeSessionIntentRequest | PayPalSessionIntentRequest;
|
|
524
566
|
interface StripeSessionIntent extends StripeSessionIntentRequest {
|
|
525
567
|
clientSecret: string;
|
|
526
568
|
providerObjectId: string;
|
|
527
569
|
}
|
|
528
|
-
interface
|
|
570
|
+
interface PayPalSessionIntentResponse {
|
|
529
571
|
clientSecret: null;
|
|
530
572
|
providerObjectId: string;
|
|
531
|
-
/** Server-derived from the session's products (a subscription product → 'subscription'). */
|
|
532
|
-
providerObjectType: 'order' | 'subscription';
|
|
533
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Direct PayPal intent response. The response echoes the request fields and
|
|
576
|
+
* correlates the selected provider object with the requested channel so
|
|
577
|
+
* impossible wire responses are not representable to SDK consumers:
|
|
578
|
+
*
|
|
579
|
+
* - `'paypal'` + `'payment'` ↔ `providerObjectType: 'order' | 'subscription'`
|
|
580
|
+
* - `'paypal_vaulted'` + `'payment'` ↔ `providerObjectType: 'order'`
|
|
581
|
+
* - `'paypal_vaulted'` + `'setup'` ↔ `providerObjectType: 'setup_token'`
|
|
582
|
+
*/
|
|
583
|
+
type PayPalSessionIntent = (PayPalLegacySessionIntentRequest & PayPalSessionIntentResponse & {
|
|
584
|
+
providerObjectType: 'order' | 'subscription';
|
|
585
|
+
}) | (PayPalVaultedPaymentSessionIntentRequest & PayPalSessionIntentResponse & {
|
|
586
|
+
providerObjectType: 'order';
|
|
587
|
+
}) | (PayPalVaultedSetupSessionIntentRequest & PayPalSessionIntentResponse & {
|
|
588
|
+
providerObjectType: 'setup_token';
|
|
589
|
+
});
|
|
534
590
|
type SessionIntent = StripeSessionIntent | PayPalSessionIntent;
|
|
535
591
|
type SessionIntentDeclineRequest = {
|
|
536
592
|
provider: 'stripe';
|
|
@@ -950,6 +1006,8 @@ interface CardCaptureAdapter {
|
|
|
950
1006
|
type VaultCardFieldKey = 'name' | 'number' | 'expiry';
|
|
951
1007
|
/** Supported upstream gateway codes. */
|
|
952
1008
|
type BillingProvider = 'stripe' | 'paypal';
|
|
1009
|
+
/** PayPal continuation object selected by the billing backend. */
|
|
1010
|
+
type PayPalProviderObjectType = 'order' | 'subscription' | 'setup_token';
|
|
953
1011
|
/** Token payload produced by client-side tokenization. */
|
|
954
1012
|
interface TokenizedBody {
|
|
955
1013
|
id?: string;
|
|
@@ -958,8 +1016,9 @@ interface TokenizedBody {
|
|
|
958
1016
|
originalPaymentMethodId?: string;
|
|
959
1017
|
/**
|
|
960
1018
|
* @deprecated Use {@link TokenizedBody.gateway} + {@link TokenizedBody.paymentMethodType}.
|
|
961
|
-
* Still populated by the SDK for PayPal
|
|
962
|
-
*
|
|
1019
|
+
* Still populated by the SDK for PayPal compatibility as the boolean `true`,
|
|
1020
|
+
* never the string `"true"`. New integrations must route by `gateway` and
|
|
1021
|
+
* `paymentMethodType` instead.
|
|
963
1022
|
*/
|
|
964
1023
|
isPaypal?: boolean;
|
|
965
1024
|
/**
|
|
@@ -1056,6 +1115,7 @@ interface NormalizedCheckoutSession {
|
|
|
1056
1115
|
paypal?: {
|
|
1057
1116
|
publishableKey?: string;
|
|
1058
1117
|
environment?: GatewayEnvironment;
|
|
1118
|
+
providerObjectType?: PayPalProviderObjectType;
|
|
1059
1119
|
};
|
|
1060
1120
|
};
|
|
1061
1121
|
raw?: unknown;
|
|
@@ -1516,218 +1576,173 @@ interface CountryOption {
|
|
|
1516
1576
|
*/
|
|
1517
1577
|
declare function isCardSetupCheckoutSession(session: CheckoutSession): boolean;
|
|
1518
1578
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
module?: string;
|
|
1524
|
-
}
|
|
1525
|
-
interface SentryEventLike {
|
|
1526
|
-
exception?: {
|
|
1527
|
-
values?: Array<{
|
|
1528
|
-
stacktrace?: {
|
|
1529
|
-
frames?: SentryStackFrameLike[];
|
|
1530
|
-
};
|
|
1531
|
-
}>;
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1579
|
+
/** Returns whether a checkout deliberately stops after placing an authorization hold. */
|
|
1580
|
+
declare function isAuthorizationOnlySession(session?: {
|
|
1581
|
+
captureMethod?: CaptureMethod;
|
|
1582
|
+
} | null): boolean;
|
|
1534
1583
|
/**
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
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.
|
|
1538
1588
|
*/
|
|
1539
|
-
declare function
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
declare const TELEMETRY_SCHEMA_VERSION: 1;
|
|
1543
|
-
declare const TELEMETRY_SDK_PACKAGES: readonly ["@flopay/shared", "@flopay/js", "@flopay/react"];
|
|
1544
|
-
type TelemetrySdkPackage = (typeof TELEMETRY_SDK_PACKAGES)[number];
|
|
1545
|
-
declare const TELEMETRY_MAX_BATCH_BYTES: number;
|
|
1546
|
-
declare const TELEMETRY_MAX_BATCH_EVENTS = 20;
|
|
1547
|
-
type TelemetryEventClass = 'technical_error' | 'lifecycle' | 'expected_outcome' | 'performance';
|
|
1548
|
-
declare const TELEMETRY_PROVIDERS: readonly ["stripe", "paypal"];
|
|
1549
|
-
type TelemetryProvider = (typeof TELEMETRY_PROVIDERS)[number];
|
|
1550
|
-
type TelemetryProviderInput = TelemetryProvider | 'flo' | 'pcivault' | 'other' | 'unknown';
|
|
1551
|
-
declare const TELEMETRY_PAYMENT_METHOD_CATEGORIES: readonly ["card", "wallet", "paypal", "apm", "saved", "unknown"];
|
|
1552
|
-
type TelemetryPaymentMethodCategory = (typeof TELEMETRY_PAYMENT_METHOD_CATEGORIES)[number];
|
|
1553
|
-
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"];
|
|
1554
|
-
type TelemetryStage = (typeof TELEMETRY_STAGES)[number];
|
|
1555
|
-
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"];
|
|
1556
|
-
type TelemetryErrorCode = (typeof TELEMETRY_ERROR_CODES)[number];
|
|
1557
|
-
declare const TELEMETRY_FAILURE_CATEGORIES: readonly ["server_error", "transport_error", "invalid_response", "provider_runtime"];
|
|
1558
|
-
type TelemetryFailureCategory = (typeof TELEMETRY_FAILURE_CATEGORIES)[number];
|
|
1559
|
-
/** Closed catalog of SDK-authored lifecycle and operational log names. */
|
|
1560
|
-
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"];
|
|
1561
|
-
type TelemetryLogName = (typeof TELEMETRY_LOG_NAMES)[number];
|
|
1562
|
-
declare const TELEMETRY_REQUEST_CATEGORIES: readonly ["session_create", "session_claim", "session_read", "intent_create", "process_payment", "vault_capture", "account_snapshot", "provider_sdk", "other"];
|
|
1563
|
-
type TelemetryRequestCategory = (typeof TELEMETRY_REQUEST_CATEGORIES)[number];
|
|
1564
|
-
declare const TELEMETRY_STATUS_CLASSES: readonly ["2xx", "3xx", "4xx", "5xx", "network_error", "timeout", "unknown"];
|
|
1565
|
-
type TelemetryStatusClass = (typeof TELEMETRY_STATUS_CLASSES)[number];
|
|
1566
|
-
declare const TELEMETRY_CHECKOUT_MODES: readonly ["full", "auto", "confirm", "setup", "unknown"];
|
|
1567
|
-
type TelemetryCheckoutMode = (typeof TELEMETRY_CHECKOUT_MODES)[number];
|
|
1568
|
-
declare const TELEMETRY_LAYOUTS: readonly ["embedded", "buttons", "automatic", "unknown"];
|
|
1569
|
-
type TelemetryLayout = (typeof TELEMETRY_LAYOUTS)[number];
|
|
1570
|
-
declare const TELEMETRY_DURATION_MODES: readonly ["machine", "buyer", "total"];
|
|
1571
|
-
type TelemetryDurationMode = (typeof TELEMETRY_DURATION_MODES)[number];
|
|
1572
|
-
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"];
|
|
1573
|
-
type TelemetryExpectedOutcome = (typeof TELEMETRY_EXPECTED_OUTCOMES)[number];
|
|
1574
|
-
interface TelemetryCommonFields {
|
|
1575
|
-
eventId: string;
|
|
1576
|
-
stage: TelemetryStage;
|
|
1577
|
-
sequence: number;
|
|
1578
|
-
provider?: TelemetryProvider;
|
|
1579
|
-
attempt?: number;
|
|
1580
|
-
statusClass?: TelemetryStatusClass;
|
|
1581
|
-
requestCategory?: TelemetryRequestCategory;
|
|
1582
|
-
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
1583
|
-
checkoutMode?: TelemetryCheckoutMode;
|
|
1584
|
-
layout?: TelemetryLayout;
|
|
1585
|
-
}
|
|
1586
|
-
interface BuildTelemetryCommonInput {
|
|
1587
|
-
eventId: string;
|
|
1588
|
-
stage: TelemetryStage;
|
|
1589
|
-
sequence: number;
|
|
1590
|
-
provider?: TelemetryProviderInput;
|
|
1591
|
-
attempt?: number;
|
|
1592
|
-
statusClass?: TelemetryStatusClass;
|
|
1593
|
-
requestCategory?: TelemetryRequestCategory;
|
|
1594
|
-
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
1595
|
-
checkoutMode?: TelemetryCheckoutMode;
|
|
1596
|
-
layout?: TelemetryLayout;
|
|
1597
|
-
}
|
|
1598
|
-
interface TelemetryErrorEvent extends TelemetryCommonFields {
|
|
1599
|
-
class: 'technical_error';
|
|
1600
|
-
code: TelemetryErrorCode;
|
|
1601
|
-
failureCategory?: TelemetryFailureCategory;
|
|
1602
|
-
}
|
|
1603
|
-
interface BuildTelemetryErrorEventInput extends BuildTelemetryCommonInput {
|
|
1604
|
-
errorCode: TelemetryErrorCode;
|
|
1605
|
-
failureCategory?: TelemetryFailureCategory;
|
|
1606
|
-
}
|
|
1607
|
-
interface TelemetryLogEvent extends TelemetryCommonFields {
|
|
1608
|
-
class: 'lifecycle';
|
|
1609
|
-
name: TelemetryLogName;
|
|
1610
|
-
}
|
|
1611
|
-
interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
|
|
1612
|
-
name: TelemetryLogName;
|
|
1613
|
-
}
|
|
1614
|
-
interface TelemetryExpectedOutcomeEvent extends TelemetryCommonFields {
|
|
1615
|
-
class: 'expected_outcome';
|
|
1616
|
-
outcome: TelemetryExpectedOutcome;
|
|
1617
|
-
}
|
|
1618
|
-
interface BuildTelemetryTerminalEventInput extends Omit<BuildTelemetryCommonInput, 'stage'> {
|
|
1619
|
-
outcome: TelemetryExpectedOutcome;
|
|
1620
|
-
stage?: TelemetryStage;
|
|
1621
|
-
}
|
|
1622
|
-
interface TelemetryPerformanceEvent extends TelemetryCommonFields {
|
|
1623
|
-
class: 'performance';
|
|
1624
|
-
durationMs: number;
|
|
1625
|
-
/** True when the measured duration exceeded the bounded wire value. */
|
|
1626
|
-
durationTruncated?: true;
|
|
1627
|
-
durationMode: TelemetryDurationMode;
|
|
1628
|
-
}
|
|
1629
|
-
interface BuildTelemetryPerformanceEventInput extends BuildTelemetryCommonInput {
|
|
1630
|
-
durationMs: number;
|
|
1631
|
-
/** Preserves a previously sanitized truncation marker during serialization. */
|
|
1632
|
-
durationTruncated?: boolean;
|
|
1633
|
-
durationMode: TelemetryDurationMode;
|
|
1634
|
-
}
|
|
1635
|
-
type TelemetryEvent = TelemetryErrorEvent | TelemetryLogEvent | TelemetryExpectedOutcomeEvent | TelemetryPerformanceEvent;
|
|
1636
|
-
interface SerializeTelemetryBatchOptions {
|
|
1637
|
-
correlationId: string;
|
|
1638
|
-
sdkPackage: TelemetrySdkPackage;
|
|
1639
|
-
sdkVersion: string;
|
|
1640
|
-
batchId?: string;
|
|
1641
|
-
}
|
|
1642
|
-
interface TelemetryBatchEnvelope {
|
|
1643
|
-
schemaVersion: typeof TELEMETRY_SCHEMA_VERSION;
|
|
1644
|
-
batchId: string;
|
|
1645
|
-
correlationId: string;
|
|
1646
|
-
sdk: {
|
|
1647
|
-
package: TelemetrySdkPackage;
|
|
1648
|
-
version: string;
|
|
1649
|
-
};
|
|
1650
|
-
events: TelemetryEvent[];
|
|
1651
|
-
}
|
|
1652
|
-
/** Build a closed SDK technical-error event. */
|
|
1653
|
-
declare function buildTelemetryErrorEvent(input: BuildTelemetryErrorEventInput): TelemetryErrorEvent;
|
|
1654
|
-
/** Build a typed SDK lifecycle event; arbitrary text is never accepted. */
|
|
1655
|
-
declare function buildTelemetryLogEvent(input: BuildTelemetryLogEventInput): TelemetryLogEvent;
|
|
1656
|
-
/** Build a non-error expected checkout outcome. */
|
|
1657
|
-
declare function buildTelemetryTerminalEvent(input: BuildTelemetryTerminalEventInput): TelemetryExpectedOutcomeEvent;
|
|
1658
|
-
/** Build a monotonic SDK-owned duration measurement. */
|
|
1659
|
-
declare function buildTelemetryPerformanceEvent(input: BuildTelemetryPerformanceEventInput): TelemetryPerformanceEvent;
|
|
1660
|
-
/** Serialize one closed backend-owned v1 telemetry envelope. */
|
|
1661
|
-
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;
|
|
1662
1592
|
|
|
1663
|
-
interface
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1593
|
+
interface CaptureMethodEligibilityParams {
|
|
1594
|
+
captureMethod?: CaptureMethod;
|
|
1595
|
+
products?: readonly CheckoutProduct[];
|
|
1596
|
+
items?: readonly CheckoutItem[];
|
|
1597
|
+
subscriptions?: readonly CheckoutSubscription[];
|
|
1667
1598
|
}
|
|
1668
1599
|
/**
|
|
1669
|
-
*
|
|
1670
|
-
* messages, error codes, or provider payloads.
|
|
1671
|
-
*/
|
|
1672
|
-
declare function classifyPaymentRejection(status: number, payload: unknown): Extract<TelemetryExpectedOutcome, 'payment_declined' | 'validation_rejected'> | undefined;
|
|
1673
|
-
/** Classify only SDK-owned error structure; never inspect messages or payloads. */
|
|
1674
|
-
declare function classifyTelemetryFailure(error: unknown, fallbackCode: TelemetryErrorCode, fallbackStatusClass?: TelemetryStatusClass): ClassifiedTelemetryFailure;
|
|
1675
|
-
declare function telemetryStatusClass(status: number | undefined, fallbackStatusClass?: TelemetryStatusClass): TelemetryStatusClass;
|
|
1676
|
-
|
|
1677
|
-
/** FloPay environment — determines which billing API URL is used. */
|
|
1678
|
-
type FloPayEnvironment = 'staging' | 'production' | 'local';
|
|
1679
|
-
/**
|
|
1680
|
-
* Configure the FloPay SDK globally. Call once at app startup.
|
|
1681
|
-
*
|
|
1682
|
-
* The environment determines which billing API URL is used for all
|
|
1683
|
-
* FloPay operations (session creation, payment processing, etc.).
|
|
1684
|
-
*
|
|
1685
|
-
* @example
|
|
1686
|
-
* ```ts
|
|
1687
|
-
* import { configureFlopay } from '@flopay/shared';
|
|
1688
|
-
*
|
|
1689
|
-
* // In production
|
|
1690
|
-
* configureFlopay({ environment: 'production' });
|
|
1600
|
+
* Reject authorisation-only checkout carts that contain a subscription.
|
|
1691
1601
|
*
|
|
1692
|
-
*
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
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.
|
|
1695
1605
|
*
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
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.
|
|
1698
1609
|
*/
|
|
1699
|
-
declare function
|
|
1700
|
-
environment: FloPayEnvironment;
|
|
1701
|
-
}): void;
|
|
1702
|
-
/** Get the billing API URL for the currently configured environment. */
|
|
1703
|
-
declare function getConfiguredBillingApiUrl(): string;
|
|
1704
|
-
/** Get the current configured environment. */
|
|
1705
|
-
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
1706
|
-
|
|
1707
|
-
/** Current SDK version. */
|
|
1708
|
-
declare const SDK_VERSION = "1.5.0";
|
|
1610
|
+
declare function assertCaptureMethodEligible(params: CaptureMethodEligibilityParams): void;
|
|
1709
1611
|
/**
|
|
1710
|
-
*
|
|
1711
|
-
* backend
|
|
1712
|
-
* can discover hosted card capture from an explicit Stripe `card` capability
|
|
1713
|
-
* and recover the widget lazily when `session.vault` is omitted.
|
|
1612
|
+
* Whether a session may be created through the **detached** shell + claim flow
|
|
1613
|
+
* (TeamFloPay/backend#1099).
|
|
1714
1614
|
*
|
|
1715
|
-
*
|
|
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.
|
|
1716
1622
|
*/
|
|
1717
|
-
declare
|
|
1718
|
-
/** Billing API URL for staging environment. */
|
|
1719
|
-
declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
1720
|
-
/** Billing API URL for production environment. */
|
|
1721
|
-
declare const BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
|
|
1722
|
-
/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */
|
|
1723
|
-
declare const DEFAULT_API_BASE_URL = "https://api.stage.flopay.com";
|
|
1724
|
-
/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */
|
|
1725
|
-
declare const BILLING_API_URL = "https://api.stage.flopay.com";
|
|
1623
|
+
declare function isDetachedSessionEligible(params: InlineSessionDraft): boolean;
|
|
1726
1624
|
/**
|
|
1727
|
-
* Resolve the
|
|
1625
|
+
* Resolve the session-level currency, honoring the documented fallback:
|
|
1626
|
+
* `session.currency ?? items[*].currency ?? subscriptions[*].currency ?? products[*].currency`.
|
|
1728
1627
|
*
|
|
1729
|
-
*
|
|
1730
|
-
*
|
|
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>;
|
|
1673
|
+
|
|
1674
|
+
/** FloPay environment — determines which billing API URL is used. */
|
|
1675
|
+
type FloPayEnvironment = 'staging' | 'production' | 'local';
|
|
1676
|
+
/**
|
|
1677
|
+
* Configure the FloPay SDK globally. Call once at app startup.
|
|
1678
|
+
*
|
|
1679
|
+
* The environment determines which billing API URL is used for all
|
|
1680
|
+
* FloPay operations (session creation, payment processing, etc.).
|
|
1681
|
+
*
|
|
1682
|
+
* @example
|
|
1683
|
+
* ```ts
|
|
1684
|
+
* import { configureFlopay } from '@flopay/shared';
|
|
1685
|
+
*
|
|
1686
|
+
* // In production
|
|
1687
|
+
* configureFlopay({ environment: 'production' });
|
|
1688
|
+
*
|
|
1689
|
+
* // In staging/development
|
|
1690
|
+
* configureFlopay({ environment: 'staging' });
|
|
1691
|
+
* ```
|
|
1692
|
+
*
|
|
1693
|
+
* Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable
|
|
1694
|
+
* to `'staging'` or `'production'` — the SDK reads it automatically.
|
|
1695
|
+
*/
|
|
1696
|
+
declare function configureFlopay(config: {
|
|
1697
|
+
environment: FloPayEnvironment;
|
|
1698
|
+
}): void;
|
|
1699
|
+
/** Get the billing API URL for the currently configured environment. */
|
|
1700
|
+
declare function getConfiguredBillingApiUrl(): string;
|
|
1701
|
+
/** Get the current configured environment. */
|
|
1702
|
+
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
1703
|
+
|
|
1704
|
+
/** Current SDK version. */
|
|
1705
|
+
declare const SDK_VERSION = "1.7.0";
|
|
1706
|
+
/**
|
|
1707
|
+
* HTTP header the SDK sends on checkout-session create/read requests so the
|
|
1708
|
+
* backend can observe compatibility. Version 1.4.9 is the first release that
|
|
1709
|
+
* can discover hosted card capture from an explicit Stripe `card` capability
|
|
1710
|
+
* and recover the widget lazily when `session.vault` is omitted. The backend
|
|
1711
|
+
* also uses this value to suppress the Flo-owned PayPal advertisement fields
|
|
1712
|
+
* (`gateways.paypal.providerObjectType` and the `paypal_vaulted` entry in
|
|
1713
|
+
* `enabledPaymentMethods`) for readers older than 1.6.0 — advertisement only,
|
|
1714
|
+
* never request routing.
|
|
1715
|
+
*
|
|
1716
|
+
* @see SDK_VERSION — the value sent in this header.
|
|
1717
|
+
*/
|
|
1718
|
+
declare const FLO_SDK_VERSION_HEADER = "x-flo-sdk-version";
|
|
1719
|
+
/**
|
|
1720
|
+
* In-band payment-method CHANNEL for Flo-owned PayPal continuations.
|
|
1721
|
+
*
|
|
1722
|
+
* The payment-method type sent to `POST /v1/checkouts/sessions/{id}/intents`
|
|
1723
|
+
* is the channel selector: requesting `paypal_vaulted` opts a single request
|
|
1724
|
+
* into the Flo-owned channel (an Order for `intentKind: 'payment'`, a vault
|
|
1725
|
+
* setup token for `intentKind: 'setup'`), while the legacy `paypal` type keeps
|
|
1726
|
+
* the released provider-managed semantics byte-identical — even when the
|
|
1727
|
+
* backend feature flag is on. Sessions advertise availability via
|
|
1728
|
+
* `gateways.paypal.providerObjectType` and an informational `paypal_vaulted`
|
|
1729
|
+
* entry in `gateways.paypal.enabledPaymentMethods`; there is no capability
|
|
1730
|
+
* header and no version-gated routing.
|
|
1731
|
+
*/
|
|
1732
|
+
declare const PAYPAL_VAULTED_PAYMENT_METHOD_TYPE = "paypal_vaulted";
|
|
1733
|
+
/** Billing API URL for staging environment. */
|
|
1734
|
+
declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
1735
|
+
/** Billing API URL for production environment. */
|
|
1736
|
+
declare const BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
|
|
1737
|
+
/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */
|
|
1738
|
+
declare const DEFAULT_API_BASE_URL = "https://api.stage.flopay.com";
|
|
1739
|
+
/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */
|
|
1740
|
+
declare const BILLING_API_URL = "https://api.stage.flopay.com";
|
|
1741
|
+
/**
|
|
1742
|
+
* Resolve the billing API URL from available configuration.
|
|
1743
|
+
*
|
|
1744
|
+
* Priority:
|
|
1745
|
+
* 1. Explicit `billingApiUrl` (prop/param override)
|
|
1731
1746
|
* 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)
|
|
1732
1747
|
* 3. `configureFlopay()` global environment setting
|
|
1733
1748
|
* 4. Fallback: staging URL
|
|
@@ -2116,58 +2131,6 @@ declare function getStateOptions(country: string): StateOption[] | null;
|
|
|
2116
2131
|
/** Returns the appropriate label for the state/province field based on country. */
|
|
2117
2132
|
declare function getStateLabel(countryCode: string): string;
|
|
2118
2133
|
|
|
2119
|
-
/**
|
|
2120
|
-
* Postal-code → state derivation for AVS.
|
|
2121
|
-
*
|
|
2122
|
-
* Used when the form configuration shows `address_line_1` but hides the
|
|
2123
|
-
* `state` input — we still want to populate `billing_details.address.state`
|
|
2124
|
-
* so Stripe Radar gets a richer address signal. Currently supports US and CA;
|
|
2125
|
-
* other countries return `null` (caller should fall back to omitting state).
|
|
2126
|
-
*/
|
|
2127
|
-
/**
|
|
2128
|
-
* Resolve a state / province code from a postal code for the given country.
|
|
2129
|
-
*
|
|
2130
|
-
* - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).
|
|
2131
|
-
* - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).
|
|
2132
|
-
* - All other countries: `null`.
|
|
2133
|
-
*
|
|
2134
|
-
* Returns `null` when the postal code is malformed or falls in an unmapped
|
|
2135
|
-
* range. Callers should treat `null` as "skip — don't derive".
|
|
2136
|
-
*/
|
|
2137
|
-
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
2138
|
-
|
|
2139
|
-
/**
|
|
2140
|
-
* True when `validator` has an authoritative postcode pattern for the country
|
|
2141
|
-
* (normalized to ISO 3166-1 alpha-2 via {@link normalizeCountryToIso2}).
|
|
2142
|
-
* Supported countries validate the postcode format; unsupported / no-postcode /
|
|
2143
|
-
* unresolvable countries fail open. Note the 2-letter passthrough means `UK`
|
|
2144
|
-
* (an unsupported `validator` locale) returns `false` here — matching the
|
|
2145
|
-
* backend; use the full name `United Kingdom` for `GB` semantics.
|
|
2146
|
-
*/
|
|
2147
|
-
declare function isPostalCodeSupported(country: string): boolean;
|
|
2148
|
-
/**
|
|
2149
|
-
* Validate a postcode against the country's expected format. A faithful mirror
|
|
2150
|
-
* of the backend's `isPostalCodeValidForCountry`, so the SDK never blocks a
|
|
2151
|
-
* value the server would accept, nor opens the submit gate on one it would
|
|
2152
|
-
* reject. Fail-open (returns `true`) in exactly the backend's three cases:
|
|
2153
|
-
*
|
|
2154
|
-
* - `postalCode` is blank / whitespace-only;
|
|
2155
|
-
* - the country can't be normalized to an ISO-2 locale;
|
|
2156
|
-
* - the ISO-2 locale isn't one `validator` recognises.
|
|
2157
|
-
*
|
|
2158
|
-
* Otherwise returns `validator`'s `isPostalCode(zip.trim(), locale)`. Callers
|
|
2159
|
-
* that distinguish "required" (empty) from "malformed" (bad format) must check
|
|
2160
|
-
* emptiness themselves — an empty value fails open here, as it does server-side.
|
|
2161
|
-
*/
|
|
2162
|
-
declare function isValidPostalCode(country: string, postalCode: string): boolean;
|
|
2163
|
-
/**
|
|
2164
|
-
* The example postcode the backend would embed in its 400 message for the
|
|
2165
|
-
* country (e.g. US `12345 or 12345-6789`, GB `SW1A 1AA`, CA `A1A 1A1`), or
|
|
2166
|
-
* `undefined` when there is none (unresolvable country, or a supported country
|
|
2167
|
-
* absent from {@link POSTAL_CODE_EXAMPLES}).
|
|
2168
|
-
*/
|
|
2169
|
-
declare function getPostalCodeExample(country: string): string | undefined;
|
|
2170
|
-
|
|
2171
2134
|
/** A single line item formatted for display in the checkout UI. */
|
|
2172
2135
|
interface DisplayLineItem {
|
|
2173
2136
|
name: string;
|
|
@@ -2232,118 +2195,6 @@ interface BuildCheckoutDisplayDataOptions {
|
|
|
2232
2195
|
*/
|
|
2233
2196
|
declare function buildCheckoutDisplayData(session: CheckoutSession, options?: BuildCheckoutDisplayDataOptions): CheckoutDisplayData;
|
|
2234
2197
|
|
|
2235
|
-
interface CaptureMethodEligibilityParams {
|
|
2236
|
-
captureMethod?: CaptureMethod;
|
|
2237
|
-
products?: readonly CheckoutProduct[];
|
|
2238
|
-
items?: readonly CheckoutItem[];
|
|
2239
|
-
subscriptions?: readonly CheckoutSubscription[];
|
|
2240
|
-
}
|
|
2241
|
-
/**
|
|
2242
|
-
* Reject authorisation-only checkout carts that contain a subscription.
|
|
2243
|
-
*
|
|
2244
|
-
* The backend remains authoritative; this shared preflight keeps every SDK
|
|
2245
|
-
* creation style from mounting or redirecting to a checkout that cannot
|
|
2246
|
-
* support manual capture.
|
|
2247
|
-
*
|
|
2248
|
-
* Subscription detection in the unified `products` shape is best-effort:
|
|
2249
|
-
* `CheckoutProduct.type` is optional, so catalog-backed subscriptions that
|
|
2250
|
-
* omit it are resolved and rejected by the authoritative backend validation.
|
|
2251
|
-
*/
|
|
2252
|
-
declare function assertCaptureMethodEligible(params: CaptureMethodEligibilityParams): void;
|
|
2253
|
-
/**
|
|
2254
|
-
* Whether a session may be created through the **detached** shell + claim flow
|
|
2255
|
-
* (TeamFloPay/backend#1099).
|
|
2256
|
-
*
|
|
2257
|
-
* Detached creation is the default, but it is not universally available:
|
|
2258
|
-
*
|
|
2259
|
-
* - The billing API accepts `deferDataAttachment` only for Full checkouts
|
|
2260
|
-
* (`IsDeferredCheckoutMode`), so `auto` and `confirm` are excluded.
|
|
2261
|
-
* - A saved-payment session (`tokenizedData`) can be charged the moment it
|
|
2262
|
-
* exists, so it must carry its cart from the start.
|
|
2263
|
-
* - `deferDataAttachment: false` is the caller's explicit opt-out.
|
|
2264
|
-
*/
|
|
2265
|
-
declare function isDetachedSessionEligible(params: InlineSessionDraft): boolean;
|
|
2266
|
-
/**
|
|
2267
|
-
* Resolve the session-level currency, honoring the documented fallback:
|
|
2268
|
-
* `session.currency ?? items[*].currency ?? subscriptions[*].currency ?? products[*].currency`.
|
|
2269
|
-
*
|
|
2270
|
-
* Returns the first non-blank currency found, or `null` when nothing is set.
|
|
2271
|
-
* Empty and whitespace-only strings are treated as unset so they do not
|
|
2272
|
-
* bypass the fallback chain.
|
|
2273
|
-
*
|
|
2274
|
-
* Post-#760 backends reject session-create requests without a session-level
|
|
2275
|
-
* currency (`@IsNotEmpty`); callers should throw a validation error when
|
|
2276
|
-
* this returns `null` rather than silently defaulting.
|
|
2277
|
-
*/
|
|
2278
|
-
declare function resolveSessionCurrency(sessionCurrency: string | undefined, items?: ReadonlyArray<{
|
|
2279
|
-
currency?: string;
|
|
2280
|
-
}> | undefined, subscriptions?: ReadonlyArray<{
|
|
2281
|
-
currency?: string;
|
|
2282
|
-
}> | undefined, products?: ReadonlyArray<{
|
|
2283
|
-
currency?: string;
|
|
2284
|
-
}> | undefined): string | null;
|
|
2285
|
-
/**
|
|
2286
|
-
* Fold legacy `items` + `subscriptions` arrays into the unified `products[]`
|
|
2287
|
-
* shape introduced by backend #760. Items become `type: 'item'`,
|
|
2288
|
-
* subscriptions become `type: 'subscription'`. The relative order is
|
|
2289
|
-
* subscriptions-first then items, matching the order the previous payload
|
|
2290
|
-
* builders emitted on the wire.
|
|
2291
|
-
*/
|
|
2292
|
-
declare function foldIntoProducts(items: readonly CheckoutItem[] | undefined, subscriptions: readonly CheckoutSubscription[] | undefined): CheckoutProduct[];
|
|
2293
|
-
/**
|
|
2294
|
-
* Build the request payload for a single product in the unified shape
|
|
2295
|
-
* introduced by backend #760. Emits `type`, `code`, `name`, `quantity`,
|
|
2296
|
-
* `totalAmount`, `overrideAmount`, `currency`, and optional `metadata`.
|
|
2297
|
-
*/
|
|
2298
|
-
declare function buildProductPayload(product: CheckoutProduct, sessionCurrency: string): Record<string, unknown>;
|
|
2299
|
-
/**
|
|
2300
|
-
* Build the request payload for a single item.
|
|
2301
|
-
*
|
|
2302
|
-
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
2303
|
-
* Retained until the next major so external callers building the legacy
|
|
2304
|
-
* `items[]` payload manually keep working.
|
|
2305
|
-
*/
|
|
2306
|
-
declare function buildItemPayload(item: CheckoutItem, sessionCurrency: string): Record<string, unknown>;
|
|
2307
|
-
/**
|
|
2308
|
-
* Build the request payload for a single subscription.
|
|
2309
|
-
*
|
|
2310
|
-
* @deprecated Use {@link buildProductPayload} with {@link foldIntoProducts}.
|
|
2311
|
-
* Retained until the next major so external callers building the legacy
|
|
2312
|
-
* `subscriptions[]` payload manually keep working.
|
|
2313
|
-
*/
|
|
2314
|
-
declare function buildSubscriptionPayload(subscription: CheckoutSubscription, sessionCurrency: string): Record<string, unknown>;
|
|
2315
|
-
|
|
2316
|
-
/** Returns whether a checkout deliberately stops after placing an authorization hold. */
|
|
2317
|
-
declare function isAuthorizationOnlySession(session?: {
|
|
2318
|
-
captureMethod?: CaptureMethod;
|
|
2319
|
-
} | null): boolean;
|
|
2320
|
-
/**
|
|
2321
|
-
* Returns whether an outcome represents money settled for the active checkout.
|
|
2322
|
-
*
|
|
2323
|
-
* `requires_capture` remains successful for legacy automatic/PayPal flows, but
|
|
2324
|
-
* can never be treated as settled for a manual-capture session.
|
|
2325
|
-
*/
|
|
2326
|
-
declare function isMoneySettledOutcome(outcome?: string | null, captureMethod?: CaptureMethod): boolean;
|
|
2327
|
-
/** Collapses provider/backend reason strings into the SDK's closed failure vocabulary. */
|
|
2328
|
-
declare function normalizeCheckoutFailureOutcome(value: unknown): CheckoutFailureOutcome | undefined;
|
|
2329
|
-
|
|
2330
|
-
/**
|
|
2331
|
-
* Look up currency information by ISO 3166-1 alpha-2 country code.
|
|
2332
|
-
* Falls back to USD when the country is not in the map.
|
|
2333
|
-
*/
|
|
2334
|
-
declare function getCurrencyByCountry(countryCode: string): CurrencyInfo;
|
|
2335
|
-
/** Returns `true` if the string looks like a Stripe publishable key. */
|
|
2336
|
-
declare function isValidPublishableKey(key: string): boolean;
|
|
2337
|
-
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
2338
|
-
declare function isValidSecretKey(key: string): boolean;
|
|
2339
|
-
/**
|
|
2340
|
-
* Returns `true` when the client secret belongs to a SetupIntent (`seti_…`).
|
|
2341
|
-
* Trial-only / $0 checkouts confirm and retrieve a SetupIntent instead of a
|
|
2342
|
-
* PaymentIntent, so callers must route those to `confirmCardSetup` /
|
|
2343
|
-
* `retrieveSetupIntent` rather than the PaymentIntent equivalents.
|
|
2344
|
-
*/
|
|
2345
|
-
declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
|
|
2346
|
-
|
|
2347
2198
|
/**
|
|
2348
2199
|
* HTTP header the SDK sends to make checkout-session creation idempotent
|
|
2349
2200
|
* (TeamFloPay/backend#972, paired SDK issue TeamFloPay/sdk#133).
|
|
@@ -2400,6 +2251,266 @@ declare function generateIdempotencyKey(): string | undefined;
|
|
|
2400
2251
|
*/
|
|
2401
2252
|
declare function resolveIdempotencyKey(supplied?: string): string | undefined;
|
|
2402
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
|
+
|
|
2403
2514
|
/**
|
|
2404
2515
|
* RFC 4122 v4 UUID shape (case-insensitive). Mirrors the backend's `@IsUUID()`
|
|
2405
2516
|
* acceptance for the fields the SDK fills, e.g. the session-intent
|
|
@@ -2420,4 +2531,21 @@ declare function isUuidV4(value: unknown): value is string;
|
|
|
2420
2531
|
*/
|
|
2421
2532
|
declare function randomUuidV4(): string;
|
|
2422
2533
|
|
|
2423
|
-
|
|
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 };
|