Payment Form: Cookbook

Programmatically Register Multiple Domains for Apple Pay

Enable Apple Pay in multiple domains by registering domains programmatically with Square.

Before you start Permalink Get a link to this section

Programmatically register multiple domains Permalink Get a link to this section

You can use the RegisterDomain endpoint to activate multiple domains and subdomains.

Bulk registering domains can save you time if you are using SqPaymentForm as part of a platform where payments are processed on multiple subdomains. For example, you might be building a shop platform (platform.com), where sellers can create their own shops and take payments (shoes.platform.com and plants.platform.com). All these individual subdomains need to be registered to enable Web Apple Pay with Square.

To programmatically register a client domain:

  1. Download Square's copy of Apple's merchant domain verification file.

  2. Host the verification file at: https://{CLIENT DOMAIN}/.well-known/apple-developer-merchantid-domain-association.

  3. Use the RegisterDomain endpoint of the Square Apple Pay API to register and validate the domain.

The following example registers example.com:

Register Domain
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
curl https://connect.squareup.com/v2/apple-pay/domains \
  -X POST \
  -H 'Square-Version: 2021-03-17' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "domain_name": "example.com"
  }'

The response JSON:

{
  "status": "VERIFIED"
}