Integration
(Mandatory Step)
TPV SDK can be integrated by following below mentioned steps:

1.Include the SDK in your app project (Mandatory Step)

The TPV SDK is offered via npm.
Use below step to include PayU TPV SDK in your app:
1
npm install react-native-payu-tpv --save
2
react-native link react-native-payu-tpv
Copied!
Next, add the following imports in the class where you need to initiate a payment
1
import {NativeModules} from 'react-native';
2
const {PayUTpv} = NativeModules;
Copied!

For iOS

TPV SDK is a dynamic framework. If you are not using 'use_frameworks!', then please add the following line at the end of your podfile.
1
$dynamic_framework = ['PayUAssetLibraryKit', 'PayUBizCoreKit', 'PayUCheckoutProBaseKit', 'PayUCheckoutProKit', 'PayUCustomBrowser',
2
'PayULoggerKit', 'PayUNetworkingKit', 'PayUUPICoreKit', 'Socket.IO-Client-Swift', 'Starscream']
3
pre_install do |installer|
4
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
5
installer.pod_targets.each do |pod|
6
if $dynamic_framework.include?(pod.name)
7
def pod.build_type;
8
Pod::BuildType.dynamic_framework
9
end
10
end
11
end
12
end
Copied!
After updating the podfile, install the pod using below command.
1
pod install
Copied!

2. ​Hash Calculation (Mandatory Step)

2.1 Payment Hash

For NB: Only single account number and corresponding IFSC code(if available) need to be passed.
1
// If IFSC is available
2
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789","ifscCode":"KKBK0004272"}'
3
// If IFSC not available
4
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789"}'
5
// Hash calculation
6
paymentHash = sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||beneficiarydetail|SALT)
Copied!
For UPI: Multiple account number and corresponding IFSC code(if available) can be passed with pipe separated. IFSC codes must be in the exact same order as account numbers ie. IFSC1 must map to AccountNo1 and so on.
For single account number, we have explained the hash calculation above.
For multiple account account number, hash can be calculated as below:
1
// If IFSC is available
2
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789|54321234|98765673|34767988","ifscCode":"KKBK0004272|PUNB0001000|SBIN0004000|ICIC9873678"}'
3
// If IFSC not available
4
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789|54321234|98765673|34767988"}'
5
// Hash calculation
6
paymentHash = sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||beneficiarydetail|SALT)
Copied!
For multiple account number, account number should be pipe separated and max 4 account numbers are allowed.

2.2 ValidateVpa Hash

This hash is used for validateVPA API. Hash formula is described below:
1
commandName = "validateVPA"
2
validateVpaHash = sha512(key|commandName|vpa|SALT)
Copied!

3.Payment​ param definition

Q: Why IFSC code is needed?
A: IFSC code is not a mandatory param. This increases the success rate of transactions.Therefore, we recommend you to pass ifsc code corresponding to account number.
Q: How this will increase success rate?
A: PayU will fetch the account number length corresponding to ifsc code and prefix zero before the passed account number if needed. Hence, account number mismatch error chances decreases.
To initiate a payment, your app will need to send transactional information to the TPV SDK.

Payment Params:

Parameter
Type
Description
Data Type & Validation
Mandatory
key
String
Merchant key received from PayU
Can not be null or empty
Yes
transactionId
String
It should be unique for each transaction
Can not be null or empty and should be unique for each transaction. It can not contain special characters like :-_/
Yes
amount
String
Total transaction amount
Can not be null or empty and should be valid double stringified eg, “100.0”
Yes
productInfo
String
Information about product
Can not be null or empty
Yes
firstName
String
Customer’s first name
Can not be null or empty
Yes
email
String
Customer’s email id
Can not be null or empty
Yes
phone
String
Customer’s phone number
Should be a valid phone number
Yes
ios_surl
String
[iOS] When the transaction gets success, PayU will load this url and pass transaction response
Should be a valid URL
Yes
ios_furl
String
[iOS] When the transaction gets fail, PayU will load this url and pass transaction response
Should be a valid URL
Yes
environment
String
Environment of SDK
"0" for Production and "1" for Test
Yes
beneficiaryAccountNumber
String
Customer bank account number
Should not be null
In NetBanking: only 1 account number can be passed. Eg: "5463546284"
In UPI:
Max 4 account number can be passed
Eg: "5436478356" or "765374657|2376547834|476374"
Yes
beneficiaryIFSC
String
Customer Bank account IFSC
If passed, then it should be correct customer bank IFSC code.
Eg: "PUNB0001000"
No
upiType
Int
It defines the type of upi payment
Eg: 1 for intent
0 for collect
Mandatory in case of UPI collect and intent
intentApp
String
Type of intent app. Currently we support gpay and phonepe
Eg: "gpay" for Google Pay
"phonepe" for PhonePe
Mandatory in case of UPI intent
vpa
String
Customer Account VPA
Mandatory in case of UPI collect and validateVPA API
bankCode
String
Bank code of bank from which user wants to pay
Eg: "ICINBTPV" for ICIC Netbanking
Mandatory in case of payment via NB

