Lookup API This is used when integrating Multi-Currency Payments
Follow below steps to integrate this API
Pre-requisites
Kindly connect with your Key Account Manager at PayU to get below credentials -
Create Request
Lookup Api needs a JSON request. Product Type need to be passed either as DCC or MCP. DCC means Direct Currency Conversion, i.e it returns the conversion prices for card currency only. To get all enabled currencies on Merchant Access Key along with their conversion prices, use product type as MCP. For DCC, cardBin is mandatory, while for MCP cardBin is not required
Below is example request for DCC as product type
Copy {
"merchantAccessKey":"E5ABOXOWAAZNXB6JEF5Z",
"baseAmount":{
"value":10000.00,
"currency":"INR"
},
"cardBin":"513382",
"merchantOrderId":"OBE-JU89-13151-110",
"productType":"DCC",
"signature":"be5a56667354d9e2ea5ea1c6af78b0afc1894eb2"
}
To create Lookup API request like above, use LookupApiRequestBuilder class as below
Java Kotlin
Copy String postData = new LookupRequest . LookupApiRequestBuilder ()
. setAmount ( "10000.00" )
. setCardBin ( "513382" )
. setCurrency ( "INR" )
. setMerchantAccessKey ( "E5ABOXOWAAZNXB6JEF5Z" )
. setMerchantOrderId ( "OBE-JU89-13151-110" )
. setProductType ( LookupRequest . ProductType . DCC )
. setSignature (hash)
. build () . prepareJSON ();
Copy val postData = LookupRequest. LookupApiRequestBuilder ()
. setAmount ( "10000.00" )
. setCardBin ( "513382" )
. setCurrency ( "INR" )
. setMerchantAccessKey ( "E5ABOXOWAAZNXB6JEF5Z" )
. setMerchantOrderId ( "OBE-JU89-13151-110" )
. setProductType (LookupRequest.ProductType.DCC)
. setSignature (hash)
. build (). prepareJSON ()
Below is example request for MCP as product type
Copy {
"merchantAccessKey":"E5ABOXOWAAZNXB6JEF5Z",
"baseAmount":{
"value":10000.00,
"currency":"INR"
},
"merchantOrderId":"OBE-JU89-13151-110",
"productType":"MCP",
"signature":"be5a56667354d9e2ea5ea1c6af78b0afc1894eb2"
}
To create Lookup API request for MCP, use LookupApiRequestBuilder class as below
Java Kotlin
Copy String postData = new LookupRequest . LookupApiRequestBuilder ()
. setAmount ( "10000.00" )
. setCurrency ( "INR" )
. setMerchantAccessKey ( "E5ABOXOWAAZNXB6JEF5Z" )
. setMerchantOrderId ( "OBE-JU89-13151-110" )
. setProductType ( LookupRequest . ProductType . MCP )
. setSignature (hash)
. build () . prepareJSON ();
Copy val postData = LookupRequest. LookupApiRequestBuilder ()
. setAmount ( "10000.00" )
. setCurrency ( "INR" )
. setMerchantAccessKey ( "E5ABOXOWAAZNXB6JEF5Z" )
. setMerchantOrderId ( "OBE-JU89-13151-110" )
. setProductType (LookupRequest.ProductType.MCP)
. setSignature (hash)
. build (). prepareJSON ()
PFB details for params used in Lookup API
To calculate signature, Create HmacSHA1 hash of below data
Copy Signature =HMAC-SHA1(data, key);
Data = baseCurrency+merchantOrderId+baseAmount
Key = Secret Key shared with the merchant at the time of on-boarding
Example data,
baseCurrency = "INR"
merchantOrderId = "OBE-JU89-13151-110"
baseAmount = "10000.00"
hashString = INROBE-JU89-13151-11010000.00
Call LookupTask
Java Kotlin
Copy payuConfig . setData (postData);
LookupTask lookupTask = new LookupTask( this ) ;
lookupTask . execute (payuConfig);
Copy payuConfig. data = postData
val lookupTask = LookupTask ( this )
lookupTask. execute (payuConfig)
Here, this is object of a class that implements LookupApiListener. Below is signature of LookupApiListener
Java Kotlin
Copy public interface LookupApiListener {
void onLookupApiResponse ( PayuResponse payuResponse);
}
Copy interface LookupApiListener {
fun onLookupApiResponse (payuResponse: PayuResponse ?)
}
Get Lookup Api Response
Once you call ‘execute’ on LookupTask, ‘onLookupApiResponse’ callback method is called.
Java Kotlin
Copy @ Override
public void onLookupApiResponse( PayuResponse payuResponse) {
//Fetch lookup Details using below code
LookupDetails lookupDetails = payuResponse . getLookupDetails ();
}
Copy override fun onLookupApiResponse (payuResponse: PayuResponse ?){
//Fetch lookup Details using below code
val lookupDetails = payuResponse.lookupDetails
}