Get the Adyen Apple Pay Provisioning SDK
Download the Adyen Apple Pay Provisioning SDK from Adyen’s GitHub repository. The repository also includes a README with the instructions for installing the SDK.System requirements
Before you install and start using the Adyen Apple Pay Provisioning SDK, ensure that your system follows the requirements:- Your application targets iOS 13.4 or later.
- Your developer environment runs Xcode 14 or later.
- Your developer environment runs Swift 5.7 or later (pre-installed with Xcode 13.2).
In-app provisioning
If you have an iOS app for your business, you must use the in-app provisioning flow described in this section. With Apple Pay in-app provisioning, your cardholders can tap Add to Apple Wallet directly within your iOS app. That tap starts an in-app provisioning flow. When the process is complete, they have their card data stored within their Apple Wallet, allowing them to make charges on that card from their Apple device. The following diagram walks you through the in-app provisioning flow. Green labels correspond to the steps described further on the page:- Get activation data
- Check for a card to add to Wallet
- Initiate card provisioning
- Provision the card
- Finalize card provisioning
Get activation data
Before you start card provisioning, you must get activation data for the specified payment instrument.-
From your server, make a GET
/paymentInstruments/{id}/networkTokenActivationDatarequest and specify theidof the payment instrument in the path. To make this request, your API credential needs the following role:- Bank Issuing PaymentInstrument Network Token Activation Data role
The response contains thesdkInputobject that you need to initialize the provisioning service in the next step. -
Pass the
sdkInputto your app.
Check for a card to add to Wallet
Initialize theProvisioningService class that is used to check if the cardholder can add a payment card to their Apple Wallet.
Check card eligibility
canAddCard method to show or hide the Add card to Apple Wallet button.
If available, you can add a payment card to both iPhone and Apple Watch. To determine the compatibility of the card with a particular device, use the canAddCardDetails() function.
Initiate card provisioning
When the cardholder selects Add card to Apple Wallet, use the Adyen Apple Pay Provisioning SDK to initiate provisioning by calling thestart() function with two parameters: delegate and presentingViewController.
Initiate card provisioning
Provision the card
ImplementProvisioningServiceDelegate to receive the provision(sdkOutput) callback from the Adyen Apple Pay Provisioning SDK. In the callback:
- From your back end, make a POST
paymentInstruments/{id}/networkTokenActivationDatarequest and passsdkOutputto provision the payment instrument. The response contains thesdkInputobject. - Return
sdkInputfrom theprovisionmethod.
Finalize card provisioning
After the provisioning is complete, the Adyen Apple Pay Provisioning SDK calls the delegate methoddidFinishProvisioning. This callback can be used to update your UI and show Added to Apple Wallet or Available in Apple Wallet.
Finalize card provisioning
Wallet provisioning
You must also support card provisioning directly from Apple Wallet. After implementing the Apple Wallet extension, your app’s name and icon appears in the From Apps on Your iPhone list of cards available to add to the Wallet. In addition to in-app provisioning, you must also support card provisioning directly from Apple Wallet.Requirements
Before you start implementing the Wallet provisioning flow:Add the Apple Wallet extension
To add the Apple Wallet extension:-
Add a new target to your Xcode project with any Extension template. Then, change the values under the
NSExtensiondictionary in theInfo.plistas follows: -
Create an
ExtensionHandlerclass that implements thePKIssuerProvisioningExtensionHandlerprotocol. This class manages the issuer-provided extension that is used during the card provisioning process. Add Wallet extension
Add the Authentication UI extension
The Apple Wallet authenticates cardholders before allowing them to provision cards. You can implement this authentication process in your UI by adding the Authentication UI extension. To add this extension:-
Add another target to your Xcode project with any Extension template. Change the values under the
NSExtensiondictionary in theInfo.plistas follows: -
Create an
AuthorizationProviderclass that is a subclass ofUIViewControllerand implements thePKIssuerProvisioningExtensionAuthorizationProvidingprotocol. Use thecompletionHandlerto communicate if the authentication was successful.
Extension provisioning flow
The following sequence diagram shows the flow to provision a card in an Apple Wallet.Initialize the Adyen Apple Pay Provisioning SDK
At the beginning of each step of the provisioning flow, you must initialize the Adyen Apple Pay Provisioning SDK, so you can call the SDK’s methods. The following sequence diagram shows the flow to initialize the SDK.- Make a GET
/paymentInstruments/{id}/networkTokenActivationDatarequest. - Receive an
sdkInputfrom Adyen. - Initialize the
ExtensionProvisioningServiceusing thesdkInput.
Show your app on Apple Wallet
When your user tries to add their Adyen-issued card to Apple Wallet, Apple Wallet must show your app as an option for provisioning. To do this, Apple Wallet uses the Apple Wallet extension to check if your app can provision card data. If your app is available for provisioning, then Apple Wallet shows it as an option. You can provide the provisioning status of your app by using the Adyen Apple Pay Provisioning SDK. Do this as follows:-
From your server, make a GET
/paymentInstruments/{id}/networkTokenActivationDatarequest and specify theidof the payment instrument in the path.
If your user has multiple payment instruments, make a request for each payment instrument. Get activation dataThe response contains thesdkInputstring that you need to initialize the provisioning service in the next step. -
Initialize the
ExtensionProvisioningServiceclass, which manages the Apple Wallet extension. Pass thesdkInputto the class as a parameter. Initiate card provisioning for one payment instrumentIf you requested multiplesdkInputstrings, pass them to the class in an array. Initiate card provisioning for multiple payment instruments -
From the Adyen Apple Pay Provisioning SDK, call
extensionStatusto implement thestatusmethod of thePKIssuerProvisioningExtensionHandlerprotocol. Consider including the following parameters:requiresAuthentication: A boolean that specifies whether you provide authentication through the UI extension.entriesUnavailableExtensionStatus: If theExtensionProvisioningServicecould not be initialized, return this parameter to indicate that the provisioning service is not available.
status object contains information about the available card passes in your app.
The time limit for your app to complete these steps is 100 milliseconds. If your app exceeds this limit, make a new GET /paymentInstruments/{id}/networkTokenActivationData request to refresh the sdkInput.
Show card passes
To enable your user to add their card to their Apple Wallet, you must show the cards as available card passes. You can do this by providing the card data and card art to Adyen Apple Pay Provisioning SDK. With this information, the SDK generates a preview of the card passes to the user. The SDK uses two different methods to generate the available card passes:-
passEntries: This method shows card passes on the Wallet app on iPhone. -
remotePassEntries: This method shows card passes on:- The Watch app on iPhone.
- The Wallet app on Apple Watch.
passEntries and remotePassEntries:
-
From your server, make a GET
/paymentInstruments/{id}/networkTokenActivationDatarequest and specify theidof the payment instrument in the path. Get activation dataThe response contains thesdkInputstring that you need to initialize the provisioning service in the next step. If the extension needs to show multiple payment instruments, request ansdkInputstring for each payment instrument. -
Initialize the
ExtensionProvisioningServiceclass, which manages the Apple Wallet extension. Pass thesdkInputto the class as a parameter. Initiate card provisioning for one payment instrumentIf you requested multiplesdkInput, pass these to the class in an array. Initiate card provisioning for multiple payment instruments -
Implement
ExtensionProvisioningServiceDelegateto receive thecardArt(forBrand: String)callback from the Adyen Apple Pay Provisioning SDK. This callback returns the card art that corresponds to each available card pass. Provide card art -
From the SDK, call
passEntriesandremotePassEntriesand pass the delegate that you created in the previous step. Get pass entries
/paymentInstruments/{id}/networkTokenActivationData request to refresh the sdkInput.
Generate a request to provision a card
After your user selects to add a card to Apple Wallet, the Apple Wallet extension calls Adyen Apple Pay Provisioning SDK to generate a request to provision the card pass. To generate a request for adding a card:-
From your server, make a GET
/paymentInstruments/{id}/networkTokenActivationDatarequest and specify theidof the payment instrument in the path.
If your user has multiple payment instruments, make a request for each payment instrument. Get activation dataThe response contains thesdkInputstring that you need to initialize the provisioning service in the next step. -
Initialize the
ExtensionProvisioningServiceclass, which manages the Apple Wallet extension. Pass thesdkInputto the class as a parameter. Initiate card provisioning for one payment instrumentIf you requested multiplesdkInputstrings, pass these to the class in an array. Initiate card provisioning for multiple payment instruments -
From the SDK, call the
generateAddPaymentPassRequestForPassEntryWithIdentifiermethod to obtain a pass request. In this call, include thedelegateparameter to handle card provisioning. Generate a request for adding a card pass - Send the pass request to the extension.
Provision the card
After the SDK sends the pass request to the Apple Wallet extension, the extension requests from Adyen the network token data of the card. The extension uses this data to provision the card in Apple Wallet. To provision the card when the extension requests it:-
Implement
ExtensionProvisioningServiceDelegateto receive theprovision(paymentInstrumentId, sdkOutput)callback from the Adyen Apple Pay Provisioning SDK. -
In the callback, make a POST
paymentInstruments/{id}/networkTokenActivationDatarequest and specify the following parameters:The response contains thesdkInputstring that the SDK needs to provision the card. -
Return the
sdkInputstring from the response back to the SDK.