@flopay/shared 1.14.5 → 1.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/before-button-click.d.ts +11 -0
  2. package/dist/card-setup-overlay-theme.d.ts +34 -0
  3. package/dist/card-setup-surface.d.ts +24 -0
  4. package/dist/card-setup-theme.d.ts +62 -0
  5. package/dist/card-setup.d.ts +7 -0
  6. package/dist/checkout-gateway-rules.d.ts +50 -0
  7. package/dist/checkout-outcomes.d.ts +14 -0
  8. package/dist/checkout-payload.d.ts +86 -0
  9. package/dist/checkout-process-request.d.ts +57 -0
  10. package/dist/config.d.ts +29 -0
  11. package/dist/constants.d.ts +452 -0
  12. package/dist/display.d.ts +64 -0
  13. package/dist/email-validation.d.ts +2 -0
  14. package/dist/errors.d.ts +53 -0
  15. package/dist/external-method-recovery.d.ts +24 -0
  16. package/dist/friendly-message.d.ts +5 -0
  17. package/dist/future-use.d.ts +24 -0
  18. package/dist/idempotency.d.ts +55 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.ts +67 -3739
  21. package/dist/index.mjs +1 -1
  22. package/dist/inline-session-cache.d.ts +20 -0
  23. package/dist/instrument-dispatch.d.ts +28 -0
  24. package/dist/instruments.d.ts +51 -0
  25. package/dist/payment-logos.generated.d.ts +1 -0
  26. package/dist/payment-method-setup-advertisement.d.ts +67 -0
  27. package/dist/paypal-buyer-identity.d.ts +46 -0
  28. package/dist/paypal-channel.d.ts +77 -0
  29. package/dist/paypal-environment.d.ts +14 -0
  30. package/dist/postal-code-lookup.d.ts +19 -0
  31. package/dist/postal-code-validation.d.ts +46 -0
  32. package/dist/primary-tile-style.d.ts +46 -0
  33. package/dist/recent-completion.d.ts +2 -0
  34. package/dist/saved-payment-methods.d.ts +96 -0
  35. package/dist/sentry-filter.d.ts +21 -0
  36. package/dist/stripe-appearance.d.ts +19 -0
  37. package/dist/stripe-paypal-presentation.d.ts +42 -0
  38. package/dist/telemetry-failure.d.ts +14 -0
  39. package/dist/telemetry.d.ts +161 -0
  40. package/dist/types.d.ts +1747 -0
  41. package/dist/uuid.d.ts +19 -0
  42. package/dist/validation.d.ts +19 -0
  43. package/dist/vault-submit-theme.d.ts +22 -0
  44. package/dist/vault-theme.d.ts +28 -0
  45. package/dist/vault-verification.d.ts +45 -0
  46. package/dist/wallet-elements-mode.d.ts +27 -0
  47. package/dist/wallet-sheet-window.d.ts +44 -0
  48. package/package.json +4 -3
  49. package/dist/index.d.cts +0 -3739
