Apple Pay

Apple Pay is easy to set up and gives your customers a simple and secure way to pay using their iPhone or iPad.
This guide explains how to process Apple Pay payments with our SDK.


In order to use Apple Pay on a real device, you will need to create keys and a certificate. Here are the steps:

  1. Add an Apple Pay Merchant ID in Apple Developer Center.
  2. In the Business Intelligence Platform, navigate to Administration -> Mobile Payment, select Generate keys and download CSR (certificate signing request).
  3. In the Apple Developer Center, select the merchant ID and choose Create Certificate. Upload the CSR from the previous step, and download the certificate. See the Apple Pay guide for more detailed instructions.
  4. Upload the certificate in the Business Intelligence Platform
  5. Turn on Apply Pay in Xcode: enable Apple Pay under Capabilities in your Project Setting, then select the merchant ID you want the app to use.

Adding Apple Pay to your app must be done in one of two ways, depending on whether you are using the Ready-to-Use UI or the SDK & Your Own UI. These two ways are covered in the sections below. Please follow the instructions relevant to the approach you have chosen.

Ready-to-Use UI

If you are using our ready-to-use checkout screens, configure Apple Pay in OPPCheckoutSettings along with other customizations. Set your Apple Pay payment request:

Make sure Apple Pay is included to the payment brand list. If you integrate Apple Pay using our drop-in buttons, you don’t have to do this part.

And you are done!

Collecting Apple Pay Shipping and Billing Information

Configure the payment request

First of all use the requiredShippingContactFields and requiredBillingContactFields properties of the payment request to indicate what billing and shipping information is needed. Then Apple Pay form will prompt shoppers to supply the requested billing and shipping information.

Note that API differs for iOS 9 and 10.

Adopt the OPPCheckoutProviderDelegate protocol

To receive callbacks from the Apple Pay form, make sure your view controller adopts OPPCheckoutProviderDelegate protocol and you set the checkoutProvider.delegate property.

Collecting Shipping Information

Apple Pay form calls two delegates when shopper provides shipping information:

  • Shipping contact: checkoutProvider:applePayDidSelectShippingContact:handler:
  • Shipping method: checkoutProvider:applePayDidSelectShippingMethod:handler:

Some shipping methods aren’t available in all areas or have different costs for different addresses. You can update this information by returning new list of shipping methods and summary items in completion block.

Shipping contact

Shipping method

NOTE: To maintain privacy, the shipping information provided in this delegate is anonymized. The returned contact contains enough information to calculate shipping costs, without revealing sensitive information about the shopper. Full shipping information will be available after shopper authorizes the payment in the checkoutProvider:applePayDidAuthorizePayment:handler delegate.

Collecting billing information

Billing information and full shipping information is available only after shopper authorizes the payment. Implement the checkoutProvider:applePayDidAuthorizePayment:handler delegate to get this data.

Updating Apple Pay transaction amount

To update Apple Pay transaction amount, you need to

  • Send updated list of PKPaymentSummaryItems in the shipping info delegates,
  • Update checkout session with the new amount by a server-to-server call. You can do it asynchronously in the checkoutProvider:continueSubmitting:completion: delegate. It is the last checkout delegate that is called right before the submitting transaction.

SDK & Your Own UI

If you are using our SDK & Your Own UI then there is a little more work to be done, but it is still easy to add. Accepting Apple Pay is quite similar to working with cards. When the shopper approves a payment, your application will receive a PKPayment object that contains encrypted card details. Create OPPApplePayPaymentParams with the received payment data and submit a transaction. See below the full Apple Pay flow.

Set up your Apple Pay button

Apple Pay is only available to a subset of iOS users. Before presenting the Apple Pay option to the current user, you should determine whether Apple Pay is available. You can do it using OPPPaymentProvider helper method.

Create a PKPaymentRequest

Next, when the shopper taps “pay by Apple Pay”, create a PKPaymentRequest object that describes the payment you want to make. SDK provides a helper method that does much of the configuration for you.

NOTE: See how to register a merchant ID in Apple Pay Documentation

Present a PKPaymentAuthorizationViewController

Next, create and present a PKPaymentAuthorizationViewController with your payment request. Use OPPPaymentProvider method to validate the final PKPaymentRequest object.

NOTE: Your view controller should implement PKPaymentAuthorizationViewControllerDelegate protocol to respond to user interaction with that view controller.

Finally, implement the necessary PKPaymentAuthorizationViewControllerDelegate methods. In your implementation of paymentAuthorizationViewController:didAuthorizePayment:completion:, create OPPApplePayPaymentParams and submit a debit transaction.