To download iOS SDK through cocoa-pod, please go here first.
To run our Sample app do the following:
Download latest SDK version and unzip it.
Now unzip Release-Universal, now drag and drop the content of unzipped file into Sample App
Initial Setup
To integrate with iOS SDK, download the latest SDK from here.
Drag and drop PayUBizCoreSDK.framework into your project
Import our SDK as below:
#import <PayUBizCoreKit/PayUBizCoreKit.h>
While working with swift project add the above code in Bridging-Header.h file.
Get all the required parameters
Create an object of PayUModelPaymentParams and set all the parameter in it
@property (strong, nonatomic) PayUModelPaymentParams *paymentParamForPassing;
self.paymentParamForPassing = [PayUModelPaymentParams new];
self.paymentParamForPassing.key = @"0MQaQP";
self.paymentParamForPassing.transactionID = @"Ywism0Q9XC88qvy";
self.paymentParamForPassing.amount = @"10.0";
self.paymentParamForPassing.productInfo = @"Nokia";
self.paymentParamForPassing.firstName = @"Ram";
self.paymentParamForPassing.email = @"email@testsdk1.com";
self.paymentParamForPassing.userCredentials = @"ra:ra";
self.paymentParamForPassing.phoneNumber = @"1111111111";
self.paymentParamForPassing.SURL = @"https://payu.herokuapp.com/ios_success";
self.paymentParamForPassing.FURL = @"https://payu.herokuapp.com/ios_failure";
self.paymentParamForPassing.udf1 = @"u1";
self.paymentParamForPassing.udf2 = @"u2";
self.paymentParamForPassing.udf3 = @"u3";
self.paymentParamForPassing.udf4 = @"u4";
self.paymentParamForPassing.udf5 = @"u5";
self.paymentParamForPassing.environment= ENVIRONMENT_PRODUCTION;
self.paymentParamForPassing.offerKey = @"offertest@1411";
//You don't need to set udf1-5 in case you are not using them email and firstname can be empty strings "" if you don't want to use them For store user card feature you need to set userCredentials
Generating URLRequest (and post parameters) for Payment
To get request, create an object of class PayUCreateRequest as below. The callbacks give your URLRequest as well as post parameters (NSString format). You can use these post parameters to initialize Custom Browser Instance.
To Pay using CCDC, we need to set CCDC parameter as below:
self.paymentParamForPassing.cardNumber = @"5123456789012346";//cardNumber
self.paymentParamForPassing.nameOnCard = @"name";//Name on card
self.paymentParamForPassing.expYear = @"2018";//Expiry year
self.paymentParamForPassing.expMonth = @"11";//ExpiryMonth
self.paymentParamForPassing.CVV = @"123";//CVV
self.paymentParamForPassing.storeCardName = @"My TestCard";//If you want to save card then pass StoreCardName otherwise it will not save & make sure userCredentials are provided
paymentParamForPassing.cardNumber ="5123456789012346"//cardNumberpaymentParamForPassing.nameOnCard ="name"//Name on cardpaymentParamForPassing.expYear ="2018"//Expiry yearpaymentParamForPassing.expMonth ="11"//ExpiryMonthpaymentParamForPassing.cvv ="123"//CVVpaymentParamForPassing.storeCardName ="My TestCard"//If you want to save card then pass StoreCardName otherwise it will not save & make sure userCredentials are provided
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_CCDC withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest().createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_CCDC, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
StoredCard
To Pay using StoredCard, we need to set StoredCard parameter as below:
let modelStoredCard = paymentRelatedDetail.storedCardArray[indexPath.row]as? PayUModelStoredCardpaymentParamForPassing.cardToken = modelStoredCard?.cardTokenpaymentParamForPassing.cardBin = modelStoredCard?.cardBinpaymentParamForPassing.cvv ="123"//CVV
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_STOREDCARD withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_STOREDCARD, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
Tokenisation
For cards tokenised outside PayU platform merchant needs to pass below parameters.
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_NET_BANKING withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_NET_BANKING, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
CashCard
To Pay using CashCard, we need to set cashcard parameter as below:
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing
forPaymentType:PAYMENT_PG_CASHCARD withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_CASHCARD, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
EMI
To Pay using EMI, you need to set EMI parameter as below:
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_EMI withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_EMI, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
Cardless EMI
To Pay using Cardless EMI, you need to set parameter as below:
After setting the above parameters, you can get the request by using createRequestWithPaymentParam
PayUMoney
To Pay using PayUMoney, we need to set only the mandatory payment param and we can get the request by using createRequestWithPaymentParam method as below:
PayUCreateRequest *createRequest = [PayUCreateRequest new];
[createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_PAYU_MONEY withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.init(paymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_PAYU_MONEY, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
Subvention EMI
Pay via Subvention EMI
To Pay using Subvention EMI, we need to set subventionAmount parameter of paymentParams
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below:
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_EMI withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_EMI, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go state. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
Hash Calculation
If subventionAmount is passed than hash formula for payment hash will be
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_LAZYPAY withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest.createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_LAZYPAY, withCompletionBlock: { request, postParam, error inif error ==nil {//It is good to go. You can use request parameter in webview to open Payment Page } else {//Something went wrong with Parameter, error contains the error Message string }})
TwidPay
To Pay using TwidPay, create the post data with CASH_CARD_TWID :
After a successful payment, you would get the Twid customer hash in the field5 param of PayuResponse, which can be used in next transactions to skip authentication.
To Pay using Sodexo, create the post data with PAYMENT_PG_SODEXO :
self.paymentParamForPassing.cardNumber = @"<Sodexo card number>";//cardNumber
self.paymentParamForPassing.nameOnCard = @"name";//Name on card
self.paymentParamForPassing.expYear = @"2018";//Expiry year
self.paymentParamForPassing.expMonth = @"11";//ExpiryMonth
self.paymentParamForPassing.CVV = @"123";//CVV
self.paymentParamForPassing.shouldSaveCard = YES;//If you want to save card then pass it otherwise it will not save
self.paymentParamForPassing.cardNumber = "<Sodexo card number>";//cardNumber
self.paymentParamForPassing.nameOnCard = "name";//Name on card
self.paymentParamForPassing.expYear = "2018";//Expiry year
self.paymentParamForPassing.expMonth = "11";//ExpiryMonth
self.paymentParamForPassing.CVV = "123";//CVV
self.paymentParamForPassing.shouldSaveCard = true;//If you want to save card then pass it otherwise it will not save
After setting the above parameters, you can get the request by using createRequestWithPaymentParam method as below
self.createRequest = [PayUCreateRequest new];
[self.createRequest createRequestWithPaymentParam:self.paymentParamForPassing forPaymentType:PAYMENT_PG_SODEXO withCompletionBlock:^(NSMutableURLRequest *request, NSString *postParam, NSString *error) {
if (error == nil) {
//It is good to go state. You can use request parameter in webview to open Payment Page
}
else{
//Something went wrong with Parameter, error contains the error Message string
}
}];
createRequest().createRequest(withPaymentParam: paymentParamForPassing, forPaymentType: PAYMENT_PG_SODEXO, withCompletionBlock: { request, postParam, error in
if error == nil {
//It is good to go state. You can use request parameter in webview to open Payment Page
} else {
//Something went wrong with Parameter, error contains the error Message string
}
})
After a successful payment, you would get the Sodexo source id in the field3 param of PayuResponse, which can be used to show and get stored Sodexo card details and also can be used for initiate payment.