MCP Integration

(Optional)

Follow below integration steps if integrating Multi-Currency Payments(MCP)

Demo of MCP flow

Pre-requisites

Kindly connect with your Key Account Manager at PayU to get the below credentials -

  1. Merchant Access Key

  2. Merchant Secret Key

Pass Merchant Access Key

Pass Merchant Access Key in Additional Params in Payment Params as mentioned here.

Swift
Objective C
Swift
paymentParam.additionalParam[PaymentParamConstant.merchantAccessKey] = <Merchant-Access-Key>
Objective C
paymentParam.additionalParam[PaymentParamConstant.merchantAccessKey] = @<Merchant-Access-Key>;

Generate Hash For MCP

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.

Swift
Objective C
Swift
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])
}
Objective C
- (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);
}