> ## 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.

# Apple Pay

> Integrate Apple Pay with Cashfree Payments using hosted checkout, direct integration, or orchestration flows to accept payments from international cardholders.

Apple Pay provides a secure and seamless payment method that enables your customers to pay using their iPhone, iPad, Apple Watch, or Mac devices. Learn how to implement Apple Pay with Cashfree Payments based on your technical requirements and business needs.

Cashfree offers three methods to integrate Apple Pay:

* **Hosted checkout**: Use Cashfree's pre-built checkout page where customers can select Apple Pay as a payment option.
* **Direct integration**: Integrate Apple Pay directly into your application, decrypt the payment payload on your servers, and send the decrypted payment details to Cashfree for authorisation.
* **Orchestrator**: If you are integrating via an orchestrator, contact your orchestrator partner to configure Apple Pay within their platform. Ensure that Cashfree is set up as the payment processor on the orchestrator's dashboard, and request that they enable Apple Pay routing through Cashfree.

To enable Apple Pay payments for your customers, contact your Cashfree account manager or submit the [support form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).

<Tabs>
  <Tab title="Hosted checkout">
    This requires no additional development work from you and is suitable for quick implementation with minimal setup. If you use `api.cashfree.com`, no additional integration work is required. Cashfree ensures seamless processing of Apple Pay transactions.

    ### Benefits

    Hosted checkout offers the following benefits:

    * **Minimal development effort**: No Apple Pay-specific coding required.
    * **Automatic updates**: New Apple Pay features are automatically available.
    * **Reduced maintenance**: Cashfree manages certificates and compliance.
    * **Enhanced security**: All sensitive data handled by Cashfree's **PCI-compliant** infrastructure.

    ### Implementation

    Follow these steps to implement Apple Pay with hosted checkout:

    <Steps>
      <Step title="Create an order">
        Create an order using the Cashfree Create Order API:

        ```bash theme={"dark"}
        curl -X POST 'https://api.cashfree.com/pg/orders' \
          -H 'Content-Type: application/json' \
          -H 'x-api-version: 2023-08-01' \
          -H 'x-client-id: YOUR_CLIENT_ID' \
          -H 'x-client-secret: YOUR_CLIENT_SECRET' \
          -d '{
            "order_id": "order_001",
            "order_amount": 100.00,
            "order_currency": "INR",
            "customer_details": {
              "customer_id": "customer_001",
              "customer_name": "John Doe",
              "customer_email": "john@example.com",
              "customer_phone": "+919876543210"
            }
          }'
        ```
      </Step>

      <Step title="Redirect to checkout">
        Redirect your customers to the checkout address returned in the order creation response. Apple Pay is automatically displayed for eligible users.
      </Step>
    </Steps>

    ### Device compatibility

    Apple Pay is shown automatically for customers using the following supported devices:

    * iPhone with **Touch ID** or **Face ID**.
    * iPad with **Touch ID** or **Face ID**.
    * **Apple Watch**.
    * Mac with **Touch ID** or Mac paired with eligible Apple devices.
    * **Safari** browser on supported devices.
  </Tab>

  <Tab title="Direct integration">
    This approach gives you full control over the Apple Pay experience while you decrypt payment tokens on your servers. You must be **PCI-compliant** to handle decrypted payment data.

    <Warning>
      You must be PCI-compliant to handle decrypted payment data. Ensure your infrastructure meets PCI DSS requirements before implementing direct integration.
    </Warning>

    ### Prerequisites

    Before implementing direct Apple Pay integration, ensure you meet the following requirements:

    * An active **Apple Developer Program** membership.
    * A registered **Apple Merchant ID**.
    * **HTTPS-enabled** website or mobile application.
    * Valid **SSL/TLS certificate**.
    * **PCI DSS compliance** for handling decrypted payment data.
    * **Apple Pay Payment Processing Certificate**.
    * Technical capability to implement **Apple Pay SDK**.

    ### Apple developer setup

    Complete the following setup process in your Apple Developer account:

    <Steps>
      <Step title="Create Apple Merchant ID">
        1. Log in to your **Apple Developer account**.
        2. Navigate to **Certificates, Identifiers & Profiles** > **Identifiers**.
        3. Select the **+** button to create a new **Merchant ID**.
        4. Select **Merchant IDs** and select **Continue**.
        5. Enter a unique identifier and description.
        6. Select **Register** to create your **Merchant ID**.
      </Step>

      <Step title="Create payment processing certificate">
        1. In your **Merchant ID** settings, find **Apple Pay Payment Processing Certificate**.
        2. Select **Create Certificate**.
        3. Generate a **Certificate Signing Request (CSR)** using `OpenSSL`:

        ```bash theme={"dark"}
        openssl ecparam -out apple_pay_private.key -name prime256v1 -genkey
        openssl req -new -sha256 -key apple_pay_private.key -out apple_pay.csr
        ```

        4. Upload the **CSR file** to Apple.
        5. Download the signed certificate (`.cer` file).
        6. Convert and store the certificate securely on your servers.
      </Step>
    </Steps>

    ### Web implementation

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

    <Steps>
      <Step title="Check Apple Pay availability">
        ```javascript theme={"dark"}
        if (window.ApplePaySession && ApplePaySession.canMakePayments()) {
          // Show Apple Pay button
          document.getElementById('apple-pay-button').style.display = 'block';
        }
        ```
      </Step>

      <Step title="Create payment request">
        ```javascript theme={"dark"}
        const paymentRequest = {
          countryCode: 'IN',
          currencyCode: 'INR',
          supportedNetworks: ['visa', 'masterCard', 'amex'],
          merchantCapabilities: ['supports3DS'],
          total: {
            label: 'Your Store Name',
            amount: '100.00'
          }
        };
        ```
      </Step>

      <Step title="Handle Apple Pay session">
        ```javascript theme={"dark"}
        const session = new ApplePaySession(3, paymentRequest);

        session.onvalidatemerchant = function(event) {
          // Validate merchant with your server
          validateMerchant(event.validationURL)
            .then(merchantSession => {
              session.completeMerchantValidation(merchantSession);
            });
        };

        session.onpaymentauthorized = function(event) {
          // Process payment with decrypted data
          processPayment(event.payment.token)
            .then(result => {
              session.completePayment(ApplePaySession.STATUS_SUCCESS);
            })
            .catch(error => {
              session.completePayment(ApplePaySession.STATUS_FAILURE);
            });
        };

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

    ### iOS implementation

    Integrate Apple Pay into your iOS application using Swift and the PassKit framework:

    <Steps>
      <Step title="Configure Xcode project">
        1. Add **Apple Pay capability** to your app.
        2. Select your **Merchant ID** in the capabilities section.
      </Step>

      <Step title="Check device compatibility">
        ```swift theme={"dark"}
        import PassKit

        if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [.visa, .masterCard, .amex]) {
            // Show Apple Pay button
        }
        ```
      </Step>

      <Step title="Create payment request">
        ```swift theme={"dark"}
        let request = PKPaymentRequest()
        request.merchantIdentifier = "merchant.com.yourcompany.app"
        request.supportedNetworks = [.visa, .masterCard, .amex]
        request.merchantCapabilities = .capability3DS
        request.countryCode = "IN"
        request.currencyCode = "INR"
        request.paymentSummaryItems = [
            PKPaymentSummaryItem(label: "Total", amount: NSDecimalNumber(string: "100.00"))
        ]
        ```
      </Step>
    </Steps>

    ### Server-side processing

    Handle the encrypted Apple Pay token on your server and process the payment:

    <Steps>
      <Step title="Decrypt Apple Pay token and process payment">
        Implement token decryption following Apple's specifications:

        ```python theme={"dark"}
        def decrypt_apple_pay_token(encrypted_token, private_key):
            # Implement Apple Pay token decryption logic
            # Extract payment data, verify signatures
            # Return decrypted payment details
            pass
        ```

        After decryption, process the payment with Cashfree. For details, see the [Authorisation Only API](/api-reference/payments/latest/apple-pay/payments/authorize-payment-for-an-order).
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Apple guidelines

Follow Apple's official guidance for both design and technical implementation when enabling Apple Pay. Ensure that the UI, button usage, flows, and web and app behaviours meet Apple's Human Interface Guidelines and implementation standards.

## Compatibility

Apple Pay availability depends on issuer support, device and browser capability, and the shopper's country or region where Apple Pay is supported. See Apple's resources for the latest details:

* [Countries and regions](https://support.apple.com/en-us/102775) where Apple Pay is available.
* [Issuers and participating banks](https://support.apple.com/en-us/109524) that support Apple Pay.
* [Supported devices and browsers](https://support.apple.com/en-us/102896) for Apple Pay on the web and in apps.

### Customer visibility

Apple Pay appears as a payment option when the shopper has added an eligible card to Apple Wallet and is using a compatible device and browser in a supported region.

## Security and compliance

Apple Pay integration requires attention to security best practices and compliance requirements:

**Certificate management**

* **Apple Pay certificates** expire every 25 months.
* Store private keys in **hardware security modules** when possible.
* Limit certificate access to authorised personnel only.

**Data protection**

* Apple Pay uses device-specific tokens instead of actual card numbers.
* Transactions require **Touch ID**, **Face ID**, or device passcode.
* All communications use **TLS encryption**.

**Compliance requirements**

* **PCI DSS compliance** required only for direct integration.
* Avoid storing Apple Pay tokens; they are single-use.
* Ensure compliance with local payment regulations.

## Troubleshooting

Review these common issues and their resolutions when implementing Apple Pay:

**Apple Pay button not appearing**

* Verify device compatibility and **Safari** browser usage.
* Check **Apple Pay wallet** has cards added.
* Ensure **HTTPS** is enabled on your domain.

**Certificate errors**

* Regenerate **CSR** from your payment processor's dashboard.
* Verify the certificate has not expired (25-month validity).
* Ensure correct **merchant ID** association.

**Payment failures**

* Check **3DS authentication** requirements.
* Verify supported networks match customer's card.
* Validate payment amounts and currency codes.

**Error codes**

| Error code            | Description                            | Resolution                                       |
| --------------------- | -------------------------------------- | ------------------------------------------------ |
| `INVALID_MERCHANT_ID` | Merchant ID not recognised             | Verify Apple Pay configuration with Cashfree     |
| `CERTIFICATE_EXPIRED` | Payment processing certificate expired | Renew certificate through Apple Developer portal |
| `UNSUPPORTED_DEVICE`  | Device does not support Apple Pay      | Guide customer to supported payment methods      |

## Best practices

Follow these practices for optimal Apple Pay implementation:

* **Progressive enhancement**: Show Apple Pay only when available.
* **Clear labelling**: Use Apple's official button designs and guidelines.
* **Error handling**: Provide clear feedback for failed transactions.
* **Performance**: Minimise steps between button tap and payment completion.

For additional support or questions about Apple Pay integration, contact the Cashfree Payments support team through the [support form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1) or see the [API documentation](/api-reference/payments/latest/apple-pay).
