iOS SDK (Non-Seamless)

Using SDK’s Inbuilt UI

Before proceeding further, make sure you have read this document

  • To integrate with iOS SDK,download sdk version 2.2.2 from github by clicking here

1 . In your app, drag and drop the SDK folder (i.e. PayU_iOS_SDK).

2 . Add the following Key-Value pair in Info.plist:

           key=”your key provided by PayU”
           command=”payment_related_details_for_mobile_sdk”
           var1=”default”

Note: To run the app on iOS9, please add the below code in info.plist

  <key>NSAppTransportSecurity</key>
     <dict>
       <key>NSAllowsArbitraryLoads</key>
     <true/>
   </dict>

3 . In PayUConstant.h, we can change the server to Test or Prod (i.e.#define TEST_SERVER 0 )

  • Now go to the class from where you want to push our SDK(i.e. class having “Pay” or “PayNow” button). Import PayU_iOS_SDK.h file in the header section. Create a property of NSDictionary type as below to hold the hashes in Key-Value pair.

    @property (nonatomic, strong) NSDictionary *hashDict;
  • Now come to IBAction method of “Pay” or “PayNow“ button and add the following code:

    PayUPaymentOptionsViewController *paymentOptionsVC = nil;
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            if(result.height == 480)
            {
                paymentOptionsVC = [[PayUPaymentOptionsViewController alloc] initWithNibName:@"AllPaymentOprionsView" bundle:nil];
            }
            else
            {
                paymentOptionsVC = [[PayUPaymentOptionsViewController alloc] initWithNibName:@"PayUPaymentOptionsViewController" bundle:nil];
            }
        }
    //Pass the parameters in paramDict in Key-Value pair as mentioned
    
    NSMutableDictionary *paramDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                  @"Nokia",@"productinfo",
                                  @"Ram",@"firstname",
                                  @"1100.6",@"amount",
                                  @"email@testsdk1.com",@"email",
                                  @"9876543210", @"phone",
                                  @"httpss://dl.dropboxusercontent.com/s/y911hgtgdkkiy0w/success_iOS.html",@"surl",
                                  @"httpss://dl.dropboxusercontent.com/s/h6m11xr93mxhfvf/Failure_iOS.html",@"furl",
        // _txnID is your Transaction ID set by you inside the app
                                @”12345678”,@"txnid",
                                  @"ra:ra",@"user_credentials",
                                 @"offertest@1411",@"offer_key",
                                  @"u1",@"udf1",
                                  @"u2",@"udf2",
                                  @"u3",@"udf3",
                                  @"u4",@"udf4",
                                  @"u5",@"udf5"
                                  ,nil];
     paymentOptionsVC.parameterDict = paramDict;
    paymentOptionsVC.callBackDelegate = self;
    paymentOptionsVC.totalAmount  = 1100.6;
    paymentOptionsVC.appTitle     = @"PayU test App";
    if(_hashDict)
            paymentOptionsVC.allHashDict = _hashDict;
    _hashDict = nil;
    [self.navigationController pushViewController:paymentOptionsVC animated:YES];

4 . Now add the observer in viewDidLoad as:

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(success:) name:@"payment_success_notifications" object:nil];

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(failure:) name:@"payment_failure_notifications" object:nil];

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cancel:) name:@"payu_notifications" object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataReceived:) name:@"passData" object:nil];
  • Now Add the definition for observer as:

     - (void) success:(NSDictionary *)info{
         [self.navigationController popToRootViewControllerAnimated:YES];
     }
    
     - (void) failure:(NSDictionary *)info{
         [self.navigationController popToRootViewControllerAnimated:YES];   
     }
    
     - (void) cancel:(NSDictionary *)info{
         [self.navigationController popToRootViewControllerAnimated:YES];   
     } 
      -(void)dataReceived:(NSNotification *)noti
    {
        NSLog(@"dataReceived from surl/furl:%@", noti.object);
        [self.navigationController popToRootViewControllerAnimated:YES];
    }

5 . Now PayUSDK is integrated.

Note: Please calculate all the hashes and assign to paymentOptionsVC.allHashDict.Please refer [PayU Integration Document] (httpss://drive.google.com/file/d/0B4URmsDLhGXmOWczQ3A5dnBOUzNEV2lwSVloaDFybnNUQUR3/view?usp=sharing) and Server Side Document for calculating hash.Hashes are provided to “paymentOptionsVC.allHashDict” in Key-Value Pair as below:

     e.g.:  
     {
         "check_offer_status_hash" = 22e773e2079e9c2249c230b1ee096efcc2555b214fe291293d5a109e65030dda2cd355d4db97751d9c1f43c5e055b347e3d4e2939830bdc1f5f48845899e5bf1;
         "delete_user_card_hash" = 793eed65afe4aaf1ddf89506093a57907a16fdd38e5c52050d7b5380e658c4300e221fa5f7da7b40ac213238b427e8d0dcc6a33bd5efe075d4261c01f143cb4e;
         "edit_user_card_hash" = 20d3ea6b9bc964e8548c8fd3fc1a9e3daa948a0226511abdd3679d77c8c54131775b7f6d3dc3589389f47edaec2906b2381033d88c1aef1920204b4989f636c9;
         "get_merchant_ibibo_codes_hash" = 307374123fb8d720d41361470984947f7f5c33ac4832598149bf1d108ea9b2ccefd7b46fe4ee4c021f67838a67f355a74f3c2d79bb37373d3b248a802c7159e2;
         "get_user_cards_hash" = dfac3cd3fe9599ceba79efc9ddd48e28cbd8fd47ab2e4ae8a3b5f6f5be559e9dbbc8328298fb224a4e0769b1c328d1b87f59354bbec3c4eb101acc968fde0508;
         "payment_hash" = 19c70354c7184da415a3a22c380235727e8d1e0aa3422e0b1cb6f40d9258e363a0dd37d611563e67fc8bd3be26960a54cba97de5b7588f323151f97c4f11dd06;
         "payment_related_details_for_mobile_sdk_hash" = 633369f45e3b98c100871be3cb8f5c631132a5d06b83c2fc1e6a12302ab7386fc23ca53fb9f9182518b6affca6b6fe5dad170ae087b7716b11f8ddc07899590e;
         "save_user_card_hash" = 09fb415be88e40de0d5c746f2ca4f7620dcf62eb2cf0da7cb0c2080eb36fed3290607b5b4bf890f2f8f5399bd72a41db18160c430c16079131272e7ce0c17a56;
          "vas_for_mobile_sdk_hash" = 7da0f4fef5bab0e5034f37f9503bdcbede00cc2cd0cf6cbb4e43baa9d57f05680305885199e2b0d38e8cf12895fd06f4d3dd3fb422535feeb555adc58e2cf3cc;
     }