Objective C-Non-Seamless
Using SDK’s Inbuilt UI
Before proceeding further, make sure you have read this document
To integrate with iOS SDK,download latest sample app from github using link : https://github.com/payu-intrepos/iOS-SDK-Sample-App/releases/
Prerequisites
Add
libz.tbdlibraries into your project (Project->Build Phases->Link Binary With Libraries)Add
-ObjCand$(OTHER_LDFLAGS)in Other Linker Flags in Project Build Settings(Project->Build Settings->Other Linker Flags)To run the app on iOS9, please add the below code in info.plist
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
Integration steps
Drag and drop PayU folder into your App.
In AppDelegate.h add the below property
@property (weak, nonatomic) UIViewController *paymentOptionVC;
Now come to checkout view controller of your app from where you want to start payment process.
Import the following file
#import "PUUIPaymentOptionVC.h"On the Pay button set the paymentparam as below:
PayUModelPaymentParams *paymentParam = [[PayUModelPaymentParams alloc] init]; PayUModelHashes *hashes = [[PayUModelHashes alloc] init];// Set the hashes here paymentParam.key = @"gtKFFx"; paymentParam.transactionID = @"txnID20170220"; paymentParam.amount = @"10"; paymentParam.productInfo = @"iPhone"; paymentParam.SURL = @"https://payu.herokuapp.com/success"; paymentParam.FURL = @"https://payu.herokuapp.com/failure"; paymentParam.firstName = @"Baalak"; paymentParam.email = @"Baalak@gmail.com"; paymentParam.udf1 = @""; paymentParam.udf2 = @""; paymentParam.udf3 = @""; paymentParam.udf4 = @""; paymentParam.udf5 = @""; paymentParam.hashes = hashes; // Set this property if you want to get the stored cards: paymentParam.userCredentials = @"gtKFFx:Baalak@gmail.com"; // Set the environment according to merchant key ENVIRONMENT_PRODUCTION for Production & // ENVIRONMENT_TEST for test environment: paymentParam.environment = ENVIRONMENT_TEST; // Set this property if you want to give offer: paymentParam.offerKey = @"";
Now call getPayUPaymentRelatedDetailForMobileSDK:paymentParam method of PayUWebServiceResponse class to get the payment related details:
PayUWebServiceResponse *webServiceResponse =[[PayUWebServiceResponse alloc]init]; [webServiceResponse getPayUPaymentRelatedDetailForMobileSDK:paymentParam withCompletionBlock:^(PayUModelPaymentRelatedDetail *paymentRelatedDetails, NSString *errorMessage, id extraParam) { if (!errorMessage) { UIStoryboard *stryBrd = [UIStoryboard storyboardWithName:@"PUUIMainStoryBoard" bundle:nil]; PUUIPaymentOptionVC * paymentOptionVC = [stryBrd instantiateViewControllerWithIdentifier:VC_IDENTIFIER_PAYMENT_OPTION]; paymentOptionVC.paymentParam = paymentParam; paymentOptionVC.paymentRelatedDetail = paymentRelatedDetails; [self.navigationController pushViewController:paymentOptionVC animated:true]; } else{ // error occurred while creating the request } }];Once the payment gets success, fails, cancel or any stored card gets deleted SDKUI fires notification to any registered observers. Add observer as below:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(responseReceived:) name:kPUUINotiPaymentResponse object:nil]; -(void)responseReceived:(NSNotification *) notification{ NSString *strConvertedRespone = [NSString stringWithFormat:@"%@",notification.object]; NSLog(@"Response Received %@",strConvertedRespone); }
Now PayUSDK is integrated.
Note: Please calculate all the hashes and assign tostrEmail paymentOptionsVC.allHashDict.Please refer this for calculating hash.Hashes are provided to
“paymentOptionsVC.allHashDict”in Key-Value Pair as below:
Last updated
Was this helpful?