# How to set up Apple Pay (https://developer.godaddy.com/en/docs/api-users/commerce/accept-payments/online-payments/apple-pay)

---
title: How to set up Apple Pay
description: >-
  Register your website domain for Apple Pay so Unified Checkout can offer it on
  web checkout.
keywords: >-
  set up Apple Pay, Apple Pay domain registration, domain association file,
  apple-developer-merchantid-domain-association, Unified Checkout Apple Pay,
  registerDomains, commerce.store.apple-pay:write, merchantUrl.
agentNotes:
  permissions:
    - GoDaddy Payments account on the business that owns the store
  scopes:
    - 'commerce.store:read'
    - 'commerce.store.apple-pay:write'
  idempotent: false
  destructive: false
  failureRecovery: >-
    Retry a GET. A POST that returns 400 because Apple can't fetch the domain
    association file succeeds after you host the file and call again. A 204
    means the store has no registration left, or a domain in unregisterDomains
    wasn't registered. Removing a domain takes Apple Pay off that hostname. The
    store itself isn't deleted. A 403 means Apple Pay isn't enabled for the
    store.
related:
  guides:
    - title: Checkout session reference
      href: /docs/api-users/commerce/accept-payments/online-payments/session-fields
    - title: How to render embedded checkout
      href: /docs/api-users/commerce/accept-payments/online-payments/embedded
    - title: How to use hosted checkout
      href: /docs/api-users/commerce/accept-payments/online-payments/hosted
    - title: About accepting payments
      href: /docs/api-users/commerce/accept-payments
  apis:
    - title: Register domains for Apple Pay
      href: /docs/references/rest/apple-pay/register-apple-pay-domains
    - title: Get Apple Pay registration
      href: /docs/references/rest/apple-pay/get-apple-pay-registration
    - title: Get the Apple Pay domain association file
      href: /docs/references/rest/apple-pay/get-apple-pay-domain-association-file
  concepts:
    - title: About online payments
      href: /docs/api-users/commerce/accept-payments/online-payments
pageId: f4622a75-ba0b-4348-a8d6-95fb7d3421c8
---

## Overview

This page covers the steps to register a website hostname with Apple so Unified Checkout can offer Apple Pay. It uses the Apple Pay API at `https://api.godaddy.com/v1/commerce`. Terminal payments through Payment Requests don't need domain registration.

Your server downloads a domain association file with `GET /stores/{storeId}/apple-pay/domain-association-file`, hosts the file unchanged on the checkout hostname, and registers that hostname with `POST /stores/{storeId}/apple-pay/registration`. The same POST can remove an old hostname, and `GET /stores/{storeId}/apple-pay/registration` returns the registered domains. Send each hostname in `registerDomains` and `unregisterDomains` with no scheme or path. `shop.example.com` is valid, and `registerDomains` accepts at most 99 hostnames per call. The body needs at least one of `registerDomains`, `unregisterDomains`, or `merchantName`. Omit `merchantName` and the store keeps its current Apple Pay name, or uses the business's doing-business-as or legal name. `merchantUrl` is an absolute URL, like `https://shop.example.com`. `reason` is optional.

