SDK Integration
  • Getting Started
  • Onboarding Requirements
  • Hash Generation
  • Test Merchant list
  • Android
    • Android SDK Offering
    • PayUCheckoutPro
      • Integration
      • Build the Payment Params
        • Additional Params
      • Hash Generation
      • Set up the payment hashes
      • Initiate the Payment
      • Customized Integration
        • Set Webview Properties
        • SDK Configuration
        • Additional Offerings
      • Offers Integration
      • Convenience Fee Integration
      • Custom Note Integration
      • MCP Integration
    • Core
      • Supported Payment Types
      • TPV Integration
      • Merchant Web Services
        • Getting Enabled Payment Options
        • GetCheckoutDetails API
        • Lookup API
    • Custom Browser
      • Integration
        • CustomBrowser Config
        • CustomBrowserCallback
        • Supporting below Lollipop Versions
        • Third-Party Payments Support
      • Sample App
      • Change Logs
    • Native OTP Assist
      • Integration
      • Customization
      • Change Logs
    • UPI
      • Integration
      • TPV Integration in UPI
      • Sample App
      • Change Logs
    • Google Pay™
      • Integration
      • Sample App
    • PhonePe
      • Integration
      • Sample App
      • Change Logs
    • OlaMoney
    • PayU OTP Parser
      • Integration
    • FAQ Android
  • iOS
    • PayUCheckoutPro
      • Integration
      • Advanced Integration
      • Set up the payment hashes
      • Convenience Fee Integration
      • MCP Integration
      • Custom Note Integration
    • Core
      • POD Integration
      • Seamless
      • Web Services
      • Objective C-Non-Seamless
      • Standing Instructions
      • TPV Integration
      • Sample App
    • Custom Browser
      • Sample App
    • OlaMoney
    • Native OTP Assist
      • Integration
      • Customization
    • UPI
      • Integration
      • Sample App
    • PayUParams
      • PayUSIParams
      • PayUBeneficiaryParams
  • Releasing to Apple
  • React-Native
    • PayUCheckoutPro
      • Integration
      • Set up the payment hashes
      • Advanced Integration
      • Change Logs
    • Core
    • Non-Seamless Wrapper
    • TPV (beta)
      • Integration
  • FAQ iOS
Powered by GitBook
On this page
  • Integration with the Native OTP Assist mobile SDK in 4 steps:
  • 1.Include the SDK in your app project (Mandatory Step)
  • Swift Package Manager Integration
  • 2. Set up the payment hashes (Mandatory Step)
  • Payment Post Data
  • 3.Initiate Payment
  • Callbacks
  • Error codes and their description.
  • Verify the transaction
  • Implementation of PayU verify API

Was this helpful?

  1. iOS
  2. Native OTP Assist

Integration

PreviousNative OTP AssistNextCustomization

Last updated 3 years ago

Was this helpful?

Integration with the Native OTP Assist mobile SDK in 4 steps:

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

The Native OTP SDK is offered via CocoaPods. To add the SDK to your app project, include the SDK framework in your podfile.

// make sure to add below-mentioned line to use dynamic frameworksuse_frameworks!​
// Add this to include our SDK
pod 'PayUIndia-NativeOtpAssist' 

Install dependency using pod installcommand in terminal

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

import PayUNativeOtpAssist
#import <PayUNativeOtpAssist/PayUNativeOtpAssist.h>

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:

  1. 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.

