Objective C-Non-Seamless
Using SDK’s Inbuilt UI
Before proceeding further, make sure you have read this document

Prerequisites

  1. 1.
    Add libz.tbd libraries into your project (Project->Build Phases->Link Binary With Libraries)
  2. 2.
    Add -ObjC and $(OTHER_LDFLAGS)in Other Linker Flags in Project Build Settings(Project->Build Settings->Other Linker Flags)
  3. 3.
    To run the app on iOS9, please add the below code in info.plist
    1
    <key>NSAppTransportSecurity</key>
    2
    <dict>
    3
    <key>NSAllowsArbitraryLoads</key>
    4
    <true/>
    5
    </dict>
    Copied!

Integration steps

  1. 1.
    Drag and drop PayU folder into your App.
  2. 2.
    In AppDelegate.h add the below property
    @property (weak, nonatomic) UIViewController *paymentOptionVC;
  3. 3.
    Now come to checkout view controller of your app from where you want to start payment process.
    1. 1.
      Import the following file
      1
      #import "PUUIPaymentOptionVC.h"
      Copied!
    2. 2.
      On the Pay button set the paymentparam as below:
      1
      PayUModelPaymentParams *paymentParam = [[PayUModelPaymentParams alloc] init];
      2
      PayUModelHashes *hashes = [[PayUModelHashes alloc] init];// Set the hashes here
      3
      paymentParam.key = @"gtKFFx";
      4
      paymentParam.transactionID = @"txnID20170220";
      5
      paymentParam.amount = @"10";
      6
      paymentParam.productInfo = @"iPhone";
      7
      paymentParam.SURL = @"https://payu.herokuapp.com/success";
      8
      paymentParam.FURL = @"https://payu.herokuapp.com/failure";
      9
      paymentParam.firstName = @"Baalak";
      10
      paymentParam.email = @"[email protected]";
      11
      paymentParam.udf1 = @"";
      12
      paymentParam.udf2 = @"";
      13
      paymentParam.udf3 = @"";
      14
      paymentParam.udf4 = @"";
      15
      paymentParam.udf5 = @"";
      16
      17
      paymentParam.hashes = hashes;
      18
      // Set this property if you want to get the stored cards:
      19
      paymentParam.userCredentials = @"gtKFFx:[email protected]";
      20
      21
      // Set the environment according to merchant key ENVIRONMENT_PRODUCTION for Production &
      22
      // ENVIRONMENT_TEST for test environment:
      23
      paymentParam.environment = ENVIRONMENT_TEST;
      24
      25
      // Set this property if you want to give offer:
      26
      paymentParam.offerKey = @"";
      Copied!
  4. 4.
    Now call getPayUPaymentRelatedDetailForMobileSDK:paymentParam method of PayUWebServiceResponse class to get the payment related details:
    1
    PayUWebServiceResponse *webServiceResponse =[[PayUWebServiceResponse alloc]init];
    2
    [webServiceResponse
    3
    getPayUPaymentRelatedDetailForMobileSDK:paymentParam
    4
    withCompletionBlock:^(PayUModelPaymentRelatedDetail *paymentRelatedDetails,
    5
    NSString *errorMessage, id extraParam) {
    6
    7
    if (!errorMessage) {
    8
    UIStoryboard *stryBrd = [UIStoryboard
    9
    storyboardWithName:@"PUUIMainStoryBoard" bundle:nil];
    10
    PUUIPaymentOptionVC * paymentOptionVC =
    11
    [stryBrd instantiateViewControllerWithIdentifier:VC_IDENTIFIER_PAYMENT_OPTION];
    12
    13
    paymentOptionVC.paymentParam = paymentParam;
    14
    paymentOptionVC.paymentRelatedDetail = paymentRelatedDetails;
    15
    16
    [self.navigationController pushViewController:paymentOptionVC animated:true];
    17
    18
    }
    19
    else{
    20
    // error occurred while creating the request
    21
    }
    22
    }];
    Copied!
  5. 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:
    1
    [[NSNotificationCenter defaultCenter]
    2
    addObserver:self selector:@selector(responseReceived:)
    3
    name:kPUUINotiPaymentResponse object:nil];
    4
    5
    -(void)responseReceived:(NSNotification *) notification{
    6
    7
    NSString *strConvertedRespone = [NSString stringWithFormat:@"%@",notification.object];
    8
    NSLog(@"Response Received %@",strConvertedRespone);
    9
    }
    Copied!
  • 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:
1
e.g.:
2
{
3
"check_offer_status_hash" = 22e773e2079e9c2249c230b1ee096efcc2555b214fe291293d5a109e65030dda2cd355d4db97751d9c1f43c5e055b347e3d4e2939830bdc1f5f48845899e5bf1;
4
"delete_user_card_hash" = 793eed65afe4aaf1ddf89506093a57907a16fdd38e5c52050d7b5380e658c4300e221fa5f7da7b40ac213238b427e8d0dcc6a33bd5efe075d4261c01f143cb4e;
5
"edit_user_card_hash" = 20d3ea6b9bc964e8548c8fd3fc1a9e3daa948a0226511abdd3679d77c8c54131775b7f6d3dc3589389f47edaec2906b2381033d88c1aef1920204b4989f636c9;
6
"get_merchant_ibibo_codes_hash" = 307374123fb8d720d41361470984947f7f5c33ac4832598149bf1d108ea9b2ccefd7b46fe4ee4c021f67838a67f355a74f3c2d79bb37373d3b248a802c7159e2;
7
"get_user_cards_hash" = dfac3cd3fe9599ceba79efc9ddd48e28cbd8fd47ab2e4ae8a3b5f6f5be559e9dbbc8328298fb224a4e0769b1c328d1b87f59354bbec3c4eb101acc968fde0508;
8
"payment_hash" = 19c70354c7184da415a3a22c380235727e8d1e0aa3422e0b1cb6f40d9258e363a0dd37d611563e67fc8bd3be26960a54cba97de5b7588f323151f97c4f11dd06;
9
"payment_related_details_for_mobile_sdk_hash" = 633369f45e3b98c100871be3cb8f5c631132a5d06b83c2fc1e6a12302ab7386fc23ca53fb9f9182518b6affca6b6fe5dad170ae087b7716b11f8ddc07899590e;
10
"save_user_card_hash" = 09fb415be88e40de0d5c746f2ca4f7620dcf62eb2cf0da7cb0c2080eb36fed3290607b5b4bf890f2f8f5399bd72a41db18160c430c16079131272e7ce0c17a56;
11
"vas_for_mobile_sdk_hash" = 7da0f4fef5bab0e5034f37f9503bdcbede00cc2cd0cf6cbb4e43baa9d57f05680305885199e2b0d38e8cf12895fd06f4d3dd3fb422535feeb555adc58e2cf3cc;
12
}
Copied!