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. 1.
    Merchant Access Key
  2. 2.
    Merchant Secret Key

Pass Merchant Access Key

Pass Merchant Access Key in Additional Params in Payment Params as mentioned here.
Swift
Objective C
1
paymentParam.additionalParam[PaymentParamConstant.merchantAccessKey] = <Merchant-Access-Key>
Copied!
1
paymentParam.additionalParam[PaymentParamConstant.merchantAccessKey] = @<Merchant-Access-Key>;
Copied!

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
1
func generateHash(for param: DictOfString, onCompletion: @escaping PayUHashGenerationCompletion) {
2
let commandName = (param[HashConstant.hashName] ?? "")
3
let hashStringWithoutSalt = (param[HashConstant.hashString] ?? "")
4
// get hash for "commandName" from server
5
// After fetching hash set its value in below variable "hashValue"
6
var hashValue = ""
7
if commandName == HashConstant.mcpLookup {
8
//To create HMACSHA1 Signature
9
// Signature = HMAC-SHA1(data, key);
10
//Data = hashStringWithoutSalt
11
//Key = Mechent Secret Key shared with the merchant at the time of on-boarding
12
hashValue = <HMACSHA1 signature from your server>
13
} else {
14
hashValue = <HMACSHA512 hash from your server>
15
}
16
onCompletion([commandName : hashValue])
17
}
Copied!
1
- (void)generateHashFor:(NSDictionary<NSString *,NSString *> * _Nonnull)param onCompletion:(void (^ _Nonnull)(NSDictionary<NSString *,NSString *> * _Nonnull))onCompletion {
2
NSString *commandName = [param objectForKey:HashConstant.hashName];
3
NSString *hashStringWithoutSalt = [param objectForKey:HashConstant.hashString];
4
// get hash for "commandName" from server
5
// After fetching hash set its value in below variable "hashValue"
6
NSString *hashValue = [NSMutableString new];
7
if (commandName == HashConstant.mcpLookup) {
8
if commandName == HashConstant.mcpLookup {
9
//To create HMACSHA1 Signature
10
// Signature = HMAC-SHA1(data, key);
11
//Data = hashStringWithoutSalt
12
//Key = Mechent Secret Key shared with the merchant at the time of on-boarding
13
hashValue = @<HMACSHA1 signature from your server>;
14
} else {
15
hashValue = @<HMACSHA512 hash from your server>;
16
}
17
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:hashValue, commandName, nil];
18
onCompletion(dict);
19
}
Copied!
Last modified 5mo ago