Integration

You can integrate with the CheckoutPro mobile SDK in 5 steps:

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

The CheckoutPro SDK is offered via npm.
Use below step to include CheckoutPro SDK in your app:
1
npm install payu-non-seam-less-react --save
2
react-native link payu-non-seam-less-react
Copied!
Next, add the following imports in the class where you need to initiate a payment
1
import PayUBizSdk from 'payu-non-seam-less-react';
Copied!

For iOS

Checkoutpro 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', 'PayULoggerKit', 'PayUNetworkingKit', 'PayUUPICoreKit', 'Socket.IO-Client-Swift', 'Starscream']
2
pre_install do |installer|
3
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
4
installer.pod_targets.each do |pod|
5
if $dynamic_framework.include?(pod.name)
6
def pod.build_type;
7
Pod::BuildType.dynamic_framework
8
end
9
end
10
end
11
end
Copied!
After updating the podfile, install the pod using below command.
1
pod install
Copied!

2. Set up the payment hashes (Mandatory Step)

Detailed document is present here.

3. Build the payment parameters (Mandatory Step)

To initiate a payment, your app will need to send transactional information to the Checkout Pro 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
android_surl
String
[Android] When the transaction gets success, PayU will load this url and pass transaction response
Should be a valid URL
Yes
android_furl
String
[Android] 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
User Credential
String
This is used for the store card feature. PayU will store cards corresponding to passed user credentials and similarly, user credentials will be used to access previously saved cards
Should be a unique value
Format : <merchantKey>:<userId>
Here,
UserId is any id/email/phone number to uniquely identify the user
No
Refer here for help regarding SI Params.

Additional Params:

Additional params are optional params that can be passed to SDK like udf params, static hashes. More details on static hash generation and passing is mentioned in hash generation section. 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
Static Hashes
String
Covered in the Hash Generation section
No
Payment param and additional param can be passed 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
android_surl: "Success Url for Android",
12
android_furl: "Failure Url for Android",
13
environment: "0 or 1",//<0 for Production/1 for Staging>
14
userCredential: "key:CustomerID",
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
payment_related_details_for_mobile_sdk: "payment_related_details_for_mobile_sdk hash",
22
vas_for_mobile_sdk: "vas_for_mobile_sdk hash",
23
payment: "Payment Hash"
24
},
25
payUSIParams: {
26
isFreeTrial:true,
27
billingAmount:'10',
28
billingInterval:1,
29
paymentStartDate:'2023-04-20',
30
paymentEndDate:'2023-04-30',
31
billingCycle:'daily', //Can be any of 'daily','weekly','yearly','adhoc','once','monthly'
32
remarks:'Test SI transcaction',
33
billingCurrency:'INR'
34
}
35
}
Copied!

4. Initiate the payment (Mandatory Step)

Initialise and launch the Checkout Pro SDK by calling the following method
1
var paymentObject = {
2
payUPaymentParams: payUPaymentParams,
3
// payUCheckoutProConfig is optional
4
// Detail can be found in latter section
5
payUCheckoutProConfig: payUCheckoutProConfig
6
}
7
PayUBizSdk.openCheckoutScreen(paymentObject);
Copied!

5.Handle the payment completion (Mandatory Step)

To get the callbacks for payment-related statuses create an object of NativeEventEmitter and subscribe to the below events.
1
import { NativeEventEmitter } from 'react-native';
2
3
//Register event emitters here.
4
componentDidMount() {
5
const eventEmitter = new NativeEventEmitter(PayUBizSdk);
6
this.paymentSuccess = eventEmitter.addListener('onPaymentSuccess', this.onPaymentSuccess);
7
this.paymentFailure = eventEmitter.addListener('onPaymentFailure', this.onPaymentFailure);
8
this.paymentCancel = eventEmitter.addListener('onPaymentCancel', this.onPaymentCancel);
9
this.error = eventEmitter.addListener('onError', this.onError);
10
this.generateHash = eventEmitter.addListener('generateHash', this.generateHash);
11
}
12
onPaymentSuccess = (e) => {
13
console.log(e.merchantResponse);
14
console.log(e.payuResponse);
15
}
16
onPaymentFailure = (e) => {
17
console.log(e.merchantResponse);
18
console.log(e.payuResponse);
19
}
20
onPaymentCancel = (e) => {
21
console.log('onPaymentCancel isTxnInitiated -' + e);
22
}
23
onError = (e) => {
24
console.log(e);
25
}
26
generateHash = (e) => {
27
console.log(e.hashName);
28
console.log(e.hashString);
29
var hashStringWithoutSalt = e.hashString;
30
var hashName = e.hashName;
31
// Pass hashStringWithoutSalt to server
32
// Server will append salt at the end and generate sha512 hash over it
33
var hashValue = "<Set hash here which is fetched from server>";
34
var result = { [hashName]: hashValue };
35
PayUBizSdk.hashGenerated(result);
36
}
37
38
//Do remember to unregister eventEmitters here
39
componentWillUnmount() {
40
this.paymentSuccess.remove();
41
this.paymentFailure.remove();
42
this.paymentCancel.remove();
43
this.error.remove();
44
this.generateHash.remove();
45
}
Copied!

Native Changes For Android

Build.gradle

1
allprojects {
2
repositories {
3
maven {
4
url "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android"
5
}
6
}
7
}
Copied!

AndroidManifest.xml

In order to Autofill OTP on bank pages SDK requires "RECEIVE_SMS" permission so kindly add the same in your AndroidManifest.xml like below.
1
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Copied!

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 PayUChekoutPro integrated.
Last modified 4mo ago