Apple Pay
Overview
For Apple Pay, your mobile app first communicates with Apple’s servers to retrieve the necessary certificates to encrypt the card details, then sends them to Bridge to retrieve the encrypted card details, and uses it to complete the provisioning process. At a high level, you can think of the process as the following:- Your cardholder requests to add their card to the mobile wallet from within your mobile app.
- Your mobile app calls Apple via the PassKit API to generate the certificates, keys, and other data required to encrypt the card details.
- Your application passes this information through your backend to Bridge, which will encrypt the card details using the provided certificates and keys, and return the encrypted payload to you.
- You provide the encrypted payload provided by Bridge via PassKit.
- Your mobile wallet decrypts the payload, validates it, tokenizes it with the card network, and activates it.
Requirements
Your app must have thecom.apple.developer.payment-pass-provisioning entitlement in order to enable adding cards to Apple Pay wallets. You can request this entitlement with Apple following this guide.
When testing this flow, ensure that you are testing with a production card in the production environment. Additionally, ensure that you are testing your app with this flow through TestFlight, as side-loading doesn’t work with in-app provisioning.
Integration guide
Within your app, create aPKAddPaymentPassRequestConfiguration to configure how the card will be displayed, using ECC_V2 as the encryption scheme. Use this to initialize a PKAddPaymentPassViewController to display the flow for adding the card to Apple Pay. As the user interacts with the flow, the controller will handle requesting Apple Servers for the necessary certificates, which will then get passed back to the generateRequestWithCertificateChain method.
In your implementation of the generateRequestWithCertificateChain method, the arguments will contain a list of certificates, a nonce, and a nonceSignature. From the list of certificates, you will take the leaf certificate (the first item), and a subordinate certificate (the second item). You can use the following snippet as a rough reference implementation in your PKAddPaymentPassViewControllerDelegate for extracting the necessary details and encoding them in base64:
activation_data, encrypted_pass_data, and ephemeral_public_key to create the PKAddPaymentPassRequest to complete the provisioning.
