UPI SDKs enable you to create and manage different UPI workflows. The iOS UPI SDKs are designed to provide the app framework to support multiple layout and style properties.
In this article, the iOS UPI SDK integration is documented in both Swift and Objective C languages.
Take care of the following prerequisites before you begin with SDK set up:
Ensure you have pay.plist
and upi.plist
files that contain configuration data necessary to set up the SDK. Contact Zeta in case if you haven't received the file.
Follow the steps below to integrate SDK:
The UPI SDK is compatible with apps supporting iOS with version 10 and above. To add the SDK to your project, follow these steps:
Download and extract the below zip folder containing an XCFramework for UPI SDK.
Drag & drop the XCFramework manually into your project's target.
Click Embed & sign under the XCFramework in your project's target.
Set Allow Non-modular Includes in Framework Modules to "YES" under Target > Build Settings.
Set Enable Bitcode to "NO" under Target > Build Settings.
A configuration file contains all the properties necessary for activating the SDK. You should add the file to your project to prepare your app to work with the SDK. You will receive the configuration file named pay.plist
and upi.plist
through email. If you haven't received the file, contact Zeta. Make sure the configuration files are available in the bundle.
UPI SDK and Pay SDK provide you with the capability to define the theme used by the SDK. These can be edited remotely so you won’t have to ship a new app build for changing how your view looks. You can change your theme by contacting Zeta and it will reflect on your app on the next launch.
To enable authentication using face recognition (Face ID), add a value to the NSfaceIdUsageDescription
(Privacy - Face ID Usage Description) with a message in the info.plist
file. Pay SDK also uses location and camera permission (if you have QR code payments enabled) to enable payments, add a value to the NSLocationWhenInUseUsageDescription
and NSCameraUsageDescription
keys in the info.plist
file.
To initialize the UPI and Pay SDKs, the following method calls should be made:
[ApolloUpiSdk initializeSdk]
method.[ApolloPaySdk initializeSdk]
method Initialize it inside the [application didFinishLaunchingWithOptions:]
method of your Application class.
#import "AppDelegate.h" #import <ApolloPay/ApolloPaySdk.h> #import <ApolloUpi/ApolloUpiSdk.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [ApolloUpiSdk initializeSdk]; [ApolloPaySdk initializeSdk]; return YES; } |
Both Pay and UPI are stateful SDKs. Before you start using the SDK features, take care of the following:
For a user of your app to be able to use the UPI SDK through your app, you need to authenticate the user with the tenantAuthToken
. The tenantAuthToken
needs to be computed in your backend as it needs sensitive information to create the token. The information used to generate the tenantAuthToken
should never be compromised.
tenantAuthToken
to the UPI SDK once the user logs into your app and you have sufficient information to issue a tenantAuthToken for the user. tenantAuthToken
to the PAY SDK once the user logs into your app and you have sufficient information to issue a tenantAuthToken for the user. To know the steps used in the generation of tenantAuthToken
, see SDK Authentication. Following is a code snippet on how to authenticate the SDKs:
[ApolloUpiSdk authenticateWithToken:token successBlock:^{} failureBlock:^(NSError *error) { }] |
[ApolloPaySdk authenticateWithToken:token successBlock:^{} failureBlock:^(NSError *error) { }] |
|
Ensure that this step is performed only after you have authenticated the SDK. |
For UPI SDK, after SDK authentication is completed successfully, you can initiate UPI registration flow by invoking the following method by passing the required arguments:
[ApolloUpiSdk triggerRegistrationWithPhoneNumbers:@[phoneNumber] firstName:firstName lastName:lastName emailID:email successBlock:^(NSString *vpa) { } failureBlock:^(NSError *error) { }]; |
For Pay SDK, there are few more steps that you need to perform before you can start making payments through the various modes offered by the SDK.
Make sure UPI registration is successful. Pay SDK will not function unless it has a valid VPA registered.
After a successful VPA registration, you will need to set up the Pay SDK by invoking the following method
[ApolloPaySdk setupWithAccountHolderID:accountHolderID successBlock:^{ } failureBlock:^(NSError *error) { }]; |
Here, accountHolderID is the tenant unique vector that is used to identify the tenant user uniquely.
You are now ready to use the Pay SDK to work with your user
You can get the navigation controller instance to start the UPI payment flow by scanning the QR Code or entering the UPI ID, by invoking the following method:
UINavigationController *viewController = [ApolloPaySdk payHook]; |
This is a nullable method. It will return nil in case Pay SDK is not yet set up properly. So, please add a null check before presenting the navigation controller returned by this method to avoid runtime exceptions.
You can get the navigation controller instance to show the QR code of the user, by invoking the following method:
UINavigationController *viewController = [ApolloPaySdk viewVpaHook]; |
This is a nullable method. It will return nil in case Pay SDK is not yet set up properly. So, please add a null check before presenting the navigation controller returned by this method to avoid runtime exceptions.
You can get the navigation controller instance to start the request money flow, by invoking the following method:
UINavigationController *viewController = [ApolloPaySdk requestMoneyHook]; |
This is a nullable method. It will return nil in case Pay SDK is not yet set up properly. So, please add a null check before presenting the navigation controller returned by this method to avoid runtime exceptions.
You can get the navigation controller instance to show the pending collect requests screen, from which the user can approve, decline received requests, or cancel the sent requests, by invoking the following method:
UINavigationController *viewController = [ApolloPaySdk viewCollectRequestsHook]; |
This is a nullable method. It will return nil in case Pay SDK is not yet set up properly. So, please add a null check before presenting the navigation controller returned by this method to avoid runtime exceptions.
Ensure that you logout the user by calling this API when you want to switch a user or the user logs out from the app. Failing to do this, the SDK may behave erratically later on. Here is a code snippet for the same.
[ApolloUpiSdk logout]; |
[ApolloPaySdk logoutWithSuccessBlock:nil failureBlock:nil]; |
After log out, you will have to perform all the steps starting from authentication using tenant token for SDK to function properly.
The following table lists the error codes, descriptions, and possible solutions. If the issue persists, contact Zeta.
Error codes | Descriptions |
---|---|
1000 | Internal error |
1001 | Unauthorized error |
Error codes | Descriptions |
---|---|
1000 | Internal error |
1001 | Unauthorized error |
|