Hashes:

Parameter
Type
Description
payment
String
While doing payment this need to be set
validateVPA
String
Set this param while calling validateVPA API

Additional Params:

Additional params are optional params that can be passed to SDK like udf params. Below is list of params that can be passed in additional params -
Parameter
Type
Description
Mandatory
udf1
String
User defined field, Merchant can store their customer id, etc.
No
udf2
String
User defined field, Merchant can store their customer id, etc.
No
udf3
String
User defined field, Merchant can store their customer id, etc.
No
udf4
String
User defined field, Merchant can store their customer id, etc.
No
udf5
String
User defined field, Merchant can store their customer id, etc.
No

4. Make Payment

4.1 UPI Collect:

To pay using UPI collect set the paymentObject as below:
1
var payUPaymentParams = {
2
key: "Merchant key",
3
transactionId: "Transaction Id",
4
amount: "Transaction amount",
5
productInfo: "product Info",
6
firstName: "Customer firstName",
7
email: "Customer email",
8
phone: "Customer phone",
9
ios_surl: "Success Url for iOS",
10
ios_furl: "Failure Url for iOS",
11
environment: "0 or 1",//<0 for Production/1 for Staging>
12
beneficiaryAccountNumber: "customer bank account number",
13
beneficiaryIFSC: "customer bank account ifsc",
14
vpa: "Customer VPA",
15
upiType: "0", // 0 is for collect
16
additionalParam: {
17
udf1: "user defined value 1",
18
udf2: "user defined value 2",
19
udf3: "user defined value 3",
20
udf4: "user defined value 4",
21
udf5: "user defined value 5",
22
},
23
hashes: {
24
payment: "Payment Hash",
25
},
26
}
27
28
var paymentObject = {
29
payUPaymentParams: payUPaymentParams
30
}
Copied!
After making the paymentObject pass the same in "makeUPIPayment" method, if there is any error it will come under errorCompletion block and once payment get's success or fail it will come successCompletion block.
This can be integrated as below:
1
PayUTpv.makeUPIPayment(
2
paymentObject,
3
(error) => {
4
console.log("-----------Error payViaUPICollect---------");
5
console.log(error);
6
console.log("------------------------------------------");
7
},
8
(paymentResponse) => {
9
console.log("-----------Success makeUPIPayment---------");
10
console.log(paymentResponse);
11
console.log("------------------------------------------");
12
}
13
);
Copied!

4.2 UPI Intent:

To pay using UPI intent set the paymentObject as below:
1
var payUPaymentParams = {
2
key: "Merchant key",
3
transactionId: "Transaction Id",
4
amount: "Transaction amount",
5
productInfo: "product Info",
6
firstName: "Customer firstName",
7
email: "Customer email",
8
phone: "Customer phone",
9
ios_surl: "Success Url for iOS",
10
ios_furl: "Failure Url for iOS",
11
environment: "0 or 1",//<0 for Production/1 for Staging>
12
beneficiaryAccountNumber: "customer bank account number",
13
beneficiaryIFSC: "customer bank account ifsc",
14
upiType: "1", // 1 is for intent
15
intentApp: "App name", // gpay or phonepe
16
additionalParam: {
17
udf1: "user defined value 1",
18
udf2: "user defined value 2",
19
udf3: "user defined value 3",
20
udf4: "user defined value 4",
21
udf5: "user defined value 5",
22
},
23
hashes: {
24
payment: "Payment Hash",
25
},
26
}
27
28
var paymentObject = {
29
payUPaymentParams: payUPaymentParams
30
}
Copied!
After making the payment object pass the same in "makeUPIPayment" method, if there is any error it will come under errorCompletion block and once payment get's success or fail it will come successCompletion block.
This can be integrated as below:
1
PayUTpv.makeUPIPayment(
2
paymentObject,
3
(error) => {
4
console.log("-----------Error payViaUPICollect---------");
5
console.log(error);
6
console.log("------------------------------------------");
7
},
8
(paymentResponse) => {
9
console.log("-----------Success makeUPIPayment---------");
10
console.log(paymentResponse);
11
console.log("------------------------------------------");
12
}
13
);
Copied!

