Learn how to add Apple Pay to the application you built in Take a Card Payment with the Web Payments SDK, using the Quickstart project sample. To see whether digital wallets are supported in your country, see Supported Payment Methods by Country.
The steps in this topic add code to the Quickstart project sample. If you haven't created an application using the Quickstart, you need to do so before completing the following steps.
The following shows the Apple Pay sheet rendered by the Web Payments SDK:
You can find a complete example of the Apple Pay code in GitHub.
The Square Web Payments SDK adheres to Apple's development requirements for Apple Pay on the Web. To take an Apple Pay payment, the following must be true:
- Apple Pay is supported on Apple Safari browsers.
- You're using HTTPS and have a Square account. Apple Pay payments cannot be tested with HTTP or from localhost.
- You use the payment form in a Safari browser that is:
If you're developing on a MacBook Pro, it might be necessary to activate Apple Pay and Touch ID, and then restart Safari.
By registering your domain to use Apple Pay and the Apple Pay Platform, you agree to the Apple Pay Platform Web Merchant Terms and Conditions.
You must configure the Terms and Conditions certificate to download when the buyer visits the URL. Otherwise, your application won't be able to validate the agreement. Also, if the certificate gets a file extension added to it by your server, the validation won't work.
To register a Sandbox domain for Apple Pay in the Square Sandbox:
Open the Developer Dashboard.
Choose the application associated with your Web Payments SDK implementation.
Set the Developer Dashboard to Sandbox mode.
In the left pane, choose Apple Pay for the selected application.
Choose the Add Sandbox Domain link and follow the instructions.
Apple Merchant ID - Because Square generates domain validation with Apple Pay when the payment page loads, you don't need to create an Apple merchant ID or call the Apple APIs to enable the functionality.
Domain association folder - If you're using the server provided by the Quickstart application, put the
.well-known/apple-developer-merchantid-domain-associationfolder and file under the
publicdirectory. The domain verification file works only with Square as the domain.
For Sandbox testing or production, the domain where you use Apple Pay must be an HTTPS domain. You cannot use a localhost or an HTTP URL with Apple Pay.