How to Integrate Apple Pay into Your iOS App?

Developing a payment gateway for a mobile application is the most required mobile solution that you need for selling your products online.

If you set up an inconvenient procedure for your customers and a page takes lots of time in loading, customers will leave the page without buying anything.

Henceforth, to make the online buying experience easier and faster for your customers, ensure to integrate Apple Pay into your iOS app.

Importance of Apple Pay Integration

When it comes to online shopping, people use their smartphones more. Paying through mobile is a buzzing trend that’s a reason why you need to make the process easy and efficient ever.

Due to the high user base of mobile payment, you should help your clients by making an easy checkout process.


According to a survey conducted in the United States in 2019, Apple Pay has been used by 51% of users to pay in stores, restaurants or other points of sale with their smartphones in the past 12 months.

Apple Pay technology has made the mobile payment process easier. This technology enables us to pay for products with one touch. Integration of Apple Pay into your iOS app enables customers to process direct payments through Siri or Messenger.

You can use Apple Pay in an offline store and reap the benefits of NFC technologies that enable clients to pay directly from their smartphone, reducing the requirement of carrying a wallet alongside them.

Nevertheless, you must install an NFC terminal for processing this. Otherwise, integrate Apple Pay technology into your iOS app.

Online security is a vital topic these days. 59% of mobile online buyers are concerned regarding their personal information.

You can consider Apple Pay a highly secure method with no doubt because it uses an exclusive code and contains a particular number for every user. Your data are secure because it doesn’t store your card number on its payment terminal.

This technology doesn’t get support from all merchants, but Apple Pay is encountering a continuous development every year. 43% of all iOS users use this payment technology on their mobile devices.

Brick-and-mortar stores are facing issues in using this technology because they are lagging. Online use of Apple Pay technology is more in demand.

iOS users would prefer the capacity of buying products and services within an iOS app via Apple’s secure gateway.

Now that you know that every successful business needs to integrate Apple Pay payment method, take a look at some guidelines to know how to proceed with this integration process.

Integrating Apple Pay into an iOS App

To integrate Apple Pay into your iOS app, Swift is the language you should opt for. Follow the steps discussed below to process it:

  1. Create a Merchant ID

To create your Merchant ID, you must make your App ID ready. So, navigate to https://developer.apple.com and sign in to your developer account. Now go to Certificates, Identifiers, and Profiles.

Now select App ID under the Identifier section. Ensure to check the Apple Pay box under Apple Services. Select the Continue button and submit to complete the creation of your App ID.

Now click on Merchant ID and in the upper right corner, click on the ‘+’ icon. After that, a window will open where you need to enter the detail of a Merchant ID.
Finally, make a Bundle ID that starts with the term ‘Merchant’.

  1. Configure Apple Pay Capabilities in Xcode for your project

After you have completed creating your Merchant ID, now open up your project in Xcode and choose Capabilities under the .xcproject section.

Turn on Apple Pay and enter your Merchant ID and ensure that the toggle from the right side is on.

Next, you must add your ID to the developer portal and ensure that the Team Box is indicating to the right time and check all items under Steps.

  1. Create a sandbox user in iTunes Connect

Once you are done with the two steps mentioned above, you need to create a new Gmail account. For this, navigate to https://itunesconnect.apple.com/ and choose Users and Roles.

Now select Sandbox Testers and tap on the ‘+’ button. Choose a nation where Apple Pay is allowed and confirm your new Gmail account formed by Apple ID.

  1. Include a test card

Now that you have a new Gmail account made by Apple ID, you need to change the iPhone region to the USA.

For this, log out of your iCloud account and log in with your sandbox user details. Include a new test card to Apple Pay. For instance:

FPAN: 3305 2288 7001 2535

Expiration Date: 09/2021

CVC: 403
  1. Make a payment request in your project

To create a payment request in your project, add any button from the storyboard to the ViewController.

Next, connect IBAction with your ViewController.swift. To use Apple Pay effectively, you must insert the following line into ViewController:

Import PassKit

After this, you can configure the payment request in purchaseItem():

@IBAction func purchaseItem(_ sender: Any) {

let request = PKPaymentRequest()

request.merchantIdentifier = “merchant.net.mobindustry.likeMe”

request.supportedNetworks = [PKPaymentNetwork.visa, PKPaymentNetwork.masterCard, PKPaymentNetwork.amex]

request.merchantCapabilities = PKMerchantCapability.capability3DS

request.countryCode = “US”

request.currencyCode = “USD”

request.paymentSummaryItems = [

PKPaymentSummaryItem(label: “Some Product”, amount: 9.99)


let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)

self.present(applePayController!, animated: true, completion: nil)

  1. Deal with the output

You need to add the following line to purchaseItem():

applePayController?.delegate = self

After that, make the following extension:

extension PaymentViewController:


func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {

controller.dismiss(animated: true, completion: nil)


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

completion(PKPaymentAuthorizationResult(status: PKPaymentAuthorizationStatus.success, errors: []))



To check whether you have done a successful Apple Pay integration into your iOS app, make a successful payment by continuing with the payment request with your selected payment method, such as MasterCard, Visa, Stripe, etc.

In order to complete the payment, insert the following line in the didAuthorizePayment method:

completion(PKPaymentAuthorizationResult(status: PKPaymentAuthorizationStatus.success, errors: []))


So, this is how you can integrate Apple Pay technology into an iOS app. Make sure to follow the steps discussed in this post to make your Apple Pay integration a success.

Blog Source- https://www.mindinventory.com/blog/apple-pay-integration-into-ios-app/