How do I integrate Apple Pay into my app?

We’ve used a React Native framework in our project.
The general workflow to implement Apple Pay is quite simple:

Create a Merchant account –> Set up an Apple Pay configuration for the project in your Xcode –> Then go to iTunes Connection. There you will need to create a sandbox user –> Add a test card –> Create a test request to make a payment –>Handle the result.

However, the details are a little more complicated. Below we will outline step by step how to set up Apple Pay:

1. Create an account to enable Apple Pay in your mobile application. Follow the official setup steps.

2. Next set up your server, not forgetting to first check out the official requirements here.

3. In the server configuration file, you will need to add one of the possible Cipher Suite referenced above. Take a look at our example configuration for Nginx.

4. Next, you need to set up your work environment. As always, check the official requirements first.

5. Here is an example of how to add the Apple Pay payment button.

6. Using the v-if directive you can check whether you have successfully installed Apple Pay sessions and whether users can now make payments using Apple Pay.

Now let’s create a certSigninRequest.certSigninRequest:

– Open Keychain Access on your Mac (located in Applications/Utilities).

– Open Preferences and click Certificates. Make sure both the Online Certificate Status Protocol and Certificate Revocation List are set to Off.

– Choose Keychain Access > Certificate Assistant > Request a Certificate Authority. N.b. If you have your private key selected when you do this, the CSR won’t be accepted. Make sure you do not have a private key selected. Next, enter your user email address and user name. Use the same address and name that you used to register in the iOS Developer Program. A CA Email Address is required.

– Select the option “Save to disk” and “Let me specify key pair information” and click Continue.

– Specify a file name and click Save.

7. After Signing in you can register for your Apple Pay Developer account at https://developer.apple.com/

8. Go to the menu “Certificates, IDs & Profiles”.

9. Click on the button ‘add new certificate’.

10. Then choose the options Apple Pay Merchant Identity Certificate.

11. Now choose the required Merchant from the list of those currently available.

12. Go to the menu “Identifiers” and filter by Merchant IDs.

13. Choose the previously created Merchant.

14. Next, create an Apple Pay Payment Processing Certificate.

15. After the creation of a certificate, you will need to upload the .csr extension which is an ECC encrypted file. We receive this file from our payment system (in our example we work with the bank, so screen made there)

16. Add and verify the domain, following the instructions on the screen. Pay attention every time you renew an SSL Certificate, as you will need to verify the domain each time.

17. If you missed step 5 go back and take a look at how to create a certSigninRequest.certSigninRequest. If you haven’t created one yet, now is the time using encryption RSA:2048.

18. Download your previously created certSigninRequest.certSigninRequest and then download merchant_id.cer.

19. Import received merchant_id.cer in Keychain (it required to export file in .p12).

20. In category Certificates in Keychain, you need to export the certificate using format .p12 .

21. Generate merchantIdentityCert from the received file using the command below: OpenSSL pkcs12 -in your_cer_name.p12 -out you_key_cert_name.pem -clcerts

22. Enter the password that was entered during export merchant_id.cer in .p12.

23. Enter PEM pass phrase – this will be the key to the generated merchantIdentityCert.

24. Put the generated merchantIdentityCert in the project’s folder.

25. Use merchantIdentityCert in the body of the request for validation Apple Pay Session.

Example of the request:

appleValidationUrl – it is an URL that is obtained when calling onvalidatemerchant event

appleMerchantId – it is the identification of Merchant in Apple Pay

displayName – it is the name of the seller.

26. Use the answer to complete Merchant validation. Take a look:

27. Create the Apple Pay button in accordance with the requirements on this page: https://applepaydemo.apple.com/ in the section “Display an Apple Pay button”

28. Code listing in Apple Pay using Payment Request API

If this instruction seems not clear, feel free to visit our original guide with screenshots for each step

Benefits for your customers

First of all, it’s guaranteed security. According to statistics, 50% of users are concerned about the security of their personal data, which is a good reason to set up Apple Pay! It uses device-specific numbers and codes, meaning it is almost impossible to copy.

Besides that, it helps you create an easy and quick user experience for your customers. A smooth one-click payment transaction is so much better than empty text inputs to enter credit card data. Especially, when you would need to save your details on the website in order to have a one-click payment on your return. In 2019 it’s essential that you are implementing the best features, even at the MVP stage, since user expectations are a lot higher these days.