import { Events, THREE_DS_WINDOW_SIZES } from './constants'; import type * as CSS from 'csstype'; export type PaymentMethod = { id: string; scheme: string; }; export type Config = { environment?: 'sandbox' | 'production'; gr4vyId: string; /** * @deprecated Use `paymentMethod` instead. This prop will be removed in a future version. */ paymentMethodId?: string; paymentMethod?: PaymentMethod; sessionId: string; }; export type InputConfig = { frameUrl: string; parentOrigin: string; font?: string; sessionId?: string; gr4vyId?: string; environment?: string; options: Field; paymentMethodScheme?: string; }; export type FieldType = 'number' | 'securityCode' | 'expiryDate' | 'postalCode'; export type AutoAdvanceConfig = { enabled: boolean; fieldOrder?: FieldType[]; }; export type FieldMaskConfig = { character?: string; showLastFour?: boolean; maskOnInput?: boolean; }; export type Field = { type: FieldType; placeholder?: string; styles?: Styles; label?: string; lengths?: Array; size?: number; autoFocus?: boolean; maskInput?: boolean | FieldMaskConfig; showSchemeIcons?: boolean | { scheme?: boolean; additionalSchemes?: boolean; placeholders?: boolean; }; maxlength?: number; }; export type FieldEventType = keyof HTMLElementEventMap | 'redacted' | 'unredacted' | 'card-details-changed'; export type FieldEvent = { type: FieldEventType; data: Omit & { id: Field['type']; valid: boolean; autofilled: boolean; empty: boolean; expired?: boolean; schema?: string; scheme?: string | null; additionalSchemes?: string[]; bin?: string | null; complete?: boolean; fromBlur?: boolean; isDeleteInputType?: boolean; }; }; export type CombinedEvents = Events | FieldEventType; export type Event = Events | `${FieldType}:${FieldEventType}`; export type SupportedCSSProperties = Partial>; export type SupportedCSSVariables = { [K in keyof SupportedCSSProperties as `--${K}`]: SupportedCSSProperties[K]; }; export type Styles = { [key in ':autofill' | ':hover' | ':focus' | ':disabled' | ':valid' | ':invalid' | ':masked' | '::placeholder']?: SupportedCSSProperties; } & SupportedCSSProperties; export type StylesTuple = [string, string][]; export type FormChangeEventData = { fields: { number: { valid: boolean; empty: boolean; autofilled: boolean; }; expiryDate: { valid: boolean; empty: boolean; autofilled: boolean; expired?: boolean; }; securityCode: { valid: boolean; empty: boolean; autofilled: boolean; }; }; complete: boolean; }; export type ClickToPayOptions = { srcDpaId?: string; dpaName?: string; cardBrands: Array<'mastercard' | 'maestro' | 'visa' | 'amex' | 'discover'>; dpaLocale: string; cardForm?: string | HTMLElement; signIn?: string | HTMLElement; consentCheckbox?: string | HTMLElement; rememberMeCheckbox?: string | HTMLElement; learnMoreLink?: string | HTMLElement; email?: string; mobileNumber?: { countryCode: string; phoneNumber: string; }; dynamicDataType?: 'NONE' | 'CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM'; authenticate?: { consumer?: boolean; checkout?: boolean; }; }; export type ClickToPayCheckoutOptions = { transactionAmount?: number; transactionCurrencyCode?: string; }; export type ClickToPayInstance = { element: HTMLElement; options: ClickToPayOptions; signIn: ({ email, mobileNumber, }: Partial>) => Promise; signOut: () => Promise; updateCheckoutOptions: (options: ClickToPayCheckoutOptions) => void; }; export type ThreeDSecureOptions = { challengeWindowSize?: (typeof THREE_DS_WINDOW_SIZES)[number]; };