export declare interface AbstractIntent { id: string; status: IntentStatus; amount: { value: string; currency: string; formatted: number; maxPayout?: number | null; }; subtotalAmount: string | null; fees: Array | null; totalDiscounts: string | null; secret: string; isLive: boolean; } export declare type ApplePayMerchantSession = any; export declare type AuthorizeOperationStatus = "pending" | "pending_authentication" | "failed" | "successful"; export declare interface BankAccount { id: string; bankIdentifier: string; status: "PENDING" | "ACTIVE" | "INACTIVE"; accounts: { accountName: string; }[]; logo: string; } export declare type BinLookUpData = { firstSixDigits: string; brand: string; cardType: string | null; issuer: string | null; issuerCountry: string | null; issuerCountryCode: string | null; product: string | null; }; declare interface BlockStyle { background?: string; borderRadius?: number | string; boxShadow?: string; borderStyle?: string; borderColor?: number | string; borderWidth?: number | string; } export declare interface ButtonStyle { base?: TextStyle & BlockStyle; hover?: TextStyle & BlockStyle; focus?: TextStyle & BlockStyle; } export declare type CaptureOperationStatus = "pending" | "pending_authentication" | "failed" | "successful"; export declare interface Card { id: string; brand: string; logo: string; first6Digits: string; last4: string; expiryMonth: string; expiryYear: string; country: string | null; requiresCvv: boolean; } export declare type CardBrand = "mastercard" | "maestro" | "visa" | "amex"; export declare type CardData = { first_six_digits: string; last_four_digits: string; card_scheme: string; card_holder_name: string; expiry_year: string; expiry_month: string; is_live: boolean; access_token: string; card_token: string; cvv: string; save_card: boolean; fingerprint: string; }; export declare type CardInfo = { brand: string; brandIconUrl: string; last4Digits: string; }; export declare type CardIntentDetails = { state: Exclude; stateDetails: null; } | { state: Extract; stateDetails: { url: string; renderStrategy: "REDIRECT"; }; }; export declare type CardListEvent = keyof CardListEventMap; export declare type CardListEventMap = { selectSrcDigitalCardId: CustomEvent; clickAddCardLink: CustomEvent; clickSignOutLink: CustomEvent; close: CustomEvent; }; export declare type CardNumberChangeData = { first6Digits: number | null; first8Digits: number | null; brand: string; brandIconUrl: string; }; export declare type CardTokenId = string; export declare type CardTokenState = "CARD_INTENT_SUCCESSFUL" | "CARD_INTENT_FAILED" | "URL_TO_RENDER"; export declare type CheckoutResponse = { /** * The checkoutActionCode will be one of the following: * COMPLETE - checkout processing completed normally * CANCEL - consumer wishes to cancel the flow. * ERROR - an error was detected and the checkout processing cannot continue. * CHANGE_CARD - consumer wishes to select an alternative card. You should return them to the Card Selection List. * ADD_CARD - Consumer wishes to add a new card. You should show the Cart Input form. * SWITCH_CONSUMER - Consumer wishes to change account profile / identity. You should show the Login screen. */ checkoutActionCode: "COMPLETE" | "CANCEL" | "ERROR" | "CHANGE_CARD" | "ADD_CARD" | "SWITCH_CONSUMER"; /** * Checkout Payload Response is a complex JSON Web Token wrapper object containing following set of attributes. * The object may be optionally signed cryptographically by the Click to Pay System. * Conditionality: Only supplied when the checkoutActionCode is COMPLETE. */ checkoutResponse?: string; /** * Existing checkoutResponse JWS will be decoded and the decoded data will be returned alongside the JWS as checkoutResponseData. The structure of the decoded JWS may differ based on the network since it is not guided by EMVCo. */ checkoutResponseData?: DpaCheckoutResponse; /** * ID Token obtained by DCF during checkout session. * Conditionality: Only supplied if obtained by the DCF during its processing of the checkout session (e.g. DCF requesting identity validation on the SRC System). */ idToken?: string; /** * The payment network used for the transaction. * Conditionality: Only supplied when the checkoutActionCode is COMPLETE. */ network?: string; /** * Dictionary containing header fields which you will use as headers in your POST /checkout request calls. * Conditionality: Only supplied when the checkoutActionCode is COMPLETE. */ headers?: Record; /** * A JWT containing the recognition token. Conditionality: Present if a cardholder opts-in through Remember Me checkbox. */ recognitionToken?: string; }; export declare interface CheckoutStyle { hideAmountSidebar?: boolean; hideHeader?: boolean; hideLoaderMessage?: boolean; hideFormHeaderMessage?: boolean; hideNavigationToPaymentMethods?: boolean; formOnly?: boolean; } export declare type CheckoutWithCardOptions = { /** * Identifies the card to be charged. The srcDigitalCardId returned in the payload response of the masked cards. */ srcDigitalCardId: string; /** * Indicates the consumer’s consent to be remembered. */ rememberMe?: boolean; /** * This structure represents the DPA-specific preferences and transaction configuration parameters that are common across all transactions. DpaTransactionOptions data replaces the DPA configuration data that passed to the init() method. */ dpaTransactionOptions: DpaTransactionOptions; }; export declare type CheckoutWithNewCardOptions = { /** * Merchant can supply consumer data in this method to auto populate the consumer information without the need for the consumer to re-enter the same details. */ consumer?: DpaConsumer; /** * This structure represents the DPA-specific preferences and transaction configuration parameters that are common across all transactions. DpaTransactionOptions data replaces the DPA configuration data that passed to the init method. */ dpaTransactionOptions: DpaTransactionOptions; /** * Indicates the consumer’s consent to be remembered by third-party cookies. */ rememberMe?: boolean; /** * Indicates the consumer’s consent to be remembered by recognition token and third-party cookie. This is applicable if Integrator supports first-party cookie and the browser supports third-party cookie. */ recognitionTokenRequested?: boolean; }; declare class Click2Pay { #private; private sdkApiHandler; complianceSettings: { privacy: { acceptedVersion: string; latestVersion: string; latestVersionUri: string; }; tnc: { acceptedVersion: string; latestVersion: string; latestVersionUri: string; }; }; /** * Underlying MasterCard Click2Pay SDK instance */ masterCard: any; private env; private srcDpaId; private dpaLocale; private mountedCardElements; lang: string; constructor(options: { sdkApiHandler: SDKApiHandler; mountedCardElements: Array; lang: string; }); /** * Loads MasterCard Click2Pay SDK script and initializes it with the provided options * and it should be called before any other method. */ init({ env, srcDpaId, dpaLocale, dpaTransactionOptions, ...options }: Click2PayInitOptions): Promise; /** * This should be called after the {@link Click2Pay.init init} method. * If the user is recognized, it returns an array of masked card information otherwise it returns an empty array. */ getCards(): Promise; /** * Card List related methods and event listeners * This object contains methods for interacting with the card list UI component. * Make sure to include the `` element in your HTML with the id `mh-src-card-list`. * ```html * * ``` * Example: * ```ts * // Load the cards into the card list * const maskedCards = await click2pay.getCards(); * await click2pay.cardList.loadCards({ maskedCards }); */ cardList: { /** * Returns the underlying MasterCard `` element */ getCardListEl(): Promise; /** * Displays the provided array of masked cards the Card List. * Make sure to include the `` element in your HTML with the id `mh-src-card-list`. * ```html * * ``` */ loadCards({ maskedCards }: { maskedCards: MaskedCard[]; }): Promise; /** * Adds an event listener to the underlying MasterCard `` element. * - `selectSrcDigitalCardId`: Fired when the user selects a card from the list. The event detail contains the selected `srcDigitalCardId`. * - `clickAddCardLink`: Fired when the user clicks the "Add Card" link. * - `clickSignOutLink`: Fired when the user clicks the "Sign Out" link. * - `close`: Fired when the user clicks the "Cancel" button. * * Returns a cleanup function to remove the event listener. */ addEventListener(event: T, callback: (event: CardListEventMap[T]) => void): () => void | undefined; }; /** * Check out with an identified card. */ checkoutWithCard({ dpaTransactionOptions, ...options }: CheckoutWithCardOptions): Promise; /** * Initiates the authentication process. * Make sure to include a `
` element in your HTML with the id `mh-src-otp-container`. * @example * ```html * * ``` */ authenticate({ identityType, identityValue, }: Click2PayAuthenticateOptions): Promise; /** * Enrolls a new card during checkout. * This card will be enrolled to the profile identified by the session, unless this is a guest checkout. */ checkoutWithNewCard({ dpaTransactionOptions, ...options }: CheckoutWithNewCardOptions): Promise; /** * Submits the checkout response obtained from the checkout process to complete the payment. */ pay({ intentId, checkoutResponse, }: { intentId: string; checkoutResponse: CheckoutResponse; }): Promise<{ intent: PaymentIntent; transaction: PaymentTransaction | null; selectedMethod: PaymentMethodSlugs | null; state: IntentState; stateDetails: { formFields: { billing: Field[] | null; shipping: Field[] | null; card: { accessToken: string; } | null; }; } | { url: string; renderStrategy: UrlRenderStrategy; } | { card: CardInfo; cvvField: Field; } | { plans: InstallmentPlan[]; } | { otpLength: number; /** * Loads MasterCard Click2Pay SDK script and initializes it with the provided options * and it should be called before any other method. */ intentOtpData: IntentOtpData; } | null; shippingData: Shipping | null; productItems: ProductItem[] | null; recommendedMethods: Method[] | null; lastUsedMethod: LastUsedMethod | null; nativePayData?: Record | undefined; paymentStatus: PaymentStatus; subscription: { plan: SubscriptionPlan; status: SubscriptionStatus | null; id: string | null; } | null; customerId?: string | undefined; }>; /** * This method disassociates a recognized Consumer Application/Device from the Consumer’s Profile. * When the consumer clicks Not your cards? */ signOut(options?: { recognitionToken?: string; }): Promise; } export declare type Click2PayAuthenticateOptions = { /** * Type of consumer identity provided by the cardholder. Valid values are EMAIL_ADDRESS, MOBILE_PHONE_NUMBER. */ identityType: "MOBILE_PHONE_NUMBER" | "EMAIL_ADDRESS"; /** * Value associated with the identityType. */ identityValue: string; }; export declare type Click2PayAuthenticateResult = { /** * The user successfully completed authentication and selected one of their cards. */ action: "AUTHENTICATED"; /** * The list of masked cards available to the user after successful authentication. */ cards: MaskedCard[]; /** * A JWT containing the recognition token. * * Conditionality: Present if a consumer opts-in through Remember Me checkbox. * * It is recommended to store/drop the recognition token as a first party cookie * on the device/browser. Integrator must manage the security aspects and ensure * that the following security measures are in place: * - Expiration Date - Cookies should have a maximum lifespan of 180 days * - Secure * - httpOnly (only applicable for server-side tokens) * - sameSite=strict * - Value=JWT */ recognitionToken?: string; } | { /** * This indicates that the consumer is not present in the Click to Pay System. */ action: "CONSUMER_NOT_PRESENT"; } | { /** * The limit for the number of retries for OTP generation was exceeded. */ action: "RETRIES_EXCEEDED"; } | { /** * The account exists but is not currently accessible (e.g., is locked). */ action: "ACCT_INACCESSIBLE"; } | { /** * One or more parameters failed validation */ action: "UNKNOWN_ERROR"; } | { action: "OTP_SEND_FAILED"; } | { /** * User clicks on Not You button to enter new email or phone number. */ action: "NOT_YOU"; }; export declare type Click2PayInitOptions = { env: "sandbox" | "production"; /** * This is a unique identifier for your Digital Payment Application (DPA), which can be obtained from your method nativePayData. */ srcDpaId: string; /** * The site preferred locale. This should have a format of ISO {LanguageCode}_{CountryCode2} pair (e.g., en_US ) for a seamless user experience and correct language. Click to Pay uses the value of the dpaLocale to deliver the default experience. */ dpaLocale: `${string}_${string}`; /** * List of card schemes the merchant accepts. We currently support mastercard, visa, amex, discover and maestro. */ cardBrands: CardBrand[]; /** * This structure represents the DPA-specific preferences and transaction configuration parameters that are common across all transactions. DpaTransactionOptions data replaces the DPA configuration data that passed to the init method. */ dpaData: DpaData; /** * DPA-specific preferences and transaction configuration parameters. */ dpaTransactionOptions: DpaTransactionOptions; /** * Array containing the legal names of your co-branded partners. To promote your brand, if the cardholder has one of your co-branded cards then this card will appear at the top of a card list. */ coBrandNames?: string[]; /** * JWT containing the recognition token that the Integrator stored on device or browser. * * It is recommended to store/drop the recognition token as a first party cookie * on the device/browser. Integrator must manage the security aspects and ensure * that the following security measures are in place: * - Expiration Date - Cookies should have a maximum lifespan of 180 days * - Secure * - httpOnly (only applicable for server-side tokens) * - sameSite=strict * - Value=JWT */ recognitionToken?: string; }; export declare type Click2PayInitResult = { availableCardBrands: CardBrand[]; availableServices: ["INLINE_CHECKOUT"]; }; export declare type Click2PaySignOutResponse = { /** * Returns false if unbind is successful, else returns true. */ recognized: false; } | { /** * Returns true if unbind is unsuccessful, else returns false. */ recognized: true; /** * If unbind is unsuccessful, returns MaskedCards present in recognized user profile. */ cards: MaskedCard[]; }; declare type CommonElementOptions = { selector: string; placeholder?: string; inputMode?: string; styles?: ElementStyles; classes?: Partial>; }; declare type ConstructorOptions = { target: Window; targetOrigin: string; }; export declare type CustomerBalances = [ { id: "SELFSERVE_WALLET"; balance: number; icon: string; isSelected: boolean; } ]; export declare interface CustomerLastUsedMethod { method: PaymentMethodSlugs; type: "saved_card" | "payment_method" | "customer_balance"; id: PaymentMethodSlugs | (string & {}); } export declare type DigitalCardData = { /** * Status of the Card in the Click to Pay System. Values: ACTIVE */ status: "ACTIVE"; /** * Name that can be used for display. Presentation text created by the Consumer to enable recognition of the PAN entered into the DCF. This value is unique to the DCF and defined by the Consumer (e.g., Nickname). */ presentationName?: string; /** * Presentation text defined by the SRC Program that describes the PAN presented as a Digital Card. This descriptor is the same across all DCFs. */ descriptorName: string; /** * HTTPS (full) URL for the cardArt. Can be card or issuer specific value, e.g, https://sbx.assets.mastercard.com/card-art/combined-image-asset/HIGH-MASK-3x.png. */ artUri: string; /** * Set of events that are pending completion such as address verification or SCA. * - `PENDING_AVS` * - `PENDING_SCA` * - `PENDING_CONSUMER_IDV` */ pendingEvents?: string[]; /** * Max Length of 128. Textual Name of the co-brand partner. Only available on tokenized Mastercard cards. */ coBrandedName?: string; /** * Indicates whether the card is co-branded. Only available on tokenized Mastercard cards. */ isCoBranded?: boolean; }; export declare interface Discount { title: { en: string; ar?: string; fr?: string; }; type: "amount" | "percentage"; value: string | number; } export declare type DpaAcquirerData = { /** * List of card schemes the merchant accepts. */ cardBrand: string; /** * Acquiring institution identification code as assigned by the 3DS Directory Server receiving the AReq message, for 3DS usage only. */ acquirerBIN: string; /** * Acquiring institution identification code. */ acquirerMerchantId: string; }; declare type DpaAddress = { /** * Identifier used to point to the address. */ addressId: string; /** * Max Length of 100. Name of the ordering customer. */ name: string; /** * Max Length of 50. Address city. */ city: string; /** * Max Length of 75. First line of the address. */ line1: string; /** * Max Length of 75. Second line of the address. */ line2?: string; /** * Max Length of 75. Third line of the address. */ line3?: string; /** * Max Length of 30. Address state. */ state?: string; /** * Max Length of 16. Address zip or postal code. */ zip?: string; /** * ISO 3166-1 alpha 2 country code. Address country code. */ countryCode?: string; }; export declare type DpaCheckoutResponse = { /** * This is the unique identifier generated by Click to Pay System to track messages. */ srcCorrelationId: string; /** * A unique id used to track the user journey. This is used for analytics to be able to correlate a single user “session” from button impression to the end of the transaction. This field may be created on the merchant page by the integrator and need to be passed-through to Mastercard network (Click to Pay System). It is passed all the way to the DCFs as well. */ srciTransactionId: string; /** * Masked card display and status data. */ maskedCard: MaskedCard; /** * Masked consumer display and status data may be supplied if known to the Click to Pay System. * Conditionality: only supplied in case the consumer data was available for the associated card/profile. */ maskedConsumer?: MaskedConsumer; /** * Unmasked shipping address postal code / ZIP. * Conditionality: only supplied in case a shipping address was requested by the merchant. */ shippingAddressZip?: string; /** * Unmasked shipping address country code. * Conditionality: only supplied in case a shipping address was requested by the merchant. */ shippingAddressCountryCode?: string; }; export declare type DpaComplianceSettings = { /** * Privacy consent status. */ privacy?: DpaConsent; /** * "T&Cs" consent status. */ tnc?: DpaConsent; }; export declare type DpaConsent = { /** * Max Length of 10. Represents the version accepted by the Consumer. */ acceptedVersion?: string; /** * Max Length of 10. Represents the latest version. */ latestVersion?: string; /** * Max Length of 1024. Represents the URI of the latest version. */ latestVersionUri?: string; }; export declare type DpaConsumer = { /** * Max Length of 255. Consumer-provided email address. */ emailAddress?: string; /** * Consumer-provided mobile number. */ mobileNumber?: DpaPhoneNumber; /** * Max Length of 255. Consumer’s first name. */ firstName?: string; /** * Max Length of 255. Consumer’s last name. */ lastName?: string; }; export declare type DpaData = { /** * Legal name of registered DPA. */ dpaName: string; /** * Display name of the DPA website. */ dpaPresentationName?: string; /** * DPA’s business address */ dpaAddress?: DpaAddress; /** * DPA’s email address . Max Length= 255 */ dpaEmailAddress?: string; /** * DPA’s contact phone number. */ dpaPhoneNumber?: DpaPhoneNumber; /** * URL to DPA’s logo. */ dpaLogoUri?: string; /** * DPA’s support contact email address. */ dpaSupportedEmailAddress?: string; /** * DPA’s support contact phone number. */ dpaSupportedPhoneNumber?: DpaPhoneNumber; /** * URL of the DPA website. */ dpaUri?: string; /** * DPA’s support URI. */ dpaSupportUri?: string; /** * Supported values are WEB_BROWSER or MOBILE_APP. */ applicationType?: "WEB_BROWSER" | "MOBILE_APP"; }; export declare type DpaMaskedConsumerIdentity = { /** * The entity or organization that collected and verifies the identity. Values: * - SRC. */ identityProvider?: string; /** * Identifies the type of Consumer Identity transmitted or collected. Values: * - EMAIL_ADDRESS * - MOBILE_PHONE_NUMBER */ identityType: "EMAIL_ADDRESS" | "MOBILE_PHONE_NUMBER"; /** * Max Length of 255. Masked consumer identifier value, e.g., masked email address or masked mobile phone number as per masking rules. */ maskedIdentityValue: string; }; export declare type DpaPaymentOption = { /** * Type of cryptogram or token used for the card data. Supported values are: CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM: Digital Secure Remote Payment (DSRP) equivalent. DSRP cryptogram is a type of dynamic data which the Integrator will have to pass within Dynamic Payment Data field (DE104 SE001) of the payment authorization request. Pass this value if the merchant requires token & DSRP cryptogram for transaction or payment authorization. NOTE: Integrators that support dual payload will receive a second payment credential in the card object, along with the token object. This payment credential should be used for additional cases outside of payment authorization. Work with your [Mastercard representative](https://developer.mastercard.com/unified-checkout-solutions/documentation/support/#get-help) for more details. NONE: Pass this value if merchant requires FPAN for transaction or payment authorization. NOTE: For countries that suppo`rt only tokens (not FPANs), payment authorization is done using the token passed in card object. Optionally, merchants can pass DTVC present in dynamicData object as part of payment authorization in place of CVC2. Refer to [View the Decrypted Payload](https://developer.mastercard.com/unified-checkout-solutions/tutorial/integrate_apis/step9/) for a description of the formats returned during checkout. Conditionality for Click to Pay: Required when payloadRequested= AUTHENTICATED. */ dynamicDataType?: "CARD_APPLICATION_CRYPTOGRAM_SHORT_FORM" | "NONE"; }; export declare type DpaPhoneNumber = { /** * Length of 1 to 4 digits. The international country code for the phone number (do not include a plus sign). */ countryCode: string; /** * Length of 4 to 14 digits. Phone number without country code. */ phoneNumber: string; }; export declare type DpaTransactionAmount = { /** * The final transaction amount must be provided. */ transactionAmount: number; /** * String specifying the ISO 4217 currency code (e.g., USD). Minimum length is 3. */ transactionCurrencyCode: string; }; export declare type DpaTransactionOptions = { /** * Billing Restrictions. * Array of country codes in ISO 3166-1 alpha-2 format - Payments from all the listed billing countries are accepted. E.g., [“US”,“CA”,“AU”]. An empty list or the absence of this data element means that all countries are accepted. * Note: Mastercard does not currently support declining payments based on the cardholder’s billing address. You should specify an empty array. */ dpaAcceptedBillingCountries?: string[]; /** * Container for amount and currency code. * Conditionality : Required if - threeDsPreference is set to NONE. */ transactionAmount?: DpaTransactionAmount; /** * What level of detail you want to see for the billing address. * @default NONE */ dpaBillingPreference?: "FULL" | "NONE" | "POSTAL_COUNTRY"; /** * Merchant site preferred locale. Format: ISO language_country pair (e.g., en_US ). This is needed to ensure correct language and user experience. The value of the dpaLocale will be used by Mastercard SRC to create user profile and deliver Click to Pay experience by default. Users can choose to change the default country/language passed in dpaLocale from a country/language selection option in the DCF screen before profile creation. If users opt to choose that, then the profile will be created in the user selected country and language and the same will also be used to deliver the experience in all future checkouts by the same user. */ dpaLocale?: `${string}_${string}`; /** * Whether DPA wants consumer email ID in the Payload. Default is FALSE. */ consumerEmailAddressRequested?: boolean; /** * Whether DPA wants consumer phone number in the Payload. Default is FALSE. */ consumerPhoneNumberRequested?: boolean; /** * Whether DPA wants consumer name in the Payload. */ consumerNameRequested?: boolean; /** * Describes the merchant’s type of business, product or service. The same value is expected in the authorization request. * @example * // Test environment * merchantCountryCode: "0001" */ merchantCategoryCode: string; /** * ISO 3166 alpha 2 country code of the merchant. * @example * // Test environment * merchantCountryCode: "US" */ merchantCountryCode: string; /** * Digital Payment Application generated order/invoice number corresponding to a Consumer purchase. * Typically, used for reconciliation purposes by the merchant. */ merchantOrderId?: string; /** * Type of the order. Valid values for enum: * - SPLIT_SHIPMENT * - PREFERRED_CARD */ orderType?: "SPLIT_SHIPMENT" | "PREFERRED_CARD"; /** * This is for a future enhancement. It will be the merchant’s 3DS preferences. Currently this should be set to NONE if provided. */ threeDsPreference?: "NONE"; /** * Consists of acquirerBIN and acquirerMerchantId for the supported cardBrand. * These values are used for initiating managed transaction authentication across different card brands/networks. * * @example * // Test environment * acquirerData: [ * { * cardBrand: 'mastercard', * acquirerMerchantId: 'SRC3DS', * acquirerBIN: '545301', * }, * { * cardBrand: 'visa', * acquirerMerchantId: '33334444', * acquirerBIN: '432104', * }, * ] */ acquirerData: DpaAcquirerData[]; }; declare type Element_2 = { mount: () => void; on>(event: T, callback: (data: CardNumberChangeData) => void): void; on>(event: T, callback: (data: { isValid: boolean; error: string | null; }) => void): void; on>(event: T, callback: (data: { isValid: boolean; length: number; }) => void): void; on(event: T, callback: () => void): void; off: (event: ElementEvents) => boolean; focus: () => void; blur: () => void; clear: () => void; }; export { Element_2 as Element } export declare type ElementClassNames = "focus" | "error"; export declare type ElementEvents = "mount" | "focus" | "blur" | "error" | "changeInput" | "cardNumberChange" | "key:Backspace" | "key:Enter"; export declare type ElementProps = { elementType: ElementType; elementOptions: CommonElementOptions & { validation?: never; }; } | { elementType: "cardHolderName"; elementOptions: CommonElementOptions & { validation?: { required?: boolean; }; } & { customValidation?: Record; }; } | { elementType: "cardNumber"; elementOptions: CommonElementOptions & { validation?: { /** * Enable luhn validation for card number.Add commentMore actions * * This helps verify that the card number follows the [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm). * @default true */ cardNumber?: boolean; }; }; } | { elementType: "cardCvv"; elementOptions: CommonElementOptions & { validation?: never; /** * Hide the entered security code like a password field. * * @default false */ mask?: boolean; }; }; export declare type Elements = { create: ElementsCreate; on: (event: FormEvents, callback: (isValid: boolean) => void) => void; off: (event: FormEvents) => void; }; declare interface ElementsCreate { (elementProps: { elementType: "cardHolderName"; value: string; }): { clear: () => void; }; (elementProps: ElementProps): Element_2; } export declare type ElementsProps = { styles?: ElementStyles; classes?: Partial>; /** * absolute URL pointing to a CSS file with @font-face definitions, * @example "https://fonts.googleapis.com/css?family=Open+Sans&display=swap" */ fontSourceCss?: string; }; export declare type ElementStyles = { color?: VariantStyle; /** * Input background color */ backgroundColor?: string; placeholderColor?: string; fontSize?: string; fontFamily?: string; /** * @default "normal" */ fontStyle?: "normal" | "italic" | "oblique"; fontWeight?: number | string; padding?: string; height?: string; direction?: "ltr" | "rtl"; textAlign?: "left" | "right" | "center"; /** * Document `` background color */ bodyBackgroundColor?: string; }; export declare type ElementType = "cardHolderName" | "cardNumber" | "cardCvv" | "cardExpiryMonth" | "cardExpiryYear"; export declare type ErrorResponse = { code: number; message: string; }; export declare interface Fee { title: { en: string; ar?: string; fr?: string; }; value: string | number; discount?: Discount; } export declare type Field = { type: FieldType; name: string; label: string; hint: string; value: string; readOnly: boolean; validation: { required: boolean; minLength: number | null; maxLength: number | null; }; dependsOn?: string; optionsList?: Array<{ label: string; value: string; }>; optionsMap?: Record>; }; export declare type FieldType = "text" | "number" | "email" | "date" | "phoneNumber" | "select"; export declare type FormEvents = "validityChange"; export declare type FormField = { choices?: Record | null; error_messages: { blank: string; null?: string; required: string; invalid: string; min_length: string; max_length: string; }; field_name: string; help_text?: string | null; label?: string; max_length?: number | null; min_length?: number | null; read_only: boolean; required: boolean; type: "PhoneNumberField" | "ChoiceField" | "CharField" | "IntegerField" | "EmailField" | "DateField"; value: string; }; declare type FormFields = { billing: Array | null; shipping: Array | null; card: { accessToken: string; } | null; }; export declare type GetMethodsOptions = { currency: string; amount?: string | number; customer?: string; flowId?: string; operation?: "purchase" | "authorize"; /** * Filter the flow based on custom fields */ customFields?: Record; }; export declare const IFrameSandboxOptions: readonly ["allow-downloads", "allow-forms", "allow-modals", "allow-orientation-lock", "allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox", "allow-presentation", "allow-same-origin", "allow-scripts", "allow-storage-access-by-user-activation", "allow-top-navigation", "allow-top-navigation-by-user-activation"]; export declare type IFrameSandboxOptionsType = typeof IFrameSandboxOptions[number]; declare interface InputAllowedStyle { height?: number; padding?: number; background?: string; borderRadius?: number | string; boxShadow?: string; borderStyle?: string; borderColor?: string; borderWidth?: number | string; color?: string; fontFamily?: string; fontWeight?: string; fontSize?: string; fontSmoothing?: string; lineHeight?: string; } export declare interface InputStyle { base?: InputAllowedStyle; hover?: InputAllowedStyle; focus?: InputAllowedStyle; error?: InputAllowedStyle; } export declare type InstallmentPlan = { id: string; installmentPeriod: number; interestRate: string | null; amount: { value: string; formatted: number; currency: string; }; upfrontFees: string | null; issuerCode: string | null; issuerNameEn: string | null; issuerNameAr: string | null; issuerLogoEn: string | null; issuerLogoAr: string | null; processingFeesType: string | null; processingFeesAmount: string | null; feeDisplayValue: string | null; }; export declare type InstallmentPlanPayload = { planId: string; issuerCode?: string; }; export declare type IntentDetails = TType extends "payment" ? { intent: PaymentIntent; transaction: PaymentTransaction | null; selectedMethod: PaymentMethodSlugs | null; /** * Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating) */ state: IntentState; stateDetails: IntentStateDetails; shippingData: Shipping | null; productItems: ProductItem[] | null; recommendedMethods: Method[] | null; lastUsedMethod: LastUsedMethod | null; nativePayData?: Record; paymentStatus: PaymentStatus; subscription: { plan: SubscriptionPlan; status: SubscriptionStatus | null; id: string | null; } | null; customerId?: string; } : { intent: PayoutIntent; transaction: PayoutTransaction | null; selectedMethod: PaymentMethodSlugs | null; /** * Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating) */ state: IntentState; stateDetails: IntentStateDetails; nativePayData?: never; }; export declare type IntentMethods = TType extends "payment" ? { paymentMethods: Method[]; expressMethods: Method[]; savedCards: Card[]; savedBankAccounts: BankAccount[]; customerBalances: CustomerBalances; customerLastUsedMethod: CustomerLastUsedMethod | null; } : { payoutMethods: Method[]; }; export declare type IntentOtpData = Record; export declare type IntentState = "METHOD_SELECTION" | "INTENT_FORM" | "INTENT_PROCESSED" | "TRANSACTION_WAITING_USER_ACTION" | "TRANSACTION_FAILED" | "EXPIRED" | "CLOSED" | "NATIVE_PAY" | "FORM_FIELDS" | "URL_TO_RENDER" | "SAVED_CARD_CVV" | "INSTALLMENT_PLANS" | "PROCESSING" | "OTP_FORM"; export declare type IntentStateDetails = TType extends "FORM_FIELDS" ? { formFields: FormFields; } : TType extends "URL_TO_RENDER" ? { url: string; renderStrategy: UrlRenderStrategy; } : TType extends "SAVED_CARD_CVV" ? { card: CardInfo; cvvField: Field; } : TType extends "INSTALLMENT_PLANS" ? { plans: InstallmentPlan[]; } : TType extends "OTP_FORM" ? { otpLength: number; intentOtpData: IntentOtpData; } : null; export declare type IntentStatus = "PROCESSED" | "UNPROCESSED" | "CLOSED" | "TIME_EXPIRED" | "PENDING" | "EXPIRED"; export declare type IntentType = "payment" | "payout"; export declare type LastUsedMethod = { type: "customer_balance" | "saved_card" | "payment_method"; id: PaymentMethodSlugs | (string & {}); }; export declare interface LoaderStyle { backgroundColor: string; color: string; } export declare type LoyaltyPayload = { providerId: string; identifierType: LoyaltyProvider["identifierType"]; /** * e.g. email, phone number or customer national id based on the identifier type */ identifier: string; }; export declare type LoyaltyProvider = { id: string; name: string; identifierType: "PHONE_NUMBER" | "NATIONAL_ID" | "EMAIL"; }; export declare type MaskedAddress = { addressId: string; /** * ISO 8601 Timestamp in the UTC timezone, e.g., “2018-09-23T04:56:07Z” the shipping address was created. * Conditionality: Only for shipping addresses. */ /** * Max Length of 60. Name of the individual receiving the delivered goods or service. */ name: string; /** * Max Length of 75. First line of the address. */ countryCode: string; /** * Max Length of 16. Address zip or postal code. */ city: string; /** * Max Length of 30. Address state. */ line1: string; /** * Max Length of 75. Second line of the address. */ line2?: string; /** * Max Length of 75. Third line of the address. */ line3?: string; /** * Max Length of 50. Address city. */ state?: string; /** * ISO 3166-1 alpha 2 country code. Address country code. */ zip?: string; /** * Identifier used to point to the address. */ createTime?: string; /** * ISO 8601 Timestamp in the UTC timezone, e.g., “2018-09-23T04:56:07Z” the shipping address was last used. * Conditionality: Only for shipping addresses. */ lastUsedTime?: string; }; export declare type MaskedCard = { /** * Max Length of 36. Unique Identifier of the card. A reference representing the PAN or Payment Token that enables a non-Issuer entity to identify the underlying PAN. A single PAN can have one or more SRC Digital Card Reference Identifiers. Digital Card information can be accompanied with SRC Digital Card Reference Identifier. It is associated with the SRC Profile to which the Digital Card belongs and is unique within a Click to Pay System. * Conditionality: Supplied when returned to SRCi or DCF; not required when returned to a participating Issuer. */ srcDigitalCardId: string; /** * Max Length = (PAN Length - 10). First significant digits of the PAN, included in an unmasked form. */ panBin?: string; /** * Length of 4. Attribute of the Payment Card that represents the Last 4 digits of the PAN included in an unmasked form. */ panLastFour: string; /** * Length of 2. Expiration month of the Payment Card, expressed as a Calendar Month used for presentation purposes. * Conditionality: Supplied when specified for the card (PAN). */ panExpirationMonth: string; /** * Length of 4. Expiration year of the Payment Card expressed as four-digit year, used for presentation purposes. * Conditionality: Supplied when specified for the card (PAN). */ panExpirationYear: string; /** * ISO 8601 Timestamp in the UTC timezone, e.g., “2018-09-23T04:56:07Z” when card was enrolled into the Click to Pay System. */ dateOfCardCreated: string; /** * Masked billing address associated with the card. */ maskedBillingAddress: MaskedAddress; /** * Masked shipping address associated with the card. */ maskedShippingAddress: MaskedAddress; /** * Digital Card Data contains digital card information that is used in the acceptance environment and in the user interface. Its purpose is to provide reference to the actual PAN or Payment Token without actually disclosing either. Digital Card Data is grouped based on the following: * - Digital Card Information: data used in Request and Response Messages * - UI/UX Presentation Data: data used user interfaces to provide the user with a recognizable descriptor * - Digital Card Art: image that accompanies Digital Card information for user interface purposes. */ digitalCardData: DigitalCardData; /** * Max Length of 32. This is the card brand, and will be a free-form string, to be defined within a program. For example, mastercard, discover, visa, american-express. */ paymentCardDescriptor?: string; /** * Max Length of 32. Conveys the card type. Enum values: CREDIT, DEBIT, PREPAID, COMBO, FLEX * * **Note**: COMBO and FLEX are for applicable regions only. */ paymentCardType?: "CREDIT" | "DEBIT" | "PREPAID" | "COMBO" | "FLEX"; }; export declare type MaskedConsumer = { /** * Click to Pay Consumer Reference Identifier as generated by the Click to Pay System. */ srcConsumerId?: string; /** * Represents the masked value of the primary verifiable consumer identifier within a Click to Pay Profile, e.g., an email address or a mobile phone number. */ maskedConsumerIdentity: DpaMaskedConsumerIdentity; /** * Max Length of 255. Masked Consumer email address. */ maskedEmailAddress?: string; /** * Masked Consumer mobile phone number. */ maskedMobileNumber?: DpaPhoneNumber; /** * Consumer compliance settings. */ complianceSettings?: DpaComplianceSettings; /** * ISO 3166 alpha 2 country code. Consumer provided country code. */ countryCode?: string; /** * ISO 639-1 Code. Consumer provided language choice. */ languageCode?: string; /** * Signifies the state of the consumer at any given time at the Click to Pay System. Values: * - ACTIVE * - SUSPENDED * - LOCKED. */ status?: "ACTIVE" | "SUSPENDED" | "LOCKED"; /** * Max Length of 50. Masked first name of the consumer. */ maskedFirstName?: string; /** * Max Length of 50. Masked last name of the consumer. */ maskedLastName?: string; /** * Max Length of 100. Masked full name of the consumer. */ maskedFullname?: string; /** * ISO 8601 Timestamp in the UTC timezone, e.g., “2018-09-23T04:56:07Z” UTC timestamp when consumer was added to the Click to Pay System. */ dateConsumerAdded: string; /** * ISO 8601 Timestamp in the UTC timezone, e.g., “2018-09-23T04:56:07Z” when consumer last transacted in the Click to Pay System. */ dateConsumerLastUsed: string; }; declare type MessagePayload = { type: string; data?: Record; /** * Per-request intent secret */ intentSecret?: string; }; declare class MessagingService> { private target; private targetOrigin; private listeners; private onIncomingMessageBind; constructor(options: ConstructorOptions); send(message: MessagePayload): void; onReceive(callbackFn: typeof MessagingService.listeners[number]): void; removeListener(callbackFn: typeof MessagingService.listeners[number]): void; onIncomingMessage(event: MessageEvent): void; abortService(): void; } export declare interface Method { id: PaymentMethodSlugs; title: string; icons: string[]; isSelected: boolean; confirmationRequired: boolean; requiredBillingFields: Field[] | null; requiredShippingFields: Field[] | null; nativePayData: Record | null; } export declare type MHErrorType = "runtime" | "network" | "cardValidation" | "unknown"; declare class MoneyHashHeadless { #private; private options; private sdkApiHandler; click2Pay: Click2Pay; private sdkEmbed; private vaultSubmitListener; private mountedCardElements; constructor(options: MoneyHashHeadlessOptions); /** * Get intent details * @example * ``` * await moneyHash.getIntentDetails(''); * ``` * * @returns Promise<{@link IntentDetails}> */ getIntentDetails(intentId: string): Promise>; /** * Get intent available payment/payout methods, saved cards and customer balances * @example * ``` * await moneyHash.getIntentMethods(''); * ``` * @returns Promise<{@link IntentMethods}> * @deprecated use {@link MoneyHashHeadless.getMethods} instead, will be removed in future versions */ getIntentMethods(intentId: string): Promise>; /** * Get available methods, saved cards and customer balances for account associated with the * publicApiKey * @example * ``` * await moneyHash.getMethods({ * currency: 'EGP', * amount: 20, * customer: '', * flowId: '', * }) * ``` */ getMethods(options: GetMethodsOptions): Promise>; /** * Get available methods, saved cards and customer balances for the intent * @example * ``` * await moneyHash.getMethods({ * intentId: '', * }) * ``` */ getMethods(options: { intentId: string; }): Promise>; /** * Proceed with a payment/payout method, card or wallet * * @example * Proceed with a payment/payout method * ``` * await moneyHash.proceedWith({ * intentId: '', * type: 'method', * id: '', * }) * ``` * @see {@link Method} - for \ * * @example * Proceed with a customer balance. e.g. wallet * ``` * await moneyHash.proceedWith({ * intentId: '', * type: 'customerBalance', * id: '', * }) * ``` * @see {@link CustomerBalances} - for \ * * @example * Proceed with a customer saved card * ``` * // Card doesn't require CVV * await moneyHash.proceedWith({ * intentId: '', * type: 'savedCard', * id: '', * }) * * // Card requires CVV * await moneyHash.proceedWith({ * intentId: '', * type: 'savedCard', * id: '', * metaData: { * cvv: '', * } * }) * ``` * @see {@link Card} - for \ & if card requires cvv or not * * @returns Promise<{@link IntentDetails}> */ proceedWith({ intentId, type, id, useWalletBalance, metaData, installmentPlanData, loyaltyData, }: { type: "method" | "customerBalance" | "savedCard" | "savedBankAccount"; intentId: string; id: string; useWalletBalance?: boolean; metaData?: { cvv: string; }; installmentPlanData?: InstallmentPlanPayload; loyaltyData?: LoyaltyPayload; }): Promise>; /** * Reset the selected method on and intent to null * * @description Can be used for `back` button after method selection * or `retry` button on failed transaction UI to try a different * method by the user. * * @example * ``` * await moneyHash.resetSelectedMethod(''); * ``` * * @returns Promise<{@link IntentDetails}> */ resetSelectedMethod(intentId: string): Promise>; /** * Delete a customer saved card * * @example * ``` * await moneyHash.deleteCard({ * cardId: '', * intentSecret: '', * }); * ``` * @see {@link Card} - for \ * @see {@link AbstractIntent} - for \ * @returns Promise<{ message: 'success'} > */ deleteCard({ cardId, intentSecret, }: { cardId: string; intentSecret: string; }): Promise<{ message: "success"; }>; /** * @param nativeReceiptData - Native receipt data from apple pay or google pay * @param methodId - Apple pay or Google pay method id from nativePayData * @param flowId - (Optional) flow id to get the bin lookup service * * Get bin lookup data using apple pay or google pay receipt * * @returns BinLookUpData */ binLookupByReceipt({ nativeReceiptData, methodId, flowId, }: { nativeReceiptData: NativeReceiptData; methodId: string; flowId?: string; }): Promise; /** * * @param methodId - Apple pay method id from nativePayData * @param validationURL - Apple pay validation url you get from `ApplePaySession.onvalidatemerchant` * @param merchantIdentifier - (Optional) For payment platforms registering merchants through the {@link https://developer.apple.com/documentation/ApplePayWebMerchantRegistrationAPI Apple Pay Web Merchant Registration API}, this should be the partnerInternalMerchantIdentifier defined for each registered merchant. * @returns */ validateApplePayMerchantSession({ methodId, validationUrl, merchantIdentifier, }: { methodId: string; validationUrl: string; merchantIdentifier?: string; }): Promise; submitPaymentReceipt({ intentId, methodId, nativeReceiptData, }: { intentId: string; methodId?: string; nativeReceiptData: NativeReceiptData; }): Promise>; tokenizeReceipt({ receipt, methodId, cardTokenIntentId, }: { receipt: string; methodId: string; cardTokenIntentId: string; }): Promise; /** * Render SDK embed forms and payment integrations * * @description must be called if `state` of an intent is `INTENT_FORM` to let MoneyHash handle the payment. * * @example * ``` * const intentDetails = await moneyHash.renderForm({ * selector: '', * intentId: '', * }); * ``` * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS Selector MDN} * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox | iframe sandbox MDN} * @returns Promise> */ renderForm(options: Parameters["render"]>[0]): Promise>; renderSubscriptionEmbed({ intentId, selector, moneyHashIntentSecret, }: { intentId: string; selector: string; moneyHashIntentSecret?: string; }): Promise>; renderCreateBankAccountTokenEmbed({ intentId, selector, }: { intentId: string; selector: string; }): Promise; /** * Change the embed localization * * @description we currently support 3 languages `English`, `Arabic`, `Français`. * * @example * ``` * await moneyHash.setLocale(""); * ``` * * @returns Promise */ setLocale(locale: SupportedLanguages): Promise; /** * Change the public api key on MoneyHash instance */ setPublicApiKey(publicApiKey: string): void; /** * Set the intent secret to authorize intent requests. * * @example * ``` * moneyHash.setIntentSecret("54db4579..."); * ``` */ setIntentSecret(intentSecret: string): void; /** * Cleanup all listeners set by the SDK * @returns Promise */ removeEventListeners(): Promise; /** * Creates Elements context used to render each card field * @description Elements context is used to create and manage card fields * such as card number, card holder name, card expiry month, card expiry year and card cvv. * * @example * ``` * const elements = moneyHash.elements({ styles: ElementsStyles }); * ``` * * @returns { Elements } */ elements({ styles, classes, fontSourceCss }: ElementsProps): Elements; /** * Bin Lookup with 8 digits card number * @example * ```ts * cardNumber.on("changeInput", ({ length }) => { * if (length === 8) { * moneyHash.cardForm.binLookup().then(console.log).catch(console.log); * } * }); * ``` */ private _binLookup; cardForm: { collect: () => Promise; pay: ({ intentId, cardData, saveCard, billingData, shippingData, installmentPlanData, loyaltyData, }: { intentId: string; cardData: CardData; saveCard?: boolean | undefined; billingData?: Record | undefined; shippingData?: Record | undefined; installmentPlanData?: InstallmentPlanPayload | undefined; loyaltyData?: LoyaltyPayload | undefined; }) => Promise>; createCardToken: ({ cardIntentId, cardData, }: { cardIntentId: string; cardData: CardData; }) => Promise; binLookup: { (): Promise; (options: { cardData: CardData; flowId?: string; }): Promise; }; }; /** * For card holder name not mounted, but have initial value from merchant */ private defaultCardHolderName; /** * Submits the form with the form fields data (card, billing, shipping) * @example * ``` * await moneyHash.submitForm({ * intentId: '', * accessToken : '', * billingData: {}, * shippingData: {}, * }); * ``` * * @returns { Promise> } */ submitForm({ intentId, accessToken, billingData, shippingData, saveCard, paymentMethod, installmentPlanData, loyaltyData, }: { intentId: string; accessToken?: string | null; billingData?: Record; shippingData?: Record; saveCard?: boolean; paymentMethod?: PaymentMethodSlugs; installmentPlanData?: InstallmentPlanPayload; loyaltyData?: LoyaltyPayload; }): Promise>; /** * Selects the instalment plan for the intent * @example * ``` * await moneyHash.selectInstallmentPlan({ intentId: '', planId: '' }); * ``` * @returns { Promise> } */ selectInstallmentPlan({ intentId, planId, issuerCode, }: { intentId: string; planId: string; issuerCode?: string; }): Promise>; /** * Get list of the instalment plan for an account. * @example * ``` * await moneyHash.getInstallmentPlans({ first6Digits: '', amount: , currency: '' }); * ``` * @returns { Promise> } */ getInstallmentPlans({ first6Digits, amount, currency, }: { first6Digits?: string; amount: string; currency: string; }): Promise>; /** * Get list of subscription plan groups * @example * All plan groups * ``` * await moneyHash.getSubscriptionPlanGroups(); * ``` * @example * Filtered by currency * ``` * await moneyHash.getSubscriptionPlanGroups({ currency: '' }); * ``` * @example * Change offset and limit * ``` * await moneyHash.getSubscriptionPlanGroups({ limit: 40, offset: 0 }); * ``` * * @default limit: 10, offset: 0 * @returns { Promise } */ getSubscriptionPlanGroups(options?: { currency?: string; offset?: number; limit?: number; }): Promise; /** * Get list of subscription plans for a specific plan group * @example * ``` * await moneyHash.getSubscriptionPlans({ planGroupId: '', customerId '' }); * ``` * @returns { Promise> } */ getSubscriptionPlans({ planGroupId, customerId, }: { planGroupId: string; customerId: string; }): Promise>; /** * Selects a subscription plan for the customer * @example * ``` * await moneyHash.selectSubscriptionPlan({ customerId: '', planId: '', planGroupId: '' }); * ``` * @returns { Promise> } */ selectSubscriptionPlan({ planGroupId, customerId, planId, }: { planGroupId: string; customerId: string; planId: string; }): Promise & { moneyHashIntentSecret?: string; }>; /** * Get list of the loyalty providers for an account. * @example * ``` * const loyaltyProviders = await moneyHash.getLoyaltyProviders(); * ``` */ getLoyaltyProviders(): Promise>; /** * Check if the account is eligible for loyalty programs. * @example * ``` * const { eligible } = await moneyHash.checkLoyaltyEligibility({ * providerId: "", * identifierType: "", * identifier: "", * }); * ``` */ checkLoyaltyEligibility({ providerId, identifierType, identifier, }: LoyaltyPayload): Promise<{ eligible: boolean; }>; /** * Submits the CVV for the tokenized card * * @example * ``` * await moneyHash.submitCvv({ intentId: '', cvv: '' }); * ``` * * @returns { Promise> } */ submitCvv({ intentId, cvv, installmentPlanData, loyaltyData, }: { intentId: string; cvv: string; installmentPlanData?: InstallmentPlanPayload; loyaltyData?: LoyaltyPayload; }): Promise>; /** * Submits the OTP form. * * @example * ``` * await moneyHash.submitOtp({ intentId: '', otp: '', intentOtpData: stateDetails.intentOtpData }); * ``` * * @returns { Promise> } */ submitOtp({ intentId, otp, intentOtpData, }: { intentId: string; otp: string; intentOtpData: IntentOtpData; }): Promise>; /** * Render the received url in an iframe, popup iframe or redirect * @description must be called if `state` of an intent is `URL_TO_RENDER`. * @example * ``` * const intentDetails = await moneyHash.renderUrl({ * intentId: '', * url: '', * renderStrategy: 'IFRAME' | 'POPUP_IFRAME' | 'REDIRECT', * }); * ``` * */ renderUrl({ intentId, url, renderStrategy, options, }: { intentId: string; url: string; renderStrategy: UrlRenderStrategy; options?: RenderOptions; }): Promise>; /** * Listen to expiration date of the intent passed or not and execute the callback * @example * ``` * moneyHash.onExpiration('', () => { * console.log('intent expired!'); * }); * ``` * @see {@link IntentDetails} - for \ * @returns Cleanup function */ onExpiration(expirationDate: string, callback: () => void): () => void; } export default MoneyHashHeadless; export declare interface MoneyHashHeadlessOptions extends Omit, "onComplete" | "onFail"> { publicApiKey?: string; } export declare type NativeCollectibleBillingData = "email"; export declare type NativeReceiptData = { receipt: string; receiptBillingData: Partial>; }; export declare type OnCompleteEventOptions = TType extends "payment" ? PaymentIntentEventOptions : PayoutIntentEventOptions; export declare type OnFailEventOptions = TType extends "payment" ? PaymentIntentEventOptions : PayoutIntentEventOptions; export declare interface PaymentIntent extends AbstractIntent { expirationDate: string | null; } export declare type PaymentIntentEventOptions = { intent: PaymentIntent; transaction: PaymentTransaction; selectedMethod: PaymentMethodSlugs | null; state: IntentState; stateDetails: IntentStateDetails; shippingData: Shipping | null; productItems: ProductItem[] | null; }; export declare type PaymentMethodSlugs = "CASH_OUTLET" | "MOBILE_WALLET" | "CARD" | "USSD" | "KNET" | "CASH_COLLECTION" | "AMAN_MASARY" | "PAYPAL" | "PAY_AT_FAWRY" | "VALU" | "SHAHRY" | "CASH_ON_DELIVERY" | "BANK_INSTALLMENTS" | "BANK_TRANSFERS" | "REFERENCE_NUMBER" | "SELFSERVE_WALLET" | "APPLE_PAY" | "GOOGLE_PAY" | "M_PESA" | "MOBILE_MONEY" | "CRYPTO_WALLET" | "NAPS" | "FORSA" | "SYMPL" | "TABBY" | "SOUHOOLA" | "GETGO" | "SAMSUNG_PAY" | "QPAY" | "TAMARA" | "BENEFIT" | "STC" | "BANK_ACCOUNT" | "CASH" | "CLICK2PAY"; export declare type PaymentStatus = { status: "NO_AUTHORIZE_ATTEMPTS" | "AUTHORIZE_ATTEMPT_FAILED" | "AUTHORIZE_ATTEMPT_PENDING" | "CAPTURED" | "ABORTED" | "AUTHORIZED" | "REFUNDED" | "VOIDED" | (string & {}); balances: Record<"totalAuthorized" | "totalVoided" | "availableToVoid" | "totalCaptured" | "availableToCapture" | "totalRefunded" | "availableToRefund", string>; }; export declare interface PaymentTransaction extends Transaction { amount: { value: number; currency: string; }; paymentMethodName: string; paymentMethod: PaymentMethodSlugs; customFormAnswers: { formFields: Record; } | null; } export declare interface PayoutIntent extends AbstractIntent { } export declare type PayoutIntentEventOptions = { intent: PayoutIntent; transaction: PayoutTransaction; selectedMethod: PaymentMethodSlugs | null; state: IntentState; stateDetails: IntentStateDetails; }; export declare interface PayoutTransaction extends Transaction { amount: { value: string; currency: string; }; payoutMethodName: string; payoutMethod: PaymentMethodSlugs; } export declare interface ProductItem { name: string; type: string; amount: string; category: string; quantity: number; description: string; subcategory: string; reference_id: string; } export declare type PurchaseOperationStatus = "pending" | "pending_authentication" | "pending_external_action" | "pending_online_external_action" | "pending_authorization" | "failed" | "successful"; export declare type RefundOperationStatus = "pending" | "failed" | "successful"; export declare type RenderOptions = { /** * Redirect to new window for `renderStrategy: "REDIRECT"` */ redirectToNewWindow?: boolean; /** * Popup window size and positions for `renderStrategy: "POPUP_IFRAME"` * @default "width=600,height=400,left=200,top=200" */ window?: { width?: number; height?: number; left?: number; top?: number; }; }; declare class SDKApiHandler { private static messagingService; private static isCommunicationReady; private intentSecret?; constructor(); setIntentSecret(intentSecret: string): void; private initSDKCommunicationIframe; request({ api, payload, }: { api: `sdk:${string}`; payload: Record; }): Promise; postMessage(message: string): void; } declare class SDKEmbed { private options; private intentSecret?; messagingService: MessagingService | null; iframe: HTMLIFrameElement | null; isCommunicationReady: Promise | null; constructor(options: SDKEmbedOptions & { headless?: boolean; }); get lang(): string; setIntentSecret(intentSecret: string): void; render({ selector, intentId, sandbox, onHeightChange, }: { selector: string; intentId: string; sandbox?: IFrameSandboxOptionsType[]; onHeightChange?: (iframeHeight: number) => void; }): Promise; setLocale(locale: SupportedLanguages): Promise; abortService(): Promise; } declare interface SDKEmbedOptions { /** * Intent type `payment`, `payout` */ type: TType; /** * Locale of rendered embed. Can be changed programmatically with `moneyHash.setLocale` */ locale?: string; /** * Listen for intent completion. e.g. successful transaction, intent closed, intent expired ...etc * @param {OnCompleteEventOptions} event * * @see {@link PaymentIntentEventOptions} - Payment intent event * @see {@link PayoutIntentEventOptions} - Payout intent event */ onComplete?(event: OnCompleteEventOptions): void; /** * Listen for intent transaction failure status * @param {OnFailEventOptions} event * * @see {@link PaymentIntentEventOptions} - Payment intent event * @see {@link PayoutIntentEventOptions} - Payout intent event */ onFail?(event: OnFailEventOptions): void; /** * Customize input styles and submit button of MoneyHash embed */ styles?: { submitButton?: ButtonStyle; input?: InputStyle; loader?: LoaderStyle; checkout?: CheckoutStyle; }; } export declare interface Shipping { phone_number: string | null; created: string | null; modified: string | null; first_name: string | null; last_name: string | null; email: string | null; address: string | null; country: string | null; city: string | null; street: string | null; floor: string | null; building: string | null; state: string | null; postal_code: string | null; apartment: string | null; description: string | null; shipping_method: string | null; } export declare type SignOutResponse = { /** * Returns false if unbind is successful */ recognized: false; } | { /** * Returns true if unbind is unsuccessful */ recognized: true; cards: MaskedCard[]; }; export declare type SubscriptionPlan = { id: string; alreadySubscribed: boolean; amount: number; created: string; currency: string; description: string; discountAmount: number | null; discountCycles: number | null; discountPercentage: number | null; name: string; oneTimeFee: number | null; recurrency: number; recurrencyUnit: "MONTH"; recurringCycles: number | null; trialPeriod: number | null; isLive: boolean; }; export declare type SubscriptionPlanGroup = { created: string; currency: string; id: string; name: string; plans: SubscriptionPlan[]; }; export declare type SubscriptionPlanGroupsResponse = { count: number; hasNext: boolean; hasPrevious: boolean; planGroups: SubscriptionPlanGroup[]; }; export declare type SubscriptionStatus = "NEW" | "TRIAL" | "INCOMPLETE" | "ACTIVE" | "PAST_DUE" | "PENDING_CANCELLATION" | "CANCELLED" | "ENDED" | "TERMINATED" | "PAUSED"; export declare type SupportedLanguages = "ar" | "en" | "fr"; declare interface TextStyle { color?: string; fontFamily?: string; fontWeight?: string; fontSize?: string; fontSmoothing?: string; lineHeight?: string; textTransform?: string; letterSpacing?: string; } export declare interface Transaction { id: string; status: TransactionStatus; responseCode: string; responseMessage: string; localizedResponseMessage: string; operations: TransactionOperation[]; createdDate: string; billingData: { apartment: string | null; building: string | null; city: string | null; country: string | null; email: string | null; first_name: string | null; floor: string | null; last_name: string | null; name: string | null; phone_number: string | null; postal_code: string | null; state: string | null; street: string | null; }; customFields: Record | null; providerTransactionFields: Record; externalActionMessage: string[]; methodErrorMessage?: string | null; } declare type TransactionOperation = { [k in keyof TransactionOperationStatusMap]: { id: string; type: k; status: `${TransactionOperationStatusMap[k]}`; amount: { value: number; currency: string; }; statuses: { id: string; value: `${TransactionOperationStatusMap[k]}`; code: string; message: string; created: string; }[]; refund_type?: "full" | "partial" | null; }; }[keyof TransactionOperationStatusMap]; declare type TransactionOperationStatusMap = { purchase: PurchaseOperationStatus; authorize: AuthorizeOperationStatus; capture: CaptureOperationStatus; refund: RefundOperationStatus; void: VoidOperationStatus; increase_authorization: AuthorizeOperationStatus; }; declare type TransactionStatus = { [k in keyof TransactionOperationStatusMap]: `${k}.${TransactionOperationStatusMap[k]}`; }[keyof TransactionOperationStatusMap]; export declare type UrlRenderStrategy = "IFRAME" | "POPUP_IFRAME" | "REDIRECT"; declare type VariantStyle = string | { base: string; error?: string; }; export declare type VoidOperationStatus = "pending" | "failed" | "successful"; export { }