val additionalParamsMap: HashMap<String, Any?> =HashMap()additionalParamsMap[PayUCheckoutProConstants.CP_MERCHANT_ACCESS_KEY] =<Merchant-Access-Key>
Set these Additional params in Payment Params mentioned here.
Generate Hash For MCP
For MCP payments, SDK require Lookup API Hash which is a Dynamic Hash. SDK will call generateHash() method as explained here
Lookup API Hash is calculated with HmacSHA1 signature. It requires a Merchant Secret key in calculating the hash. Below example code demonstrate the calculation of Lookup API Hash-
@OverridepublicvoidgenerateHash(HashMap<String, String> valueMap,PayUHashGenerationListener hashGenerationListener) {String hashName =valueMap.get(PayUCheckoutProConstants.CP_HASH_NAME);String hashData =valueMap.get(PayUCheckoutProConstants.CP_HASH_STRING);if (!TextUtils.isEmpty(hashName) &&!TextUtils.isEmpty(hashData)) {String hash =null; //Below if statement is required only when integrating MCPif (hashName.equalsIgnoreCase(PayUCheckoutProConstants.CP_LOOKUP_API_HASH)){//Calculate HmacSHA1 HASH for calculating Lookup API Hash ///Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side. hash = hashString; // here hashString is hash calculated from your Server Side } else {//Calculate SHA-512 Hash here hash = hashString; // here hashString is hash calculated from your Server Side }HashMap<String,String> dataMap =newHashMap<>();dataMap.put(hashName, hash);hashGenerationListener.onHashGenerated(dataMap); } }
overridefungenerateHash( map: HashMap<String, String?>, hashGenerationListener: PayUHashGenerationListener ) {if (map.containsKey(CP_HASH_STRING) && map.containsKey(CP_HASH_NAME)) {val hashData = map[CP_HASH_STRING]val hashName = map[CP_HASH_NAME]var hash: String? =null//Below if statement is required only when integrating MCPif (hashName.equals(PayUCheckoutProConstants.CP_LOOKUP_API_HASH, ignoreCase =true)) {//Calculate HmacSHA1 HASH for calculating Lookup API Hash ///Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side. hash = hashString // here hashString is hash calculated from your Server Side } else {//Calculate SHA-512 Hash here hash = hashString // here hashString is hash calculated from your Server Side }if (!TextUtils.isEmpty(hash)) {val hashMap: HashMap<String, String?> =HashMap() hashMap[hashName!!] = hash!! hashGenerationListener.onHashGenerated(hashMap) } } }