# Types Definition
# MountOptions
type Locale = "en-US" | "en-CA" | "fr-CA";
interface Card {
id: string;
type: string;
numberLast4: string;
expirationMonth?: number;
expirationYear?: number;
cardHolderFirstName?: string;
cardHolderLastName?: string;
};
interface DisplayComponents {
...
emailAddress?: boolean;
firstName?: boolean;
lastName?: boolean;
};
interface CardAgreementOptions {
businessName: string;
businessWebsite: string;
businessPhone: string;
style?: {
globalContainer?: Record<string, string>;
agreementContainer?: Record<string, string>;
title?: Record<string, string>;
closeIconContainer?: Record<string, string>;
closeIcon?: Record<string, string>;
mainText?: Record<string, string>;
businessNameText?: Record<string, string>;
businessWebsiteLink?: Record<string, string>;
businessPhoneText?: Record<string, string>;
actionButtonsContainer?: Record<string, string>;
acceptButton?: Record<string, string>;
declineButton?: Record<string, string>;
};
};
interface CustomCss {
...
cardOnFile?: {
container?: Record<string, string>;
wrapper?: Record<string, string>;
checkbox?: Record<string, string>;
label?: Record<string, string>;
agreement?: Record<string, string>;
link?: Record<string, string>;
};
};
interface MountOptions {
...
locale?: Locale;
displayComponents?: DisplayComponents;
additionalFieldsToValidate?: string[];
enableCardOnFile?: boolean;
forceSaveCardOnFile?: boolean;
CardAgreementOptions?: CardAgreementOptions;
savedCards?: Card[];
};
# ErrorResponse
interface Error {
message: string;
type: "invalid_details" | "missing_fields" | "card_on_file";
data: Record<string, any>;
source: "field" | "submit";
}
interface EventData {
error: Error;
};
interface ErrorResponse {
data: EventData;
type: "error";
};
# CardOnFileSelectResponse
interface EventData {
cardId: string | undefined;
};
interface CardOnFileCardSelectResponse {
data: EventData;
type: "card_on_file_card_select";
};
# NonceRequest
interface NonceRequest {
firstName: string;
lastName: string;
emailAddress: string;
};
# NonceResponse
interface CardAgreementMetadata {
lang: string;
countryCode: string;
businessName: string;
businessPhone: string;
businessWebsite: string;
};
interface CardAgreement {
email: string;
metadata: CardAgreementMetadata;
status: "ACCEPTED" | "DECLINED";
};
interface EventData {
...
nonce: string;
cardAgreement?: CardAgreement;
cardOnFile?: boolean;
firstName?: string;
lastName?: string;
emailAddress?: string;
};
interface NonceResponse {
data: EventData;
type: "nonce";
};