> ## Documentation Index
> Fetch the complete documentation index at: https://developers.pcibooking.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Apple Pay Setup

> Configure Apple Pay with PCI Booking. Certificate generation, merchant ID registration, and domain verification.

**Requires:** [Apple Developer Program](https://developer.apple.com/programs/) membership (\$99/year).

Apple Pay setup involves creating a Merchant ID, verifying your domain, and generating two certificates in the Apple Developer Portal.

## 1. Create a Merchant ID

A Merchant ID identifies you as a merchant who can accept payments via Apple Pay.

1. Sign in to your [Apple Developer Account](https://developer.apple.com/account/).
2. Go to **Certificates, Identifiers & Profiles** > **Identifiers**.
3. Click **+** to add a new identifier.
4. Select **Merchant IDs**.
5. Enter a **description** and a **unique identifier** (e.g. `merchant.com.example.yourbusiness`).
6. Click **Continue**, review, and **Register**.

## 2. Verify Your Domain

Apple requires your domain to be verified before Apple Pay can be used on it.

1. Go back to your **Merchant ID** page in the developer portal.
2. Under your Merchant ID, click **Edit** and then **Verify Your Domain**.
3. Enter the domain name (e.g. `example.com`).
4. Download the **Apple Pay Verification File** (`apple-developer-merchantid-domain-association`).
5. Upload the file to the `.well-known` directory on your domain. The full URL should be: `https://yourdomain.com/.well-known/apple-developer-merchantid-domain-association`
6. Return to the Apple Developer Portal and click **Verify**.

<Warning>
  The file must be served over HTTPS without redirects. Download the file only once. Repeated downloads generate new content.
</Warning>

## 3. Create Payment Processing Certificate

This certificate is used to handle payment data securely.

1. Generate a Certificate Signing Request (CSR):

```bash theme={null}
openssl ecparam -genkey -name prime256v1 -out ~/mykey.key -noout
openssl req -new -sha256 -key ~/mykey.key -out ~/request.csr -subj /CN=www.mydomain.com
```

2. In the Apple Developer Portal, select your **Merchant ID**.
3. Under **Apple Pay Payment Processing Certificate**, click **Create Certificate**.
4. Upload your `request.csr`.
5. Download the certificate (`apple_pay.cer`).
6. Convert to PEM:

```bash theme={null}
openssl x509 -inform DER -in ~/apple_pay.cer -out ~/apple_pay.pem
```

## 4. Create Merchant Identity Certificate

This certificate allows your server to authenticate itself to Apple's servers.

1. Generate a CSR and key file:

```bash theme={null}
openssl req -out ~/uploadMe.csr -new -newkey rsa:2048 -nodes -keyout ~/clientCertificate.key
```

<Info>
  In the prompt, enter your details. The **Common Name** should match the one used in the previous step. When asked for a password, leave it blank and press Enter.
</Info>

2. In the Apple Developer Portal, select your **Merchant ID**.
3. Under **Apple Pay Merchant Identity Certificate**, click **Create Certificate**.
4. Upload your `uploadMe.csr`.
5. Download the certificate (`merchant_id.cer`).
6. Convert to PEM:

```bash theme={null}
openssl x509 -inform der -in ~/merchant_id.cer -out ~/clientCertificate.pem
```

## 5. Store in PCI Booking

After completing the steps above, you should have these files:

| File                    | Generated In |
| ----------------------- | ------------ |
| `mykey.key`             | Step 3       |
| `apple_pay.pem`         | Step 3       |
| `clientCertificate.key` | Step 4       |
| `clientCertificate.pem` | Step 4       |

When creating the eWallet account in PCI Booking, provide:

| Field                                   | Value                                                                            |
| --------------------------------------- | -------------------------------------------------------------------------------- |
| **eWallet Type**                        | ApplePay                                                                         |
| **Merchant Identifier**                 | Your Apple Merchant ID (e.g. `merchant.com.example.yourbusiness`)                |
| **Merchant Display Name**               | Name shown to payers                                                             |
| **Domain Name**                         | Domain where Apple Pay button is hosted (must match the CN in your certificates) |
| **Client Certificate PEM**              | Contents of `clientCertificate.pem`                                              |
| **Client Certificate Private Key PEM**  | Contents of `clientCertificate.key`                                              |
| **Payment Certificate Private Key PEM** | Contents of `mykey.key`                                                          |
| **Payment Certificate PEM**             | Contents of `apple_pay.pem`                                                      |

## Testing

Use [Apple Pay Sandbox](https://developer.apple.com/apple-pay/sandbox-testing/) with test cards in Safari on macOS or iOS.

## Next Steps

<CardGroup cols={2}>
  <Card title="Payments Library Credentials" icon="book" href="/account-setup/payments-library-credentials">
    Overview of all payment method credentials
  </Card>

  <Card title="Payments Library Overview" icon="book" href="/payments-library/overview">
    Integrate the library in your checkout page
  </Card>
</CardGroup>
