Apple Pay Push Provisioning
NiumPushPay SDK helps Mobile app developers to easily implement an Add to Apple Wallet button or Add to Google Pay button in mobile banking applications.
SDK can enable cardholders to provision their card details from their mobile app to their device's payment wallet in a simple, secure way, eliminating the need to enter their card information manually.
The SDK is intended to be embedded into the mobile application(s). The SDK is intended to be embedded into the mobile application(s). Whereas the mobile app provider is in charge of the app's user experience, the SDK allows clients to take advantage of Nium's infrastructure.
Set up NiumPushPay SDK so that you can add cards to Apple Wallet.
Getting started with the iOS SDK requires the below steps.
Step 1: Install SDK
1.1 Install Dependencies
To integrate the Nium Push Provisioning libraries, use CocoaPods to install and configure dependencies.
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. CocoaPods is distributed as a ruby gem, and is installed by running the following commands in Terminal:
$sudo gem install cocoapods
$pod setup
1.2 Create a Podfile
Create a Podfile for your CocoaPod to specify them during development.
Close Xcode and enter the following commands in Terminal to create the Podfile:
$cd ~/<Project Folder Path>
$pod init
$open -a Xcode Podfile
This creates a new Podfile and opens it in Xcode.
1.3 Update Podfile
Replace the entire contents of the new Podfile with the following:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://bitbucket.org/instadevelopers/push-provisioning-pod.git'
target '<Project Name>' do
use_frameworks!
pod 'NiumPayPushProvisioning'
end
NOTE: Replace <Project Name>
with your own Project name.
1.4 Populate the New Pod
Save and close the Podfile, and then enter the following command in Terminal:
$cd ~/<Project Folder Path>
$pod install
Step 2: Configure the SDK into your app
Import the above POD into your Controller with the following command:
import NiumPayPushProvisioning
To configure SDK in your app, initialize the SDK by using the following method:
initialize(application, clientHashId, customerHashId, walletHashId, apiSecret)
NOTE: This can be initialized in any part of the app, ideally after having the below details
clientHashId
customerHashId
walletHashId
apiSecret
NiumCardsPushProvisioning.initialize(clientHashId: “clientHashId”,
customerHashId: “customerHashId”,
walletHashId: “walletHashId”,
apiSecret: “secret”,
env: .production)
Step 3: Create an Add to Apple Wallet Button
You can create an Add to Apple wallet button by calling the createButton(buttonStyle: AddPassButtonStyle, superview: UIView)
method. This method requires a superview which will contain this button. This method will return a button and you use this button to create an action for it.
let addToAppleWalletButton = AddPassButton().createButton(.black, superview: buttonContainerView)
addToAppleWalletButton.addTarget(self, action: #selector(self.addToWalletAction), for: .touchUpInside)
Step 4: Provision the Card to the Wallet
To provision (add) a card to the wallet, use the method addToWallet(viewController: UIViewController, cardHashId: String, completion: (Result\<String,Error>) -> ())
Upon success, the card will be added to the Apple Wallet, and this callback will update whether provisioning was a success or failure.
@objc func addToWalletAction(){
NiumCardsPushProvisioning.shared?.addToWallet(viewController: self, cardHashId: "Made Card Number", completion: {
result in
switch result {
case .success(let message):
print("card added")
case .failure(let err):
print(err.localizedDescription)
}
})
}
Step 5: Update single card visibility status
Use getSingleCardProvisionStatus(cardSuffix: String, completion:(Result<Bool, Error>) -> ()) method to verify If the card is already provisioned to the Apple Wallet.
If yes returns true, then hide the “Add to Apple Wallet” button.
NiumCardsPushProvisioning.shared?.getSingleCardProvisionStatus(cardSuffix: String completion: {
result in
switch result {
case .success(let status):
if status {
addToAppleWalletButton.isHidden = true
} else {
addToAppleWalletButton.isHidden = false
}
case .failure( _):
//Handle Failure
}
})
Note: Step 4 and Step 5 functionally similar, Step 4 is to get the provisioning status of a single card and Step 5 can be used to get the status of multiple cards.
Step 6: Update multi-card visibility status
Using the method getMultiCardProvisionStatus(CardSuffix:[String] ,CardListResultListener) to verify If the list of cards are already provisioned to the Apple Wallet.
NiumCardsPushProvisioning.shared?.getMultiCardProvisionStatus(cardSuffix:[String], completion: {
result in
switch result {
case .success(let arrCardDetail):
for cardDetail in arrCardDetail {
if cardDetail.status {
addToAppleWalletButton.isHidden = true
} else {
addToAppleWalletButton.isHidden = false
}
}
case .failure( _):
//Handle Failure
}
})
Step 7: SSL Pinning (Initialize TrustKit)
This step will do SSL Pinning for Domain name
Call this method in AppDelegate → didFinishLaunchingWithOptions
do {
try NiumCardsPushProvisioning.initialiseTrustKit(domain: "nium.com")
} catch let (error) {
print(error)
}
Note: In-App provisioning functionality will not be available for any apps that have not received the entitlement. Follow the below link to complete Entitlement.
Updated 6 months ago