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 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.
Java
Kotlin
1
HashMap<String, Object> additionalParams = new HashMap<>();
2
additionalParams.put(PayUCheckoutProConstants.CP_MERCHANT_ACCESS_KEY,<Merchant-Access-Key>)
Copied!
1
val additionalParamsMap: HashMap<String, Any?> = HashMap()
2
additionalParamsMap[PayUCheckoutProConstants.CP_MERCHANT_ACCESS_KEY] = <Merchant-Access-Key>
Copied!
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-
Java
Kotlin
1
@Override
2
public void generateHash(HashMap<String, String> valueMap, PayUHashGenerationListener hashGenerationListener) {
3
String hashName = valueMap.get(PayUCheckoutProConstants.CP_HASH_NAME);
4
String hashData = valueMap.get(PayUCheckoutProConstants.CP_HASH_STRING);
5
if (!TextUtils.isEmpty(hashName) && !TextUtils.isEmpty(hashData)) {
6
7
String hash = null;
8
//Below if statement is required only when integrating MCP
9
if (hashName.equalsIgnoreCase(PayUCheckoutProConstants.CP_LOOKUP_API_HASH)){
10
//Calculate HmacSHA1 HASH for calculating Lookup API Hash
11
///Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
12
13
hash = hashString; // here hashString is hash calculated from your Server Side
14
} else {
15
16
//Calculate SHA-512 Hash here
17
hash = hashString; // here hashString is hash calculated from your Server Side
18
}
19
20
HashMap<String, String> dataMap = new HashMap<>();
21
dataMap.put(hashName, hash);
22
hashGenerationListener.onHashGenerated(dataMap);
23
}
24
}
Copied!
1
override fun generateHash(
2
map: HashMap<String, String?>,
3
hashGenerationListener: PayUHashGenerationListener
4
) {
5
if (map.containsKey(CP_HASH_STRING) && map.containsKey(CP_HASH_NAME)) {
6
val hashData = map[CP_HASH_STRING]
7
val hashName = map[CP_HASH_NAME]
8
9
var hash: String? = null
10
11
//Below if statement is required only when integrating MCP
12
if (hashName.equals(PayUCheckoutProConstants.CP_LOOKUP_API_HASH, ignoreCase = true)) {
13
//Calculate HmacSHA1 HASH for calculating Lookup API Hash
14
///Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
15
16
hash = hashString // here hashString is hash calculated from your Server Side
17
} else {
18
19
//Calculate SHA-512 Hash here
20
hash = hashString // here hashString is hash calculated from your Server Side
21
}
22
23
if (!TextUtils.isEmpty(hash)) {
24
val hashMap: HashMap<String, String?> = HashMap()
25
hashMap[hashName!!] = hash!!
26
hashGenerationListener.onHashGenerated(hashMap)
27
}
28
}
29
}
Copied!
Last modified 6mo ago