> ## Documentation Index
> Fetch the complete documentation index at: https://www.cashfree.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cashfree Decrypts Apple Pay Using Cashfree's Apple Account

> Integrate Apple Pay on a custom web checkout with no Apple Developer account required, using Cashfree's own Apple credentials.

Cashfree manages all Apple Pay credentials, domain registration, and merchant validation on your behalf. You do not need an Apple Developer account. Cashfree also handles decryption and authorisation.

<Warning>
  This option is for web checkout only. If you need Apple Pay in an iOS app, you must have your own Apple Developer account. See [Cashfree Decrypts, Own Apple Account](/docs/payments/manage/payment-methods/credit-and-debit-cards/apple-pay/custom-checkout/cashfree-decrypts/own-account).
</Warning>

<Info>
  No PCI DSS compliance is required for decryption, and no Apple Developer account is required. Cashfree manages all Apple credentials and certificates.
</Info>

## Prerequisites

Before implementing Apple Pay with this option, ensure you meet the following requirements.

* HTTPS-enabled website.
* Valid SSL/TLS certificate.
* Technical capability to implement the Apple Pay JS SDK.

## Set up Apple Pay on the Cashfree Merchant Dashboard

Complete the following setup process on the Merchant Dashboard.

<Steps>
  <Step title="Add your checkout domains">
    1. Log in to the [Merchant Dashboard](https://merchant.cashfree.com/auth/login).
    2. Navigate to **Settings > Payment Methods > Apple Pay**.
    3. Select **Custom Checkout > Cashfree Decrypts > I don't have an Apple Developer Account**.
    4. Add all your checkout domains where you want to accept Apple Pay as a payment option, for example `checkout.yourstore.com`. You can add multiple domains; each is registered separately with Apple.
  </Step>

  <Step title="Host the domain verification file">
    1. Select **Download Verification File** in the Merchant Dashboard.
    2. Host the file at this exact path on each of your domains:

    ```text theme={"dark"}
    https://<YOUR_DOMAIN>/.well-known/apple-developer-merchantid-domain-association
    ```

    The file must be publicly accessible, with no login and no redirect, served over HTTPS. The path must match exactly; Apple does not accept variations.

    <Warning>
      Domain registration fails if the verification file is not accessible at the correct path. Ensure the file is live before selecting **Verify** in the next step.
    </Warning>
  </Step>

  <Step title="Verify your domain">
    1. Return to the Merchant Dashboard.
    2. Select **Activate**. Cashfree registers your domains with Apple, and Apple Pay is enabled for each of those domains.
  </Step>
</Steps>

<Note>
  If you add new checkout domains in future, repeat the file-hosting and verification steps for each new domain. Apple Pay does not work on unregistered domains.
</Note>

## Implement Apple Pay on web

Implement Apple Pay in your web application using the following JavaScript steps.

<Steps>
  <Step title="Check Apple Pay availability">
    ```javascript theme={"dark"}
    // Check if the Apple Pay JS API is available on this device/browser
    if (!window.ApplePaySession) {
      // Apple Pay not supported — hide button
      return;
    }

    // Check device capability
    if (!ApplePaySession.canMakePayments()) {
      // Device does not support Apple Pay
      return;
    }

    // Check if the customer has an active card in Wallet.
    // Use Cashfree's merchant identifier here.
    const merchantIdentifier = '<cashfree_merchant_identifier>';
    const status = await ApplePaySession.applePayCapabilities(merchantIdentifier);
    if (status.paymentCredentialStatus === 'paymentCredentialsAvailable') {
      document.getElementById('apple-pay-button').style.display = 'block';
    }
    ```
  </Step>

  <Step title="Load the Apple Pay button">
    ```html theme={"dark"}
    <!-- Include the Apple Pay JS SDK -->
    <script src="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js"></script>

    <!-- Render the Apple Pay button -->
    <apple-pay-button buttonstyle="black" type="buy" locale="en-IN"></apple-pay-button>
    ```
  </Step>

  <Step title="Create the payment request and initiate the session">
    ```javascript theme={"dark"}
    const paymentRequest = {
      countryCode: 'IN',
      currencyCode: 'INR',
      supportedNetworks: ['visa', 'masterCard', 'amex'],
      supportedCountries: ['IN'],
      merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
      total: {
        label: 'Your Store Name',
        amount: '100.00',
        type: 'final'
      }
    };
    const session = new ApplePaySession(3, paymentRequest);
    ```
  </Step>

  <Step title="Handle merchant validation through Cashfree">
    You must call Cashfree to handle the session request during merchant validation, as it requires Cashfree's Apple credentials.

    ```javascript theme={"dark"}
    session.onvalidatemerchant = async (event) => {
      // Call Cashfree's merchant validation API.
      // Cashfree handles the Apple session request on your behalf.
      const response = await fetch('https://api.cashfree.com/pg/applepay/validate-merchant', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          payment_session_id: '<payment_session_id>',
          validation_url: event.validationURL,
          domain_name: window.location.hostname
        })
      });
      const merchantSession = await response.json();
      session.completeMerchantValidation(merchantSession);
    };
    ```
  </Step>

  <Step title="Handle payment authorisation">
    After the customer authenticates with Face ID or Touch ID, Apple Pay fires the `onpaymentauthorized` event with the encrypted payment token. Pass the encrypted token to your server, then call the Cashfree [Authorisation Only API](/docs/api-reference/payments/latest/payments/order-pay-authorise-only) with the encrypted data. Cashfree decrypts it and processes authorisation on your behalf.

    ```javascript theme={"dark"}
    session.onpaymentauthorized = async (event) => {
      // Forward the encrypted token to Cashfree for decryption and authorisation.
      const response = await fetch('https://api.cashfree.com/pg/orders/sessions/pay', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          payment_session_id: '<payment_session_id>',
          encrypted_token: event.payment.token,
          transaction_type: 'APPLE_PAY'
        })
      });
      const result = await response.json();

      if (result.payment_status === 'SUCCESS') {
        session.completePayment(ApplePaySession.STATUS_SUCCESS);
      } else {
        session.completePayment(ApplePaySession.STATUS_FAILURE);
      }
    };

    session.begin();
    ```
  </Step>
</Steps>

## Decryption and authorisation via Cashfree

Pass the encrypted payment object received from Apple Pay to process the payment with Cashfree using the [Authorisation Only API](/docs/api-reference/payments/latest/payments/order-pay-authorise-only). Cashfree decrypts it and processes authorisation on your behalf.

<div class="hidden" data-table-of-contents="bottom">
  <p class="mt-4 font-medium flex items-center gap-2 related-docs-heading">
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="w-4 h-4">
      <path d="M3 4h7a2 2 0 0 1 2 2v13a2 2 0 0-2-2H3z" />

      <path d="M21 4h-7a2 2 0 0 0-2 2v13a2 2 0 0 1 2-2h7z" />
    </svg>

    <span>Related topics</span>
  </p>

  <ul>
    <li><a href="/docs/api-reference/payments/latest/payments/order-pay-authorise-only">Authorisation Only API</a></li>
    <li><a href="/docs/payments/manage/payment-methods/credit-and-debit-cards/apple-pay/custom-checkout/overview">Apple Pay Custom Checkout Overview</a></li>
    <li><a href="/docs/payments/manage/payment-methods/credit-and-debit-cards/apple-pay/custom-checkout/cashfree-decrypts/own-account">Cashfree Decrypts, Own Apple Account</a></li>
  </ul>
</div>
