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:

npm install react-native-payu-tpv --save
react-native link react-native-payu-tpv 

Next, add the following imports in the class where you need to initiate a payment

import {NativeModules} from 'react-native';
const {PayUTpv} = NativeModules;

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.

  $dynamic_framework = ['PayUAssetLibraryKit', 'PayUBizCoreKit', 'PayUCheckoutProBaseKit', 'PayUCheckoutProKit', 'PayUCustomBrowser', 
  'PayULoggerKit', 'PayUNetworkingKit', 'PayUUPICoreKit', 'Socket.IO-Client-Swift', 'Starscream']
  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if $dynamic_framework.include?(pod.name)
        def pod.build_type;
        Pod::BuildType.dynamic_framework
      end
    end
  end
end

After updating the podfile, install the pod using below command.

pod install

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.

// If IFSC is available
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789","ifscCode":"KKBK0004272"}'
// If IFSC not available
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789"}'
// Hash calculation
paymentHash = sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||beneficiarydetail|SALT)

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:

// If IFSC is available
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789|54321234|98765673|34767988","ifscCode":"KKBK0004272|PUNB0001000|SBIN0004000|ICIC9873678"}'
// If IFSC not available
beneficiarydetail = '{"beneficiaryAccountNumber":"123456789|54321234|98765673|34767988"}'
// Hash calculation
paymentHash = sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||beneficiarydetail|SALT)

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:

commandName = "validateVPA"
validateVpaHash = sha512(key|commandName|vpa|SALT)

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

Eg: "umang@icic"

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:

var payUPaymentParams = {
    key: "Merchant key",
    transactionId: "Transaction Id",
    amount: "Transaction amount",
    productInfo: "product Info",
    firstName: "Customer firstName",
    email: "Customer email",
    phone: "Customer phone",
    ios_surl: "Success Url for iOS",
    ios_furl: "Failure Url for iOS",
    environment: "0 or 1",//<0 for Production/1 for Staging>
    beneficiaryAccountNumber: "customer bank account number",
    beneficiaryIFSC: "customer bank account ifsc",
    vpa: "Customer VPA",
    upiType: "0", // 0 is for collect
    additionalParam: {
        udf1: "user defined value 1",
        udf2: "user defined value 2",
        udf3: "user defined value 3",
        udf4: "user defined value 4",
        udf5: "user defined value 5",
    },
    hashes: {
      payment: "Payment Hash",
    },
}

var paymentObject = {
    payUPaymentParams: payUPaymentParams
}

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:

    PayUTpv.makeUPIPayment(
      paymentObject,
      (error) => {
        console.log("-----------Error payViaUPICollect---------");
        console.log(error);
        console.log("------------------------------------------");
      },
      (paymentResponse) => {
        console.log("-----------Success makeUPIPayment---------");
        console.log(paymentResponse);
        console.log("------------------------------------------");
      }
    );

4.2 UPI Intent:

To pay using UPI intent set the paymentObject as below:

var payUPaymentParams = {
    key: "Merchant key",
    transactionId: "Transaction Id",
    amount: "Transaction amount",
    productInfo: "product Info",
    firstName: "Customer firstName",
    email: "Customer email",
    phone: "Customer phone",
    ios_surl: "Success Url for iOS",
    ios_furl: "Failure Url for iOS",
    environment: "0 or 1",//<0 for Production/1 for Staging>
    beneficiaryAccountNumber: "customer bank account number",
    beneficiaryIFSC: "customer bank account ifsc",
    upiType: "1", // 1 is for intent
    intentApp: "App name", // gpay or phonepe
    additionalParam: {
        udf1: "user defined value 1",
        udf2: "user defined value 2",
        udf3: "user defined value 3",
        udf4: "user defined value 4",
        udf5: "user defined value 5",
    },
    hashes: {
      payment: "Payment Hash",
    },
}

var paymentObject = {
    payUPaymentParams: payUPaymentParams
}

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:

    PayUTpv.makeUPIPayment(
      paymentObject,
      (error) => {
        console.log("-----------Error payViaUPICollect---------");
        console.log(error);
        console.log("------------------------------------------");
      },
      (paymentResponse) => {
        console.log("-----------Success makeUPIPayment---------");
        console.log(paymentResponse);
        console.log("------------------------------------------");
      }
    );

4.3 Get Netbanking Param

To get Netbanking param set the paymentObject as below:

var payUPaymentParams = {
    key: "Merchant key",
    transactionId: "Transaction Id",
    amount: "Transaction amount",
    productInfo: "product Info",
    firstName: "Customer firstName",
    email: "Customer email",
    phone: "Customer phone",
    ios_surl: "Success Url for iOS",
    ios_furl: "Failure Url for iOS",
    environment: "0 or 1",//<0 for Production/1 for Staging>
    beneficiaryAccountNumber: "customer bank account number",
    beneficiaryIFSC: "customer bank account ifsc",
    bankCode: "Bank Code of bank",
    additionalParam: {
        udf1: "user defined value 1",
        udf2: "user defined value 2",
        udf3: "user defined value 3",
        udf4: "user defined value 4",
        udf5: "user defined value 5",
    },
    hashes: {
      payment: "Payment Hash",
    },
}

var paymentObject = {
    payUPaymentParams: payUPaymentParams
}

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:

    PayUTpv.getNBParam(
      paymentObject,
      (error) => {
        console.log("-----------Error getNBParam---------");
        console.log(error);
        console.log("------------------------------------");
      },
      (params) => {
        console.log("-----------Success getNBParam---------");
        console.log(params.url);
        console.log(params.bodyParam);
        console.log("--------------------------------------");
      }
    );

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:

var payUPaymentParams = {
    key: "Merchant key",
    transactionId: "Transaction Id",
    amount: "Transaction amount",
    productInfo: "product Info",
    firstName: "Customer firstName",
    email: "Customer email",
    phone: "Customer phone",
    ios_surl: "Success Url for iOS",
    ios_furl: "Failure Url for iOS",
    environment: "0 or 1",//<0 for Production/1 for Staging>
    vpa: "Customer VPA",
    additionalParam: {
        udf1: "user defined value 1",
        udf2: "user defined value 2",
        udf3: "user defined value 3",
        udf4: "user defined value 4",
        udf5: "user defined value 5",
    },
    hashes: {
        validateVPA: "validate vpa hash",
      },
}


var paymentObject = {
    payUPaymentParams: payUPaymentParams
}

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:

PayUTpv.validateVPA(
	paymentObject,
	(error) => {
		console.log("-----------Error validateVPA---------");
		console.log(error);
		console.log("-------------------------------------");
	},
	(response) => {
		console.log("-----------Success validateVPA---------");
		console.log(response);
		console.log("---------------------------------------");
	}
	);

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:

PayUTpv.intentApps(
	(apps) => {
		console.log("-----------Success intentApps---------");
		console.log(apps);
		console.log("---------------------------------------");
	}
	);

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

<key>LSApplicationQueriesSchemes</key>
<array>
<string>phonepe</string>
<string>tez</string>
<string>paytm</string>
</array>

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 updated