Virtual Cards Integration

You can integrate Virtual card using PayUPPIiOS SDK in iOS.

Step 1: Add the dependency

Add the following dependency in your app.Β 

Cocoapods

Use PayUIndia-PPI version 1.0.0.

pod 'PayUIndia-PPI-SDK'

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")

Step 2: SDK initialisation

  1. import the OnePayUJSKit SDK in your project
import OnePayUJSKit
  1. Create the 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> Β  Β  Β  Β )
  1. Create a OnePayUJSSDK object using the getInstance call showCards function similar to the following code block:
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.

Step 3: Hashing

Get hash string in map "hashString" key and hash name "hashName" in generateHash.Β  You 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Β  ([<hashName>:<hash>]).

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

Sample Code

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]) Β  Β }

πŸ“˜

Reference:

For more information on Static Hashing, refer to Generate Static Hash.