-
Notifications
You must be signed in to change notification settings - Fork 1
4. iOS Payment SDK
You can download the SDK & sample app from here. Supported iOs version: iOS 8 & above.
Include the following in the plist
LSApplicationQueriesSchemes - > UnoPayDev, UnoPayProd
Drag and Drop “UnopayPaymentFramework.framework“ into the project.
1.2.1 Build Settings
In Project Target Build Settings,
Please set the following under “Search Paths”
Build Settings flags:
Name: Framework Search path
Value : $(SRCROOT) , recursive
1.2.2 Build phases
In Target->Build phases, Add “New Copy files Phase” as shown below. Set destination as framework followed by drag & drop of the UnoPay framework(which is already added to the project ).
###1.3 Code Integration
1.3.1 Initialization of SDK
Import UPSDKInAppPaymentManager and add the following code in AppDelegate.m
#import UnopayPaymentFramework/UPSDKInAppPaymentManager.h - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:kPaymentStatusNotification object:nil]; [[UPSDKInAppPaymentManager sharedInstance] initializeWithApiSDKKey:@"" withPartnerId:@"" environment:UPEnvironmentTypeDevelopment]; return YES; }
1.3.2 Payment Initiation
Create the object of UPSDKRequest class and set the parameters shown in the below code snippet.
#import UnopayPaymentFramework/UPSDKInAppPaymentManager.h UPSDKRequest *request = [[UPSDKRequest alloc] init]; request.amount = 100.0 request.orderId = @"30958345245"; request.callbackUrlScheme = @"sdktest"; request.mobileNumber= @“9008876333”; [[UPSDKInAppPaymentManager sharedInstance] initiatePaymentWithRequest:request];
2.3.3 Call back on Payment status
Application needs to listen to the kPaymentStatusNotification notification. In the call back, you will receive UPSDKResponse.
/* Adding observer */ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:kPaymentStatusNotification object:nil]; - (void)handleNotification:(NSNotification *)notification{ UPSDKResponse *response = notification.userInfo[kPaymentStatusNotificationUserInfoKey]; NSString *text = nil; if(response.status == UPResponseStatusSuccess) { text = [[NSString alloc]initWithFormat:@"Transaction SUCCESSFUL\nTransaction Id: %@\nRequested amount:%1.2f \n Merchant amount :%1.2f",response.transactionId,response.requestedAmount,response.merchantAmount]; } else if(response.status == UPResponseStatusFailure){ text = [[NSString alloc]initWithFormat:@"Transaction FAILED \n Transaction Id: %@\n Error message %@",response.transactionId,[response.error localizedDescription]]; } else if(response.status == UPResponseStatusCancel){ text = [[NSString alloc]initWithFormat:@"Transaction FAILED \n Transaction Id: %@\n Error message %@",response.transactionId,[response.error localizedDescription]]; } UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Status" message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil , nil]; [alertView show]; }