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

  2. Merchant Secret Key

Pass Merchant Access Key

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

Java
Kotlin
Java
HashMap<String, Object> additionalParams = new HashMap<>();
additionalParams.put(PayUCheckoutProConstants.CP_MERCHANT_ACCESS_KEY,<Merchant-Access-Key>)
Kotlin
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-

Java
Kotlin
Java
@Override
public void generateHash(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 MCP
if (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 = new HashMap<>();
dataMap.put(hashName, hash);
hashGenerationListener.onHashGenerated(dataMap);
}
}
Kotlin
override fun generateHash(
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 MCP
if (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)
}
}
}