Test Merchant key/salt for the production environment: ol4Spy/J0ZXw2z9
Test Merchant key/salt for the test environment: gtKFFx/eCwWELxi
Compatibility
Min iOS Version: 11
Please set "Excluded Architectures" to "arm64" in the Build Settings of your project to run in Simulator.
CrashReporter
In order to receive all the crashes related to our SDKs, add the below-mentioned line your AppDelegate's didFinishLaunchingWithOptions.
PayUOtpAssist.start()
[PayUOtpAssist start];
Swift Package Manager Integration
You can integrate PayUIndia-NativeOtpAssist with your app or SDK in two ways:
Via Package.Swift - Add below line in Package.swift dependencies
2. Set up the payment hashes (Mandatory Step)
You need to implement a payment hash.
Every transaction (payment or non-payment) needs a hash by the merchant before sending the transaction details to PayU. This is required for PayU to validate the authenticity of the transaction. This should be done on your server.
Payment Post Data
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 a special character and not more than 25 characters.
Initialize the Native OTP Assist SDK by providing the PayUOtpAssistConfig object having postdata and reference to the PayUOtpAssistCallback to listen to the SDK events.
List of the callback function provided by PayUOtpAssistDelegate class:
func onPaymentSuccess(merchantResponse: String?, payUResponse: String?)- Called when payment succeeds.
func onPaymentFailure(merchantResponse: String?, payUResponse: String?)- Called when payment fails.
func onError(errorCode: String?, errorMessage: String?)- Called when we got some error where,
errorCode : Error Code
errorMessage : Error Description
funconPaymentCancel(isTxnInitiated:Bool)- called when user cancel the transaction.
func shouldHandleFallback(payUAcsRequest: PayUAcsRequest) -> Bool {
if shouldHandleFallback { // Return 'true', when merchant doesn't want to handle fallback scenarios
return true
}
// Set the merchantKey and transactionId
PUCBConfiguration.getSingletonInstance()?.merchantKey = key
PUCBConfiguration.getSingletonInstance()?.transactionId = payUAcsRequest.transactionId ?? ""
if let issuerUrl = payUAcsRequest.issuerUrl, let issuerPostData = payUAcsRequest.issuerPostData, !issuerUrl.isEmpty {
// Set the issuerUrl and issuerPostData to open in WebView
PUCBConfiguration.getSingletonInstance()?.paymentPostParam = issuerPostData
PUCBConfiguration.getSingletonInstance()?.paymentURL = issuerUrl
}
else
if let acsTemplate = payUAcsRequest.acsTemplate {
// Set the acsTemplate to open in WebView
PUCBConfiguration.getSingletonInstance()?.htmlData = acsTemplate
}
// Open CB
let webVC = try PUCBWebVC(
postParam: PUCBConfiguration.getSingletonInstance()?.paymentPostParam ?? "=",
url: URL(string: PUCBConfiguration.getSingletonInstance()?.paymentURL ?? "https://www.google.com"),
merchantKey: self.key
)
webVC.cbWebVCDelegate = self
self.navigationController?.setNavigationBarHidden(false, animated: false)
self.present(webVC, animated: true)
} catch let error {
self.onError(errorCode: "0", errorMessage: error.localizedDescription)
}
return false
}
You will get PayUAcsRequest on shouldHandleFallback() callback.
whether you will get issuerUrl and issuerPostData or acsTemplate on PayUAcsRequest acsTemplate is the Html string that you need to load to the Webview.
- ErrorCode: Description
- 1001 : No Internet
- 1002 : Network timeout, please verify with your server.
- 1003 : Gateway timeout, please verify with your server.
- 1005 : Something went wrong , please verify with your server.
- 1006 : Bank page timed out, please verify with your server.
Verify the transaction
Once you get the response from SDK, make sure to confirm it with the PayU server. It is recommended to implement the PayU backend verify call from your backend.
Implementation of PayU verify API
Since you already have the txnID (Order ID generated at your end) value for such cases, you simply need to execute the verify_payment API with the necessary input parameters.
The output would return you the transaction status in "status" key and various other parameters also.
In this parameter, you can put all the txnid(Your transaction ID/order ID) values in a pipe-separated form.
100123|100124|100125
command
This parameter must have the name of the web service.
It must be verify_payment
key
It's the merchant key that PayU provided you.
hash
This parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below: sha512(key|command|var1|salt) sha512 is the encryption method used here.
func shouldHandleFallback(payUAcsRequest: PayUAcsRequest) -> Bool - It's an optional callback, override when you want to handle the Bank page redirection flow. You just need to change the return value to false.
You can also open in fallback scenarios. Below is the code snippet to open the CustomBrowser.