Setting up Apple Pay

Apple Pay is a mobile payment and digital wallet service created by Apple in 2014. It enables users to make payments with all the devices from their ecosystem. That’s all great, but it can be tricky to setup. The documentation is at times misleading and doesn’t provide enough details, especially for testing in the Sandbox environment.

Here I’ll summarise the steps needed to set this up properly.

App ID setup

First, you will need to update the App ID in with the Apple Pay functionality.

Screen Shot 2017-02-21 at 16.27.31.png

After Apple Pay is enabled, you will need to setup Merchant ID for it. For this, go to the Merchant IDs menu item under Identifiers in the developer portal:

Screen Shot 2017-02-22 at 15.18.21.png

Next, you need to create a certificate for the created Merchant ID. Select the merchant id and click edit and afterwards you will see this screen:

Screen Shot 2017-02-22 at 15.34.56.png

If you don’t have a certificate created, or you want to create another one, you will need to press “Create Certificate”. The other section below is for setting up Apple Pay on the Web. There you will need to upload a file which Apple sends to your server to validate that this is really your server.

Creating a certificate requires Certificate Signing request which is different from the regular ones we use for creating development or distribution certificates from the Keychain. For Payment Processing certificate, Apple requires 256 bit elliptic curve key pair. To create this, you need to following commands:

$ openssl ecparam -out private.key -name prime256v1 -genkey
$ openssl req -new -sha256 -key private.key -nodes -out request.csr -subj '/O=Your Name or Company/C=US'

However, if you use Apple Pay with third party backend service, they usually provide an admin tool from where you can create the Signing Request and use that one in the certificate generation process. After you create the certificate, usually you will have to upload the certificate back to the admin tool, so the third party service can verify the requests coming from your app.

After the Merchant ID and certificate is created, you will need to connect it with the App ID for your app. For this, press the Edit button for Apple Pay (see first screenshot) for the given App ID, which shows the available merchant ids:

Screen Shot 2017-02-21 at 16.29.57.png

If everything is setup correctly, you should have the following screen (the Apple Pay section is important here):


Next, you need to re-generate the provisioning profile you have for your app and add it to Xcode.

Xcode setup

Apple Pay needs to be enabled in the Capabilities section in Xcode and the generated merchant id should be selected in the list displayed upon enabling the feature.


After you do this, Xcode will automatically generate entitlements file (if you don’t have one already), and put the merchant id in there:

Screen Shot 2017-02-22 at 15.28.59.png


This post is more setup oriented, if you want to see how you can integrate Apple Pay in your code, I recommend to check this tutorial. If you are using third party SDK which offers Apple Pay as a functionality, like for example Stripe, you can also check their documentation for more details regarding the integration.

Testing Apple Pay in Sandbox Environment

Apple’s guide for setting up sandbox testers should be a good starting point, but at moments it lacks clear information about where you should login and why some parts might not be visible.

First, Sandbox tester should be created from the iTunesConnect page.

Screen Shot 2017-02-22 at 16.14.42.png

Then, you should logout from all production accounts you already have in the iPhone. The Sandbox account is a bit special, since it can’t be used to login in iTunes (if you do that, the account will be blocked and you will need to create another one). This means you will need to login to iCloud with the Sandbox credentials.


Make sure that Wallet is enabled for the iCloud account:


Sandbox testing is only available in certain regions – this is not connected to the availability of Apple Pay in those regions. For example, Apple Pay is available in Switzerland, but sandbox testing is not available there. The only eligible countries are Australia, Canada, United Kingdom and United States.

This means that the region of the phone has to be setup in one of those countries. You can spend a lot of time figuring out why you can’t add test card in the Wallet if you’ve missed this detail:


After this, go to the Wallet app and you will see the new section for adding cards for Apple Pay:


If you press the plus icon, you will have the following UI, where you have to insert one of those test cards provided in the bottom section of Apple’s guide (or of course you can add real one for productive payments):


After this, the card is added to the wallet and any app that offers the Apple Pay feature will list the card as available for transactions.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s