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 CocoaPods. To add the SDK to your app project, include the SDK framework in your podfile.
1
// make sure to add below-mentioned line to use dynamic frameworks
2
use_frameworks!
3
4
// Add this to include our SDK
5
pod 'PayUIndia-CheckoutPro'
Copied!
Install dependency using pod installcommand in terminal
Next, add the following imports in the class where you need to initiate a payment
Swift
Objective-C
1
import PayUCheckoutProKit
2
import PayUCheckoutProBaseKit
3
import PayUParamsKit
Copied!
1
#import <PayUCheckoutProKit/PayUCheckoutProKit.h>
2
#import <PayUCheckoutProBaseKit/PayUCheckoutProBaseKit.h>
3
#import <PayUParamsKit/PayUParamsKit.h>
Copied!
Test Merchant key/salt for production environment : 3TnMpV/g0nGFe03
Test Merchant key/salt for test environment : gtKFFx/eCwWELxi
CrashReporter
In order to receive all the crashes related to our SDKs, add the below-mentioned line your AppDelegate's didFinishLaunchingWithOptions.
Swift
Objective-C
1
PayUCheckoutPro.start()
Copied!
1
[PayUCheckoutPro start];
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. To pass this information, build a payment parameter object as
TransactionId can't have special character and not more than 25 characters.
Swift
Objective-C
1
let paymentParam = PayUPaymentParam(key: <#T##String#>,
2
transactionId: <#T##String#>,
3
amount: <#T##String#>,
4
productInfo: <#T##String#>,
5
firstName: <#T##String#>,
6
email: <#T##String#>,
7
phone: <#T##String#>,
8
surl: <#T##String#>,
9
furl: <#T##String#>,
10
environment: <#T##Environment#> /*.production or .test*/)
11
12
paymentParam.userCredential = <#T##String#> // For saving and fetching user’s saved card
Copied!
1
PayUPaymentParam *paymentParam = [[PayUPaymentParam alloc] initWithKey:<#(NSString * _Nonnull)#>
2
transactionId:<#(NSString * _Nonnull)#>
3
amount:<#(NSString * _Nonnull)#>
4
productInfo:<#(NSString * _Nonnull)#>
5
firstName:<#(NSString * _Nonnull)#>
6
email:<#(NSString * _Nonnull)#>
7
phone:<#(NSString * _Nonnull)#>
8
surl:<#(NSString * _Nonnull)#>
9
furl:<#(NSString * _Nonnull)#>
10
environment:<#(enum Environment)#> /*EnvironmentProduction or EnvironmentTest*/];
11
12
paymentParam.userCredential = <#(NSString)#>; // For saving and fetching use saved card
Copied!

For Recurring Payments(SI)

If you are integrating SI, then create an object of SIParam as mentioned here.
After creating an object, pass the object as below:
Swift
Objective-C
1
paymentParam.siParams = siParam
Copied!
1
paymentParam.siParams = siParam;
Copied!

Payment parameter definition

Parameter
Type
Description
Data Type & Validation
Mandatory
Key
String
Merchant key received from PayU
Can not be null or empty
Yes
Transaction ID
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
Product info
String
Information about product
Can not be null or empty and should be less than 100 Characters.
Yes
First Name
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
SURL
String
When the transaction is successful, PayU will load this url and pass transaction response
Should be a valid URL
Yes
FURL
String
When the transaction is a failure, PayU will load this url and pass transaction response
Should be a valid URL
Yes
Environment
Environment
Environment of SDK
Should be either Swift: Environment.production or Environment.test
ObjectiveC: EnvironmentProduction or EnvironmentTest
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
PayUSIParams
Object of PayUSIParams
Details can be found here
Object of PayUSIParams
No
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
PaymentParamConstant.udf1
String
User defined field, Merchant can store their customer id, etc.
No
PaymentParamConstant.udf2
String
User defined field, Merchant can store their customer id, etc.
No
PaymentParamConstant.udf3
String
User defined field, Merchant can store their customer id, etc.
No
PaymentParamConstant.udf4
String
User defined field, Merchant can store their customer id, etc.
No
PaymentParamConstant.udf5
String
User defined field, Merchant can store their customer id, etc.
No
Static Hashes
String
Covered in the Hash Generation section
No
Swift
Objective-C
1
paymentParam.additionalParam[PaymentParamConstant.udf1] = <#T##String#>
2
paymentParam.additionalParam[PaymentParamConstant.udf2] = <#T##String#>
3
paymentParam.additionalParam[PaymentParamConstant.udf3] = <#T##String#>
4
paymentParam.additionalParam[PaymentParamConstant.udf4] = <#T##String#>
5
paymentParam.additionalParam[PaymentParamConstant.udf5] = <#T##String#>
6
Copied!
1
paymentParam.additionalParam = [[NSDictionary alloc] initWithObjectsAndKeys:
2
<#(NSString)#>, PaymentParamConstant.udf1,
3
<#(NSString)#>, PaymentParamConstant.udf2,
4
<#(NSString)#>, PaymentParamConstant.udf3,
5
<#(NSString)#>, PaymentParamConstant.udf4,
6
<#(NSString)#>, PaymentParamConstant.udf5,
7
<#(NSString)#>, HashConstant.paymentRelatedDetailForMobileSDK,
8
<#(NSString)#>, HashConstant.vasForMobileSDK,
9
<#(NSString)#>, HashConstant.payment,
10
nil];
Copied!

4. Initiate the payment (Mandatory Step)

Initialise and launch the Checkout Pro SDK by calling the following method from your UIViewController’s subclass
Swift
Objective-C
1
PayUCheckoutPro.open(on: self, paymentParam: paymentParam, config: <#T##PayUCheckoutProConfig?#>, delegate: self)
Copied!
1
[PayUCheckoutPro openOn:self paymentParam:paymentParam config:<#(PayUCheckoutProConfig * _Nullable)#> delegate:self];
Copied!

5.Handle the payment completion (Mandatory Step)

Confirm to PayUCheckoutProDelegate and use these functions to get appropriate callbacks from the SDK:
Swift
Objective-C
1
/// This function is called when we successfully process the payment
2
/// - Parameter response: success response
3
func onPaymentSuccess(response: Any?) {
4
5
}
6
7
/// This function is called when we get failure while processing the payment
8
/// - Parameter response: failure response
9
func onPaymentFailure(response: Any?) {
10
11
}
12
13
/// This function is called when the user cancel’s the transaction
14
/// - Parameter isTxnInitiated: tells whether payment cancelled after reaching bankPage
15
func onPaymentCancel(isTxnInitiated: Bool) {
16
17
}
18
19
/// This function is called when we encounter some error while fetching payment options or there is some validation error
20
/// - Parameter error: This contains error information
21
func onError(_ error: Error?) {
22
23
}
24
25
/// Use this function to provide hashes
26
/// - Parameters:
27
/// - param: Dictionary that contains key as HashConstant.hashName & HashConstant.hashString
28
/// - onCompletion: Once you fetch the hash from server, pass that hash with key as param[HashConstant.hashName]
29
func generateHash(for param: DictOfString, onCompletion: @escaping PayUHashGenerationCompletion) {
30
// Send this string to your backend and append the salt at the end and send the sha512 back to us, do not calculate the hash at your client side, for security is reasons, hash has to be calculated at the server side
31
let hashStringWithoutSalt = param[HashConstant.hashString] ?? ""
32
// Or you can send below string hashName to your backend and send the sha512 back to us, do not calculate the hash at your client side, for security is reasons, hash has to be calculated at the server side
33
let hashName = param[HashConstant.hashName] ?? ""
34
35
// Set the hash in below string which is fetched from your server
36
let hashFetchedFromServer = <#T##String#>
37
38
onCompletion([hashName : hashFetchedFromServer])
39
}
Copied!
1
/// This function is called when we successfully process the payment
2
/// @param response success response
3
- (void)onPaymentSuccessWithResponse:(id _Nullable)response {
4
5
}
6
7
/// This function is called when we get failure while processing the payment
8
/// @param response failure response
9
- (void)onPaymentFailureWithResponse:(id _Nullable)response {
10
11
}
12
13
/// This function is called when the user cancel’s the transaction
14
/// @param isTxnInitiated tells whether payment cancelled after reaching bankPage
15
- (void)onPaymentCancelWithIsTxnInitiated:(BOOL)isTxnInitiated {
16
17
}
18
19
/// This function is called when we encounter some error while fetching payment options or there is some validation error
20
/// @param error This contains error information
21
- (void)onError:(NSError * _Nullable)error {
22
23
}
24
25
/// Use this function to provide hashes
26
/// @param param NSDictionary that contains key as HashConstant.hashName & HashConstant.hashString
27
/// @param onCompletion Once you fetch the hash from server, pass that hash with key as param[HashConstant.hashName]
28
- (void)generateHashFor:(NSDictionary<NSString *, NSString *> * _Nonnull)param onCompletion:(void (^ _Nonnull)(NSDictionary<NSString *, NSString *> * _Nonnull))onCompletion {
29
// Send below string hashStringWithoutSalt to your backend and append the salt at the end and send the sha512 back to us, do not calculate the hash at your client side, for security is reasons, hash has to be calculated at the server side
30
NSString *hashStringWithoutSalt = [param objectForKey:HashConstant.hashString];
31
// Or you can send below string hashName to your backend and send the sha512 back to us, do not calculate the hash at your client side, for security is reasons, hash has to be calculated at the server side
32
NSString * hashName = [param objectForKey:HashConstant.hashName];
33
34
// Set the hash in below string which is fetched from your server
35
NSString *hashFetchedFromServer = <#(NSString)#>;
36
37
NSDictionary *hashResponseDict = [NSDictionary dictionaryWithObjectsAndKeys:hashFetchedFromServer, hashName, nil];
38
onCompletion(hashResponseDict);
39
}
Copied!

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 1mo ago