Go to [How to configure checkout](https://developer.godaddy.com/docs/api-users/commerce/accept-payments/online-payments/configure#choose-payment-methods) for the `applePay` payment method. Go to [Register domains for Apple Pay](https://developer.godaddy.com/docs/references/rest/apple-pay/register-apple-pay-domains) for the request and response schemas.

## Prerequisites

You need the following before you can set up Apple Pay:

* a [GoDaddy Payments](https://www.godaddy.com/payments) account on the business that owns the store

  Go to [Set up a GoDaddy Payments account](https://www.godaddy.com/help/get-started-with-godaddy-payments-40721) for account creation and store activation.
* a [Personal Access Token (PAT)](https://developer.godaddy.com/docs/api-users/auth/how-to) with the `commerce.store:read` and `commerce.store.apple-pay:write` scopes, created on the account that owns the store
* your `storeId`

  Sign in to your GoDaddy account. Go to [About the Commerce API](https://developer.godaddy.com/docs/api-users/commerce#your-stores) for your `storeId`.
* a public HTTPS domain where web checkout is offered

## Register a domain

The following procedure registers a checkout domain for Apple Pay.

1. Download the domain association file:

   The response body is `text/plain`. Host that file unchanged.

   ```bash tab="curl"
   curl -fsS "https://api.godaddy.com/v1/commerce/stores/$STORE_ID/apple-pay/domain-association-file" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -o apple-developer-merchantid-domain-association
   ```

   ```js tab="Node"
   import { writeFile } from "node:fs/promises";

   const token = process.env.GODADDY_PAT;
   const storeId = process.env.STORE_ID;

   const res = await fetch(
     `https://api.godaddy.com/v1/commerce/stores/${storeId}/apple-pay/domain-association-file`,
     { headers: { Authorization: `Bearer ${token}` } }
   );
   if (!res.ok) {
     throw new Error(`Download failed: ${res.status}`);
   }
   await writeFile(
     "apple-developer-merchantid-domain-association",
     Buffer.from(await res.arrayBuffer())
   );
   ```

   ```python tab="Python"
   import os, requests

   token = os.environ["GODADDY_PAT"]
   store_id = os.environ["STORE_ID"]

   res = requests.get(
       f"https://api.godaddy.com/v1/commerce/stores/{store_id}/apple-pay/domain-association-file",
       headers={"Authorization": f"Bearer {token}"},
   )
   res.raise_for_status()
   with open("apple-developer-merchantid-domain-association", "wb") as association_file:
       association_file.write(res.content)
   ```

   ```go tab="Go"
   package main

   import (
   	"fmt"
   	"io"
   	"net/http"
   	"os"
   )

   func main() {
   	token := os.Getenv("GODADDY_PAT")
   	storeId := os.Getenv("STORE_ID")

   	url := fmt.Sprintf(
   		"https://api.godaddy.com/v1/commerce/stores/%s/apple-pay/domain-association-file",
   		storeId,
   	)
   	req, _ := http.NewRequest("GET", url, nil)
   	req.Header.Set("Authorization", "Bearer "+token)

   	res, err := http.DefaultClient.Do(req)
   	if err != nil {
   		panic(err)
   	}
   	defer res.Body.Close()
   	if res.StatusCode != http.StatusOK {
   		panic(res.Status)
   	}

   	body, _ := io.ReadAll(res.Body)
   	os.WriteFile("apple-developer-merchantid-domain-association", body, 0644)
   }
   ```

2. Host the downloaded file unchanged at `/.well-known/apple-developer-merchantid-domain-association`:

   Apple fetches this file in production before registration can succeed. The register call returns `400` when Apple can't fetch the file.

3. Register the domain:

   ```bash tab="curl"
   curl -s -X POST "https://api.godaddy.com/v1/commerce/stores/$STORE_ID/apple-pay/registration" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -H "Content-Type: application/json" \
     -d '{
       "registerDomains": ["'"$DOMAIN"'"]
     }'
   ```

   ```js tab="Node"
   const token = process.env.GODADDY_PAT;
   const storeId = process.env.STORE_ID;

   const res = await fetch(
     `https://api.godaddy.com/v1/commerce/stores/${storeId}/apple-pay/registration`,
     {
       method: "POST",
       headers: {
         Authorization: `Bearer ${token}`,
         "Content-Type": "application/json",
       },
       body: JSON.stringify({
         registerDomains: [process.env.DOMAIN],
       }),
     }
   );
   console.log(res.status, await res.text());
   ```

   ```python tab="Python"
   import os, requests

   token = os.environ["GODADDY_PAT"]
   store_id = os.environ["STORE_ID"]

   res = requests.post(
       f"https://api.godaddy.com/v1/commerce/stores/{store_id}/apple-pay/registration",
       headers={
           "Authorization": f"Bearer {token}",
           "Content-Type": "application/json",
       },
       json={
           "registerDomains": [os.environ["DOMAIN"]],
       },
   )
   res.raise_for_status()
   print(res.status_code, res.text)
   ```

   ```go tab="Go"
   package main

   import (
   	"bytes"
   	"encoding/json"
   	"fmt"
   	"io"
   	"net/http"
   	"os"
   )

   func main() {
   	token := os.Getenv("GODADDY_PAT")
   	storeId := os.Getenv("STORE_ID")

   	body, _ := json.Marshal(map[string]any{
   		"registerDomains": []string{os.Getenv("DOMAIN")},
   	})

   	url := fmt.Sprintf(
   		"https://api.godaddy.com/v1/commerce/stores/%s/apple-pay/registration",
   		storeId,
   	)
   	req, _ := http.NewRequest("POST", url, bytes.NewReader(body))
   	req.Header.Set("Authorization", "Bearer "+token)
   	req.Header.Set("Content-Type", "application/json")

   	res, err := http.DefaultClient.Do(req)
   	if err != nil {
   		panic(err)
   	}
   	defer res.Body.Close()

   	payload, _ := io.ReadAll(res.Body)
   	fmt.Println(res.StatusCode, string(payload))
   }
   ```

4. Check the registration:

   ```bash tab="curl"
   curl -s -w "\n%{http_code}\n" "https://api.godaddy.com/v1/commerce/stores/$STORE_ID/apple-pay/registration" \
     -H "Authorization: Bearer $GODADDY_PAT"
   ```

   ```js tab="Node"
   const token = process.env.GODADDY_PAT;
   const storeId = process.env.STORE_ID;

   const res = await fetch(
     `https://api.godaddy.com/v1/commerce/stores/${storeId}/apple-pay/registration`,
     { headers: { Authorization: `Bearer ${token}` } }
   );
   if (res.status !== 200) {
     console.log(res.status, await res.text());
   } else {
     const registration = await res.json();
     console.log(registration.domains);
   }
   ```

   ```python tab="Python"
   import os, requests

   token = os.environ["GODADDY_PAT"]
   store_id = os.environ["STORE_ID"]

   res = requests.get(
       f"https://api.godaddy.com/v1/commerce/stores/{store_id}/apple-pay/registration",
       headers={"Authorization": f"Bearer {token}"},
   )
   res.raise_for_status()
   print(res.json().get("domains"))
   ```

   ```go tab="Go"
   package main

   import (
   	"encoding/json"
   	"fmt"
   	"io"
   	"net/http"
   	"os"
   )

   func main() {
   	token := os.Getenv("GODADDY_PAT")
   	storeId := os.Getenv("STORE_ID")

   	url := fmt.Sprintf(
   		"https://api.godaddy.com/v1/commerce/stores/%s/apple-pay/registration",
   		storeId,
   	)
   	req, _ := http.NewRequest("GET", url, nil)
   	req.Header.Set("Authorization", "Bearer "+token)

   	res, err := http.DefaultClient.Do(req)
   	if err != nil {
   		panic(err)
   	}
   	defer res.Body.Close()

   	if res.StatusCode != http.StatusOK {
   		payload, _ := io.ReadAll(res.Body)
   		fmt.Println(res.StatusCode, string(payload))
   		return
   	}

   	var registration map[string]any
   	json.NewDecoder(res.Body).Decode(&registration)
   	fmt.Println(registration["domains"])
   }
   ```

## Move to a new domain

The following procedure moves Apple Pay to a new domain.

1. Host the same domain association file, unchanged, on the new domain:

   Apple fetches `/.well-known/apple-developer-merchantid-domain-association` on the new hostname before the move can succeed.

2. Register the new domain and remove the old one:

   ```bash tab="curl"
   curl -s -w "\n%{http_code}\n" -X POST "https://api.godaddy.com/v1/commerce/stores/$STORE_ID/apple-pay/registration" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -H "Content-Type: application/json" \
     -d '{
       "registerDomains": ["'"$DOMAIN"'"],
       "unregisterDomains": ["'"$OLD_DOMAIN"'"]
     }'
   ```

   ```js tab="Node"
   const token = process.env.GODADDY_PAT;
   const storeId = process.env.STORE_ID;

   const res = await fetch(
     `https://api.godaddy.com/v1/commerce/stores/${storeId}/apple-pay/registration`,
     {
       method: "POST",
       headers: {
         Authorization: `Bearer ${token}`,
         "Content-Type": "application/json",
       },
       body: JSON.stringify({
         registerDomains: [process.env.DOMAIN],
         unregisterDomains: [process.env.OLD_DOMAIN],
       }),
     }
   );
   console.log(res.status, await res.text());
   ```

   ```python tab="Python"
   import os, requests

   token = os.environ["GODADDY_PAT"]
   store_id = os.environ["STORE_ID"]

   res = requests.post(
       f"https://api.godaddy.com/v1/commerce/stores/{store_id}/apple-pay/registration",
       headers={
           "Authorization": f"Bearer {token}",
           "Content-Type": "application/json",
       },
       json={
           "registerDomains": [os.environ["DOMAIN"]],
           "unregisterDomains": [os.environ["OLD_DOMAIN"]],
       },
   )
   res.raise_for_status()
   print(res.status_code, res.text)
   ```

   ```go tab="Go"
   package main

   import (
   	"bytes"
   	"encoding/json"
   	"fmt"
   	"io"
   	"net/http"
   	"os"
   )

   func main() {
   	token := os.Getenv("GODADDY_PAT")
   	storeId := os.Getenv("STORE_ID")

   	body, _ := json.Marshal(map[string]any{
   		"registerDomains":   []string{os.Getenv("DOMAIN")},
   		"unregisterDomains": []string{os.Getenv("OLD_DOMAIN")},
   	})

   	url := fmt.Sprintf(
   		"https://api.godaddy.com/v1/commerce/stores/%s/apple-pay/registration",
   		storeId,
   	)
   	req, _ := http.NewRequest("POST", url, bytes.NewReader(body))
   	req.Header.Set("Authorization", "Bearer "+token)
   	req.Header.Set("Content-Type", "application/json")

   	res, err := http.DefaultClient.Do(req)
   	if err != nil {
   		panic(err)
   	}
   	defer res.Body.Close()

   	payload, _ := io.ReadAll(res.Body)
   	fmt.Println(res.StatusCode, string(payload))
   }
   ```

3. Go to [Register a domain](#register-a-domain) for the registration check.

## Example responses

The following examples show trimmed `200` responses.

### Register domains

`200` returns the store's current registration. The response omits `merchantUrl` when you don't send it.

`204` has no body when the store has no registration left, or when a domain in `unregisterDomains` isn't registered.

The following example shows a `200` response:

```json
{
  "domains": ["$DOMAIN"],
  "merchantName": "$MERCHANT_NAME"
}
```

### Get the registration

The hostname you registered appears in `domains` on a `200` response. A missing hostname in that body means the register call didn't add it.

The following example shows a `200` response with the registered domains and merchant name:

```json
{
  "domains": ["$DOMAIN"],
  "merchantName": "$MERCHANT_NAME"
}
```

## Common errors

The following table lists common errors for these calls:

| Status | Most likely cause                                                               | Note                                                                                                                                                                                                                                                                         |
| ------ | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | The input is invalid. On `POST`, Apple can't fetch the domain association file. | Host the file at `/.well-known/apple-developer-merchantid-domain-association` before `POST`. Send hostnames with no scheme or path. `registerDomains` accepts at most 99 hostnames per call. Send at least one of `registerDomains`, `unregisterDomains`, or `merchantName`. |
| `401`  | The PAT is missing, expired, or lacks the required scope.                       | `POST` needs `commerce.store.apple-pay:write`. Both `GET` calls need `commerce.store:read`.                                                                                                                                                                                  |
| `403`  | Apple Pay isn't enabled for the store.                                          | This API doesn't enable Apple Pay.                                                                                                                                                                                                                                           |
| `404`  | The store doesn't exist.                                                        | Confirm `storeId`.                                                                                                                                                                                                                                                           |
| `429`  | The call exceeded the rate limit.                                               | Wait, then retry the same request.                                                                                                                                                                                                                                           |
| `500`  | The API returned an internal server error.                                      | Retry the same call.                                                                                                                                                                                                                                                         |
| `502`  | Apple returned a server error on `POST`.                                        | Retry the register call.                                                                                                                                                                                                                                                     |
| `504`  | The call to Apple timed out on `POST`.                                          | Retry the register call.                                                                                                                                                                                                                                                     |

Go to [Register domains for Apple Pay](https://developer.godaddy.com/docs/references/rest/apple-pay/register-apple-pay-domains) for the full schemas.
