---
title: A Complete Apple Pay Integration Tutorial - How to Do it Right?
description: Apple Pay integration process is a tricky one. Yet, nearly 400 M of people use that solution worldwide! Read our article to do it right.
image: https://blog-hubspot.railwaymen.org/hubfs/apple%20pay%20integration.webp
---

[![Railwaymen](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/Railwaymen_September2018/Images/logo_bia%C5%82e.png?width=260&height=70&name=logo_bia%C5%82e.png "Railwaymen")](https://railwaymen.org/)

- [Blog Main Page](https://blog-hubspot.railwaymen.org)
- [About Us](https://railwaymen.org/about-us)
- [Our Work](https://railwaymen.org/case-studies)
- [FAQ](https://railwaymen.org/our-ai-knowledge-base)
- [Contact Us](https://railwaymen.org/contact-us)

![a complete apple pay integration tutorial - how to do it right?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration.webp?width=1320&name=apple%20pay%20integration.webp)

[Mobile Development](https://blog-hubspot.railwaymen.org/tag/mobile-development)

# A Complete Apple Pay Integration Tutorial - How to Do it Right?

- [Piotr Pawluś](https://blog-hubspot.railwaymen.org/author/piotr-pawlus-senior-ios-developer)
- [15th August '19](https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right)

Carrying around cash has become less and less popular these days. After all, why you should worry about losing those precious banknotes from your wallet when you can have all your money safe & sound on your credit card or - **on your phone**.

![apple pay integration](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration-1.jpg?width=500&height=333&name=apple%20pay%20integration-1.jpg)

 

More and more people appear to agree with that point of view, as [Apple Pay users number has tripled over the last year and reached nearly 400 million users!](https://www.statista.com/statistics/911914/number-apple-pay-users/)

As for payment solution invented in 2014, that’s a pretty impressive score. So if you are thinking about making or upgrading your mobile app - integrating (or not) Apple Pay to it may have a huge impact on its success.

### Table of Contents:

[1. Apple Pay integration advantages - is this payment method safe to use?](https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right#pa)

[2. Apple Pay integration tutorial - step by step.](https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right#pb)

[3. Conclusion.](https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right#pc)

## Apple Pay integration advantages - is this payment method safe to use?

If you are one of those people who are scared of paying with your phone - just stop. **I can assure you, that it is probably much more secure than other solutions, that you are using right now.** For example - if you are having a credit card, with a contactless payment option available, all it takes to get you ripped off is losing it. Then, anyone who finds it can pay with it, without even knowing your PIN number to the specific amount on money. **With Apple Pay it’s impossible.** To access your money you need to positively pass Touch or Face identification process. So even though someone will find your phone laying on the ground it will be extremely difficult for him to steal some money from you.

 

Here are more proofs backing up the “Apple Pay is extremely safe” statement:

- The information you enter is becoming encrypted so it safely leaves your device when sent to Apple’s servers. **Even if someone will intercept them, they will be useless.**
- When you activate Apple Pay on your device, it uses two-factor authentication – they text you a code which must be typed in the app so access to your card is permitted.
- It has built-in security features to make sure that your transactions are safe.

 

![apple pay integration ](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%201.jpg?width=500&height=333&name=apple%20pay%20integration%201.jpg)

 

- Even if you will scan your card with your phone camera, it will not be saved on your device or in the iCloud.
- You can’t use Apple Pay if you don’t have a passcode set up on your device. It also enables you to use [biometric authentication](https://heimdalsecurity.com/blog/biometric-authentication/) methods (Face ID or Touch ID).
- It doesn’t store or have access to your original card numbers associated with Apple Pay. It also doesn’t save transaction information, that could track back to you.
- **Apple Pay has got many functionalities, that aim is to avoid fraud.** Apple may inform your card issuer or other providers associated with your card to the usage of Apple Pay and determine if your card is eligible. If your card is approved, your card issuer creates a Device Account Number, encrypts it, and only afterward the information is sent to Apple.
- The Device Account Number can’t be decrypted by Apple, but it gets stored in the Secure Element – **a chip specifically designed to safely store your information.**
- The Device Account Number in the Secure Element is isolated from Apple’s operating systems (iOS, watchOS, and macOS) and it never gets saved on Apple’s servers or backed up to iCloud.

## Apple Pay integration tutorial - step by step

Below you will find a clear and easy to follow tutorial about how to integrate your app with Apple Pay. In case of any questions and confusion - feel free to ask them in the comment section!

 

1. First of all, you need to enable Apple Pay Capabilities in Xcode

 

![apple pay capabilities](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%20(6).png?width=500&height=121&name=apple%20pay%20integration%20(6).png)

 

2. Now, you have to create a Merchant ID for your application. You are able to do this automatically using Xcode or [Apple Developer](https://blog-hubspot.railwaymen.org/how-to-enroll-in-the-apple-developer-program-and-why-its-so-important) service.

a) Xcode:

 

![apple pay xcode](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20xcode.jpg?width=711&height=233&name=apple%20pay%20xcode.jpg)

 

b) Apple developer service:

Go to developer.apple.com. Open **Certificates, Identifiers & Profiles**. Next, go to **Identifiers**. From the left drop-down menu select **Merchant IDs.**

 

![apple pay id](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%20(2).png?width=330&height=500&name=apple%20pay%20integration%20(2).png)

 

Then, register a new identifier.

 

![apple pay registration](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20registration.jpg?width=500&height=369&name=apple%20pay%20registration.jpg)

 

Provide name and Merchant ID.

 

![apple pay identification](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%20(1).png?width=500&height=117&name=apple%20pay%20integration%20(1).png)

 

3. And now - **it’s coding time! :)**

 

a) Add PassKit library to your project

b) Create PKPaymentRequest

```

	// 1
        let request = PKPaymentRequest()
        // 2
        request.merchantIdentifier = merchantID
        // 3
        request.countryCode = countryCode // e.g. “US”
        // 4
        request.currencyCode = currency // e.g. “USD”
        // 5
        request.merchantCapabilities = .capability3DS
        // 6
        request.supportedNetworks = supportedNetworks
        // 7
        request.paymentSummaryItems = paymentSummaryItems
```

Explanation:

- Create the property of PKPaymentRequest
- Set merchant identifier created earlier
- Set country code - the two-letter ISO 3166 country code.
- Set currency - the three-letter ISO 4217 currency code.
- If the payment should support 3-D Secure or/and EMV protocols we have to set it before payment request.
- Set supported participating networks. A list of available participating banks [is available here](https://support.apple.com/en-us/HT204916).
- The last step to proper configured PKPaymentRequest object is a list of items, where the last item has to be a summary of all items.

c) Add Apple Pay button

Now it’s time to add Apple Pay button to the view. To do this, we will use **PKPaymentButton.**

 

![apple pay button](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%20(3).png?width=980&name=apple%20pay%20integration%20(3).png)

 

d) Present Apple Pay controller

```

let controller = PKPaymentAuthorizationViewController(paymentRequest: request)
self.parentController.present(controller, animated: true)
```

 

![apple pay payments](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/apple%20pay%20integration%20(8).png?width=500&height=346&name=apple%20pay%20integration%20(8).png)

Implement delegate methods **PKPaymentAuthorizationViewControllerDelegate**

```

    // 1
    func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {
    }
    
    // 2
    func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
                                            didAuthorizePayment payment: PKPayment,
                                            handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) {
    }

```

 

Explanation:

- **1** **paymentAuthorizationViewControllerDidFinish**

Allows handling what should happen after dismissing Apple Pay pop up.

- **2** **paymentAuthorizationViewController(controller: \_, didAuthorizePayment: \_, completion: \_)**

Tells us that payment has been authorized and asks for a result. In this method we have to send given payment data to the backend to proceed the payment, e.g. Stripe, Checkout.com or own backend.

Last but not least, a very important step is **testing your Apple Pay integration to make sure it's working fine.**

For this purpose, Apple provides us with its [Sandbox Testing](https://developer.apple.com/apple-pay/sandbox-testing/) environment. The first step is to create a sandbox tester account in [App Store Connect](https://appstoreconnect.apple.com/). **For this account, you will need to use the email address that was never used in Apple’s domains.** Next step is to log in on devices with newly created account and adding credit cards that you want to test.

## Conclusion

Apple Pay raising popularity is not surprising at all. As we are all living in a constant hurry now, we want to make things as quickly and conveniently as possible. Apple Pay payment method ticks all the boxes in this matter, as it doesn’t require you to add the same credit card over and over to every application that needs it. **Just add it to your wallet once and then, all of your apps can use it - of course, if you allow them to do so.** That’s why if you are thinking about creating a mobile app offering you to buy some physical goods and services outside of the app - you should definitely give Apple Pay a go!

**I hope our Apple Pay integration tutorial will serve you well. If you are interested in reading more in the matter of mobile iOS development, check our other article about** [Storing structs in a persistence storage Protocol-oriented programming](https://blog-hubspot.railwaymen.org/storing-structs-in-protocol-oriented-programming)**.**

[Mobile Development](https://blog-hubspot.railwaymen.org/tag/mobile-development)

- Share:
- <https://twitter.com/share?text=A%20Complete%20Apple%20Pay%20Integration%20Tutorial%20-%20How%20to%20Do%20it%20Right?&url=https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right>
- <http://www.facebook.com/sharer/sharer.php?u=https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right>
- <http://www.reddit.com/submit?url=https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right&title=A%20Complete%20Apple%20Pay%20Integration%20Tutorial%20-%20How%20to%20Do%20it%20Right>
- <https://www.pinterest.com/pin/create/button/?url=https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right>
- <http://www.linkedin.com/shareArticle?mini=true&url=https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right>

![Piotr Pawluś](https://blog-hubspot.railwaymen.org/hubfs/Piotr-Pawlu%C5%9B%20(1).jpg)

Author

#### [Piotr Pawluś](https://blog-hubspot.railwaymen.org/author/piotr-pawlus-senior-ios-developer)

- <https://www.linkedin.com/in/piotr-pawlu%C5%9B-05470a100/>

 Piotr (iOS Developer) focuses on mobile app development and the development process. As an experienced developer, he brings support to RWM's team.

##### [![7 ways to make a mobile app successful - proven to keep users engaged](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/how%20to%20make%20a%20mobile%20app%20successful.jpg?width=305&name=how%20to%20make%20a%20mobile%20app%20successful.jpg) Related Article Business and Technology 7 Ways to Make a Mobile App Successful - Proven to Keep Users Engaged 12 min read Full Article](https://blog-hubspot.railwaymen.org/how-can-a-mobile-app-become-a-game-changer)

##### [![how gpt-5 will change your business and give you a competitive edge?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/GPT-5%20(1).jpg?width=305&name=GPT-5%20(1).jpg) Related Article Business and Technology How GPT-5 will change your business and give you a competitive edge? 5 min read Full Article](https://blog-hubspot.railwaymen.org/gpt-5-revolution-business-advantage)

##### [![how to choose the best mobile app development company](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/the%20best%20Mobile%20App%20Development%20Company.jpg?width=305&name=the%20best%20Mobile%20App%20Development%20Company.jpg) Related Article Business and Technology How to Choose the Best Mobile App Development Company 12 min read Full Article](https://blog-hubspot.railwaymen.org/best-mobile-app-development-company)

## [![10 ruby on rails blogs you should be following \[2025 update\]](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/ruby%20on%20rails%20blogs.jpg?width=1905&height=510&name=ruby%20on%20rails%20blogs.jpg) Next Post --- 10 Ruby on Rails Blogs You Should Be Following \[2025 Update\] Mobile Development](https://blog-hubspot.railwaymen.org/10-ruby-on-rails-blogs-you-should-be-following)

[![Railwaymen Logo](https://railwaymen.org/assets/svgs/rwm-logo-white-ae5182ba602bcbf3713fd6bb3a5288956e484b62ddf1c647e53f2fb72644913d.svg)](https://railwaymen.org)

 Railwaymen Sp. z o.o.   
 Email: info@railwaymen.org   
 NIP: 6793065841

[![European Funds Smart Growth](https://railwaymen.org/assets/icons/logos/unia-98bb8c7ed12fa79f2ddbe0e00b222213700102dba79748d59f43a304d9803de6.png)](https://railwaymen.org/grants)

[Estimate Project](https://railwaymen.org/estimate-project) [Newsletter Subscribe](https://learn.railwaymen.org/newsletter)

- <https://www.linkedin.com/company/railwaymen>
- <https://www.facebook.com/railwaymen.software.development>
- <https://www.youtube.com/channel/UCu5v1NuohjsTZXGV4K60KWA>
- <https://www.instagram.com/railwaymen_org>
- <https://twitter.com/Railwaymen_org>
- <https://dribbble.com/Railwaymen_org>
- <https://www.behance.net/railwaymen>

##### Company

- [Services](https://railwaymen.org/services)
- [Our Work](https://railwaymen.org/case-studies)
- [About us](https://railwaymen.org/about-us)
- [Blog](https://blog.railwaymen.org)
- [Career](https://railwaymen.org/careers)
- [Personal Data Protection](https://railwaymen.org/personal-data-protection)
- [Cookies Policy](https://railwaymen.org/docs/Cookie_Policy.pdf)
- Cookie Settings

##### Services

- [Web Development](https://railwaymen.org/services/web-development)
- [Mobile Development](https://railwaymen.org/services/mobile-development)
- [Product Design](https://railwaymen.org/services/product-design)
- [Discovery Phase](https://railwaymen.org/services/discovery-phase)
- [MVP Development](https://railwaymen.org/services/mvp-development)
- [Digital Transformation](https://railwaymen.org/services/digital-transformation)
- [Social Networking Software](https://railwaymen.org/services/social-networking-software)
- [Restaurant App Development](https://railwaymen.org/services/restaurant-app-development)
- [Construction Sofware Development](https://railwaymen.org/services/construction-software-development)
- [Custom Marketing Software Development](https://railwaymen.org/services/custom-marketing-software-development)
- [FinTech App Development](https://railwaymen.org/services/fintech-development)

##### Our Experts Must - Reads

- [Is Ruby on Rails Dead in 2025?](https://blog.railwaymen.org/is-ruby-on-rails-dead)
- [How to Start an App Development Project? \[Checklist\]](https://blog.railwaymen.org/checklist-what-you-have-to-do-to-start-the-app-development-project)
- [How to Build an MVP? \[5 Steps\]](https://blog.railwaymen.org/how-to-build-an-mvp)
- [How Long Does it Take to Make An App in 2025?](https://blog.railwaymen.org/how-long-does-it-take-to-make-an-app)
- [Agile Discovery Phase: a Must Have for Your Business](https://blog.railwaymen.org/why-a-discovery-phase-is-a-must-have-for-your-project)
- [Railwaymen App Development Cost Breakdown - How Much do We Charge and Why?](https://blog.railwaymen.org/app-development-cost-breakdown)
- [FAQ: Web & Mobile Development With Us Explained](https://blog.railwaymen.org/railwaymen-faq-web-and-mobile-development-with-us-explained)

 Awards

[![Clutch Recognition Best B2B Companies Global](https://railwaymen.org/assets/awards/Top_B2B_Companies_Global_2018-5d1c8e5358737540e214ce8d51e450fe06ac4be35a0a220c0c2ccfa912787879.png)](https://clutch.co/profile/railwaymen)[![Clutch Recognition Best Ruby on Rails Developers](https://railwaymen.org/assets/awards/ClutchAward2021-013bdba335eecb6eb59319b0475d099899bbb2fa50e4596186ea2126d5b606af.png)](https://clutch.co/press-releases/recognizes-top-performing-development-companies-poland-2021)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperPoland_2022-d094b46bd3ce96c9355d21d0c6a05bc4f5959ec255f6815af8797c0a938a6b9e.png)](https://clutch.co/profile/railwaymen)[![Clutch Top React Native Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopReactNativePoland_2022-a50094d73ac73fec5c868c5544048db746c9a086fcbe9e7dcf3644875c47762c.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopRubyOnRailsPoland_2022-dc90eec21384445755158dd53914b6e3ef947e75cfe6dba521822c73bd64b789.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Software Developer Fintech 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperFintech_2022-ba75658f45c04d38d0fa4f9dcbfc78e2982b62222d681d6dc3f2f40fe2cafc9b.png)](https://clutch.co/profile/railwaymen)[![Clutch B2B Services 2022](https://railwaymen.org/assets/awards/Best-PerformingB2B2022-4a7057260a703088e644083b31320fe6fdafbfe3491eadf7e9a711fa9e3f9174.png)](https://clutch.co/profile/railwaymen)

[![Clutch Recognition Best App Development Company](https://railwaymen.org/assets/awards/TheClutch1000-a5cd5e3433659ee45539838fa945002f147b6ed9065166f8ba9ff56d216173eb.png)](https://blog.railwaymen.org/railwaymen-named-global-leaders-top-10-ruby-on-rails-developers-2018?_gl=1*1lggq91*_gcl_au*MTY4NzY2MDQ5Mi4xNzMxNDAxMDg4*_ga*MTY1MzUxNjI1Ni4xNzMxNDAxMDg4*_ga_1TW68M8Z6C*MTczMjcwMDE4Ny4xNi4xLjE3MzI3MDExMzYuMzIuMC4w)[![Top Software Development Company](https://railwaymen.org/assets/awards/Custom-Software-Development-Companies-1c56b8d73fbc48c21514311021c65f85a53cd955a3f910a9c2347a6c4a934b0f.png)](https://www.softwareworld.co/top-custom-software-development-companies/)[![Hire elite software development vendors at Pangea](https://railwaymen.org/assets/awards/Pangea-3db009da8ad6d19dfdafc66c51d16928730a715c3195776579bff5e0df4c13d4.png)](https://www.pangea.ai/vendors/railwaymen/)[![GoodFirms Badge](https://railwaymen.org/assets/awards/goodfirms-6880d7b6b80ee00d7189656a8236466571c5f94f146a8d42f5421d85f53b05df.svg)](https://www.goodfirms.co/company/railwaymen)[![Digital Knights](https://railwaymen.org/assets/awards/dk-8e9cb01c4fb52cd6dd812212e5d6925772aa6399c71d47387e3f8a8d5d58ac59.svg)](https://www.digitalknights.co/)

Railwaymen locations

- Kraków
  
  Na Zjeździe 11, 30-527
- San Francisco
  
   Silicon Valley Acceleration Center. 180 Sansome Street

 You can change your cookie settings at any time Close and don't show again

© 2026 Railwaymen

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Piotr Pawluś",
    "url" : "https://blog-hubspot.railwaymen.org/author/piotr-pawlus-senior-ios-developer"
  },
  "dateModified" : "2025-03-27T10:43:05.527Z",
  "datePublished" : "2019-08-15T08:00:00.000Z",
  "headline" : "A Complete Apple Pay Integration Tutorial - How to Do it Right?",
  "image" : [ "https://blog-hubspot.railwaymen.org/hubfs/apple%20pay%20integration.webp" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog-hubspot.railwaymen.org/a-complete-apple-pay-integration-tutorial-how-to-do-it-right",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog-hubspot.railwaymen.org/hubfs/new%20website/rwm%20logotype.png"
    },
    "name" : "Railwaymen Sp. z o.o."
  }
}
```