Adyen Apple Pay Provisioning
iOS SDK simplifies integration with Apple wallet.
The SDK is available via Swift Package Manager
or via manual installation.
- Follow Apple's Adding Package Dependencies to Your App guide on how to add a Swift Package dependency.
- Use
https://github.com/Adyen/adyen-apple-pay-provisioning-ios
as the repository URL.
Drag the dynamic AdyenApplePayProvisioning/XCFramework/Dynamic/AdyenApplePayProvisioning.xcframework
and AdyenApplePayExtensionProvisioning/XCFramework/Dynamic/AdyenApplePayExtensionProvisioning.xcframework
(wallet extension) to the Frameworks, Libraries, and Embedded Content
section in your general target settings. Select "Copy items if needed" when asked.
- Drag the static
AdyenApplePayProvisioning/XCFramework/Static/AdyenApplePayProvisioning.xcframework
andAdyenApplePayExtensionProvisioning/XCFramework/Static/AdyenApplePayExtensionProvisioning.xcframework
(wallet extension) to theFrameworks, Libraries, and Embedded Content
section in your general target settings. - Make sure the static
AdyenApplePayProvisioning.xcframework
andAdyenApplePayExtensionProvisioning.xcframework
is not embedded. - Select
AdyenApplePayProvisioning.bundle
insideAdyenApplePayProvisioning.xcframework
(same for extension) and check "Copy items if needed", then select "Add".
Create an instance of ProvisioningService
with the sdk input data retrieved from the call to /paymentInstruments/\(paymentInstrumentId)/networkTokenActivationData
.
provisioningService = try ProvisioningService(sdkInput: sdkInput)
Check if the cardholder can add a payment card to their Apple Wallet (phone or watch). If the card cannot be added it means it is already in the wallet. However, when the watch is not available it is not possible to determine if that card is already added. Watch availability needs to be determined on the caller's side by using WCSession
.
let state = provisioningService.canAddCardDetails(isWatchAvailable: true)
if state.canAddCard {
// show "Add to Apple Wallet" button
}
When the cardholder selects Add card to Apple Wallet
, initiate provisioning by calling the start()
method with two parameters: delegate
and presentingViewController
try provisioningService.start(
delegate: self,
presentingViewController: viewController
)
Implement ProvisioningServiceDelegate
to receive the provision(sdkOutput)
callback from the SDK
. In the callback:
- From your back-end, make a
POST
paymentInstruments/{id}/networkTokenActivationData
request and pass sdkOutput to provision the payment instrument. The response contains thesdkInput
object. - Return
sdkInput
from theprovision
method.
func provision(sdkOutput: Data, paymentInstrumentId: String) async -> Data? {
struct ProvisioningBody: Encodable {
let sdkOutput: Data
}
let encoder = JSONEncoder()
encoder.dataEncodingStrategy = .base64
do {
let body = try encoder.encode(ProvisioningBody(sdkOutput: sdkOutput))
let sdkInput = // POST the body to the server and receive `sdkInput` back
return sdkInput
} catch {
return nil
}
}
When the provisioning is complete update your UI
func didFinishProvisioning(with pass: PKPaymentPass?, error: Error?) {
// Update your UI
}
In your wallet extension target create a subclass of PKIssuerProvisioningExtensionHandler
which conforms to ExtensionProvisioningServiceDelegate
protocol. Implement required methods (override parent class methods and implement protocol methods) and pass the data provided by the SDK.
import PassKit
import AdyenApplePayExtensionProvisioning
class ActionRequestHandler: PKIssuerProvisioningExtensionHandler, ExtensionProvisioningServiceDelegate {
// Your implementation goes here
}
- Full documentation at Adyen
- Full documentation for this version
- SDK reference Adyen Apple Pay Provisioning
- SDK reference Adyen Apple Pay Extension Provisioning
- Data security at Adyen
This SDK is available under the MIT License. For more information, see the LICENSE file.