Integration in iOS

Merchant can integrate Virtual card using PayUPPIiOS SDK in iOS. Below are the details of integration

1. Add Dependency:

Add below dependency in your app.

a. Cocoapods:

Use PayUIndia-PPI version 1.0.0.

pod 'PayUIndia-PPI-SDK'

a. SPM:

Use PayUIndia-PPI version 1.0.0.

.package(name: "PayUIndia-PPI-SDK", url: "https://github.com/payu-intrepos/PayUIndia-PPI", from: "1.0.0")

2. SDK Initialisation:

import OnePayUJSKit SDK in your project

import OnePayUJSKit

First create OnePayUJSParams Object

OnePayUJSParams(
            merchantKey = <String - Merchant Key>,
            referenceId = <String - Any unique reference id>,
            environment = <Environment - Prod or Test>,
            mobileNumber = <String - user mobile number>,
            walletUrn = <String - User wallet urn linked with aboved mobile number>,
            walletIdentifier = <String - merchant wallet Identifier>
        )
        

Then call OnePayUJSSDK show Cards function

 OnePayUJSSDK.showCards(parentVC: <current view Controller>, params: OnePayUJSParams, delegate: OnePayUJSSDKDelegate)
 Params:
 parentVC: Current Viewcontroller in which want to open cards page
 onePayUJSParams: OnePayUJSModel object with all parameters and hash
 OnePayUJSSDKDelegate: This is a delegate class in which you will got below callbacks
  1. onCancel() - If user press back button on card page or verify otp page
  2. func onError(code: Int, message: String) -  If any error occured
  3. func generateHash(for param: [String : String], onCompletion: @escaping OnePayUJSHashCompletion) -  create and send dynamic hash. 
 

HASH

We will get hash string in map "hashString" key and hash name "hashName" in generateHash. We need to send this string to server and append salt there, after appending salt convert string to sha512 hash and return back to sdk in OnePayUJSHashCompletion as ([:]).

  OnePayUJSHashCompletion -
     (_ hashDict: [String: String]) -> Void

Sample Code for Hash

    func generateHash(for param: [String : String], onCompletion: @escaping OnePayUJSKit.OnePayUJSHashCompletion) {
        let commandName = param["hashName"] ?? ""
        let hashStringWithoutSalt = param["hashString"] ?? ""
        // get hash for "commandName" from server
        // get hash for "hashStringWithoutSalt" from server
        // After fetching hash set its value in below variable "hashValue"
        let hashValue = <fetch hash from server, on server add salt in last of hashStringWithoutSalt and create sha512 Hash>
        onCompletion([commandName : hashValue])
    }