Objective C-Non-Seamless

Using SDK’s Inbuilt UI

Before proceeding further, make sure you have read this document

Prerequisites

  1. Add libz.tbd libraries into your project (Project->Build Phases->Link Binary With Libraries)

  2. Add -ObjC and $(OTHER_LDFLAGS)in Other Linker Flags in Project Build Settings(Project->Build Settings->Other Linker Flags)

  3. 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

  1. Drag and drop PayU folder into your App.

  2. In AppDelegate.h add the below property

    @property (weak, nonatomic) UIViewController *paymentOptionVC;

  3. Now come to checkout view controller of your app from where you want to start payment process.

    1. Import the following file

      #import "PUUIPaymentOptionVC.h"
    2. 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 = @"";
  4. 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
     }
     }];
  5. 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?