iOS SDK

Accept payments in iPhone and iPad apps, with built-in support for PayUMoney Wallet & Saved Cards.PayUmoney iOS SDK is a quick and easy way to integrate the payment checkout experience in your app.

You can check out our sample app in GitHub here for reference
https://github.com/payu-intrepos/PayUMoney-IOS-SDK/tree/master/SampleApps

Features Supported

The following features are supported in the PayUmoney iOS SDK.

  • Saved Cards
  • Custom Browser

Payment Modes Supported

The following payment modes are supported in the PayUmoney iOS SDK.

Steps to Integrate

1

Prerequisites

Meet the Prerequisites

2

Install and configure

Install and configure the SDK as shown in the guide.

3

Server Side Changes

Calculate the server-side hash

4

Initiate Transaction Request

Set the transaction details & hash on the SDK and start payment activity.

5

Response Handling

Verify response hash and display transaction status to payer

Getting Started with the iOS SDK

This guide will take you through building your app's payment flow using PayUMoney iOS SDK.The SDK handles collecting, saving, and reusing your user's payment details, and can also be used to collect billing info.Have a look at the iOS SDK Payment Activity Diagram before you take the deep dive.

Steps to Integrate

1

Prerequisites

Meet the Prerequisites

2

Install and configure

Install and configure the SDK as shown in the guide.

3

Server Side Changes

Calculate the server-side hash

4

Initiate Transaction Request

Set the transaction details & hash on the SDK and start payment activity.

5

Response Handling

Verify response hash and display transaction status to payer

Prerequisites

To Integrate PayUmoney iOS SDK, you must :

  • Have a merchant account with PayUmoney Signup
  • Know your key & Salt. These are available on the PayUmoney dashboard Dashboard

Install and configure the SDK

  1. Head to our GitHub releases page and download PayUmoney_SDK.framework.
  2. Add PayUmoney_SDK.framework file into your project as shown below:

Choose the PayUmoney.framework file from the downloaded location and click on add.

The entry PayUmoney_SDK.framework will now reflect under 'Linked Frameworks and Libraries'.

Add PayUmoney_SDK.framework to the "Embedded Binaries" section of your Project.

Click on the '+' sign to Add items under Embedded Binaries.

Choose PayUmoney_SDK.framework from the correct path as shown below.

Make sure the entry 'PayUmoney_SDK.framework' is reflecting in 'Embedded Binaries' and 'Linked Frameworks and Libraries' under General settings of your project.

Remove it, If you find any duplicate entry in the Linked Frameworks and Libraries section.

Import umbrella header file into the View Controller from where you to initiate the epayment.

#import <PayUmoney_SDK/PayUmoney_SDK.h>

On your checkout view controller, add property ‘params’ as shown below

@property(nonatomic,strong) PUMRequestParams * params;

Set Transaction Details

To initiate the payment create an object of type ‘PUMRequestParams’ and set all the mandatory parameters as shown below:

self.params = [PUMRequestParams sharedParams];//Using ’init’ and    //‘new’should be avoided here. ‘sharedParams’ is the dedicated
//initializer (or designated initializer)for ‘PUMRequestParams’.
self.params.environment = PUMEnvironmentProduction;
self.params.surl =@“https://www.yourdomain.com/success.php”;
self.params.furl = @“https://www.yourdomain.com/failure.php”;
self.params.amount = @"100";
self.params.key = @"pass your own key here";
self.params.merchantid = @"pass your unique id here";[d][e]
self.params.txnid =@"pass random transaction id each time";
self.params.delegate = self;[f][g][h]                              self.params.hashValue=@“653fdfdf79f8074e6cf638f869bc5ff9ae6bd2aeea3cd1d6d17965b74e599afb4fad5ccf3ec423217aec1e2539267f9212dbde6de1cc88045376e9f967b14db5”;
/// Pass the hash generated from the server side code here. Refer ‘Calculating Hash’ section below.
self.params.firstname = @"Ashish";
self.params.productinfo = @"iPhone";
self.params.email = @"test@gmail.com";
self.params.phone = @"9876543210";
self.params.udf1 = @"";
self.params.udf2 = @"";
self.params.udf3 = @"";
self.params.udf4 = @"";
self.params.udf5 = @"";

You may also pass the following Non-mandatory parameters if required.The ‘udf’ stands for user defined field.The ‘udf1...udf5’ are mandatory fields.Merchant is required to pass an empty string value here if he doesn’t want to use it.

These parameters are explained in the ‘Parameters’ Section.

The fields ‘udf6...udf10’ are non-mandatory.Merchant may or may not pass it.

self.params.udf6 = @"";
self.params.udf7 = @"";
self.params.udf8 = @"";
self.params.udf9 = @"";
self.params.udf10 = @"";
Note:
udf1 to udf10 are user-defined fields. A Merchant may use this to send any additional values along with the payment request.

