@flopay/shared 1.2.8 → 1.3.1
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 +25 -0
- package/dist/index.cjs +212 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +349 -6
- package/dist/index.d.ts +349 -6
- package/dist/index.mjs +197 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,8 @@ declare function networkError(message: string): FloPayError;
|
|
|
33
33
|
/** Theme variables that map to CSS custom properties on FloPay elements. */
|
|
34
34
|
interface FloPayThemeVariables {
|
|
35
35
|
colorPrimary?: string;
|
|
36
|
+
/** Hover background for all "flo" buttons (submit / card / wallet CTAs). */
|
|
37
|
+
colorPrimaryHover?: string;
|
|
36
38
|
colorBackground?: string;
|
|
37
39
|
colorText?: string;
|
|
38
40
|
colorDanger?: string;
|
|
@@ -58,14 +60,23 @@ interface ButtonsLayoutStyles {
|
|
|
58
60
|
cardFormContainer?: Record<string, string | number>;
|
|
59
61
|
/** Border color for card input fields. */
|
|
60
62
|
cardInputBorder?: string;
|
|
61
|
-
/** Text color inside
|
|
63
|
+
/** Text color inside the card input fields (number, expiry, CVC). */
|
|
62
64
|
cardInputColor?: string;
|
|
63
|
-
/** Placeholder text color for
|
|
65
|
+
/** Placeholder text color for the card input fields. */
|
|
64
66
|
cardInputPlaceholderColor?: string;
|
|
65
|
-
/** Font size for
|
|
67
|
+
/** Font size for the card input fields. */
|
|
66
68
|
cardInputFontSize?: string;
|
|
67
69
|
/** Background color for card input fields. */
|
|
68
70
|
cardInputBackground?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Opt-in escape hatch for vault-only style hooks that the appearance →
|
|
73
|
+
* hosted-field mapper cannot express. Merged last (last-write-wins) into the
|
|
74
|
+
* style config handed to the vault PCI card form, so these win over the
|
|
75
|
+
* auto-translated `cardInput*` knobs and `appearance.variables`. Keys are
|
|
76
|
+
* passed through verbatim — use vault-supported style property names.
|
|
77
|
+
* No effect on the legacy Stripe-Elements card path.
|
|
78
|
+
*/
|
|
79
|
+
vaultCardForm?: Record<string, string | number>;
|
|
69
80
|
/** Style for the full-name text input. */
|
|
70
81
|
nameInput?: Record<string, string | number>;
|
|
71
82
|
/** Style for the "Go back" button text/container. */
|
|
@@ -266,6 +277,16 @@ interface CheckoutGateway {
|
|
|
266
277
|
* card path stays on the split-fields elements. Absent on legacy backends.
|
|
267
278
|
*/
|
|
268
279
|
enabledPaymentMethods?: string[];
|
|
280
|
+
/**
|
|
281
|
+
* Per-method buyer-country gate (uppercase ISO 3166-1 alpha-2), keyed by the
|
|
282
|
+
* same method strings as {@link enabledPaymentMethods}. A method absent here
|
|
283
|
+
* has no country restriction. The SDK filters the rendered tile row by the
|
|
284
|
+
* buyer's *live* country (which can change via AVS after the session is
|
|
285
|
+
* created) against this map — so per-method country eligibility lives in one
|
|
286
|
+
* place (the backend) rather than a hardcoded SDK table. Absent on legacy
|
|
287
|
+
* backends (the SDK then falls back to its built-in table).
|
|
288
|
+
*/
|
|
289
|
+
enabledPaymentMethodCountries?: Record<string, string[]>;
|
|
269
290
|
}
|
|
270
291
|
/**
|
|
271
292
|
* Map of gateways attached to a session, keyed by gateway code. A session can
|
|
@@ -289,6 +310,23 @@ interface CheckoutSession {
|
|
|
289
310
|
customer?: Customer;
|
|
290
311
|
metadata?: Record<string, string>;
|
|
291
312
|
checkoutMode?: CheckoutMode;
|
|
313
|
+
/**
|
|
314
|
+
* Embedded hosted vault capture credentials (TeamFloPay/backend#823),
|
|
315
|
+
* populated on the `POST /v1/checkouts/sessions` response when the SDK
|
|
316
|
+
* declared `X-Flo-SDK-Version >= 1.3.0` and the backend advertises a
|
|
317
|
+
* `pcivault` gateway. The SDK injects {@link VaultCaptureBlock.html} as the
|
|
318
|
+
* card-capture widget. Absent on legacy backends or when the SDK must fetch
|
|
319
|
+
* the block via `POST /v1/checkouts/sessions/{id}/vault/capture` instead.
|
|
320
|
+
*/
|
|
321
|
+
vault?: VaultCaptureBlock;
|
|
322
|
+
/**
|
|
323
|
+
* Generic, provider-agnostic payment method identifier for a card already on
|
|
324
|
+
* file for the customer (TeamFloPay/backend#823). For the initial
|
|
325
|
+
* Stripe-behind-vault rollout this is the Stripe `pm_…` id, but the SDK
|
|
326
|
+
* treats it as an opaque card-method token. Present for returning customers
|
|
327
|
+
* so the SDK can skip the vault widget; `null`/absent otherwise.
|
|
328
|
+
*/
|
|
329
|
+
providerPaymentMethodId?: string | null;
|
|
292
330
|
/** Unified products array as returned by post-#760 backends. */
|
|
293
331
|
products?: CheckoutSessionProduct[];
|
|
294
332
|
successUrl?: string;
|
|
@@ -513,6 +551,262 @@ interface PaymentProviderAdapter {
|
|
|
513
551
|
createPayPalElements(options: ElementOptions): unknown;
|
|
514
552
|
destroy(): void;
|
|
515
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Identifier for a card-capture backend that owns the hosted PCI card form.
|
|
556
|
+
* The SDK models card collection as a generic card method so additional
|
|
557
|
+
* vault/card providers can be added behind the same {@link CardCaptureAdapter}
|
|
558
|
+
* without changing the React card form. `'pcivault'` is the first (and
|
|
559
|
+
* currently only) implementation.
|
|
560
|
+
*/
|
|
561
|
+
type CardCaptureProviderId = 'pcivault';
|
|
562
|
+
/**
|
|
563
|
+
* Server-rendered hosted vault capture credentials (TeamFloPay/backend#823).
|
|
564
|
+
*
|
|
565
|
+
* Returned either embedded on the `POST /v1/checkouts/sessions` response (when
|
|
566
|
+
* the SDK declared `X-Flo-SDK-Version >= 1.3.0`) or from the explicit
|
|
567
|
+
* `POST /v1/checkouts/sessions/{id}/vault/capture` endpoint. `html` is a
|
|
568
|
+
* self-contained, Flo-bundled hosted-form widget (PCIVault card fields, its own
|
|
569
|
+
* submit button, status overlay, and — owned entirely by the backend — card
|
|
570
|
+
* tokenization, PaymentIntent creation/confirmation, 3DS, and decline display).
|
|
571
|
+
* The SDK injects `html` and steps back; PAN / CVC never enter the SDK runtime.
|
|
572
|
+
*
|
|
573
|
+
* `url` is the raw PCIVault submit endpoint the bundle POSTs to; it is surfaced
|
|
574
|
+
* for diagnostics and is not used directly by the Model-A (inject-the-widget)
|
|
575
|
+
* integration. The PCIVault submit *secret* is intentionally **not** part of
|
|
576
|
+
* this type — it is server-only and must never cross onto the public session
|
|
577
|
+
* surface (logs / telemetry / client inspection).
|
|
578
|
+
*/
|
|
579
|
+
interface VaultCaptureBlock {
|
|
580
|
+
/** Self-contained hosted-form widget HTML the SDK injects into the card slot. */
|
|
581
|
+
html?: string;
|
|
582
|
+
/** PCIVault submit URL the hosted form POSTs the captured card to. */
|
|
583
|
+
url?: string;
|
|
584
|
+
/**
|
|
585
|
+
* One-time integrity token minted by the backend and baked into the widget
|
|
586
|
+
* bootstrap. When present the SDK threads it into
|
|
587
|
+
* {@link CardCaptureMountOptions.messageToken} and rejects any terminal
|
|
588
|
+
* `postMessage` outcome whose {@link VaultCaptureResultMessage.messageToken}
|
|
589
|
+
* does not match — the primary defence against same-window forged outcomes
|
|
590
|
+
* (TeamFloPay/backend#823).
|
|
591
|
+
*/
|
|
592
|
+
messageToken?: string;
|
|
593
|
+
/**
|
|
594
|
+
* Exact origin the hosted widget posts its terminal outcomes from, when it
|
|
595
|
+
* runs in a cross-origin frame. When present the SDK rejects messages from
|
|
596
|
+
* any other origin.
|
|
597
|
+
*/
|
|
598
|
+
expectedOrigin?: string;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Lifecycle / outcome events emitted by a {@link CardCaptureAdapter}.
|
|
602
|
+
*
|
|
603
|
+
* Under the Model-A (backend-orchestrated) vault flow the hosted widget owns
|
|
604
|
+
* the entire payment — capture, charge, and 3DS — so the SDK observes only:
|
|
605
|
+
* - `ready` — the widget mounted and is accepting input.
|
|
606
|
+
* - `complete`— the backend reported a successful (terminal) charge.
|
|
607
|
+
* - `decline` — the backend reported a declined / failed charge.
|
|
608
|
+
* - `error` — the widget failed to load, or an unexpected runtime error.
|
|
609
|
+
*
|
|
610
|
+
* `complete` / `decline` arrive via a `postMessage` from the hosted widget (see
|
|
611
|
+
* {@link VaultCaptureResultMessage}); the backend is responsible for emitting
|
|
612
|
+
* them. When it does not, the widget falls back to its own success redirect.
|
|
613
|
+
*/
|
|
614
|
+
type CardCaptureEventType = 'ready' | 'submitting' | 'complete' | 'decline' | 'error' | 'validation'
|
|
615
|
+
/**
|
|
616
|
+
* The buyer clicked the widget's submit button but the host had gated it
|
|
617
|
+
* (see {@link CardCaptureAdapter.setSubmitGate}) — the widget blocked its own
|
|
618
|
+
* charge so the host can surface its merchant-DOM validation (e.g. AVS) the
|
|
619
|
+
* same way the widget surfaces inline card validation.
|
|
620
|
+
*/
|
|
621
|
+
| 'blocked'
|
|
622
|
+
/**
|
|
623
|
+
* The provider needs the buyer to complete an additional verification step
|
|
624
|
+
* (e.g. Stripe 3DS-2 challenge) before the payment can settle. The widget
|
|
625
|
+
* surfaces the provider-hosted challenge URL on the outcome event; the host
|
|
626
|
+
* should:
|
|
627
|
+
* 1. Hide its "processing" backdrop so the buyer can interact with the
|
|
628
|
+
* challenge (the widget renders the iframe at the parent page level
|
|
629
|
+
* so it isn't trapped inside the vault iframe).
|
|
630
|
+
* 2. Render the challenge — the SDK's default vault adapter creates a
|
|
631
|
+
* full-page overlay iframe pointing at `nextActionRedirectUrl`.
|
|
632
|
+
* The next `complete` / `decline` / `error` fires after the buyer finishes
|
|
633
|
+
* (or abandons) the challenge.
|
|
634
|
+
*/
|
|
635
|
+
| 'action_required';
|
|
636
|
+
/** Payload for a {@link CardCaptureAdapter} outcome event. */
|
|
637
|
+
interface CardCaptureOutcomeEvent {
|
|
638
|
+
/** Owning checkout session id, for correlation. */
|
|
639
|
+
sessionId?: string;
|
|
640
|
+
/** Provider intent / transaction id on a terminal outcome, when available. */
|
|
641
|
+
intentId?: string;
|
|
642
|
+
/** Mapped decline reason on `decline` (backend `PaymentDeclineReason` enum). */
|
|
643
|
+
declineReason?: string;
|
|
644
|
+
/** Human-readable message for `decline` / `error`. */
|
|
645
|
+
message?: string;
|
|
646
|
+
/**
|
|
647
|
+
* Provider-hosted next-action URL the buyer must complete on
|
|
648
|
+
* `action_required` (e.g. Stripe 3DS-2 challenge page). Absent on every
|
|
649
|
+
* other event type.
|
|
650
|
+
*/
|
|
651
|
+
nextActionRedirectUrl?: string;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* `window.postMessage` payload the hosted vault widget sends its embedding SDK
|
|
655
|
+
* to report a terminal payment outcome.
|
|
656
|
+
*
|
|
657
|
+
* The widget HTML is injected **same-window** (see `PciVaultCardCapture`), so
|
|
658
|
+
* `event.origin` for a genuine outcome is the merchant page's own origin and
|
|
659
|
+
* the bare `source` string alone is forgeable by any other script on the page.
|
|
660
|
+
* Authenticity therefore rests on, in order of strength:
|
|
661
|
+
* 1. `messageToken` — an unguessable per-session token the backend bakes into
|
|
662
|
+
* the widget bootstrap and echoes here; the SDK rejects terminal outcomes
|
|
663
|
+
* that omit/mismatch it ({@link CardCaptureMountOptions.messageToken}).
|
|
664
|
+
* 2. `sessionId` — money-affecting outcomes (`complete` / `decline`) must be
|
|
665
|
+
* bound to the mounted session; the SDK rejects ones that are not.
|
|
666
|
+
* 3. `expectedOrigin` — an optional strict origin gate for widgets that post
|
|
667
|
+
* from a cross-origin frame ({@link CardCaptureMountOptions.expectedOrigin}).
|
|
668
|
+
*/
|
|
669
|
+
interface VaultCaptureResultMessage {
|
|
670
|
+
source: 'flopay-vault';
|
|
671
|
+
type: 'ready' | 'submitting' | 'complete' | 'decline' | 'error' | 'action_required';
|
|
672
|
+
/**
|
|
673
|
+
* Owning checkout session id. Always present for terminal outcomes
|
|
674
|
+
* (`complete` / `decline`) — the SDK rejects money-affecting outcomes that
|
|
675
|
+
* are not bound to the mounted session. May be absent on a pre-bootstrap
|
|
676
|
+
* `ready` / load-`error` the widget emits before the session is wired.
|
|
677
|
+
*/
|
|
678
|
+
sessionId?: string;
|
|
679
|
+
/**
|
|
680
|
+
* Integrity token echoed from the widget bootstrap; must equal the value the
|
|
681
|
+
* SDK was mounted with ({@link CardCaptureMountOptions.messageToken}). When
|
|
682
|
+
* the SDK was given a token it rejects messages that omit or mismatch it.
|
|
683
|
+
*/
|
|
684
|
+
messageToken?: string;
|
|
685
|
+
intentId?: string;
|
|
686
|
+
declineReason?: string;
|
|
687
|
+
message?: string;
|
|
688
|
+
/**
|
|
689
|
+
* Provider-hosted next-action URL the buyer must complete on
|
|
690
|
+
* `type === 'action_required'` (e.g. Stripe 3DS-2 challenge page). The host
|
|
691
|
+
* SDK renders the challenge at the parent page level so the buyer isn't
|
|
692
|
+
* blocked by the SDK's processing backdrop.
|
|
693
|
+
*/
|
|
694
|
+
nextActionRedirectUrl?: string;
|
|
695
|
+
}
|
|
696
|
+
/** Options for mounting the hosted vault widget into a container element. */
|
|
697
|
+
interface CardCaptureMountOptions {
|
|
698
|
+
/**
|
|
699
|
+
* Server-rendered hosted-form widget HTML (the vault capture block's `html`).
|
|
700
|
+
* The adapter injects this and lets the bundled `<script>` bootstrap the
|
|
701
|
+
* PCIVault form; the SDK does not own its fields or styling.
|
|
702
|
+
*/
|
|
703
|
+
html: string;
|
|
704
|
+
/**
|
|
705
|
+
* Per-session integrity token (the vault block's `messageToken`). When
|
|
706
|
+
* supplied, the adapter rejects any `postMessage` outcome whose
|
|
707
|
+
* {@link VaultCaptureResultMessage.messageToken} does not match — closing the
|
|
708
|
+
* same-window forgery vector. Omit when the backend does not (yet) mint one.
|
|
709
|
+
*/
|
|
710
|
+
messageToken?: string;
|
|
711
|
+
/**
|
|
712
|
+
* Exact origin expected for terminal `postMessage` outcomes (the vault
|
|
713
|
+
* block's `expectedOrigin`). When supplied, the adapter rejects messages from
|
|
714
|
+
* any other origin. Omit to skip the origin gate (default).
|
|
715
|
+
*/
|
|
716
|
+
expectedOrigin?: string;
|
|
717
|
+
/**
|
|
718
|
+
* Merchant theme colors to apply to the hosted form. The SDK owns theming;
|
|
719
|
+
* the adapter pushes these into the (cross-origin) widget so the card form
|
|
720
|
+
* matches the surrounding checkout. Only provided keys are applied — the
|
|
721
|
+
* backend ships neutral defaults for the rest. Re-pushable at runtime via
|
|
722
|
+
* {@link CardCaptureAdapter.applyTheme} for live theme switches.
|
|
723
|
+
*/
|
|
724
|
+
theme?: VaultCardThemeColors;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Merchant style values the SDK pushes into the hosted vault card form so it
|
|
728
|
+
* matches the SDK-rendered (Stripe) card fields. The form's own surface stays
|
|
729
|
+
* transparent — these only drive the inputs, submit button, and overlay.
|
|
730
|
+
*/
|
|
731
|
+
interface VaultCardThemeColors {
|
|
732
|
+
/** Submit button background. */
|
|
733
|
+
primaryColor?: string;
|
|
734
|
+
/** Submit button hover background. */
|
|
735
|
+
primaryHoverColor?: string;
|
|
736
|
+
/** Card input fill (the surrounding form surface stays transparent). */
|
|
737
|
+
inputBackgroundColor?: string;
|
|
738
|
+
/** Input + selected-value text color. */
|
|
739
|
+
textColor?: string;
|
|
740
|
+
/** Input border color. */
|
|
741
|
+
borderColor?: string;
|
|
742
|
+
/** Input placeholder color. */
|
|
743
|
+
placeholderColor?: string;
|
|
744
|
+
/** Error/invalid border + overlay color. */
|
|
745
|
+
errorColor?: string;
|
|
746
|
+
/** Success overlay color. */
|
|
747
|
+
successColor?: string;
|
|
748
|
+
/** Input font family. */
|
|
749
|
+
fontFamily?: string;
|
|
750
|
+
/** Input font size (e.g. `16px`). */
|
|
751
|
+
fontSize?: string;
|
|
752
|
+
/**
|
|
753
|
+
* Input + placeholder font weight (e.g. `400`). Sent as a string so the
|
|
754
|
+
* hosted widget's string-only theme applier picks it up. Mirrors the SDK's
|
|
755
|
+
* `resolvedInputFontWeight` so the vault inputs match the AVS fields.
|
|
756
|
+
*/
|
|
757
|
+
fontWeight?: string;
|
|
758
|
+
/** Outer corner radius for the grouped card inputs (e.g. `8px`). */
|
|
759
|
+
borderRadius?: string;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Abstraction for a hosted, PCI-scoped card capture widget. The React card
|
|
763
|
+
* form depends only on this interface — never on Stripe element types — so the
|
|
764
|
+
* card path stays decoupled from any specific card provider.
|
|
765
|
+
*
|
|
766
|
+
* Under the Model-A vault flow (TeamFloPay/backend#823) the widget is rendered
|
|
767
|
+
* server-side and the backend orchestrates the whole charge (tokenize → create
|
|
768
|
+
* + confirm PaymentIntent → 3DS → fulfilment). The SDK's only job is to inject
|
|
769
|
+
* the widget HTML and relay its terminal `postMessage` outcome to the host
|
|
770
|
+
* checkout. No Stripe.js is involved on the card path.
|
|
771
|
+
*/
|
|
772
|
+
interface CardCaptureAdapter {
|
|
773
|
+
/** The card-capture backend backing this adapter. */
|
|
774
|
+
readonly provider: CardCaptureProviderId;
|
|
775
|
+
/** Inject the hosted widget HTML into `container` and bootstrap it. */
|
|
776
|
+
mount(container: HTMLElement, options: CardCaptureMountOptions): Promise<void>;
|
|
777
|
+
/** Subscribe to a lifecycle / outcome event. Returns an unsubscribe fn. */
|
|
778
|
+
on(event: CardCaptureEventType, handler: (event: CardCaptureOutcomeEvent) => void): () => void;
|
|
779
|
+
/**
|
|
780
|
+
* Push merchant theme colors into the mounted widget (live). Lets the host
|
|
781
|
+
* re-skin the card form on a runtime theme switch without a remount. No-op
|
|
782
|
+
* before the widget is ready or if unsupported.
|
|
783
|
+
*/
|
|
784
|
+
applyTheme?(theme: VaultCardThemeColors): void;
|
|
785
|
+
/**
|
|
786
|
+
* Gate the widget's submit button from the host. When `blocked` is `true`,
|
|
787
|
+
* the widget cancels its own submit on the next click and emits a `'blocked'`
|
|
788
|
+
* event instead of `'submitting'` — letting the host validate merchant-DOM
|
|
789
|
+
* fields (e.g. AVS) and surface errors uniformly before any charge. The
|
|
790
|
+
* latest gate is re-applied when the widget (re)becomes ready. No-op if
|
|
791
|
+
* unsupported.
|
|
792
|
+
*/
|
|
793
|
+
setSubmitGate?(blocked: boolean): void;
|
|
794
|
+
/**
|
|
795
|
+
* Push the card-field display/tab order into the widget (live), plus whether
|
|
796
|
+
* the widget should move the cursor to its first field on load. `order` is a
|
|
797
|
+
* permutation of the rows ({@link VaultCardFieldKey}); `null` restores the
|
|
798
|
+
* default. `autoFocus` is `false` when the host renders AVS fields above the
|
|
799
|
+
* widget (it focuses the first AVS field itself). Re-applied on `ready`.
|
|
800
|
+
*/
|
|
801
|
+
setCardFieldOrder?(order: VaultCardFieldKey[] | null, autoFocus: boolean): void;
|
|
802
|
+
/** Tear down the widget and release resources. */
|
|
803
|
+
unmount(): void;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* The reorderable rows of the hosted vault card form. `'expiry'` is the combined
|
|
807
|
+
* expiry + CVV row. The submit button always stays last.
|
|
808
|
+
*/
|
|
809
|
+
type VaultCardFieldKey = 'name' | 'number' | 'expiry';
|
|
516
810
|
/** Supported upstream gateway codes. */
|
|
517
811
|
type BillingProvider = 'stripe' | 'paypal';
|
|
518
812
|
/** Token payload produced by client-side tokenization. */
|
|
@@ -556,6 +850,15 @@ interface CheckoutProcessError {
|
|
|
556
850
|
field: string;
|
|
557
851
|
message: string;
|
|
558
852
|
}>;
|
|
853
|
+
/**
|
|
854
|
+
* Provider-hosted next-action URL on `type === '3ds_required'` (e.g.
|
|
855
|
+
* Stripe's hosted 3DS challenge page). Present on auto-checkout upsell
|
|
856
|
+
* errors when the saved PM requires a fresh 3DS challenge — the SDK's
|
|
857
|
+
* AutomaticPaymentButton mounts this URL in a full-page overlay iframe
|
|
858
|
+
* so the buyer can authenticate without being demoted to a fresh
|
|
859
|
+
* card-entry flow.
|
|
860
|
+
*/
|
|
861
|
+
nextActionRedirectUrl?: string;
|
|
559
862
|
}
|
|
560
863
|
/** Recoverable checkout-processing state returned when fulfillment is still in progress. */
|
|
561
864
|
interface CheckoutProcessingPending {
|
|
@@ -599,6 +902,8 @@ interface NormalizedCheckoutSession {
|
|
|
599
902
|
* set. Absent on backends that have not yet adopted the field.
|
|
600
903
|
*/
|
|
601
904
|
enabledPaymentMethods?: string[];
|
|
905
|
+
/** Mirrors {@link CheckoutGateway.enabledPaymentMethodCountries}. */
|
|
906
|
+
enabledPaymentMethodCountries?: Record<string, string[]>;
|
|
602
907
|
};
|
|
603
908
|
/**
|
|
604
909
|
* Direct PayPal gateway configuration. Present only when the backend has
|
|
@@ -1007,7 +1312,17 @@ declare function getConfiguredBillingApiUrl(): string;
|
|
|
1007
1312
|
declare function getFloPayEnvironment(): FloPayEnvironment;
|
|
1008
1313
|
|
|
1009
1314
|
/** Current SDK version. */
|
|
1010
|
-
declare const SDK_VERSION = "1.
|
|
1315
|
+
declare const SDK_VERSION = "1.3.1";
|
|
1316
|
+
/**
|
|
1317
|
+
* HTTP header the SDK sends on `POST /v1/checkouts/sessions` so the backend
|
|
1318
|
+
* can decide whether to embed the vault capture block (the hosted PCI card
|
|
1319
|
+
* widget) in the create-session response. Backends at TeamFloPay/backend#823
|
|
1320
|
+
* only serve the embedded `vault` block to SDKs that declare `>= 1.3.0` here;
|
|
1321
|
+
* older SDKs are unaffected and keep the legacy Stripe card path.
|
|
1322
|
+
*
|
|
1323
|
+
* @see SDK_VERSION — the value sent in this header.
|
|
1324
|
+
*/
|
|
1325
|
+
declare const FLO_SDK_VERSION_HEADER = "x-flo-sdk-version";
|
|
1011
1326
|
/** Billing API URL for staging environment. */
|
|
1012
1327
|
declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
1013
1328
|
/** Billing API URL for production environment. */
|
|
@@ -1385,7 +1700,12 @@ declare function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFiel
|
|
|
1385
1700
|
* Check if an AVS field should be visible for the given country.
|
|
1386
1701
|
* - `undefined` / `false` → hidden
|
|
1387
1702
|
* - `true` → visible for all countries
|
|
1388
|
-
* - `string[]` → visible only for listed country codes
|
|
1703
|
+
* - `string[]` (non-empty) → visible only for listed country codes
|
|
1704
|
+
* - `[]` (empty) → visible for no countries; use `true` to show everywhere.
|
|
1705
|
+
* A UI that wants "clear the country list = show everywhere" must normalize
|
|
1706
|
+
* the cleared list to `true` before persisting — preserves the historical
|
|
1707
|
+
* `[]` = "off" semantics so existing configs don't start rendering AVS
|
|
1708
|
+
* globally.
|
|
1389
1709
|
*/
|
|
1390
1710
|
declare function isAVSFieldVisible(field: boolean | string[] | undefined, country: string): boolean;
|
|
1391
1711
|
/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */
|
|
@@ -1424,6 +1744,29 @@ declare function getStateLabel(countryCode: string): string;
|
|
|
1424
1744
|
*/
|
|
1425
1745
|
declare function getStateFromPostalCode(country: string, postalCode: string): string | null;
|
|
1426
1746
|
|
|
1747
|
+
/**
|
|
1748
|
+
* True when `validator` has an authoritative postcode pattern for the country
|
|
1749
|
+
* (ISO 3166-1 alpha-2, case-insensitive). Supported countries validate the
|
|
1750
|
+
* postcode format; unsupported / no-postcode countries fail open.
|
|
1751
|
+
*/
|
|
1752
|
+
declare function isPostalCodeSupported(country: string): boolean;
|
|
1753
|
+
/**
|
|
1754
|
+
* Validate a postcode against the country's expected format.
|
|
1755
|
+
*
|
|
1756
|
+
* - Unsupported / no-postcode country → `true` (fail open; never block).
|
|
1757
|
+
* - Supported country → `validator`'s `isPostalCode(zip, locale)` on the
|
|
1758
|
+
* trimmed value. An empty string is not a valid postcode, so a supported
|
|
1759
|
+
* country with an empty value returns `false`; callers that distinguish
|
|
1760
|
+
* "required" (empty) from "malformed" (format) should check emptiness first.
|
|
1761
|
+
*/
|
|
1762
|
+
declare function isValidPostalCode(country: string, postalCode: string): boolean;
|
|
1763
|
+
/**
|
|
1764
|
+
* A curated example postcode for the country (e.g. US `12345 or 12345-6789`,
|
|
1765
|
+
* GB `SW1A 1AA`, CA `A1A 1A1`), or `undefined` when there is no curated example
|
|
1766
|
+
* (unsupported country, or a supported country not in the map).
|
|
1767
|
+
*/
|
|
1768
|
+
declare function getPostalCodeExample(country: string): string | undefined;
|
|
1769
|
+
|
|
1427
1770
|
/** A single line item formatted for display in the checkout UI. */
|
|
1428
1771
|
interface DisplayLineItem {
|
|
1429
1772
|
name: string;
|
|
@@ -1555,4 +1898,4 @@ declare function isValidSecretKey(key: string): boolean;
|
|
|
1555
1898
|
*/
|
|
1556
1899
|
declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
|
|
1557
1900
|
|
|
1558
|
-
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 ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, 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 StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isSetupIntentClientSecret, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
|
|
1901
|
+
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 ButtonsLayoutStyles, type ButtonsLayoutTheme, CA_PROVINCES, COUNTRY_OPTIONS, CURRENCY_MAP, type CardCaptureAdapter, type CardCaptureEventType, type CardCaptureMountOptions, type CardCaptureOutcomeEvent, type CardCaptureProviderId, type CheckoutAccount, type CheckoutButtonMethod, type CheckoutDisplayData, type CheckoutGateway, type CheckoutGateways, type CheckoutItem, type CheckoutMode, type CheckoutModeKind, type CheckoutProcessError, type CheckoutProcessingPending, type CheckoutProduct, type CheckoutProductType, type CheckoutSession, type CheckoutSessionProduct, type CheckoutSessionResult, type CheckoutSubscription, type ConfirmCardPaymentParams, type ConfirmCardPaymentResult, type ConfirmPaymentParams, type CountryOption, type CreateCustomerParams, type CreatePaymentMethodResult, type CreateSessionParams, type CurrencyInfo, type Customer, DEFAULT_API_BASE_URL, DEFAULT_API_VERSION, DEFAULT_APPEARANCE, DEFAULT_CURRENCY, type DeclineEvent, type DisplayLineItem, ELEMENT_TYPES, type ElementChangeEvent, type ElementOptions, type ElementType, FLAT_APPEARANCE, FLO_SDK_VERSION_HEADER, type FloPayAppearance, type FloPayConfig, type FloPayEnvironment, FloPayError, type FloPayErrorType, type FloPayThemeVariables, GLASS_DARK_APPEARANCE, GLASS_LIGHT_APPEARANCE, type GatewayEnvironment, type InlineSessionDraft, type InlineSessionParams, type InlineSessionPatch, type LineItem, MODERN_DARK_APPEARANCE, MODERN_LIGHT_APPEARANCE, type MountedElement, NIGHT_APPEARANCE, type NormalizedCheckoutSession, type NormalizedGatewayEnvironment, 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 StateOption, type StripeMethodEntry, type StripeMethodThemeVariant, THEMES, type TagsData, type ThemeBundle, type ThemeBundleId, type ThemeId, type TokenizedBody, US_STATES, type UpdateCustomerParams, type VaultCaptureBlock, type VaultCaptureResultMessage, type VaultCardFieldKey, type VaultCardThemeColors, type WebhookEvent, apiError, authenticationError, buildCheckoutDisplayData, buildItemPayload, buildProductPayload, buildSubscriptionPayload, configureFlopay, filterStripeMethodsByAmount, filterStripeMethodsByCountry, filterStripeMethodsByCurrency, foldIntoProducts, getConfiguredBillingApiUrl, getCountryByCode, getCurrencyByCountry, getFloPayEnvironment, getPostalCodeExample, getPostalCodeLabel, getStateFromPostalCode, getStateLabel, getStateOptions, getStripeMethodDisplayName, hasVendoredStripeMethodLogo, isAVSEnabled, isAVSFieldVisible, isPostalCodeSupported, isSetupIntentClientSecret, isValidPostalCode, isValidPublishableKey, isValidSecretKey, needsStripeMethodExplicitConfirm, networkError, normalizeGatewayEnvironment, partitionStripeMethods, rateLimitError, resolveAVSConfig, resolveBillingApiUrl, resolveButtonsLayoutTheme, resolveSessionCurrency, resolveStripeMethodBrandVariant, resolveTheme, stripeExpressMethodToOptionKey, validationError };
|