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:
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:
Hashes:
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 -
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.
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.
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 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.
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.