For MCP payments, SDK requires Lookup API Hash which is a Dynamic Hash. SDK will call generateHash() method as explained here
Lookup API Hash is calculated with the HmacSHA1 signature. It requires a Merchant Secret key in calculating the hash. Below example, code demonstrates the calculation of Lookup API Hash.
func generateHash(for param: DictOfString, onCompletion: @escaping PayUHashGenerationCompletion) { let commandName = (param[HashConstant.hashName] ??"") let hashStringWithoutSalt = (param[HashConstant.hashString] ??"")// get hash for "commandName" from server// After fetching hash set its value in below variable "hashValue"var hashValue =""if commandName ==HashConstant.mcpLookup {//To create HMACSHA1 Signature // Signature = HMAC-SHA1(data, key);//Data = hashStringWithoutSalt//Key = Mechent Secret Key shared with the merchant at the time of on-boarding hashValue =<HMACSHA1 signature from your server> } else { hashValue =<HMACSHA512 hash from your server> }onCompletion([commandName : hashValue]) }
- (void)generateHashFor:(NSDictionary<NSString *,NSString *> * _Nonnull)param onCompletion:(void (^ _Nonnull)(NSDictionary<NSString *,NSString *> * _Nonnull))onCompletion {
NSString *commandName = [param objectForKey:HashConstant.hashName]; NSString *hashStringWithoutSalt = [param objectForKey:HashConstant.hashString];// get hash for "commandName" from server// After fetching hash set its value in below variable "hashValue" NSString *hashValue = [NSMutableString new];if (commandName == HashConstant.mcpLookup) {if commandName == HashConstant.mcpLookup {//To create HMACSHA1 Signature // Signature = HMAC-SHA1(data, key);//Data = hashStringWithoutSalt//Key = Mechent Secret Key shared with the merchant at the time of on-boarding hashValue = @<HMACSHA1 signature from your server>; } else { hashValue = @<HMACSHA512 hash from your server>; } NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:hashValue, commandName, nil];onCompletion(dict);}