let paymentParam = PayUPaymentParam(key: <#T##String#>,
                                    transactionId: <#T##String#>,
                                    amount: <#T##String#>,
                                    productInfo: <#T##String#>,
                                    firstName: <#T##String#>,
                                    email: <#T##String#>,
                                    phone: <#T##String#>,
                                    surl: <#T##String#>,
                                    furl: <#T##String#>,
                                    environment: <#T##Environment#> /*.production or .test*/)

paymentParam.hashes = PayUHashes()
paymentParam.hashes?.paymentHash = <#T##SHA512 HashString#>
let ccdc = CCDC()
ccdc.cardNumber = <#T##String#>
ccdc.expiryYear = <#T##String#>
ccdc.expiryMonth = <#T##String#>
ccdc.cvv = <#T##String#>
ccdc.txnS2SFlow = <#T##String#> //"4" for transactions on native otp assist
ccdc.nameOnCard = <#T##String#>
ccdc.shouldSaveCard = <#T##String#>
paymentParam.paymentOption = ccdc
paymentParam.userCredential = <#T##String#> // For saving and fetching user’s saved card
PayUPaymentParam *paymentParam = [[PayUPaymentParam alloc] initWithKey:<#(NSString * _Nonnull)#>
                                                         transactionId:<#(NSString * _Nonnull)#>
                                                                amount:<#(NSString * _Nonnull)#>
                                                           productInfo:<#(NSString * _Nonnull)#>
                                                             firstName:<#(NSString * _Nonnull)#>
                                                                 email:<#(NSString * _Nonnull)#>
                                                                 phone:<#(NSString * _Nonnull)#>
                                                                  surl:<#(NSString * _Nonnull)#>
                                                                  furl:<#(NSString * _Nonnull)#>
                                                           environment:<#(enum Environment)#> /*EnvironmentProduction or EnvironmentTest*/];
paymentParam.hashes = [PayUHashes new];
paymentParam.hashes.paymentHash = <#T##SHA512 HashString#>;
CCDC *ccdc = [CCDC new];
ccdc.cardNumber = <#T##String#>;
ccdc.expiryYear = <#T##String#>;
ccdc.expiryMonth = <#T##String#>;
ccdc.cvv = <#T##String#>;
ccdc.txnS2SFlow = <#T##String#>; //"4" for transactions on native otp assist
ccdc.nameOnCard = <#T##String#>;
ccdc.shouldSaveCard = <#T##String#>;
paymentParam.paymentOption = ccdc;
paymentParam.userCredential = <#(NSString)#>; // For saving and fetching use saved 

3.Initiate Payment

Initialize the Native OTP Assist SDK by providing the PayUOtpAssistConfig object having postdata and reference to the PayUOtpAssistCallback to listen to the SDK events.

PayUOtpAssist.open(
                    parentVC: self,
                    paymentParam: paymentParam,
                    config: <#T##PayUOtpAssistConfig?#>,
                    delegate: self
                )
[PayUCheckoutPro openOn:self paymentParam:paymentParam config:<#(PayUOtpAssistConfig * _Nullable)#> delegate:self];

Initiate payment must be on Main Thread.

Callbacks

List of the callback function provided by PayUOtpAssistDelegate class:

  1. func onPaymentSuccess(merchantResponse: String?, payUResponse: String?)- Called when payment succeeds.

  2. func onPaymentFailure(merchantResponse: String?, payUResponse: String?)- Called when payment fails.

  3. func onError(errorCode: String?, errorMessage: String?)- Called when we got some error where,

    • errorCode : Error Code

    • errorMessage : Error Description

  4. func onPaymentCancel(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.

PayUAcsRequest field

Description

issuerUrl

It's the Bank/ACS page Url.

issuerPostData

You need to load issuerUrl to the Webview

along with this issuerPostdata string.

Ex: webView.postUrl(issuerUrl, issuerPostData.toByteArray())

acsTemplate

If issuerUrl is empty, you need to load acsTemplate to the Webview.

Ex: webView.loadData(acsTemplate, "text/html", "UTF-8");

Error codes and their description.

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

​

curl --location --request POST '{{Url}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'key={merchantKey}' \
--data-urlencode 'command=verify_payment' \
--data-urlencode 'hash=c6febddfaaf6986dd8bd982d3769f856ab149e4de92dbad995c8df808ffcfbcb2c227a3fae38b69eb39ad7b6ce4e06e6b12289f70cc500cea5a2cda449c7dcba' \
--data-urlencode 'var1=Txn1234'

var1:

Parameter

Description

Sample Value

var1

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.

c6febddfaaf6986dd8bd982d3769f856ab149e4de92dbad995c8df808ffcfbcb2c227a3fae38b69eb39ad7b6ce4e06e6b12289f70cc500cea5a2cda449c7dcba

Via Xcode - Go to File-> Add Package->

.package(name: "PayUIndia-NativeOtpAssist", url: "", from: "2.0.0")

A detailed document is present .

Use library to generate payment postdata.

Check here for definitions.

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.

Url:

​

https://github.com/payu-intrepos/PayUNativeOtpAssist-iOS
https://github.com/payu-intrepos/PayUNativeOtpAssist-iOS
here
Core Sdk
Payment parameter
CustomeBrowser
https://info.payu.in/merchant/postservice.php?form=2
Verify the transaction
Include the SDK in your app project
Set up the payment hash and post data
Initiate the payment