Skip to content
Go back

How To Test Apple Pay for Web

Posted on:February 23, 2023 at 11:00 AM

The implementation of Apple Pay itself isn’t very complicated. The biggest challenge is to get it to work in a development environment. In this article, I’ll show you how to test Apple Pay for web.

What is Apple Pay?

Apple Pay is a payment method that allows you to pay for goods and services with your Apple device. It’s a very secure way of paying, as it uses Touch ID or Face ID to verify your identity. It’s also very convenient, as you don’t have to enter your credit card details every time you want to make a purchase.

What do you need to test Apple Pay for your website?

To test Apple Pay for your website you need:

You could connect an iPhone to your Macbook, but when using a Macbook you can use the built-in developer tools of Safari. This makes it a lot easier to test and debug your Apple Pay implementation.

Creating a second user on your Mac

Unless you are willing to sign out your Apple ID from your normal Mac user, you will need to create a second user on your Mac. This is because you can only have one Apple ID signed in at a time. If you want to test Apple Pay for your website, you will need to sign in with your “Sandbox Tester” Apple ID.

But that means having to set up an entire development environment again. After some searching, I found a way to create a second user on your Mac without having to set up a new development environment manually. This is how you do it:

  1. Open the Terminal app
  2. Run sudo mkdir /users/newshortname (replace newshortname with the shortname of the new user)
  3. Run sudo ditto ~ /users/newshortname. This will copy all the files from your current user to the new user.
  4. From your current user, go to System Preferences > Users & Groups
  5. Click the lock icon in the bottom left corner to unlock the settings
  6. Click the ”+” button to add a new user
  7. Fill in the details of the new user
  8. Click “Create User”
  9. You will be prompted to use the existing home directory. This is the one you just created in step 3.
  10. Log out of your current user and log in with the new user
  11. Open your terminal and navigate to your home directory
  12. Run sudo chown -R $(whoami) . to change ownership of the home directory via the terminal. This is necessary because the ownership of the home directory is still the same as your old user.

Now we can add one of the testing credit cards to our new user. This is how you do it:

  1. Go to System Preferences > Apple ID
  2. Log in with your “Sandbox Tester” Apple ID
  3. Go to Apple’s sandbox testing page and copy one of the testing credit cards
  4. Go to System Preferences > Wallet & Apple Pay
  5. Add the testing credit card to your Apple Pay wallet

If this all worked without errors, you should now be able to test your Apple Pay implementation. If you are getting an error when adding the test credit card, you might need to double-check your Apple ID’s region. It needs to be set to a country that is allowed to test Apple Pay (e.g. the US).

Start your development servers and start your tunneling service for your website and your mock API if you have one. Then open Safari on your Apple device and navigate to your website. You should now be able to test Apple Pay for your website.

Apple Pay pop-up showing a "processing" status with a line item saying "Pay demo (card is not charged)"

Conclusion

Testing Apple Pay for your website can be a bit of a hassle. But once you have everything set up, it’s actually not that complicated. I hope this article helped you to get started with testing Apple Pay for your website.

Resources used