@@ -0,0 +1,1747 @@
1
+ /** Theme variables that map to CSS custom properties on FloPay elements. */
2
+ export interface FloPayThemeVariables {
3
+ colorPrimary?: string;
4
+ /** Hover background for all "flo" buttons (submit / card / wallet CTAs). */
5
+ colorPrimaryHover?: string;
6
+ colorBackground?: string;
7
+ colorText?: string;
8
+ colorDanger?: string;
9
+ borderRadius?: string;
10
+ fontFamily?: string;
11
+ fontSizeBase?: string;
12
+ spacingUnit?: string;
13
+ }
14
+ /** Controls the visual appearance of all FloPay elements. */
15
+ export interface FloPayAppearance {
16
+ theme?: 'default' | 'flat' | 'night' | 'none';
17
+ variables?: FloPayThemeVariables;
18
+ /** CSS-like rules keyed by selector (e.g. `".Input"`, `".Label"`). */
19
+ rules?: Record<string, Record<string, string>>;
20
+ }
21
+ /** Style overrides for the `buttons` layout mode. */
22
+ export interface ButtonsLayoutStyles {
23
+ /** Style for the "Credit / Debit Card" button. */
24
+ cardButton?: Record<string, string | number>;
25
+ /** Font size for the "Credit / Debit Card" button label. */
26
+ cardButtonFontSize?: string;
27
+ /** Style for the card form container when expanded. */
28
+ cardFormContainer?: Record<string, string | number>;
29
+ /** Border color for card input fields. */
30
+ cardInputBorder?: string;
31
+ /** Text color inside the card input fields (number, expiry, CVC). */
32
+ cardInputColor?: string;
33
+ /** Placeholder text color for the card input fields. */
34
+ cardInputPlaceholderColor?: string;
35
+ /** Font size for the card input fields. */
36
+ cardInputFontSize?: string;
37
+ /** Background color for card input fields. */
38
+ cardInputBackground?: string;
39
+ /**
40
+ * Opt-in escape hatch for vault-only style hooks that the appearance →
41
+ * hosted-field mapper cannot express. Merged last (last-write-wins) into the
42
+ * style config handed to the vault PCI card form, so these win over the
43
+ * auto-translated `cardInput*` knobs and `appearance.variables`. Keys are
44
+ * passed through verbatim — use vault-supported style property names.
45
+ * Applied only to the hosted vault card form.
46
+ */
47
+ vaultCardForm?: Record<string, string | number>;
48
+ /** Style for the full-name text input. */
49
+ nameInput?: Record<string, string | number>;
50
+ /** Style for the "Go back" button text/container. */
51
+ backButton?: Record<string, string | number>;
52
+ /** Font size for the "Go back" button label. */
53
+ backButtonFontSize?: string;
54
+ /** Style for the back button circle icon. */
55
+ backButtonIcon?: Record<string, string | number>;
56
+ /** Style for the submit/confirm button. */
57
+ submitButton?: Record<string, string | number>;
58
+ /** Font size for the submit button label. */
59
+ submitButtonFontSize?: string;
60
+ /** Style for the "Secure card checkout" title. */
61
+ title?: Record<string, string | number>;
62
+ /** Font size for the "Secure card checkout" title. */
63
+ titleFontSize?: string;
64
+ /** Style for the error banner. */
65
+ errorBanner?: Record<string, string | number>;
66
+ /** Style for the country select dropdown container (AVS). */
67
+ countrySelect?: Record<string, string | number>;
68
+ /** Style for the ZIP/postcode input container (AVS). */
69
+ zipInput?: Record<string, string | number>;
70
+ /** Style for the street address input (AVS address_line_1). */
71
+ addressLine1Input?: Record<string, string | number>;
72
+ /** Style for the apt/suite input (AVS address_line_2). */
73
+ addressLine2Input?: Record<string, string | number>;
74
+ /** Style for the city input (AVS). */
75
+ cityInput?: Record<string, string | number>;
76
+ /** Style for the state/province input or dropdown (AVS). */
77
+ stateInput?: Record<string, string | number>;
78
+ }
79
+ /** Predefined theme for the `buttons` layout. */
80
+ export type ButtonsLayoutTheme = 'default' | 'minimal' | 'rounded' | 'dark' | 'modern-light' | 'modern-dark' | 'bold-light' | 'bold-dark' | 'glass-light' | 'glass-dark';
81
+ /**
82
+ * Identifier for a coherent {appearance, buttonsLayout} theme bundle exported
83
+ * by `@flopay/shared`. Subset of `ButtonsLayoutTheme` covering the bundles
84
+ * that ship matching `*_APPEARANCE` + `BUTTONS_LAYOUT_*` halves.
85
+ */
86
+ export type ThemeBundleId = 'modern-light' | 'modern-dark' | 'bold-light' | 'bold-dark' | 'glass-light' | 'glass-dark';
87
+ /**
88
+ * Theme identifier accepted by FloPay React components (`FloPayCheckout`,
89
+ * `FloPayAutomaticPaymentButton`, `SplitCardForm`) on the `theme` prop.
90
+ *
91
+ * - `'classic'` — historic FloPay look (no bundle applied); kept as the
92
+ * no-theme baseline so consumers can declare it explicitly.
93
+ * - Bundle ids (`'modern-light'`, `'glass-dark'`, …) pull both halves
94
+ * (`appearance` + `buttonsLayout`) from {@link THEMES} so a single prop
95
+ * styles every part of the checkout consistently.
96
+ */
97
+ export type ThemeId = 'classic' | ThemeBundleId;
98
+ /** A coherent theme: appearance for Stripe Elements + wrapper styles for the FloPay buttons/card form. */
99
+ export interface ThemeBundle {
100
+ appearance: FloPayAppearance;
101
+ buttonsLayout: ButtonsLayoutStyles;
102
+ }
103
+ /**
104
+ * Per-field AVS configuration.
105
+ * - `true` = show for all countries
106
+ * - `string[]` = show only for listed country codes (ISO 3166-1 alpha-2)
107
+ * - `false` or omitted = hidden
108
+ */
109
+ export interface AVSFieldConfig {
110
+ /** Street address (line 1). */
111
+ address_line_1?: boolean | string[];
112
+ /** Apt, suite, unit, etc. (line 2). */
113
+ address_line_2?: boolean | string[];
114
+ /** City / Town. */
115
+ city?: boolean | string[];
116
+ /** State / Province / Region. Renders as dropdown for US and CA. */
117
+ state?: boolean | string[];
118
+ /** ZIP / Postal code. */
119
+ postal_code?: boolean | string[];
120
+ /** Country dropdown. */
121
+ country?: boolean | string[];
122
+ }
123
+ /** A customer attached to a checkout session. */
124
+ export interface Customer {
125
+ id: string;
126
+ email: string;
127
+ firstName?: string;
128
+ lastName?: string;
129
+ gender?: string;
130
+ city?: string;
131
+ state?: string;
132
+ country?: string;
133
+ zip?: string;
134
+ /** Street address (line 1). */
135
+ line1?: string;
136
+ /** Apt, suite, unit (line 2). */
137
+ line2?: string;
138
+ }
139
+ /** Recurring interval configuration for subscription line items. */
140
+ export interface RecurringInterval {
141
+ interval: 'month' | 'year';
142
+ intervalCount?: number;
143
+ }
144
+ /** Inline product data when no pre-created price is referenced. */
145
+ export interface PriceData {
146
+ currency: string;
147
+ unitAmount: number;
148
+ productData: {
149
+ name: string;
150
+ description?: string;
151
+ };
152
+ recurring?: RecurringInterval;
153
+ }
154
+ /** A single line item within a checkout session. */
155
+ export interface LineItem {
156
+ /** Reference to a pre-created price object on the provider. */
157
+ price?: string;
158
+ /** Inline price data (used when no `price` reference exists). */
159
+ priceData?: PriceData;
160
+ quantity: number;
161
+ }
162
+ /** Checkout mode controlling the payment UI behavior. */
163
+ export type CheckoutMode = 'full' | 'auto' | 'confirm';
164
+ /** Merchant preference for wallet approval presentation when the provider supports it. */
165
+ export type WalletPresentation = 'auto' | 'popup' | 'prefer_redirect';
166
+ /** Non-sensitive client context preserved with a checkout session. */
167
+ export type CheckoutMetadata = Record<string, string>;
168
+ /**
169
+ * Checkout mode reported by a session read. `setup` is read-only in the
170
+ * browser SDK: merchant-authenticated setup-session creation stays on the
171
+ * merchant's server (its body is {@link CreateCardSetupSessionRequest}), while
172
+ * the existing create parameter types intentionally continue to accept only
173
+ * {@link CheckoutMode}.
174
+ */
175
+ export type CheckoutSessionMode = CheckoutMode | 'setup';
176
+ /** Whether checkout captures immediately or only authorises funds for later capture. */
177
+ export type CaptureMethod = 'automatic' | 'manual';
178
+ /** Stable, provider-neutral authorization lifecycle failures exposed by the SDK. */
179
+ export type CheckoutFailureOutcome = 'authorization_declined' | 'authentication_required' | 'authorization_expired' | 'capture_failed';
180
+ /** Stable provider-neutral outcome for a saved method that cannot fund this checkout. */
181
+ export type StoredPaymentMethodOutcomeCode = 'stored_payment_method_unsupported';
182
+ /** Lifecycle states returned by the merchant-scoped saved-method list. */
183
+ export type SavedPaymentMethodStatus = 'pending' | 'active' | 'deleted';
184
+ /**
185
+ * Display-only card fields safe to show to a customer. This deliberately has
186
+ * no provider payment-method id, vault token, capture reference, or reusable
187
+ * credential.
188
+ */
189
+ export interface SavedCardDisplay {
190
+ /** FloPay payment-method UUID. */
191
+ id: string;
192
+ brand: string;
193
+ lastFour: string;
194
+ expiryMonth: number;
195
+ expiryYear: number;
196
+ status: SavedPaymentMethodStatus;
197
+ }
198
+ /** Stable conflicts returned by `DELETE /v1/payment-methods/:id`. */
199
+ export type PaymentMethodRemovalConflictCode = 'payment_method_has_active_payment' | 'payment_method_in_use' | 'payment_method_reassignment_requires_payer_action';
200
+ /** Indistinguishable missing-or-inaccessible saved-method response. */
201
+ export interface PaymentMethodRemovalNotFoundError {
202
+ statusCode: 404;
203
+ code: 'payment_method_not_found';
204
+ message?: string;
205
+ }
206
+ /** A blocked removal that requires merchant/customer guidance. */
207
+ export interface PaymentMethodRemovalConflictError {
208
+ statusCode: 409;
209
+ code: PaymentMethodRemovalConflictCode;
210
+ message?: string;
211
+ }
212
+ /** Provider-neutral reason accompanying a retry-safe removal failure. */
213
+ export type PaymentMethodRemovalFailureReason = 'payment_method_data_incomplete' | 'provider_cleanup_failed' | 'provider_unavailable' | 'provider_verification_failed';
214
+ /** Retry-safe incomplete provider/vault cleanup response. */
215
+ export interface PaymentMethodRemovalRetryableError {
216
+ statusCode: 502;
217
+ code: 'payment_method_deletion_failed';
218
+ reason: PaymentMethodRemovalFailureReason;
219
+ retrySafe: true;
220
+ resolution: string;
221
+ message?: string;
222
+ }
223
+ /** Stable error union for merchant-server saved-method removal calls. */
224
+ export type PaymentMethodRemovalError = PaymentMethodRemovalNotFoundError | PaymentMethodRemovalConflictError | PaymentMethodRemovalRetryableError;
225
+ /**
226
+ * Stripe's future-use values. Future use is platform policy: the billing API
227
+ * sets every Stripe attempt up `'off_session'` and reports it on the session
228
+ * read as `CheckoutSession.futureUse`.
229
+ */
230
+ export type CardSetupFutureUse = 'on_session' | 'off_session';
231
+ /**
232
+ * A method the billing API cannot set up for future use (read field
233
+ * `futureUseUnsupported`). `reason` is the billing API's own code, passed
234
+ * through unchanged.
235
+ */
236
+ export interface FutureUseUnsupportedMethod {
237
+ paymentMethodType: string;
238
+ reason: string;
239
+ }
240
+ /**
241
+ * Body of the merchant-authenticated `POST /v1/checkouts/sessions/setup`
242
+ * request. Type-only: no FloPay package sends it or holds the merchant
243
+ * credential it needs. The merchant's server sends it with its own
244
+ * authenticated client and passes only the returned session id and nonce to
245
+ * the browser card-setup component.
246
+ *
247
+ * `country`, `currency`, and `futureUse` are independent, optional transaction
248
+ * context honoured by billing API v1.9.48+; older billing APIs silently ignore
249
+ * them. Send values as you hold them: the billing API owns normalization,
250
+ * validation, and defaults, and alone decides which gateway verifies the card.
251
+ * This context never selects or hints a gateway.
252
+ */
253
+ export interface CreateCardSetupSessionRequest {
254
+ /** UUID of an existing FloPay customer linked to the authenticated merchant. */
255
+ userId: string;
256
+ /** Success URL recorded on the setup session. */
257
+ successUrl?: string | null;
258
+ /** Cancel URL recorded on the setup session. */
259
+ cancelUrl?: string | null;
260
+ /**
261
+ * ISO 3166-1 alpha-2 country the card will be used in. The billing API trims
262
+ * and uppercases it before validating it, and never infers a currency from it.
263
+ */
264
+ country?: string | null;
265
+ /**
266
+ * Three-letter code of the currency later payments will be charged in. The
267
+ * billing API trims and uppercases it before validating it, and never infers
268
+ * a country from it. When supplied, it becomes the setup session's currency.
269
+ */
270
+ currency?: string | null;
271
+ /**
272
+ * @deprecated Future use is platform policy: the billing API always sets up
273
+ * `'off_session'` and ignores this value. Still accepted, so existing
274
+ * requests keep working; leave it out of new code.
275
+ */
276
+ futureUse?: CardSetupFutureUse | null;
277
+ }
278
+ /**
279
+ * Discriminator describing whether a checkout product is a one-time item or a
280
+ * recurring subscription. Mirrors the backend's `ProductTypeEnum`.
281
+ */
282
+ export type CheckoutProductType = 'item' | 'subscription';
283
+ /** Unified checkout product from a session response. */
284
+ export interface CheckoutSessionProduct {
285
+ uuid: string;
286
+ checkoutSessionId: string;
287
+ /**
288
+ * Whether this product is a one-time item or a recurring subscription.
289
+ * Optional to mirror {@link CheckoutProduct.type}; when omitted, consumers
290
+ * treat the product as an `'item'` for display ordering.
291
+ */
292
+ type?: CheckoutProductType;
293
+ /** Preferred catalog code for the product. */
294
+ code?: string;
295
+ /**
296
+ * Display-only name. Resolved from the catalog server-side; the SDK
297
+ * populates this from the client-side display cache when missing.
298
+ */
299
+ name?: string | null;
300
+ /** Display-only description from the catalog. */
301
+ description?: string | null;
302
+ quantity: number;
303
+ /** Display-only. Populated from cache when the server omits it. */
304
+ totalAmount?: number;
305
+ /** Display-only. Populated from cache when the server omits it. */
306
+ overrideAmount?: number | null;
307
+ /** @deprecated Prefer the session-level `currency` on {@link CheckoutSession}. */
308
+ currency?: string;
309
+ metadata?: Record<string, unknown> | null;
310
+ }
311
+ /**
312
+ * Environment for an upstream gateway. Accepts both the gateway-native values
313
+ * (`'sandbox'` | `'live'`) and FloPay's internal aliases (`'stage'` |
314
+ * `'production'`) so the same string can flow from the billing API straight
315
+ * to gateway SDKs without translation at every call site. Use
316
+ * {@link normalizeGatewayEnvironment} to collapse to the canonical pair
317
+ * before handing the value to a gateway SDK.
318
+ */
319
+ export type GatewayEnvironment = 'sandbox' | 'live' | 'stage' | 'production';
320
+ /** Canonical gateway-native form returned by {@link normalizeGatewayEnvironment}. */
321
+ export type NormalizedGatewayEnvironment = 'sandbox' | 'live';
322
+ /**
323
+ * Map FloPay's environment aliases to the gateway-native `'sandbox'`/`'live'`
324
+ * pair. `'stage'` → `'sandbox'`, `'production'` → `'live'`. Returns `undefined`
325
+ * for `undefined` input and logs a console warning for unrecognized strings
326
+ * (so misconfiguration surfaces immediately instead of hanging later — most
327
+ * gateway SDKs silently fall back to live endpoints on an unknown env, which
328
+ * then fails opaquely against sandbox credentials).
329
+ */
330
+ export declare function normalizeGatewayEnvironment(env: GatewayEnvironment | string | undefined | null): NormalizedGatewayEnvironment | undefined;
331
+ /** Per-gateway configuration returned by the billing API. */
332
+ export interface CheckoutGateway {
333
+ /** Public client identifier (e.g. Stripe publishable key, PayPal client id). */
334
+ publishableKey?: string | null;
335
+ /** Sandbox or live mode for the gateway credentials. */
336
+ environment?: GatewayEnvironment;
337
+ /**
338
+ * Optional Stripe PaymentIntent client secret exposed by the billing API
339
+ * when additional authentication is required for a saved payment method.
340
+ * Stripe-specific.
341
+ */
342
+ stripeClientSecret?: string | null;
343
+ /**
344
+ * Optional publishable key for a dedicated Stripe sub-account that renders
345
+ * PayPal via Stripe Elements. Stripe-specific. Distinct from
346
+ * `gateways.paypal.publishableKey`, which is a PayPal client id used by the
347
+ * direct PayPal SDK.
348
+ */
349
+ paypalPublishableKey?: string | null;
350
+ /**
351
+ * Per-session list of payment method type identifiers that the gateway has
352
+ * enabled for this consumer (e.g. `['apple_pay', 'google_pay', 'cashapp',
353
+ * 'klarna']`). Populated by the billing API after looking up the gateway's
354
+ * Payment Method Configurations. The SDK partitions this list against
355
+ * {@link STRIPE_EXPRESS_METHODS} to decide which methods render in the
356
+ * `ExpressCheckoutElement` row (Apple Pay / Google Pay / PayPal / Link /
357
+ * Amazon Pay / Klarna) vs the `PaymentElement` accordion (Cash App Pay /
358
+ * Affirm / iDEAL / Bancontact / …). `card` is never rendered by Stripe:
359
+ * starting with SDK 1.4.9, its presence explicitly advertises that the
360
+ * provider-neutral hosted card form can be recovered from
361
+ * `POST /v1/checkouts/sessions/{id}/vault/capture` when no embedded
362
+ * {@link CheckoutSession.vault} block is present. Absent on legacy backends.
363
+ * `SplitCardForm` uses this list to scope the retained wallet/APM surfaces.
364
+ * When a buyer selects one, the SDK requests a session-scoped intent for
365
+ * that explicit method. Card checkout uses the hosted vault.
366
+ */
367
+ enabledPaymentMethods?: string[];
368
+ /**
369
+ * Per-method buyer-country gate (uppercase ISO 3166-1 alpha-2), keyed by the
370
+ * same method strings as {@link enabledPaymentMethods}. A method absent here
371
+ * has no country restriction. The SDK filters the rendered tile row by the
372
+ * buyer's *live* country (which can change via AVS after the session is
373
+ * created) against this map — so per-method country eligibility lives in one
374
+ * place (the backend) rather than a hardcoded SDK table. Absent on legacy
375
+ * backends (the SDK then falls back to its built-in table).
376
+ */
377
+ enabledPaymentMethodCountries?: Record<string, string[]>;
378
+ /**
379
+ * PayPal object the backend selected for this checkout continuation — which
380
+ * PayPal JS flow the session needs. New backends advertise `'order'` or
381
+ * `'setup_token'` (legacy provider-managed subscriptions are expressed by
382
+ * omission, though `'subscription'` remains accepted for robustness). Absent
383
+ * → released fallback: `isSubscription ? 'subscription' : 'order'`. The
384
+ * backend suppresses this advertisement for `x-flo-sdk-version` readers
385
+ * older than 1.6.0 (header-less direct integrations always see it);
386
+ * advertisement only — routing follows the payment-method type the client
387
+ * requests. On `gateways.paypal`, {@link enabledPaymentMethods} may also
388
+ * carry an informational `'paypal_vaulted'` entry when the Flo-owned
389
+ * channel is available.
390
+ */
391
+ providerObjectType?: PayPalProviderObjectType;
392
+ /**
393
+ * Backend-advertised approval presentation for a one-time PayPal Order.
394
+ * Return URLs and resume capabilities remain backend-owned.
395
+ */
396
+ approvalPresentation?: PayPalApprovalPresentation;
397
+ }
398
+ /**
399
+ * Map of gateways attached to a session, keyed by gateway code. A session can
400
+ * advertise multiple gateways concurrently — e.g. `gateways.stripe` for card
401
+ * + wallets and `gateways.paypal` for direct PayPal rendering. A session
402
+ * created with the Worldpay capability may also carry
403
+ * `gateways.worldpayCorporateGateway` (TeamFloPay/backend#1563): a card
404
+ * gateway the billing API processes entirely server-side behind the hosted
405
+ * vault form, with no browser credentials or methods.
406
+ */
407
+ export interface CheckoutGateways {
408
+ stripe?: CheckoutGateway;
409
+ paypal?: CheckoutGateway;
410
+ [key: string]: CheckoutGateway | undefined;
411
+ }
412
+ /** Represents a FloPay checkout session. */
413
+ export interface CheckoutSession {
414
+ id: string;
415
+ clientSecret: string;
416
+ mode: 'payment' | 'subscription' | 'setup';
417
+ status: 'open' | 'authorized' | 'complete' | 'expired';
418
+ amount: number;
419
+ currency: string;
420
+ /** Capture behavior persisted by the billing API. Omitted on legacy sessions. */
421
+ captureMethod?: CaptureMethod;
422
+ /** FloPay payment transaction UUID used by the merchant capture REST route. */
423
+ paymentId?: string;
424
+ /** Provider authorisation deadline. Present while an authorisation is capturable. */
425
+ authorizationExpiresAt?: string;
426
+ /** Stable failure outcome when the authorization lifecycle did not settle. */
427
+ failureOutcome?: CheckoutFailureOutcome;
428
+ lineItems?: LineItem[];
429
+ /**
430
+ * Buyer data attached to this checkout. Anonymous sessions keep this object
431
+ * for routing/address fields, but omit unresolved identity fields until the
432
+ * buyer is identified.
433
+ */
434
+ customer?: Partial<Customer>;
435
+ /** Immutable client context returned by the FloPay checkout-session API. */
436
+ checkoutMetadata?: CheckoutMetadata;
437
+ metadata?: Record<string, string>;
438
+ checkoutMode?: CheckoutSessionMode;
439
+ /**
440
+ * Payment methods the billing API advertises on a setup session (backend#1846),
441
+ * exactly as received. Absent on older backends, which a card-only client may ignore.
442
+ */
443
+ advertisedPaymentMethods?: import('./saved-payment-methods.js').AdvertisedPaymentMethod[];
444
+ /**
445
+ * The usage the billing API sets every Stripe attempt of this session up for
446
+ * (platform policy, sdk#430 / backend#1989), exactly as the purchase or setup
447
+ * read returns it. Absent on older backends. Stripe Elements declare it
448
+ * through `resolveSetupFutureUsage`; the SDK never chooses or coerces it.
449
+ */
450
+ futureUse?: CardSetupFutureUse | null;
451
+ /**
452
+ * Methods the billing API cannot set up for future use, each with a reason,
453
+ * exactly as the read returns them (malformed entries dropped). A listed
454
+ * method declares no `setupFutureUsage` and stays payable one-off. Absent on
455
+ * older backends.
456
+ */
457
+ futureUseUnsupported?: FutureUseUnsupportedMethod[];
458
+ /** Whether the backend has resolved and attached a buyer to this session. */
459
+ buyerIdentified?: boolean;
460
+ /**
461
+ * Optional embedded hosted vault capture credentials
462
+ * (TeamFloPay/backend#823). This remains the preferred fast path during the
463
+ * SDK 1.4.9 rollout: when present, the SDK injects
464
+ * {@link VaultCaptureBlock.html} without a recovery request. A Stripe
465
+ * gateway whose `enabledPaymentMethods` explicitly includes `card`, or an
466
+ * open session with a server-side card gateway
467
+ * (`gateways.worldpayCorporateGateway`), may omit this block; the SDK then
468
+ * lazily requests `POST /v1/checkouts/sessions/{id}/vault/capture` when Card
469
+ * is opened.
470
+ */
471
+ vault?: VaultCaptureBlock;
472
+ /**
473
+ * Generic, provider-agnostic payment method identifier for a card already on
474
+ * file for the customer (TeamFloPay/backend#823). For the initial
475
+ * Stripe-behind-vault rollout this is the Stripe `pm_…` id, but the SDK
476
+ * treats it as an opaque card-method token. Present for returning customers
477
+ * so the SDK can skip the vault widget; `null`/absent otherwise.
478
+ */
479
+ providerPaymentMethodId?: string | null;
480
+ /** Unified products array as returned by post-#760 backends. */
481
+ products?: CheckoutSessionProduct[];
482
+ successUrl?: string;
483
+ cancelUrl?: string;
484
+ coupons?: string[];
485
+ /**
486
+ * Pre-discount total in cart-currency major units (e.g. 24.95). Populated by
487
+ * billing API ≥ v1.1.2; `undefined` on older backends — readers must fall
488
+ * back to summing per-line `totalAmount`.
489
+ */
490
+ subtotalAmount?: number;
491
+ /**
492
+ * Total reduction from applied coupons in cart-currency major units.
493
+ * Populated by billing API ≥ v1.1.2; `undefined` on older backends.
494
+ */
495
+ discountAmount?: number;
496
+ /**
497
+ * Final charge amount in cart-currency major units (subtotal − discount,
498
+ * clamped ≥ 0). Populated by billing API ≥ v1.1.2; `undefined` on older
499
+ * backends — readers must fall back to summing per-line `overrideAmount`.
500
+ */
501
+ totalAmount?: number;
502
+ createdAt?: string;
503
+ /**
504
+ * Per-gateway configuration. A session can advertise multiple concurrent
505
+ * gateways — read `gateways.stripe` for card/wallets, `gateways.paypal` for
506
+ * direct PayPal, and so on.
507
+ */
508
+ gateways?: CheckoutGateways;
509
+ accountData?: {
510
+ /** Null until an anonymous checkout is attached to a buyer. */
511
+ userId: string | null;
512
+ /** Null until an anonymous checkout is attached to a buyer. */
513
+ email: string | null;
514
+ firstName: string | null;
515
+ lastName: string | null;
516
+ gender?: string | null;
517
+ city?: string | null;
518
+ state?: string | null;
519
+ country?: string | null;
520
+ zip?: string | null;
521
+ };
522
+ tagsData?: TagsData;
523
+ }
524
+ /** The result of a payment confirmation attempt. */
525
+ export interface PaymentResult {
526
+ status: 'authorized' | 'succeeded' | 'processing' | 'requires_action' | 'failed';
527
+ /** FloPay payment transaction UUID, present for an authorised outcome. */
528
+ paymentId?: string;
529
+ /** Owning checkout session UUID, present for an authorised outcome. */
530
+ sessionId?: string;
531
+ /** Provider authorisation deadline, present while the hold is capturable. */
532
+ authorizationExpiresAt?: string;
533
+ paymentIntentId?: string;
534
+ paymentMethodId?: string;
535
+ checkoutMethod?: CheckoutButtonMethod;
536
+ error?: import('./errors.js').FloPayError;
537
+ }
538
+ /** Billing details passed to Stripe for AVS (Address Verification). */
539
+ export interface BillingDetails {
540
+ email?: string;
541
+ name?: string;
542
+ address?: {
543
+ country?: string;
544
+ postal_code?: string;
545
+ city?: string;
546
+ line1?: string;
547
+ line2?: string;
548
+ state?: string;
549
+ };
550
+ }
551
+ /** Result from the Stripe-hosted PayPal confirmation or redirect-resume flow. */
552
+ export interface PayPalPaymentResult {
553
+ status: 'succeeded' | 'processing' | 'requires_action' | 'requires_capture' | 'failed';
554
+ paymentIntentId?: string;
555
+ paymentMethodId?: string;
556
+ error?: import('./errors.js').FloPayError;
557
+ }
558
+ /** Non-card method families accepted by the public session intent endpoint. */
559
+ export type NonCardPaymentMethodCategory = 'wallet' | 'apm';
560
+ /**
561
+ * Stable identity of one buyer authorization attempt (a v4 UUID).
562
+ *
563
+ * The backend folds this into the provider idempotency key, so reusing the same
564
+ * value makes a transport retry reuse the *same* provider intent, while a fresh
565
+ * value deliberately starts a new authorization. Optional on the SDK request:
566
+ * `PaymentAPI.createSessionIntent` generates one when omitted and only advanced
567
+ * callers that drive their own retries need to pass a stable value.
568
+ */
569
+ interface SessionIntentAuthorizationAttempt {
570
+ authorizationAttemptId?: string;
571
+ }
572
+ /** Stripe wallet/APM request. Direct card is deliberately not representable. */
573
+ export interface StripeSessionIntentRequest extends SessionIntentAuthorizationAttempt {
574
+ provider: 'stripe';
575
+ paymentMethodCategory: NonCardPaymentMethodCategory;
576
+ paymentMethodType: string;
577
+ paymentMethodId: string | null;
578
+ intentKind: 'payment' | 'setup';
579
+ }
580
+ /** Fields shared by every direct PayPal intent request channel. */
581
+ interface PayPalSessionIntentRequestBase extends SessionIntentAuthorizationAttempt {
582
+ provider: 'paypal';
583
+ paymentMethodCategory: 'wallet';
584
+ paymentMethodId: null;
585
+ }
586
+ /**
587
+ * Legacy provider-managed channel. `paymentMethodType: 'paypal'` keeps the
588
+ * released contract byte-identical: always `intentKind: 'payment'`, and the
589
+ * backend derives Order vs provider-managed Subscription from the session.
590
+ */
591
+ interface PayPalLegacySessionIntentRequest extends PayPalSessionIntentRequestBase {
592
+ paymentMethodType: 'paypal';
593
+ intentKind: 'payment';
594
+ }
595
+ /**
596
+ * Flo-owned channel, payment continuation. `paymentMethodType:
597
+ * 'paypal_vaulted'` with `intentKind: 'payment'` requests a Flo-owned PayPal
598
+ * Order (advertised as `providerObjectType: 'order'`).
599
+ */
600
+ interface PayPalVaultedPaymentSessionIntentRequest extends PayPalSessionIntentRequestBase {
601
+ paymentMethodType: 'paypal_vaulted';
602
+ intentKind: 'payment';
603
+ }
604
+ /**
605
+ * Flo-owned channel, setup continuation. `paymentMethodType: 'paypal_vaulted'`
606
+ * with `intentKind: 'setup'` requests a PayPal vault setup token for an
607
+ * item-free deferred Flo-owned start (advertised as `providerObjectType:
608
+ * 'setup_token'`).
609
+ */
610
+ interface PayPalVaultedSetupSessionIntentRequest extends PayPalSessionIntentRequestBase {
611
+ paymentMethodType: 'paypal_vaulted';
612
+ intentKind: 'setup';
613
+ }
614
+ /**
615
+ * Direct PayPal intent request. The payment-method type is the in-band channel
616
+ * selector: `'paypal'` keeps provider-managed semantics, `'paypal_vaulted'`
617
+ * opts the request into the Flo-owned channel. The union makes the invalid
618
+ * combination (`'paypal'` with `intentKind: 'setup'`) unrepresentable.
619
+ */
620
+ export type PayPalSessionIntentRequest = PayPalLegacySessionIntentRequest | PayPalVaultedPaymentSessionIntentRequest | PayPalVaultedSetupSessionIntentRequest;
621
+ export type CreateSessionIntentRequest = StripeSessionIntentRequest | PayPalSessionIntentRequest;
622
+ export interface StripeSessionIntent extends StripeSessionIntentRequest {
623
+ clientSecret: string;
624
+ providerObjectId: string;
625
+ }
626
+ interface PayPalSessionIntentResponse {
627
+ clientSecret: null;
628
+ providerObjectId: string;
629
+ }
630
+ /**
631
+ * Direct PayPal intent response. The response echoes the request fields and
632
+ * correlates the selected provider object with the requested channel so
633
+ * impossible wire responses are not representable to SDK consumers:
634
+ *
635
+ * - `'paypal'` + `'payment'` ↔ `providerObjectType: 'order' | 'subscription'`
636
+ * - `'paypal_vaulted'` + `'payment'` ↔ `providerObjectType: 'order'`
637
+ * - `'paypal_vaulted'` + `'setup'` ↔ `providerObjectType: 'setup_token'`
638
+ */
639
+ export type PayPalSessionIntent = (PayPalLegacySessionIntentRequest & PayPalSessionIntentResponse & {
640
+ providerObjectType: 'order' | 'subscription';
641
+ }) | (PayPalVaultedPaymentSessionIntentRequest & PayPalSessionIntentResponse & {
642
+ providerObjectType: 'order';
643
+ }) | (PayPalVaultedSetupSessionIntentRequest & PayPalSessionIntentResponse & {
644
+ providerObjectType: 'setup_token';
645
+ });
646
+ export type SessionIntent = StripeSessionIntent | PayPalSessionIntent;
647
+ export type SessionIntentDeclineRequest = {
648
+ provider: 'stripe';
649
+ paymentMethodCategory: NonCardPaymentMethodCategory;
650
+ paymentMethodType: string;
651
+ /** Provider classification code only; messages and identifiers are rejected. */
652
+ providerDeclineReason: string;
653
+ /** Correlates the decline to a Stripe PaymentIntent returned by Flo; never telemetry. */
654
+ providerIntentId?: string;
655
+ } | {
656
+ provider: 'paypal';
657
+ paymentMethodCategory: 'wallet';
658
+ paymentMethodType: 'paypal';
659
+ /** Provider classification code only; messages and identifiers are rejected. */
660
+ providerDeclineReason: string;
661
+ };
662
+ /** Top-level configuration for initializing FloPay. */
663
+ export interface FloPayConfig {
664
+ publishableKey: string;
665
+ /** Billing API base URL (e.g. https://api.stage.flopay.com). */
666
+ billingApiUrl?: string;
667
+ /**
668
+ * Flo-owned privacy-safe operational telemetry. Enabled by default; set to
669
+ * `false` to opt out. This intentionally accepts no endpoint, tags, user
670
+ * context, messages, or custom metadata.
671
+ */
672
+ telemetry?: boolean;
673
+ locale?: string;
674
+ appearance?: FloPayAppearance;
675
+ apiVersion?: string;
676
+ }
677
+ /**
678
+ * Abstraction layer for payment providers.
679
+ *
680
+ * Currently only Stripe is implemented (`StripeAdapter`). The interface
681
+ * ensures that adding new providers (Chargebee, Recurly, etc.) will not
682
+ * require changes in consumer code.
683
+ */
684
+ export interface PaymentProviderAdapter {
685
+ readonly name: string;
686
+ initialize(config: FloPayConfig): Promise<void>;
687
+ /** Get the raw underlying provider instance (e.g. Stripe object). */
688
+ getRawProvider(): unknown;
689
+ destroy(): void;
690
+ }
691
+ /**
692
+ * Identifier for a card-capture backend that owns the hosted PCI card form.
693
+ * The SDK models card collection as a generic card method so additional
694
+ * vault/card providers can be added behind the same {@link CardCaptureAdapter}
695
+ * without changing the React card form. `'pcivault'` is the first (and
696
+ * currently only) implementation.
697
+ */
698
+ export type CardCaptureProviderId = 'pcivault';
699
+ /**
700
+ * Server-rendered hosted vault capture credentials (TeamFloPay/backend#823).
701
+ *
702
+ * Returned either as the optional embedded fast path on a card-capable
703
+ * session create/read response or from the explicit
704
+ * `POST /v1/checkouts/sessions/{id}/vault/capture` endpoint. `html` is a
705
+ * self-contained, Flo-bundled hosted-form widget (PCIVault card fields, its own
706
+ * submit button, status overlay, and — owned entirely by the backend — card
707
+ * tokenization, PaymentIntent creation/confirmation, 3DS, and decline display).
708
+ * The SDK injects `html` and steps back; PAN / CVC never enter the SDK runtime.
709
+ *
710
+ * `url` is the raw PCIVault submit endpoint the bundle POSTs to; it is surfaced
711
+ * for diagnostics and is not used directly by the Model-A (inject-the-widget)
712
+ * integration. The PCIVault submit *secret* is intentionally **not** part of
713
+ * this type — it is server-only and must never cross onto the public session
714
+ * surface (logs / telemetry / client inspection).
715
+ */
716
+ export interface VaultCaptureBlock {
717
+ /** Self-contained hosted-form widget HTML the SDK injects into the card slot. */
718
+ html?: string;
719
+ /** PCIVault submit URL the hosted form POSTs the captured card to. */
720
+ url?: string;
721
+ /**
722
+ * One-time integrity token minted by the backend and baked into the widget
723
+ * bootstrap. When present the SDK threads it into
724
+ * {@link CardCaptureMountOptions.messageToken} and rejects any terminal
725
+ * `postMessage` outcome whose {@link VaultCaptureResultMessage.messageToken}
726
+ * does not match — the primary defence against same-window forged outcomes
727
+ * (TeamFloPay/backend#823). It also authenticates the host's submit-label
728
+ * directive ({@link CardCaptureAdapter.setSubmitLabel}); embedded create,
729
+ * read, and claim blocks carry it from billing API v1.9.35.
730
+ */
731
+ messageToken?: string;
732
+ /**
733
+ * Exact origin the hosted widget posts its terminal outcomes from, when it
734
+ * runs in a cross-origin frame. When present the SDK rejects messages from
735
+ * any other origin, and it is the exact `postMessage` target of the
736
+ * submit-label directive.
737
+ */
738
+ expectedOrigin?: string;
739
+ /**
740
+ * Verification descriptor the backend adds when a human check is required
741
+ * before card capture. The SDK never renders the widget or reads `siteKey`.
742
+ */
743
+ verification?: {
744
+ required: boolean;
745
+ provider: 'turnstile';
746
+ siteKey?: string;
747
+ action?: string;
748
+ cData?: string;
749
+ };
750
+ }
751
+ /**
752
+ * Lifecycle / outcome events emitted by a {@link CardCaptureAdapter}.
753
+ *
754
+ * Under the Model-A (backend-orchestrated) vault flow the hosted widget owns
755
+ * the entire payment — capture, charge, and 3DS — so the SDK observes only:
756
+ * - `ready` — the widget mounted and is accepting input.
757
+ * - `complete`— the backend reported a successful (terminal) charge.
758
+ * - `decline` — the backend reported a declined / failed charge.
759
+ * - `error` — the widget failed to load, or an unexpected runtime error.
760
+ *
761
+ * `complete` / `decline` arrive via a `postMessage` from the hosted widget (see
762
+ * {@link VaultCaptureResultMessage}); the backend is responsible for emitting
763
+ * them. When it does not, the widget falls back to its own success redirect.
764
+ */
765
+ export type CardCaptureEventType = 'ready' | 'submitting' | 'complete' | 'decline' | 'error' | 'validation'
766
+ /**
767
+ * The buyer clicked the widget's submit button but the host had gated it
768
+ * (see {@link CardCaptureAdapter.setSubmitGate}) — the widget blocked its own
769
+ * charge so the host can surface its merchant-DOM validation (e.g. AVS) the
770
+ * same way the widget surfaces inline card validation.
771
+ */
772
+ | 'blocked'
773
+ /**
774
+ * The provider needs the buyer to complete an additional verification step
775
+ * (e.g. Stripe 3DS-2 challenge) before the payment can settle. The widget
776
+ * surfaces the provider-hosted challenge URL on the outcome event; the host
777
+ * should:
778
+ * 1. Hide its "processing" backdrop so the buyer can interact with the
779
+ * challenge (the widget renders the iframe at the parent page level
780
+ * so it isn't trapped inside the vault iframe).
781
+ * 2. Render the challenge — the SDK's default vault adapter creates a
782
+ * full-page overlay iframe pointing at `nextActionRedirectUrl`.
783
+ * The next `complete` / `decline` / `error` fires after the buyer finishes
784
+ * (or abandons) the challenge.
785
+ */
786
+ | 'action_required'
787
+ /**
788
+ * The buyer closed the verification challenge without finishing it. This is
789
+ * NOT an outcome: the hosted form keeps polling for the rest of its
790
+ * authentication window, and a late `complete` / `decline` / `error` still
791
+ * arrives — an out-of-band approval (e.g. the buyer's banking app) can
792
+ * settle after the challenge window is gone. It exists so the host can drop
793
+ * the processing backdrop it raised on `submitting` and leave the card form
794
+ * usable again, instead of holding the buyer behind a modal for the rest of
795
+ * that window.
796
+ */
797
+ | 'challenge_dismissed';
798
+ /** Payload for a {@link CardCaptureAdapter} outcome event. */
799
+ export interface CardCaptureOutcomeEvent {
800
+ /** Owning checkout session id, for correlation. */
801
+ sessionId?: string;
802
+ /** Provider-neutral terminal result. Absent on legacy widget messages. */
803
+ outcome?: 'authorized' | 'succeeded';
804
+ /** FloPay payment transaction UUID used by the merchant capture REST route. */
805
+ paymentId?: string;
806
+ /** Provider authorisation deadline while the hold is capturable. */
807
+ authorizationExpiresAt?: string;
808
+ /** Stable provider-neutral failure for decline/error outcomes. */
809
+ failureOutcome?: CheckoutFailureOutcome;
810
+ /**
811
+ * The processing gateway's reference on a terminal outcome, when available.
812
+ * A Stripe intent id only when Stripe took the card; a server-side card
813
+ * gateway (Worldpay) reports an opaque order reference instead.
814
+ */
815
+ intentId?: string;
816
+ /** Mapped decline reason on `decline` (backend `PaymentDeclineReason` enum). */
817
+ declineReason?: string;
818
+ /** Human-readable message for `decline` / `error`. */
819
+ message?: string;
820
+ /**
821
+ * Provider-hosted next-action URL the buyer must complete on
822
+ * `action_required` (e.g. Stripe 3DS-2 challenge page). Absent on every
823
+ * other event type.
824
+ */
825
+ nextActionRedirectUrl?: string;
826
+ /** Display-only saved card produced by a successful setup, when supplied. */
827
+ paymentMethod?: SavedCardDisplay;
828
+ }
829
+ /**
830
+ * `window.postMessage` payload the hosted vault widget sends its embedding SDK
831
+ * to report a terminal payment outcome.
832
+ *
833
+ * The widget HTML is injected **same-window** (see `PciVaultCardCapture`), so
834
+ * `event.origin` for a genuine outcome is the merchant page's own origin and
835
+ * the bare `source` string alone is forgeable by any other script on the page.
836
+ * Authenticity therefore rests on, in order of strength:
837
+ * 1. `messageToken` — an unguessable per-session token the backend bakes into
838
+ * the widget bootstrap and echoes here; the SDK rejects terminal outcomes
839
+ * that omit/mismatch it ({@link CardCaptureMountOptions.messageToken}).
840
+ * 2. `sessionId` — money-affecting outcomes (`complete` / `decline`) must be
841
+ * bound to the mounted session; the SDK rejects ones that are not.
842
+ * 3. `expectedOrigin` — an optional strict origin gate for widgets that post
843
+ * from a cross-origin frame ({@link CardCaptureMountOptions.expectedOrigin}).
844
+ */
845
+ export interface VaultCaptureResultMessage {
846
+ source: 'flopay-vault';
847
+ type: 'ready' | 'submitting' | 'complete' | 'decline' | 'error' | 'action_required';
848
+ /**
849
+ * Owning checkout session id. Always present for terminal outcomes
850
+ * (`complete` / `decline`) — the SDK rejects money-affecting outcomes that
851
+ * are not bound to the mounted session. May be absent on a pre-bootstrap
852
+ * `ready` / load-`error` the widget emits before the session is wired.
853
+ */
854
+ sessionId?: string;
855
+ /**
856
+ * Integrity token echoed from the widget bootstrap; must equal the value the
857
+ * SDK was mounted with ({@link CardCaptureMountOptions.messageToken}). When
858
+ * the SDK was given a token it rejects messages that omit or mismatch it.
859
+ */
860
+ messageToken?: string;
861
+ /** Provider-neutral terminal result. Absent on legacy widget messages. */
862
+ outcome?: 'authorized' | 'succeeded';
863
+ /** FloPay payment transaction UUID used by the merchant capture REST route. */
864
+ paymentId?: string;
865
+ /** Provider authorisation deadline while the hold is capturable. */
866
+ authorizationExpiresAt?: string;
867
+ /** Stable provider-neutral failure for decline/error outcomes. */
868
+ failureOutcome?: CheckoutFailureOutcome;
869
+ intentId?: string;
870
+ declineReason?: string;
871
+ message?: string;
872
+ /**
873
+ * Provider-hosted next-action URL the buyer must complete on
874
+ * `type === 'action_required'` (e.g. Stripe 3DS-2 challenge page). The host
875
+ * SDK renders the challenge at the parent page level so the buyer isn't
876
+ * blocked by the SDK's processing backdrop.
877
+ */
878
+ nextActionRedirectUrl?: string;
879
+ /** Display-only saved card produced by a successful setup, when supplied. */
880
+ paymentMethod?: SavedCardDisplay;
881
+ }
882
+ /** Options for mounting the hosted vault widget into a container element. */
883
+ export interface CardCaptureMountOptions {
884
+ /**
885
+ * Server-rendered hosted-form widget HTML (the vault capture block's `html`).
886
+ * The adapter injects this and lets the bundled `<script>` bootstrap the
887
+ * PCIVault form; the SDK does not own its fields or styling.
888
+ */
889
+ html: string;
890
+ /**
891
+ * Per-session integrity token (the vault block's `messageToken`). When
892
+ * supplied, the adapter rejects any `postMessage` outcome whose
893
+ * {@link VaultCaptureResultMessage.messageToken} does not match — closing the
894
+ * same-window forgery vector. Omit when the backend does not (yet) mint one.
895
+ */
896
+ messageToken?: string;
897
+ /**
898
+ * Exact origin expected for terminal `postMessage` outcomes (the vault
899
+ * block's `expectedOrigin`). When supplied, the adapter rejects messages from
900
+ * any other origin. Omit to skip the origin gate (default).
901
+ */
902
+ expectedOrigin?: string;
903
+ /**
904
+ * Merchant theme colors to apply to the hosted form. The SDK owns theming;
905
+ * the adapter pushes these into the (cross-origin) widget so the card form
906
+ * matches the surrounding checkout. Only provided keys are applied — the
907
+ * backend ships neutral defaults for the rest. Re-pushable at runtime via
908
+ * {@link CardCaptureAdapter.applyTheme} for live theme switches.
909
+ */
910
+ theme?: VaultCardThemeColors;
911
+ /**
912
+ * Initial wording for the hosted card form's final submit button (see
913
+ * {@link CardCaptureAdapter.setSubmitLabel} for live updates and the full
914
+ * contract). `null` is the explicit reset to the session default. Omit it to
915
+ * keep the label this adapter instance last received (replayed on `ready`);
916
+ * nothing is sent if it was never given one.
917
+ */
918
+ submitLabel?: string | null;
919
+ /**
920
+ * The mounted form sits behind the backend's production human check (the
921
+ * vault block's `verification.required`). An `error` the frame posts before
922
+ * the buyer submits is then the check's own state (failed, expired or
923
+ * unavailable) rather than a broken card form: it still reaches `error`
924
+ * listeners, but is not reported as a vault load failure.
925
+ */
926
+ verificationRequired?: boolean;
927
+ }
928
+ /**
929
+ * Merchant style values the SDK pushes into the hosted vault card form so it
930
+ * matches the surrounding checkout fields. The form's own surface stays
931
+ * transparent — these only drive the inputs, submit button, and overlay.
932
+ */
933
+ export interface VaultCardThemeColors {
934
+ /** Submit button background. */
935
+ primaryColor?: string;
936
+ /** Submit button hover background. */
937
+ primaryHoverColor?: string;
938
+ /** Card input fill (the surrounding form surface stays transparent). */
939
+ inputBackgroundColor?: string;
940
+ /** Input + selected-value text color. */
941
+ textColor?: string;
942
+ /** Input border color. */
943
+ borderColor?: string;
944
+ /** Input placeholder color. */
945
+ placeholderColor?: string;
946
+ /** Error/invalid border + overlay color. */
947
+ errorColor?: string;
948
+ /** Success overlay color. */
949
+ successColor?: string;
950
+ /** Input font family. */
951
+ fontFamily?: string;
952
+ /** Input font size (e.g. `16px`). */
953
+ fontSize?: string;
954
+ /**
955
+ * Input + placeholder font weight (e.g. `400`). Sent as a string so the
956
+ * hosted widget's string-only theme applier picks it up. Mirrors the SDK's
957
+ * `resolvedInputFontWeight` so the vault inputs match the AVS fields.
958
+ */
959
+ fontWeight?: string;
960
+ /** Outer corner radius for the grouped card inputs (e.g. `8px`). */
961
+ borderRadius?: string;
962
+ /**
963
+ * Complete snapshot for the backend-hosted submit control (billing API
964
+ * v1.9.6+). Additive: the flat keys above are still sent alongside it, so an
965
+ * older hosted asset ignores the object and keeps its solid approximation
966
+ * from `primaryColor` / `primaryHoverColor`. When present, the hosted asset
967
+ * clears the previous expanded submit treatment before applying the valid
968
+ * members, so omitted members never leak across live preset changes.
969
+ */
970
+ submitButton?: VaultSubmitButtonTheme;
971
+ }
972
+ /**
973
+ * Color forms the hosted asset accepts for expanded submit members:
974
+ * `#RRGGBB`, integer-channel `rgb(r, g, b)`, or `rgba(r, g, b, a)` with alpha
975
+ * `0..1`. Named colors, `var()`, `calc()`, URLs, and image functions are
976
+ * rejected by the widget and must not be sent.
977
+ */
978
+ export type VaultThemeColor = string;
979
+ /** Solid fill for the hosted submit control. */
980
+ export interface VaultSolidBackground {
981
+ type: 'solid';
982
+ color: VaultThemeColor;
983
+ }
984
+ /** One stop of a hosted submit gradient; `position` is a percentage `0..100`. */
985
+ export interface VaultGradientStop {
986
+ color: VaultThemeColor;
987
+ position: number;
988
+ }
989
+ /**
990
+ * Linear-gradient fill for the hosted submit control: `angle` in degrees
991
+ * (`0..360`) and two through five stops in non-decreasing position order.
992
+ */
993
+ export interface VaultLinearGradientBackground {
994
+ type: 'linearGradient';
995
+ angle: number;
996
+ stops: VaultGradientStop[];
997
+ }
998
+ /** Structured hosted submit fill — a solid color or a bounded linear gradient. */
999
+ export type VaultSubmitBackground = VaultSolidBackground | VaultLinearGradientBackground;
1000
+ /** Bounded typography for the hosted submit label. */
1001
+ export interface VaultSubmitTypography {
1002
+ /** One through four safe family tokens (letters, digits, spaces, hyphens; at most 32 characters each). */
1003
+ fontFamilies?: string[];
1004
+ /** Pixels, `10..32`. */
1005
+ fontSize?: number;
1006
+ /** Unitless integer, `100..900`. */
1007
+ fontWeight?: number;
1008
+ /** Em, `-0.1..0.5`. */
1009
+ letterSpacing?: number;
1010
+ /** Unitless, `0.8..2`. */
1011
+ lineHeight?: number;
1012
+ textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
1013
+ }
1014
+ /** Bounded padding for the hosted submit control, in pixels (`0..64`). */
1015
+ export interface VaultSubmitSpacing {
1016
+ paddingBlock?: number;
1017
+ paddingInline?: number;
1018
+ }
1019
+ /** One structured `box-shadow` layer for the hosted submit control. */
1020
+ export interface VaultShadowLayer {
1021
+ color: VaultThemeColor;
1022
+ inset: boolean;
1023
+ /** Pixels, `-64..64`. */
1024
+ offsetX: number;
1025
+ /** Pixels, `-64..64`. */
1026
+ offsetY: number;
1027
+ /** Pixels, `0..128`. */
1028
+ blur: number;
1029
+ /** Pixels, `-32..32`. */
1030
+ spread: number;
1031
+ }
1032
+ /**
1033
+ * Complete, bounded theme snapshot for the backend-hosted submit control
1034
+ * (`theme.submitButton` on the hosted form theme bridge, billing API v1.9.6+).
1035
+ * Every member is optional; the hosted asset ignores an invalid or out-of-range
1036
+ * member and keeps its legacy/neutral fallback, and theme input never blocks
1037
+ * card capture. Raw CSS is not part of this contract by design.
1038
+ */
1039
+ export interface VaultSubmitButtonTheme {
1040
+ /** Label color; the hosted default is white. */
1041
+ foregroundColor?: VaultThemeColor;
1042
+ /** Enabled fill. */
1043
+ background?: VaultSubmitBackground;
1044
+ /** Hover fill. */
1045
+ hoverBackground?: VaultSubmitBackground;
1046
+ /** Disabled fill (composited with {@link VaultSubmitButtonTheme.disabledOpacity}). */
1047
+ disabledBackground?: VaultSubmitBackground;
1048
+ typography?: VaultSubmitTypography;
1049
+ spacing?: VaultSubmitSpacing;
1050
+ /** Zero through four layers; an empty array renders no shadow. */
1051
+ shadow?: VaultShadowLayer[];
1052
+ /** Pixels, `0..9999`. */
1053
+ borderRadius?: number;
1054
+ /** Unitless, `0..1`; the hosted default is `0.5`. */
1055
+ disabledOpacity?: number;
1056
+ /** Pixels, `0..40`. */
1057
+ backdropBlur?: number;
1058
+ }
1059
+ /**
1060
+ * Abstraction for a hosted, PCI-scoped card capture widget. The React card
1061
+ * form depends only on this interface — never on Stripe element types — so the
1062
+ * card path stays decoupled from any specific card provider.
1063
+ *
1064
+ * Under the Model-A vault flow (TeamFloPay/backend#823) the widget is rendered
1065
+ * server-side and the backend orchestrates the whole charge (tokenize → create
1066
+ * + confirm PaymentIntent → 3DS → fulfilment). The SDK's only job is to inject
1067
+ * the widget HTML and relay its terminal `postMessage` outcome to the host
1068
+ * checkout. No Stripe.js is involved on the card path.
1069
+ */
1070
+ export interface CardCaptureAdapter {
1071
+ /** The card-capture backend backing this adapter. */
1072
+ readonly provider: CardCaptureProviderId;
1073
+ /** Inject the hosted widget HTML into `container` and bootstrap it. */
1074
+ mount(container: HTMLElement, options: CardCaptureMountOptions): Promise<void>;
1075
+ /** Subscribe to a lifecycle / outcome event. Returns an unsubscribe fn. */
1076
+ on(event: CardCaptureEventType, handler: (event: CardCaptureOutcomeEvent) => void): () => void;
1077
+ /**
1078
+ * Push merchant theme colors into the mounted widget (live). Lets the host
1079
+ * re-skin the card form on a runtime theme switch without a remount. `null`
1080
+ * is the explicit classic reset: the widget restores every historical
1081
+ * neutral value and the adapter retains the reset so a widget that becomes
1082
+ * ready later replays it. No-op before the widget is ready or if unsupported.
1083
+ */
1084
+ applyTheme?(theme: VaultCardThemeColors | null): void;
1085
+ /**
1086
+ * Gate the widget's submit button from the host. When `blocked` is `true`,
1087
+ * the widget cancels its own submit on the next click and emits a `'blocked'`
1088
+ * event instead of `'submitting'` — letting the host validate merchant-DOM
1089
+ * fields (e.g. AVS) and surface errors uniformly before any charge. The
1090
+ * latest gate is re-applied when the widget (re)becomes ready. No-op if
1091
+ * unsupported.
1092
+ */
1093
+ setSubmitGate?(blocked: boolean): void;
1094
+ /**
1095
+ * Push the card-field display/tab order into the widget (live), plus whether
1096
+ * the widget should move the cursor to its first field on load. `order` is a
1097
+ * permutation of the rows ({@link VaultCardFieldKey}); `null` restores the
1098
+ * default. `autoFocus` is `false` when the host renders AVS fields above the
1099
+ * widget (it focuses the first AVS field itself). Re-applied on `ready`.
1100
+ */
1101
+ setCardFieldOrder?(order: VaultCardFieldKey[] | null, autoFocus: boolean): void;
1102
+ /**
1103
+ * Set the hosted card form's final submit wording (live, billing API
1104
+ * v1.9.35+). The text replaces the button label in place, so the widget is
1105
+ * not remounted and buyer-entered card data is kept. Pass the final,
1106
+ * already-localized plain text (e.g. `'Pay $10'`); the hosted form
1107
+ * normalizes it, renders it as inert text, and falls back to its session
1108
+ * default — `CONFIRM PAYMENT` for payments, `ADD CARD` for card setup — for
1109
+ * blank or invalid text. `null` is the explicit reset to that default.
1110
+ *
1111
+ * The latest value is retained and replayed every time the widget
1112
+ * (re)becomes ready. The directive is posted only to the vault block's exact
1113
+ * `expectedOrigin`, bound to the mounted session and `messageToken`; a
1114
+ * widget mounted without those fields keeps its default. No-op if
1115
+ * unsupported.
1116
+ */
1117
+ setSubmitLabel?(label: string | null): void;
1118
+ /** Tear down the widget and release resources. */
1119
+ unmount(): void;
1120
+ }
1121
+ /**
1122
+ * The reorderable rows of the hosted vault card form. `'expiry'` is the combined
1123
+ * expiry + CVV row. The submit button always stays last.
1124
+ */
1125
+ export type VaultCardFieldKey = 'name' | 'number' | 'expiry';
1126
+ /** Supported upstream gateway codes. */
1127
+ export type BillingProvider = 'stripe' | 'paypal';
1128
+ /** PayPal continuation object selected by the billing backend. */
1129
+ export type PayPalProviderObjectType = 'order' | 'subscription' | 'setup_token';
1130
+ /** Backend-advertised non-popup approval modes for one-time PayPal Orders. */
1131
+ export type PayPalApprovalPresentation = 'app_switch' | 'redirect';
1132
+ /** Token payload produced by client-side tokenization. */
1133
+ export interface TokenizedBody {
1134
+ id?: string;
1135
+ type?: string;
1136
+ threeDSecureActionResultTokenId?: string;
1137
+ originalPaymentMethodId?: string;
1138
+ /**
1139
+ * @deprecated Use {@link TokenizedBody.gateway} + {@link TokenizedBody.paymentMethodType}.
1140
+ * Still populated by the SDK for PayPal compatibility as the boolean `true`,
1141
+ * never the string `"true"`. New integrations must route by `gateway` and
1142
+ * `paymentMethodType` instead.
1143
+ */
1144
+ isPaypal?: boolean;
1145
+ /**
1146
+ * Upstream gateway that produced the token. `'stripe'` covers every Stripe
1147
+ * payment method (card / wallets / Cash App Pay / Klarna / …); `'paypal'`
1148
+ * is set when DirectPayPalButton produced the token via the PayPal JS SDK.
1149
+ * Backend should route `/process` by `(gateway, paymentMethodType)` instead
1150
+ * of branching on `isPaypal` once consumers have adopted the new fields.
1151
+ */
1152
+ gateway?: BillingProvider | (string & {});
1153
+ /**
1154
+ * Concrete payment method type. For Stripe gateways this mirrors the Stripe
1155
+ * PaymentMethod.type value (`'card'`, `'apple_pay'`, `'google_pay'`,
1156
+ * `'cashapp'`, `'klarna'`, …). For PayPal it is the literal `'paypal'`.
1157
+ */
1158
+ paymentMethodType?: string;
1159
+ }
1160
+ /** Structured checkout-processing error returned by the billing API. */
1161
+ export interface CheckoutProcessError {
1162
+ type: string;
1163
+ /** Stable provider-neutral machine code supplied by the billing API. */
1164
+ code?: StoredPaymentMethodOutcomeCode;
1165
+ /** Stable provider-neutral failure outcome when supplied by the backend. */
1166
+ outcome?: CheckoutFailureOutcome;
1167
+ message?: string;
1168
+ transactionId?: string;
1169
+ /** Fresh PayPal Order/Subscription id used to resume Direct PayPal approval. */
1170
+ orderId?: string;
1171
+ threeDSecureToken?: string;
1172
+ paymentMethodId?: string;
1173
+ checkoutMethod?: CheckoutButtonMethod;
1174
+ advice?: string;
1175
+ gatewayErrorCode?: string;
1176
+ fields?: Array<{
1177
+ field: string;
1178
+ message: string;
1179
+ }>;
1180
+ /**
1181
+ * Provider-hosted next-action URL on `type === '3ds_required'` (e.g.
1182
+ * Stripe's hosted 3DS challenge page). Present on auto-checkout upsell
1183
+ * errors when the saved PM requires a fresh 3DS challenge — the SDK's
1184
+ * AutomaticPaymentButton mounts this URL in a full-page overlay iframe
1185
+ * so the buyer can authenticate without being demoted to a fresh
1186
+ * card-entry flow.
1187
+ */
1188
+ nextActionRedirectUrl?: string;
1189
+ }
1190
+ /** Recoverable checkout-processing state returned when fulfillment is still in progress. */
1191
+ export interface CheckoutProcessingPending {
1192
+ type: 'checkout_processing';
1193
+ sessionId: string;
1194
+ retryAfterMs: number;
1195
+ statusUrl?: string;
1196
+ sessionUrl?: string;
1197
+ }
1198
+ /** Checkout mode: tokenize client-side or redirect to hosted page. */
1199
+ export type CheckoutModeKind = 'tokenize' | 'redirect';
1200
+ /**
1201
+ * Provider-agnostic normalized checkout session. Backend may attach multiple
1202
+ * gateways per session — read each from `data.<gatewayCode>`.
1203
+ */
1204
+ export interface NormalizedCheckoutSession {
1205
+ /** Gateway codes advertised by the backend for this session, for diagnostics. */
1206
+ providers: BillingProvider[];
1207
+ mode: CheckoutModeKind;
1208
+ autoProcessingError?: CheckoutProcessError;
1209
+ autoProcessingAttempted?: boolean;
1210
+ autoProcessingPending?: CheckoutProcessingPending;
1211
+ /** Immutable client context returned by the FloPay checkout-session API. */
1212
+ checkoutMetadata?: CheckoutMetadata;
1213
+ data: {
1214
+ hostedUrl?: string;
1215
+ clientToken?: string;
1216
+ session?: CheckoutSession;
1217
+ stripe?: {
1218
+ clientSecret?: string;
1219
+ publishableKey?: string;
1220
+ /**
1221
+ * Optional dedicated Stripe sub-account publishable key for rendering
1222
+ * PayPal via Stripe Elements. When present and distinct, the saved-PM
1223
+ * resume flow loads a separate FloPay instance for the PayPal PI.
1224
+ */
1225
+ paypalPublishableKey?: string;
1226
+ environment?: GatewayEnvironment;
1227
+ /**
1228
+ * Mirrors {@link CheckoutGateway.enabledPaymentMethods}. Drives dynamic
1229
+ * `ExpressCheckoutElement` / `PaymentElement` rendering inside
1230
+ * `SplitCardForm` instead of the historic hardcoded Apple/Google/PayPal
1231
+ * set. Absent on backends that have not yet adopted the field.
1232
+ */
1233
+ enabledPaymentMethods?: string[];
1234
+ /** Mirrors {@link CheckoutGateway.enabledPaymentMethodCountries}. */
1235
+ enabledPaymentMethodCountries?: Record<string, string[]>;
1236
+ };
1237
+ /**
1238
+ * Direct PayPal gateway configuration. Present only when the backend has
1239
+ * configured a dedicated PayPal gateway for the consumer; absent means the
1240
+ * Stripe-rendered PayPal fallback should be used (if Stripe is configured).
1241
+ */
1242
+ paypal?: {
1243
+ publishableKey?: string;
1244
+ environment?: GatewayEnvironment;
1245
+ providerObjectType?: PayPalProviderObjectType;
1246
+ approvalPresentation?: PayPalApprovalPresentation;
1247
+ };
1248
+ };
1249
+ raw?: unknown;
1250
+ }
1251
+ /**
1252
+ * Two-phase result of a **detached** checkout-session create
1253
+ * (TeamFloPay/backend#1099).
1254
+ *
1255
+ * `shell` resolves first, from a create that ran no catalog validation and took
1256
+ * no buyer-identity advisory locks. It already carries the session id, nonce,
1257
+ * routed `gateways` and the hosted `vault` block, so the card form can mount
1258
+ * from it. It does **not** carry products, coupons, buyer identity or cart
1259
+ * totals — those arrive with `claimed`.
1260
+ *
1261
+ * `claimed` starts immediately and resolves when
1262
+ * `PATCH /v1/checkouts/sessions/{id}/claim` attaches the catalog. A draft with
1263
+ * email uses a combined catalog+buyer claim; an email-less draft omits
1264
+ * `accountData` and resolves with a fully-populated anonymous session whose
1265
+ * `buyerIdentified` marker is false. Nothing may be charged until it settles:
1266
+ * the billing API rejects process / intent / decline calls on an unclaimed
1267
+ * session with `409 checkout_session_data_attachment_required`, and its vault
1268
+ * webhook holds an unclaimed charge with a `503` until the claim lands.
1269
+ */
1270
+ export interface DetachedCheckoutSession {
1271
+ /** Lightweight shell — mountable card form, no cart or buyer data yet. */
1272
+ shell: NormalizedCheckoutSession;
1273
+ /** Session id of the shell, available before `claimed` settles. */
1274
+ sessionId: string;
1275
+ /** Session-bound checkout token, required by the claim and every later call. */
1276
+ nonce: string;
1277
+ /** Resolves with the catalog-attached session once the initial claim lands. */
1278
+ claimed: Promise<NormalizedCheckoutSession>;
1279
+ /**
1280
+ * Attach buyer identity collected after an email-less session's catalog was
1281
+ * attached. Sessions created with an email return `claimed` from this method.
1282
+ *
1283
+ * Once a claim has actually started, repeated calls return the same
1284
+ * replay-safe claim promise. A call rejected by *local* validation (e.g. a
1285
+ * missing or malformed email) does not consume the operation: it returns a
1286
+ * fresh rejected promise, so a later call with a valid email can still start
1287
+ * buyer attachment. Blank/null identity fields are omitted from the request.
1288
+ */
1289
+ claim(account?: Partial<CheckoutAccount>): Promise<NormalizedCheckoutSession>;
1290
+ }
1291
+ /** A one-time purchase item for checkout session creation. */
1292
+ export interface CheckoutItem {
1293
+ /**
1294
+ * Catalog code for the item — the preferred identifier. When omitted, the
1295
+ * deprecated `providerItemId` is used as a fallback.
1296
+ */
1297
+ code?: string;
1298
+ /**
1299
+ * @deprecated Use {@link CheckoutItem.code}. Still accepted as a fallback
1300
+ * when `code` is not provided.
1301
+ */
1302
+ providerItemId?: string;
1303
+ /**
1304
+ * Display-only name for the item. Takes priority over the deprecated
1305
+ * `providerItemName`. Backend resolves names from the catalog; pass this
1306
+ * to seed the client-side display cache for the post-redirect fetch.
1307
+ */
1308
+ itemName?: string | null;
1309
+ /** @deprecated Use {@link CheckoutItem.itemName}. Still accepted as a fallback when `itemName` is not provided. */
1310
+ providerItemName?: string | null;
1311
+ /** Defaults to 1. */
1312
+ quantity?: number;
1313
+ /** Display-only. Backend resolves prices from the catalog; pass this to seed the client-side display cache so the UI can render the regular price after redirect. */
1314
+ totalAmount?: number;
1315
+ /** Display-only. Backend ignores this entirely; pass this to seed the client-side display cache so the UI can render the discounted price after redirect. */
1316
+ overrideAmount?: number | null;
1317
+ /** @deprecated Prefer the session-level `currency` on {@link CreateSessionParams}/{@link InlineSessionParams}. */
1318
+ currency?: string;
1319
+ /** Arbitrary key/value metadata forwarded to the backend. */
1320
+ metadata?: Record<string, unknown> | null;
1321
+ }
1322
+ /**
1323
+ * Unified product input for checkout session creation. Mirrors the backend's
1324
+ * `CreateCheckoutProductBodyDto` introduced in #760 — the SDK accepts this
1325
+ * shape on `CreateSessionParams.products`. Callers using the legacy
1326
+ * {@link CheckoutItem} / {@link CheckoutSubscription} shapes do not need to
1327
+ * migrate; the SDK folds them into this shape internally.
1328
+ */
1329
+ export interface CheckoutProduct {
1330
+ /**
1331
+ * @deprecated Optional and no longer needed — the backend resolves item vs
1332
+ * subscription from the catalog `code`. Pass it only to refine the
1333
+ * client-side optimistic display rendered before the session response loads
1334
+ * (subscriptions are listed first). Safe to omit.
1335
+ */
1336
+ type?: CheckoutProductType;
1337
+ /** Catalog code — preferred identifier. */
1338
+ code?: string;
1339
+ /** @deprecated Falls back to {@link CheckoutProduct.code} for back-compat. */
1340
+ providerItemId?: string;
1341
+ /** @deprecated Falls back to {@link CheckoutProduct.code} for back-compat. */
1342
+ providerPlanId?: string;
1343
+ /** Display-only name for the product. */
1344
+ name?: string | null;
1345
+ /** @deprecated Use {@link CheckoutProduct.name}. */
1346
+ itemName?: string | null;
1347
+ /** @deprecated Use {@link CheckoutProduct.name}. */
1348
+ providerItemName?: string | null;
1349
+ /** @deprecated Use {@link CheckoutProduct.name}. */
1350
+ subscriptionName?: string | null;
1351
+ /** @deprecated Use {@link CheckoutProduct.name}. */
1352
+ providerPlanName?: string | null;
1353
+ /** Defaults to 1. */
1354
+ quantity?: number;
1355
+ /** Display-only. Backend resolves prices from the catalog. */
1356
+ totalAmount?: number;
1357
+ /** Display-only discount override. Backend ignores this entirely. */
1358
+ overrideAmount?: number | null;
1359
+ /** @deprecated Prefer the session-level `currency`. */
1360
+ currency?: string;
1361
+ metadata?: Record<string, unknown> | null;
1362
+ }
1363
+ /** A recurring subscription plan for checkout session creation. */
1364
+ export interface CheckoutSubscription {
1365
+ /**
1366
+ * Catalog code for the plan — the preferred identifier. When omitted, the
1367
+ * deprecated `providerPlanId` is used as a fallback.
1368
+ */
1369
+ code?: string;
1370
+ /**
1371
+ * @deprecated Use {@link CheckoutSubscription.code}. Still accepted as a
1372
+ * fallback when `code` is not provided.
1373
+ */
1374
+ providerPlanId?: string;
1375
+ /**
1376
+ * Display-only name for the subscription plan. Takes priority over the
1377
+ * deprecated `providerPlanName`. Backend resolves names from the catalog;
1378
+ * pass this to seed the client-side display cache for the post-redirect fetch.
1379
+ */
1380
+ subscriptionName?: string | null;
1381
+ /** @deprecated Use {@link CheckoutSubscription.subscriptionName}. Still accepted as a fallback when `subscriptionName` is not provided. */
1382
+ providerPlanName?: string | null;
1383
+ /** Defaults to 1. */
1384
+ quantity?: number;
1385
+ /** Display-only. Backend resolves prices from the catalog; pass this to seed the client-side display cache so the UI can render the regular price after redirect. */
1386
+ totalAmount?: number;
1387
+ /** Display-only. Backend ignores this entirely; pass this to seed the client-side display cache so the UI can render the discounted price after redirect. */
1388
+ overrideAmount?: number | null;
1389
+ /** @deprecated Prefer the session-level `currency` on {@link CreateSessionParams}/{@link InlineSessionParams}. */
1390
+ currency?: string;
1391
+ /** Arbitrary key/value metadata forwarded to the backend. */
1392
+ metadata?: Record<string, unknown> | null;
1393
+ }
1394
+ /** Buyer's account information for session creation. */
1395
+ export interface CheckoutAccount {
1396
+ userId: string;
1397
+ firstName?: string;
1398
+ lastName?: string;
1399
+ email: string;
1400
+ country?: string | null;
1401
+ gender?: string | null;
1402
+ city?: string | null;
1403
+ state?: string | null;
1404
+ zip?: string | null;
1405
+ /** Street address (line 1). */
1406
+ addressLine1?: string | null;
1407
+ /** Apt, suite, unit (line 2). */
1408
+ addressLine2?: string | null;
1409
+ }
1410
+ /** Analytics / pixel tags forwarded to the checkout page. */
1411
+ export interface TagsData {
1412
+ googleContainerId?: string | null;
1413
+ sessionId?: string | null;
1414
+ testEventCode?: string | null;
1415
+ }
1416
+ /**
1417
+ * Parameters for creating a checkout session via the billing API.
1418
+ * Mirrors the `CreateCheckoutSessionOptions` from clicktech-core-ui.
1419
+ */
1420
+ export interface CreateSessionParams {
1421
+ /** Base URL of the billing API, e.g. https://billing.clicktech.com */
1422
+ billingApiUrl: string;
1423
+ /** Base URL of the checkout frontend, e.g. https://checkout.clicktech.com */
1424
+ checkoutBaseUrl: string;
1425
+ /** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
1426
+ telemetry?: boolean;
1427
+ /** The client ID for the checkout session. */
1428
+ clientId: string;
1429
+ /**
1430
+ * Session-level ISO 4217 currency code. **Required** by post-#760
1431
+ * backends (`@IsNotEmpty`). The SDK resolves it from this field first,
1432
+ * then `items[0].currency`, then `subscriptions[0].currency`, then
1433
+ * `products[0].currency`. When none resolve, the SDK throws
1434
+ * `FloPayError('validation_error')` before issuing the HTTP request.
1435
+ */
1436
+ currency?: string;
1437
+ /**
1438
+ * Unified products array. When supplied, it is sent verbatim and
1439
+ * {@link CreateSessionParams.items} / {@link CreateSessionParams.subscriptions}
1440
+ * are ignored. Otherwise the SDK folds the legacy fields into this shape
1441
+ * before POSTing to the backend.
1442
+ */
1443
+ products?: CheckoutProduct[];
1444
+ /** One-time purchase items. Folded into `products[]` before send. */
1445
+ items?: CheckoutItem[];
1446
+ /** Recurring subscription plans. Folded into `products[]` before send. */
1447
+ subscriptions?: CheckoutSubscription[];
1448
+ /** Buyer's account information. */
1449
+ account: CheckoutAccount;
1450
+ /** URL to redirect to after successful payment. */
1451
+ successUrl: string;
1452
+ /** URL to redirect to if the user cancels. */
1453
+ cancelUrl: string;
1454
+ /**
1455
+ * Checkout mode sent to the billing API.
1456
+ * - 'confirm' – show a payment confirmation page (default)
1457
+ * - 'auto' – skip confirmation when a payment method is already on file
1458
+ * - 'full' – full checkout flow
1459
+ */
1460
+ checkoutMode?: 'confirm' | 'auto' | 'full';
1461
+ /**
1462
+ * Payment capture behavior. Omit (or use `'automatic'`) to preserve
1463
+ * immediate capture; use `'manual'` to authorise funds for later capture.
1464
+ * Manual capture is not supported for subscription products.
1465
+ */
1466
+ captureMethod?: CaptureMethod;
1467
+ /** Coupon codes to apply. */
1468
+ couponCodes?: string[];
1469
+ /** Non-sensitive client context preserved as an immutable checkout-lifecycle snapshot. */
1470
+ checkoutMetadata?: CheckoutMetadata | null;
1471
+ /** Pixel / analytics tags forwarded to the checkout page. */
1472
+ tagsData?: TagsData;
1473
+ /** Extra query params appended to the checkout redirect URL. */
1474
+ redirectParams?: Record<string, string>;
1475
+ /** Whether to set the checkout_data cookie. Defaults to true. */
1476
+ setCookie?: boolean;
1477
+ /** Request timeout in milliseconds. Defaults to 12000. */
1478
+ timeoutMs?: number;
1479
+ /** UTM and funnel tracking metadata. */
1480
+ utmMetadata?: Record<string, string | null | undefined>[];
1481
+ /**
1482
+ * Optional idempotency key identifying exactly **one** logical checkout
1483
+ * creation (TeamFloPay/backend#972). When supplied it is sent unchanged as
1484
+ * the `Idempotency-Key` header and reused across the SDK's transport retries,
1485
+ * so a timeout or lost response cannot mint a second session. Supply this to
1486
+ * keep the key stable across React remounts, multiple SDK instances, or
1487
+ * server retries you control; it **must not** be reused for a new purchase.
1488
+ * In browser flows (`@flopay/js` and `@flopay/react`), omitting the option
1489
+ * generates a fresh cryptographically random key for the SDK's retry loop.
1490
+ * `@flopay/node` has no internal retry loop, so omission sends no header and
1491
+ * the server integration owns key reuse across calls. Must be non-empty and
1492
+ * at most 255 characters when supplied.
1493
+ */
1494
+ idempotencyKey?: string;
1495
+ }
1496
+ /**
1497
+ * Parameters for inline session creation via `FloPayCheckout.createSession`.
1498
+ * Subset of `CreateSessionParams` — no redirect fields needed since the
1499
+ * component handles the checkout flow inline.
1500
+ */
1501
+ export interface InlineSessionParams {
1502
+ /** The client ID for the checkout session. */
1503
+ clientId: string;
1504
+ /**
1505
+ * Session-level ISO 4217 currency code. **Required** by post-#760
1506
+ * backends (`@IsNotEmpty`). The SDK resolves it from this field first,
1507
+ * then `items[0].currency`, then `subscriptions[0].currency`, then
1508
+ * `products[0].currency`. When none resolve, the SDK throws
1509
+ * `FloPayError('validation_error')` before issuing the HTTP request.
1510
+ */
1511
+ currency?: string;
1512
+ /**
1513
+ * Unified products array. When supplied, it is sent verbatim and
1514
+ * {@link InlineSessionParams.items} / {@link InlineSessionParams.subscriptions}
1515
+ * are ignored. Otherwise the SDK folds the legacy fields into this shape
1516
+ * before POSTing to the backend.
1517
+ */
1518
+ products?: CheckoutProduct[];
1519
+ /** One-time purchase items. Folded into `products[]` before send. */
1520
+ items?: CheckoutItem[];
1521
+ /** Recurring subscription plans. Folded into `products[]` before send. */
1522
+ subscriptions?: CheckoutSubscription[];
1523
+ /** Buyer's account information. */
1524
+ account: CheckoutAccount;
1525
+ /** URL to redirect to after successful payment. */
1526
+ successUrl: string;
1527
+ /** URL to redirect to if the user cancels. */
1528
+ cancelUrl: string;
1529
+ /** Checkout mode: 'full' (default), 'auto', or 'confirm'. */
1530
+ checkoutMode?: 'full' | 'auto' | 'confirm';
1531
+ /**
1532
+ * Payment capture behavior. Omit (or use `'automatic'`) to preserve
1533
+ * immediate capture; use `'manual'` to authorise funds for later capture.
1534
+ * Manual capture is not supported for subscription products.
1535
+ */
1536
+ captureMethod?: CaptureMethod;
1537
+ /** Optional saved/tokenized payment method for inline auto or confirm checkout. */
1538
+ tokenizedData?: TokenizedBody;
1539
+ /** Coupon codes to apply. */
1540
+ couponCodes?: string[];
1541
+ /** Non-sensitive client context preserved as an immutable checkout-lifecycle snapshot. */
1542
+ checkoutMetadata?: CheckoutMetadata | null;
1543
+ /** Pixel / analytics tags. */
1544
+ tagsData?: TagsData;
1545
+ /** UTM and funnel tracking metadata. */
1546
+ utmMetadata?: Record<string, string | null | undefined>[];
1547
+ /**
1548
+ * `timeoutMs` is the checkout-session request deadline in milliseconds and
1549
+ * defaults to 12000. During detached creation, the shell POST and initial catalogue claim PATCH
1550
+ * each receive this full budget independently. A one-shot create retains one
1551
+ * total deadline across its request, retries, and backoff.
1552
+ */
1553
+ timeoutMs?: number;
1554
+ /**
1555
+ * Optional idempotency key identifying exactly **one** logical checkout
1556
+ * creation (TeamFloPay/backend#972). When supplied it is sent unchanged as
1557
+ * the `Idempotency-Key` header and reused across the SDK's transport retries.
1558
+ * Supply this to keep the key stable across React remounts, multiple SDK
1559
+ * instances, or server retries you control; it **must not** be reused for a
1560
+ * new purchase. When omitted, the SDK generates a fresh, cryptographically
1561
+ * random key per create. Must be non-empty and at most 255 characters.
1562
+ */
1563
+ idempotencyKey?: string;
1564
+ /**
1565
+ * Opt out of **detached** session creation (TeamFloPay/backend#1099).
1566
+ *
1567
+ * Defaults to `true`: the SDK creates a lightweight session *shell* first
1568
+ * (`POST /v1/checkouts/sessions` with `deferDataAttachment: true`), mounts the
1569
+ * hosted card form from that response, then attaches buyer identity, address,
1570
+ * products and coupons in the background via
1571
+ * `PATCH /v1/checkouts/sessions/{id}/claim`. The shell create takes no
1572
+ * buyer-identity advisory locks and runs no catalog validation, so the card
1573
+ * form becomes interactive without waiting for either.
1574
+ *
1575
+ * Set to `false` to use the original one-shot create, which sends buyer and
1576
+ * catalog data in the single `POST` and returns the fully-populated session.
1577
+ * Behaviour is otherwise identical — the same session, callbacks and results.
1578
+ *
1579
+ * Detached creation requires `checkoutMode: 'full'` (the billing API rejects
1580
+ * `deferDataAttachment` for `auto` / `confirm`) and is skipped automatically
1581
+ * when {@link InlineSessionParams.tokenizedData} is supplied, since a
1582
+ * saved-payment session must carry its cart from the start.
1583
+ */
1584
+ deferDataAttachment?: boolean;
1585
+ /** Whether AVS is enabled for this checkout. */
1586
+ avsCheck?: boolean;
1587
+ /** Checkout type: 'standard_checkout' or 'embedded_checkout'. */
1588
+ checkoutType?: string;
1589
+ /** Checkout layout: 'default_layout', 'buttons_layout', or 'custom_layout'. */
1590
+ checkoutLayout?: string;
1591
+ /** AVS field configuration for analytics. */
1592
+ avsConfig?: AVSFieldConfig;
1593
+ }
1594
+ /** Payment methods exposed by the React buttons layout callbacks. */
1595
+ export type CheckoutButtonMethod = 'card' | 'paypal' | 'apple_pay' | 'google_pay';
1596
+ /**
1597
+ * Draft inline-session params used by `FloPayCheckout` before a real
1598
+ * checkout session has been created. Buttons-layout checkout can seed
1599
+ * placeholder account data up front; `onBeforeButtonClick` can still
1600
+ * update it before the selected payment button continues.
1601
+ */
1602
+ export interface InlineSessionDraft extends Omit<InlineSessionParams, 'account'> {
1603
+ account: Omit<CheckoutAccount, 'email'> & {
1604
+ email?: string;
1605
+ };
1606
+ }
1607
+ /**
1608
+ * Partial inline-session fields that can be returned from
1609
+ * `onBeforeButtonClick` and merged into the draft session params.
1610
+ */
1611
+ export interface InlineSessionPatch {
1612
+ account?: Partial<CheckoutAccount>;
1613
+ couponCodes?: string[];
1614
+ /** Replaces the draft checkout metadata as a whole value. */
1615
+ checkoutMetadata?: CheckoutMetadata | null;
1616
+ tagsData?: TagsData;
1617
+ utmMetadata?: Record<string, string | null | undefined>[];
1618
+ }
1619
+ /** Context passed to the `onBeforeButtonClick` callback for buttons-layout payment methods. */
1620
+ export interface BeforeButtonClickEvent {
1621
+ method: CheckoutButtonMethod;
1622
+ sessionId?: string;
1623
+ createSession?: InlineSessionDraft;
1624
+ }
1625
+ /** Structured decline event emitted by the React checkout components. */
1626
+ export interface DeclineEvent {
1627
+ method: CheckoutButtonMethod;
1628
+ message: string;
1629
+ code?: string;
1630
+ declineCode?: string;
1631
+ /**
1632
+ * The checkout session that was declined, when one exists: for matching the
1633
+ * decline to `payment.*` webhooks and the dashboard. Never the session nonce.
1634
+ */
1635
+ sessionId?: string;
1636
+ }
1637
+ /**
1638
+ * The buyer closed or left PayPal without approving: reported once per click
1639
+ * attempt by the direct PayPal button and forwarded by `SplitCardForm` and
1640
+ * `FloPayCheckout` (`onCancel` in React, the `cancel` event in Vue). It is
1641
+ * never reported for an approval, a decline or a technical failure.
1642
+ */
1643
+ export interface FloPayPaymentCancelEvent {
1644
+ status: 'cancelled';
1645
+ /** The attempt's session: the click-time patched session, else the button's. */
1646
+ sessionId: string;
1647
+ provider: 'paypal';
1648
+ /** `paypal_vaulted` on the Flo-owned vaulted channel, `paypal` otherwise. */
1649
+ paymentMethodType: 'paypal' | 'paypal_vaulted';
1650
+ }
1651
+ /** Result from creating a checkout session. */
1652
+ export type CheckoutSessionResult = {
1653
+ status: 201;
1654
+ redirectUrl: string;
1655
+ /**
1656
+ * Session-bound checkout token returned by the billing API alongside the
1657
+ * session UUID. Must be echoed back on every continuation request via the
1658
+ * `x-checkout-session-token` header — backend `TeamFloPay/backend#640`
1659
+ * matches this value against `checkout_session.nonce` to authorize the
1660
+ * call. Surfaced here so the redirect-style flow's caller can forward it
1661
+ * (e.g. into a hosted checkout page that hits continuation routes).
1662
+ */
1663
+ nonce: string;
1664
+ } | {
1665
+ status: 204;
1666
+ } | {
1667
+ status: number;
1668
+ };
1669
+ /**
1670
+ * Data submitted when processing a payment (tokenized card/wallet data).
1671
+ * Mirrors checkout project's ProcessCheckoutBodyDto.
1672
+ */
1673
+ export interface ProcessPaymentParams {
1674
+ sessionId: string;
1675
+ /** Privacy-safe payment-method family used to attribute processing telemetry. */
1676
+ paymentMethodCategory?: import('./telemetry.js').TelemetryPaymentMethodCategory;
1677
+ /**
1678
+ * Session-bound checkout token returned from session creation. Forwarded as
1679
+ * the `x-checkout-session-token` header on every call to
1680
+ * `POST /v1/checkouts/sessions/:id/process`. Required by post-#640 backends —
1681
+ * `PaymentAPI.processPayment` throws `MissingCheckoutSessionToken` when this
1682
+ * is missing or empty so the 401 fails fast on the client instead of after
1683
+ * the network round trip. Typed as optional so callers do not need to coerce
1684
+ * `undefined` to `''` to satisfy the type — pass the value through verbatim
1685
+ * and let `processPayment` surface the missing-token error.
1686
+ */
1687
+ nonce?: string;
1688
+ tokenizedData?: TokenizedBody;
1689
+ accountData: {
1690
+ userId: string;
1691
+ email: string;
1692
+ firstName?: string;
1693
+ lastName?: string;
1694
+ zip?: string;
1695
+ country?: string;
1696
+ city?: string;
1697
+ state?: string;
1698
+ addressLine1?: string;
1699
+ addressLine2?: string;
1700
+ };
1701
+ chv?: string;
1702
+ /** Current page URL for redirect-capable auth flows such as 3DS and PayPal. */
1703
+ returnUrl?: string;
1704
+ /** Whether AVS (Address Verification) was enabled for this checkout. */
1705
+ avsCheck?: boolean;
1706
+ /** Checkout type: 'standard_checkout' or 'embedded_checkout'. */
1707
+ checkoutType?: string;
1708
+ /** Checkout layout: 'default_layout', 'buttons_layout', or 'custom_layout'. */
1709
+ checkoutLayout?: string;
1710
+ /** AVS field configuration for analytics — which fields were shown. */
1711
+ avsConfig?: AVSFieldConfig;
1712
+ }
1713
+ /** Parameters for creating a customer. */
1714
+ export interface CreateCustomerParams {
1715
+ email: string;
1716
+ name?: string;
1717
+ metadata?: Record<string, string>;
1718
+ }
1719
+ /** Parameters for updating a customer. */
1720
+ export interface UpdateCustomerParams {
1721
+ email?: string;
1722
+ name?: string;
1723
+ metadata?: Record<string, string>;
1724
+ }
1725
+ /** A webhook event from FloPay. */
1726
+ export interface WebhookEvent {
1727
+ id: string;
1728
+ type: string;
1729
+ data: Record<string, unknown>;
1730
+ created: number;
1731
+ }
1732
+ /** Currency information mapped to a country. */
1733
+ export interface CurrencyInfo {
1734
+ currency: string;
1735
+ symbol: string;
1736
+ country: string;
1737
+ countryCode: string;
1738
+ /** 0 = no tax, 1 = tax (VAT) applies. */
1739
+ tax: number;
1740
+ }
1741
+ /** A country option for UI select elements. */
1742
+ export interface CountryOption {
1743
+ code: string;
1744
+ name: string;
1745
+ flag: string;
1746
+ }
1747
+ export {};