Payment Form: Cookbook

Programmatically register multiple domains

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

Payment Form

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 a part of a platform where payments are processed on multiple subdomains. For example, you might be building a shop platform (, where users can create their own shops and take payments (, All of 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 Square's ApplePay API to register and validate the domain. Here is an example using the Connect v2 PHP SDK.
//Replace with your access token and domain name.
$accessToken = '{REPLACE_ME}';
$domain = '{REPLACE_ME}';

// Include the Square Connect API resources
require_once(__DIR__ . '/local/path/to/Square/Connect/SDK/autoload.php');

// Create and configure a new API client object
$defaultApiConfig = new \SquareConnect\Configuration();

$defaultApiClient = new \SquareConnect\ApiClient($defaultApiConfig);
$apiInstance = new SquareConnect\Api\ApplePayApi($defaultApiClient);

// Create a request object.
$request = new \SquareConnect\Model\RegisterDomainRequest();
// Set the domain field in the request object.
// Send the request. This will print the results for testing purposes.
try {
    $result = $apiInstance->registerDomain($request);
catch (Exception $e) {
    echo 'Exception when calling the RegisterDomain endpoint ',
    $e->getMessage(), PHP_EOL;

Or you can use a cURL command:

curl  \
  -H 'Authorization: Bearer {ACCESS_TOKEN}'             \
  -H 'Content-Type: application/json'                   \
  -d '{ "domain_name" : "{{CLIENT DOMAIN}}" }'

Contact Developer Support, join our Slack channel, or ask for help on Stack Overflow