Interface ICardApplePay

This interface contains all methods available in the instance returned by initApplePayButton.

Hierarchy

  • ICardApplePay

Methods

  • This event is used to know when the token process is canceled.

    Parameters

    • callback: (() => void)
        • (): void
        • Returns void

    Returns void

    Example

    Instance of cardApplePay is previously initialized with initApplePayButton

    cardApplePay.onCancel(() => {
    console.log("Apple Pay token process canceled");
    });
  • This event is used to know when the user clicks on the Apple Pay button.

    Parameters

    • callback: (() => void)
        • (): void
        • Returns void

    Returns void

    Example

    Instance of cardApplePay is previously initialized with initApplePayButton

    cardApplePay.onClick(() => {
    console.log("Apple Pay button clicked");
    });
  • Starts the Apple Pay payment flow and requests a Kushki card token.

    This token is already processed and ready to be used in Kushki’s API to perform a charge

    ⚠️ This method requires that initApplePayButton has been successfully initialized and uses a valid ICardApplePay instance.

    Parameters

    • options: ApplePayGetTokenOptions

      Configuration options for the Apple Pay payment request.

      • countryCode: Merchant’s country (e.g., "BR", "CL", "CO", "CR", "EC", "SV", "GT", "HN", "MX", "NI", "PA", "PE").
      • currencyCode: Currency for the transaction (e.g., "USD", "COP", "CLP", "UF", "PEN", "MXN", "BRL", "CRC", "GTQ", "HNL", "NIO").
      • displayName: The merchant name displayed in the Apple Pay sheet.
      • amount: Transaction amount.
      • optionalApplePayFields: Additional Apple Pay configuration fields, following Apple’s specification: https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest These fields allow merchants to customize their checkout experience (e.g., required shipping methods, billing address, etc.).

    Returns Promise<AppleTokenResponse>

    Promise resolving to the tokenized payment response.

    Throws

    Example

    Basic Example usage:

    try{
    const response = await cardApplePay.requestApplePayToken(
    {
    countryCode: "EC",
    currencyCode: "USD",
    displayName: "My Store",
    amount: 5000
    });

    console.log("Card token:", response.token);
    } catch(error){
    console.error("Error requesting token:", error);
    }

    Example

    Required billing and shipping data Example usage:

    try{
    const response = await cardApplePay.requestApplePayToken(
    {
    countryCode: "EC",
    currencyCode: "USD",
    displayName: "My Store",
    amount: 5000,
    optionalApplePayFields:{
    requiredBillingContactFields: ["postalAddress"],
    requiredShippingContactFields: ["postalAddress"],
    }
    });

    console.log("Card token:", response.token);
    console.log("Apple Wallet billing data:", response.billingContact);
    console.log("Apple Wallet shipping data:", response.shippingContact);
    } catch(error){
    console.error("Error requesting token:", error);
    }

Generated using TypeDoc