import { EnvironmentOptions } from '../../../types/internal'; import UseCase from '../../../interfaces/UseCase/types'; export declare enum SdkCommandName { CLEAR_INPUT = "clear_input", FOCUS_INPUT = "focus_input", SUBMIT_CARD_NUMBER = "submit_card_number", SUBMIT_BALANCE_CHECK = "submit_balance_check", SUBMIT_PAYMENT_CAPTURE = "submit_payment_capture", SUBMIT_DEFER_PAYMENT_CAPTURE = "submit_defer_payment_capture", INITIALIZE_IFRAME = "initialize_iframe" } export interface SdkCommand { name: T; payload?: Record; } export interface SubmitPayload { sessionToken: string; merchantId: string; customerId: string | null; } export interface StyleRules { borderColor?: string | null; borderWidth?: string | null; } export interface Style { placeholder?: string | null; rules: StyleRules; } export interface Appearance { variables?: { colorPlaceholderText?: string; colorText?: string; colorBackground?: string; padding?: string; boxShadow?: string; fontWeightNormal?: string; fontSizeBase?: string; fontLineHeight?: string; fontFamily?: string; borderRadius?: string; }; } export type PaymentSheetType = 'HSAFSA' | 'UNSET'; export type PaymentSheetFieldName = 'cardHolderName' | 'cardNumber' | 'cardExpiration' | 'cardCVV' | 'cardZipCode'; export type FieldStyles = Partial>; export interface PaymentSheetFieldStyles { labelStyles?: FieldStyles; inputStyles?: FieldStyles; } export interface PaymentSheetFieldConfig { /** label text that will be placed on the field */ labelText: string; /** optional placeholder text value */ placeholderText?: string; /** bespoke styles that will override the common styles settings on the PaymentSheet */ styles?: PaymentSheetFieldStyles; } export interface PaymentSheetConfig { paymentType: PaymentSheetType; /** default styles will cascade to fields */ styles: PaymentSheetFieldStyles; /** default error styles */ errorStyles: PaymentSheetFieldStyles; fields: Record; } export interface IframeConfig { sdkClientOrigin: string | null; frameId: string | null; merchantId: string | null; sessionToken: string | null; env: EnvironmentOptions | null; usecase: UseCase | null; style?: Style; appearance?: Appearance; paymentSheet?: PaymentSheetConfig; /** package version of this SDK, e.g. '1.3.2' */ sdkVersion: string; /** package name of this SDK build, e.g. 'forage-js-sdk' */ sdkName: string; } export interface InitializeIframeCmd extends SdkCommand { name: SdkCommandName.INITIALIZE_IFRAME; payload: IframeConfig; } export interface ClearInputCmd extends SdkCommand { name: SdkCommandName.CLEAR_INPUT; } export interface FocusInputCmd extends SdkCommand { name: SdkCommandName.FOCUS_INPUT; } export interface SubmitCardNumberCmd extends SdkCommand { name: SdkCommandName.SUBMIT_CARD_NUMBER; payload: SubmitPayload & { reusable?: boolean; }; } export interface SubmitBalanceCheckCmd extends SdkCommand { name: SdkCommandName.SUBMIT_BALANCE_CHECK; payload: SubmitPayload & { paymentMethodRef: string; }; } export interface SubmitPaymentCaptureCmd extends SdkCommand { name: SdkCommandName.SUBMIT_PAYMENT_CAPTURE; payload: SubmitPayload & { paymentRef: string; }; } export interface SubmitDeferPaymentCaptureCmd extends SdkCommand { name: SdkCommandName.SUBMIT_DEFER_PAYMENT_CAPTURE; payload: SubmitPayload & { paymentRef: string; }; } export type SdkCmdHandler = (event: MessageEvent) => void; export type SdkCmdCallback = (o: T['payload']) => void; export type SdkCmdListener = (cb: SdkCmdCallback) => SdkCmdHandler; export type CmdPayload = T['payload']; export type CmdFactory = (payload: CmdPayload) => T;