Calculate Server-Side Hash

The only server side change required while integrating PayUMoney iOS SDK is to generate a hash parameter for both the payment request & response.

A hash is an encrypted value (checksum) that is to be sent by the merchant in a payment request and sent by PayUMoney in the payment response. A hash is used to protect transactions against “man in the middle attack”.

Payment Request

hashSequence = key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt.
$hash = hash("sha512", $hashSequence);
Note:
A blank udf field is to be used while computing hashSequence, even if a merchant is not passing any udf field in input request.

Payment Response

responseHashSequence = salt|status||||||udf5|udf4|udf3|udf2|udf1|email|firstname|productinfo|amount|txnid|key
$responseHash = hash("sha512", $responseHashSequence);
Note:
The entire hash logic is built on the assumption ‘Salt’ is always safe with the merchant. Hence is very important for the merchant to keep the ‘Salt’ safe by adhering to the best security practices. For eg: Merchant should always compute from the server side and never from the client side, should never share the ‘Salt & Key’ over emails or directly commit on public repositories like Github.

Initiate Payment

Once all the payment request parameters are set including the hash, then follow the steps below to initiate the payment

  1. Create a view controller of type PUMMainVController
  2. Create a UINavigationController with controller created in step 1 as root view controller
  3. Present the navigation controller created in step 2

Refer to the code below to implement these steps.

PUMMainVController *paymentVC = [[PUMMainVController alloc] init];
UINavigationController *paymentNavController = [[UINavigationController alloc]
initWithRootViewController:paymentVC];
[self presentViewController:paymentNavController animated:YES
completion:nil];

This will open the PayUmoney checkout page as shown below.

Logged-in User

Logged in user screen

Guest User

Guest user screen

The Customer will now interact with PayUmoney screens till the transaction is complete.

Response Handling

The payment response is given as a callback. Implement the following callback methods to handle the response from the checkout UI.

/// For successful transactions
-(void)transactionCompletedWithResponse:(NSDictionary*)response
errorDescription:(NSError* )error {}
/// For transactions that failed
-(void)transactinFailedWithResponse:(NSDictionary* )response
errorDescription:(NSError* )error {}
/// Transactions cancelled by user on checkout page.
-(void)transactinCanceledByUser {}

Transaction Parameters

This section contains the details about different request & response parameters to used while transacting using PayUmoney.

REQUEST

Sl No. Parameter Mandatory Description
1. environment Yes
2. surl Yes Success URL
3. furl Yes Failure URL
4. amount Yes Transaction Amount
5. key Yes Merchant Key ;available from the PayUmoney Dashboard
6. merchantid Yes Merchant Id; available from the PayUmoney Dashboard
7. txnid Yes Unique transaction id to be passed by you
8. delegate Yes Pass the object that will receive callback here.Typically ‘Self’.
9. firstname Yes Address of the payer.
10. productinfo Yes Information Regarding Product. 255 Char Max
11. email Yes Email Id of the payer
12. phone Yes Mobile No of the payer
13. udf1 Yes User Defined Field
14. udf2 Yes User Defined Field
15. udf3 Yes User Defined Field
16. udf4 Yes User Defined Field
17. udf5 Yes User Defined Field
18. udf6 Yes User Defined Field
19. udf7 Yes User Defined Field
20. udf8 Yes User Defined Field
21. udf9 Yes User Defined Field
22. udf10 Yes User Defined Field

RESPONSE

Sl No. Parameter Descripiton
1. status Transaction Status. (Described in detail in the Transaction Status section)
2. firstname First name of the Payer
3. amount Transaction Amount
4. txnid Unique Transaction Id passed by you in request.
5. hash Response Hash
6. key Merchant key
7. productinfo Product Info passed in request
8. email Email Id of the payer

Transaction Status

A transaction can have several different statuses as explained in the table below.

No. Status Description
1. Not Started The transaction has not been started yet.
2. Initiated The transaction has been started but not completed.
3. Money With PayUMoney The transaction was successful and the transaction amount is with PayUMoney.
4. Under Dispute A dispute for the transaction has been raised.
5. Refunded The entire amount of the transaction has been refunded.
6. Partially Refunded A part of the amount of the transaction has been refunded.
7. . Bounced Incomplete or no details provided at PayUMoney payment page.
8. Failed The transaction didn't complete due to a failure.
9. Settlement in Process Settlement for the transaction is in process.
10. Completed The transaction is settled and complete.

Sample App

PayUMoney recommends that you download the sample and test it out to understand the integration and payment flow. Check it out here:
https://github.com/payu-intrepos/PayUMoney-IOS-SDK/tree/master/SampleApps