4.3 Get Netbanking Param

To get Netbanking param set the paymentObject as below:
1
var payUPaymentParams = {
2
key: "Merchant key",
3
transactionId: "Transaction Id",
4
amount: "Transaction amount",
5
productInfo: "product Info",
6
firstName: "Customer firstName",
7
email: "Customer email",
8
phone: "Customer phone",
9
ios_surl: "Success Url for iOS",
10
ios_furl: "Failure Url for iOS",
11
environment: "0 or 1",//<0 for Production/1 for Staging>
12
beneficiaryAccountNumber: "customer bank account number",
13
beneficiaryIFSC: "customer bank account ifsc",
14
bankCode: "Bank Code of bank",
15
additionalParam: {
16
udf1: "user defined value 1",
17
udf2: "user defined value 2",
18
udf3: "user defined value 3",
19
udf4: "user defined value 4",
20
udf5: "user defined value 5",
21
},
22
hashes: {
23
payment: "Payment Hash",
24
},
25
}
26
27
var paymentObject = {
28
payUPaymentParams: payUPaymentParams
29
}
Copied!
After making the paymentObject pass the same in "getNBParam" method, if there is any error it will come under errorCompletion block and if not url and body param will come in successCompletion block.
This can be integrated as below:
1
PayUTpv.getNBParam(
2
paymentObject,
3
(error) => {
4
console.log("-----------Error getNBParam---------");
5
console.log(error);
6
console.log("------------------------------------");
7
},
8
(params) => {
9
console.log("-----------Success getNBParam---------");
10
console.log(params.url);
11
console.log(params.bodyParam);
12
console.log("--------------------------------------");
13
}
14
);
Copied!

5.API

5.1 ValidateVPA

This API is used to validate the vpa and get the name associated with the given vpa.
Set the paymentObject as below:
1
var payUPaymentParams = {
2
key: "Merchant key",
3
transactionId: "Transaction Id",
4
amount: "Transaction amount",
5
productInfo: "product Info",
6
firstName: "Customer firstName",
7
email: "Customer email",
8
phone: "Customer phone",
9
ios_surl: "Success Url for iOS",
10
ios_furl: "Failure Url for iOS",
11
environment: "0 or 1",//<0 for Production/1 for Staging>
12
vpa: "Customer VPA",
13
additionalParam: {
14
udf1: "user defined value 1",
15
udf2: "user defined value 2",
16
udf3: "user defined value 3",
17
udf4: "user defined value 4",
18
udf5: "user defined value 5",
19
},
20
hashes: {
21
validateVPA: "validate vpa hash",
22
},
23
}
24
25
26
var paymentObject = {
27
payUPaymentParams: payUPaymentParams
28
}
Copied!
After setting paymentObject call validateVPA API as below:
After making the paymentObject pass the same in "validateVPA" method, if there is any error it will come under errorCompletion block and if not API response will come in successCompletion block.
This can be integrated as below:
1
PayUTpv.validateVPA(
2
paymentObject,
3
(error) => {
4
console.log("-----------Error validateVPA---------");
5
console.log(error);
6
console.log("-------------------------------------");
7
},
8
(response) => {
9
console.log("-----------Success validateVPA---------");
10
console.log(response);
11
console.log("---------------------------------------");
12
}
13
);
Copied!

6. Helper Methods

6.1 Supported IntentApp

This method will help in getting list of PSP apps which are supported by PayU and installed in user's device.
To get list of supported intentApp call intentApps method as below:
1
PayUTpv.intentApps(
2
(apps) => {
3
console.log("-----------Success intentApps---------");
4
console.log(apps);
5
console.log("---------------------------------------");
6
}
7
);
Copied!
The app name which you get in this list should be passed in intentApp parameter while doing intent payment.

Native Changes For iOS

For UPI Intent (Optional Step)

Currently we support only PhonePe and GooglePay via Intent. Add the query schemes in info.plist
1
<key>LSApplicationQueriesSchemes</key>
2
<array>
3
<string>phonepe</string>
4
<string>tez</string>
5
</array>
Copied!

Distributing your app (App Store / Ad-hoc) (Mandatory Step)

What you get by default is a fat framework that allows you to test your app seamlessly on device as well as simulator. But before archiving your app, you need to remove simulator slices from the framework. Please see the doc which assists in archiving your app with TPV integrated.
Last modified 3mo ago