1. Integration Steps

Explore a complete, working code sample of integration with Android checkout pro SDK.

Before you start with the integration, enable the payment methods that you want to offer to your customers from Dashboard > Settings > Payment methods. We enable Cards, UPI, and other payment methods by default, and we recommend that you enable other payment methods that are relevant to you.

Step 1: Create a PayU account

First, create a PayU account. For more information, refer to Register for a Merchant Account.


Step 2: Set up build.gradle

To include the CheckoutPro SDK in your project, add the following code snippet to your app’s build.gradle file inside the android{} block:

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.9'
    }

❗️

Compatibility

  1. Android SDK — Version 21 and above.
  2. Compile SDK — version 31 and above.

Step 3: Create the payment object

To initiate a payment, your app must send transactional information to the CheckoutPro SDK. To pass this information, create thepayUPaymentParams object with the payment parameters.


 val payUPaymentParams = PayUPaymentParams.Builder() 
    .setAmount()      
    .setIsProduction()  
    .setKey()       
    .setProductInfo()   
    .setPhone()  
    .setTransactionId() 
    .setFirstName() 
    .setEmail() 
    .setSurl() 
    .setFurl() 
    .setUserCredential()
    .setUserToken()
    .setAdditionalParams(<HashMap>) //Optional, can contain any additional PG params 
    .build() 
val payUPaymentParams = PayUPaymentParams.Builder() 
    .setAmount()      
    .setIsProduction()  
    .setKey()       
    .setProductInfo()   
    .setPhone()  
    .setTransactionId() 
    .setFirstName() 
    .setEmail() 
    .setSurl() 
    .setFurl() 
    .setUserCredential() 
    .setUserToken()
    .setAdditionalParams(<HashMap>) //Optional, can contain any additional PG params 
    .build()

Step 3.1: Add split payments details (Optional)

For a split payment transaction, create a JSON string with the split payment parameters as shown below:

{
   "type":"absolute",
   "splitInfo":{
      "P****Y":{
         "aggregatorSubTxnId":"9a70ea0155268101001ba",
         "aggregatorSubAmt":"50",
         "aggregatorCharges":"20"
      },
      "P***K":{
         "aggregatorSubTxnId":"9a70ea0155268101001bb",
         "aggregatorSubAmt":"30"
      }
   }
}

Then create an object of the PayUPaymentParam class and set the splitPaymentDetails property of the object to the JSON string you created in the earlier step.

paymentParam.splitPaymentDetails = "";
paymentParam.splitPaymentDetails = ""

Sample Code

PayUPaymentParams.Builder builder = new PayUPaymentParams.Builder(); 
builder.setAmount()  
        .setIsProduction()  
        .setProductInfo()   
        .setKey()      
        .setPhone()      
        .setTransactionId()  
        .setFirstName() 
        .setEmail() 
        .setSurl() 
        .setFurl() 
        .setUserCredential() 
        .setAdditionalParams(<HashMap>); //Optional, can contain any additional PG params  
        .setPayUSIParams(siDetails)
        .setSplitPaymentDetails(splitPaymentDetails);
PayUPaymentParams payUPaymentParams = builder.build(); 
PayUPaymentParams.Builder builder = new PayUPaymentParams.Builder(); 
builder.setAmount()  
        .setIsProduction()  
        .setProductInfo()   
        .setKey()      
        .setPhone()      
        .setTransactionId()  
        .setFirstName() 
        .setEmail() 
        .setSurl() 
        .setFurl() 
        .setUserCredential() 
        .setAdditionalParams(<HashMap>); //Optional, can contain any additional PG params  
        .setPayUSIParams(siDetails)
        .setSplitPaymentDetails(splitPaymentDetails);
PayUPaymentParams payUPaymentParams = builder.build(); 

Step 3.2: Payment parameters

The following fields are included in the splitPaymentDetails parameter in a JSON format to specify the split details. The fields in the JSON format are described in the following table:

ParameterDescription
Key
mandatory
String This parameter must contain your merchant key received from PayU.
transactionId
mandatory
String It should be unique for each transaction.
Amount
mandatory
String Total transaction amount.
productInfo
mandatory
String Information about the product.
firstName
mandatory
String Customer’s first name
Email
mandatory
String Customer’s email id
Phone
mandatory
String Customer’s phone number.
ios_surl
mandatory
String When the transaction gets successful, PayU will load this URL and pass the transaction response.
Note: This field is applicable for iOS integration
ios_furl
mandatory
String When the transaction fails, PayU will load this URL and pass the transaction response.
Note: This field is applicable for iOS integration
android_surl
mandatory
String When the transaction gets successful, PayU will load this URL and pass the transaction response.
Note: This field is applicable for Android integration
Sample SURL: https://cbjs.payu.in/sdk/success
android_furl
mandatory
String When the transaction gets fail, PayU will load this url and pass transaction response.
When the transaction gets success, PayU will load this url and pass transaction response.
Note: This field is applicable for Android integration
Environment
mandatory
String Environment of SDK
User Credential
mandatory
String This is used for the store card feature. PayU will store cards corresponding to passed user credentials and similarly, user credentials will be used to access previously saved cards. Format:
<merchantKey>:<userId>
Here,
UserId is any id/email/phone number to uniquely identify the user.
isProdcution mandatoryString Set the value of this parameter as true when you deploy the integration in production. To test the integration set the value as false.

Additional parameters are optional parameters such as UDF (user-defined fields), etc. For more details on dynamic hash generation and passing, refer to Generate Hash.

Step 3.3: Additional parameters (Optional)

Additional parameters are optional parameters such as UDF (User Defined Fields), static hashes, etc. More details on static hash generation and passing are mentioned in the hash generation section. The following is a list of other parameters that can be passed in additional parameters.

HashMap additionalParams = new HashMap(); 
additionalParams.put(PayUCheckoutProConstants.CP_UDF1, "udf1"); 
additionalParams.put(PayUCheckoutProConstants.CP_UDF2, "udf2"); 
additionalParams.put(PayUCheckoutProConstants.CP_UDF3, "udf3"); 
additionalParams.put(PayUCheckoutProConstants.CP_UDF4, "udf4"); 
additionalParams.put(PayUCheckoutProConstants.CP_UDF5, "udf5"); 
// to show saved sodexo card
additionalParams.put(PayUCheckoutProConstants.SODEXO_SOURCE_ID, "srcid123"); 
 additionalParamsMap[PayUCheckoutProConstants.WALLET_URN] = "<Wallet URN>"
PayUPaymentParams.Builder builder = new PayUPaymentParams.Builder(); 
builder.setAmount("1.0") 
        .setIsProduction(true) 
        .setProductInfo("Macbook Pro") 
        .setKey(key) 
        .setPhone(phone) 
        .setTransactionId(String.valueOf(System.currentTimeMillis())) 
        .setFirstName("John") 
        .setEmail("[email protected]") 
        .setSurl("https://payuresponse.firebaseapp.com/success") 
        .setFurl("https://payuresponse.firebaseapp.com/failure") 
        .setUserCredential(key+":[email protected]") 
        .setAdditionalParams(additionalParams); 
PayUPaymentParams payUPaymentParams = builder.build();  
val additionalParamsMap: HashMap = HashMap() 
  additionalParamsMap[PayUCheckoutProConstants.CP_UDF1] = "udf1" 
  additionalParamsMap[PayUCheckoutProConstants.CP_UDF2] = "udf2" 
  additionalParamsMap[PayUCheckoutProConstants.CP_UDF3] = "udf3" 
  additionalParamsMap[PayUCheckoutProConstants.CP_UDF4] = "udf4" 
  additionalParamsMap[PayUCheckoutProConstants.CP_UDF5] = "udf5" 
  additionalParamsMap[PayUCheckoutProConstants.SODEXO_SOURCE_ID] = "srcid123" 
  
  val payUPaymentParams = PayUPaymentParams.Builder() 
                          .setAmount("1.0") 
                          .setIsProduction(true) 
                          .setKey(key) 
                          .setProductInfo("Macbook Pro") 
                          .setPhone(phone) 
                          .setTransactionId(System.currentTimeMillis().toString()) 
                          .setFirstName("John") 
                          .setEmail("[email protected]") 
                          .setSurl(“https://payuresponse.firebaseapp.com/success”) 
                          .setFurl("https://payuresponse.firebaseapp.com/failure ") 
                          .setUserCredential("$key:[email protected]”) 
                          .setAdditionalParams(additionalParamsMap) 
                          .build() 

Step 3.4: Recurring Payments (Optional)

If you are integrating SI, generate the following payment parameters additionally:

PayUSIParams siDetails  = new PayUSIParams.Builder()
                .setIsFreeTrial(true) //set it to true for free trial. Default value is false 
                .setBillingAmount("1.0")
                .setBillingCycle(PayUBillingCycle.ONCE)     
                .setBillingCurrency("INR")
                .setBillingInterval(1)
                .setPaymentStartDate("2021-12-24")
                .setPaymentEndDate("2021-12-31")
                .setBillingRule(PayuBillingRule.MAX)
                .setBillingLimit(PayuBillingLimit.ON)
                .setRemarks("SI Txn")
                .build();
val siDetails  = PayUSIParams.Builder()
                .setIsFreeTrial(true) //set it to true for free trial. Default value is false
                .setBillingAmount("1.0")
                .setBillingCycle(PayUBillingCycle.ONCE)     
                .setBillingCurrency("INR")
                .setBillingInterval(1)
                .setPaymentStartDate("2021-12-24")
                .setPaymentEndDate("2021-12-31")
                .setBillingRule(PayuBillingRule.MAX)
                .setBillingLimit(PayuBillingLimit.ON)
                .setRemarks("SI Txn")
                .build()

📘

Tip

For the absolute type split, you must ensure that the sum of amount of all splits is equal to the parent transaction amount.

For the percentage type split, you must ensure that the sum of percentage of all splits is equal to 100. You can use any number decimal places for each split, but ensure the sum of percentage of all splits is equal to 100.

For more information on the PayUSIParams parameters, refer to PayU Standing Instructions Parameters. After creating the above PayUSIParams object, configure it in the PayUPaymentParams object. For Standing Instruction, complete PayUPaymentParams similar to the following code block:

PayUPaymentParams.Builder builder = new PayUPaymentParams.Builder(); 
builder.setAmount()  
        .setIsProduction()  
        .setProductInfo()   
        .setKey()      
        .setPhone()      
        .setTransactionId()  
        .setFirstName() 
        .setEmail() 
        .setSurl() 
        .setFurl() 
        .setUserCredential() 
        .setAdditionalParams(<HashMap>); //Optional, can contain any additional PG params  
        .setPayUSIParams(siDetails)
        .setSplitPaymentDetails(splitPaymentDetails);
PayUPaymentParams payUPaymentParams = builder.build(); 
 val payUPaymentParams = PayUPaymentParams.Builder() 
    .setAmount()      
    .setIsProduction()  
    .setKey()       
    .setProductInfo()   
    .setPhone()  
    .setTransactionId() 
    .setFirstName() 
    .setEmail() 
    .setSurl() 
    .setFurl() 
    .setUserCredential() 
    .setAdditionalParams(<HashMap>) //Optional, can contain any additional PG params 
    .setPayUSIParams(siDetails)
    .setSplitPaymentDetails(splitPaymentDetails)
    .build()  

Step 4: Secure the payment request using Hash

This step is to generate a hash that secures your payment request to PayU.

🚧

Remember

Always generate the hashes on your server. Do not generate the hashes locally in your app, as it will compromise the security of the transactions.

The CheckoutPro SDK uses hashes to ensure the security of the transaction and prevent any unauthorized intrusion or modification. The CheckoutPro SDK requires two types of hashes. For more information on the two types of hashes, refer to Generate Hash CheckoutPro SDK.

Step 4.1: Set Up Payment Hashes

Passing static hashes

For passing static hashes during integration, use the following code snippet:

HashMap<String, Object> additionalParams = new HashMap<>();  
additionalParams.put(PayUCheckoutProConstants.CP_VAS_FOR_MOBILE_SDK], <String>); 
additionalParams.put(PayUCheckoutProConstants.CP_PAYMENT_RELATED_DETAILS_FOR_MOBILE_SD K], <String>); 
val additionalParamsMap: HashMap<String, Any?> = HashMap() 
additionalParamsMap[PayUCheckoutProConstants.CP_VAS_FOR_MOBILE_SDK] = <String> 
additionalParamsMap[PayUCheckoutProConstants.CP_PAYMENT_RELATED_DETAILS_FOR_MOBILE_SDK] = <String> 

Step 4.2: Passing dynamic hashes

For generating and passing dynamic hashes, the merchant will receive a call from the generateHash method of PayUCheckoutProListener.

void generateHash(HashMap<String,String> map, PayUHashGenerationListener hashGenerationListener) 
 fun generateHash(map:HashMap<String,String>,hashGenerationListener: PayUHashGenerationListener) 

Here:

map -> a hash map that contains hash string and hash name
hashGenerationListener -> After the hash is generated on the merchant side. Pass the generated hash in the onHashGenerated() method of the hashGenerationListener.

interface PayUHashGenerationListener { 
    void onHashGenerated(HashMap<String,String> map) 
} 
interface PayUHashGenerationListener { 
    fun onHashGenerated(map: HashMap<String,String?>) 
} 

The generateHash() method is called by the SDK each time it needs an individual hash. The CP_HASH_NAME will contain the name of the specific hash requested in that call, and the CP_HASH_STRING will contain the data/string that needs to be hashed.

Step 4.3: Getting Hash data to calculate hash

Checkout Pro SDK will give a callback in the generateHash() method whenever any hash is needed by it. The merchant needs to calculate that hash and pass it back to the SDK.

To extract the hash string and hash name from the map received in generateHash() method, use the following keys:

CP_HASH_STRING -> This will contain a complete hash string excluding salt. For eg, for vas for mobile SDK hash, the hash string will contain “|||”. Merchant can append their salt at the end of the hash string to calculate the hash.
CP_HASH_NAME -> This will contain the hash name.

Step 4.4: Pass generated hash to SDK

Prepare a map, where the key should be the hash name in Step 2: Build the Payment Parameters and value should be generated hash value and pass this map in onHashGenerated() method described above.

@Override 
public void generateHash(@NotNull HashMap map, @NotNull PayUHashGenerationListener hashGenerationListener) { 
    String hashName = map.get(CP_HASH_NAME); 
    String hashData = map.get(CP_HASH_STRING); 
    if (!TextUtils.isEmpty(hashName) && !TextUtils.isEmpty(hashData)) { 

//Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
        String hash = hashString 
        if (!TextUtils.isEmpty(hash)) { 
            HashMap hashMap = new HashMap(); 
            hashMap.put(hashName, hash); 
            hashGenerationListener.onHashGenerated(hashMap); 
        } 
    } 
}
override fun generateHash( 
    map: HashMap, 
    hashGenerationListener: PayUHashGenerationListener 
) { 
    if (map.containsKey(CP_HASH_STRING) 
        && map.containsKey(CP_HASH_STRING) != null 
        && map.containsKey(CP_HASH_NAME) 
        && map.containsKey(CP_HASH_NAME) != null 
    ) { 
 
        val hashData = map[CP_HASH_STRING]  
        val hashName = map[CP_HASH_NAME]  
 
 //Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
        val hash: String? = hashString;

        if (!TextUtils.isEmpty(hash)) { 
            val hashMap: HashMap = HashMap() 
            hashMap[hashName!!] = hash!! 
            hashGenerationListener.onHashGenerated(hashMap) 
        } 
    } 
} 

Step 5: Initiate the Payment

Initialize the PayUCheckoutPro SDK by submitting the payment parameters prepared in the previous step and a reference to the transaction listener.

PayUCheckoutPro.open(
    Activity activity, 
    PayUPaymentParams payUPaymentParams, 
    PayUCheckoutProListener payUCheckoutProListener)
PayUCheckoutPro.open(
    activity: Activity, 
    payUPaymentParams: PayUPaymentParams,  
    payUCheckoutProListener: PayUCheckoutProListener) 

Sample Code

    PayUCheckoutPro.open(
            this,
            payUPaymentParams,
            new PayUCheckoutProListener() {
                
                @Override
                public void onPaymentSuccess(Object response) {
                    //Cast response object to HashMap
                    HashMap result = (HashMap) response;
                    String payuResponse = (String)result.get(PayUCheckoutProConstants.CP_PAYU_RESPONSE);
                    String merchantResponse = (String) result.get(PayUCheckoutProConstants.CP_MERCHANT_RESPONSE);
                }

                @Override
                public void onPaymentFailure(Object response) {
                    //Cast response object to HashMap
                    HashMap result = (HashMap) response;
                    String payuResponse = (String)result.get(PayUCheckoutProConstants.CP_PAYU_RESPONSE);
                    String merchantResponse = (String) result.get(PayUCheckoutProConstants.CP_MERCHANT_RESPONSE);
                }

                @Override
                public void onPaymentCancel(boolean isTxnInitiated) {
                }

                @Override
                public void onError(ErrorResponse errorResponse) {
                    String errorMessage = errorResponse.getErrorMessage();
                }

                @Override
                public void setWebViewProperties(@Nullable WebView webView, @Nullable Object o) {
                    //For setting webview properties, if any. Check Customized Integration section for more details on this
                }

                @Override
                public void generateHash(HashMap 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)) {
                        //Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
                        String hash = hashString;
                        HashMap dataMap = new HashMap();
                        dataMap.put(hashName, hash);
                        hashGenerationListener.onHashGenerated(dataMap);
                    }
                }
            }
);
 PayUCheckoutPro.open( 
        this, payUPaymentParams, 
        object : PayUCheckoutProListener { 

 
            override fun onPaymentSuccess(response: Any) { 
                response as HashMap 
                val payUResponse = response[PayUCheckoutProConstants.CP_PAYU_RESPONSE]
                val merchantResponse = response[PayUCheckoutProConstants.CP_MERCHANT_RESPONSE]  
            } 

 
            override fun onPaymentFailure(response: Any) { 
                response as HashMap 
                val payUResponse = response[PayUCheckoutProConstants.CP_PAYU_RESPONSE]
                val merchantResponse = response[PayUCheckoutProConstants.CP_MERCHANT_RESPONSE]  
            } 

 
            override fun onPaymentCancel(isTxnInitiated:Boolean) { 
            } 

 
            override fun onError(errorResponse: ErrorResponse) { 
                val errorMessage: String 
                if (errorResponse != null && errorResponse.errorMessage != null && errorResponse.errorMessage!!.isNotEmpty()) 
                    errorMessage = errorResponse.errorMessage!! 
                else 
                    errorMessage = resources.getString(R.string.some_error_occurred) 
            } 
            
            override fun setWebViewProperties(webView: WebView?, bank: Any?) {
                //For setting webview properties, if any. Check Customized Integration section for more details on this
            }
                     
            override fun generateHash( 
                valueMap: HashMap, 
                hashGenerationListener: PayUHashGenerationListener 
            ) { 
                if ( valueMap.containsKey(CP_HASH_STRING) 
                    && valueMap.containsKey(CP_HASH_STRING) != null 
                    && valueMap.containsKey(CP_HASH_NAME) 
                    && valueMap.containsKey(CP_HASH_NAME) != null) { 
 
                    val hashData = valueMap[CP_HASH_STRING] 
                    val hashName = valueMap[CP_HASH_NAME] 
 
                    //Do not generate hash from local, it needs to be calculated from server side only. Here, hashString contains hash created from your server side.
                    val hash: String? = hashString
                    if (!TextUtils.isEmpty(hash)) { 
                        val dataMap: HashMap = HashMap() 
                        dataMap[hashName!!] = hash!! 
                        hashGenerationListener.onHashGenerated(dataMap) 
                    } 
                } 
            } 
        })

🚧

Watch Out

In case of UPI intent/InApp flow, you will not receive a callback response in surl or furl. In this case, the format of PayU response received will be different from other payment options that you can handle accordingly. For handling surl or furl, refer to Handling Return URLs.If you get mihpayid in the PayU response, consider as a PayU ID/ID


Placeholder for CheckoutPro Recipes


Additional Integrations

The following are the additional Android SDK offerings:

Offers Integration

Step 1: Create an Offers List

Create a list of offers that you want to pass to the CheckoutPro SDK. For each offer in the list, the offer title, offer description, offer key, and provide payment types need to be passed. On the Checkout page, SDK will show the best offer applicable on that payment mode based on the offers list sent to the SDK. The following is an example code for the offers list:

// After checkoutPro version 1.8.5 no integration code required for offer 
ArrayList<PayUOfferDetails> offerDetails = new ArrayList<>();
 PayUOfferDetails payUOfferDetails1 = new PayUOfferDetails();
 payUOfferDetails1.setOfferTitle("Instant discount of Rs.2");
 payUOfferDetails1.setOfferDescription("Get Instant dicount of Rs.2 on all Credit and Debit card transactions");
 payUOfferDetails1.setOfferKey("OfferKey@9227");

 ArrayList<PaymentType> offerPaymentTypes1 = new ArrayList<>();
 offerPaymentTypes1.add(PaymentType.CARD);
 payUOfferDetails1.setOfferPaymentTypes(offerPaymentTypes1);

 PayUOfferDetails payUOfferDetails2 = new PayUOfferDetails();
 payUOfferDetails2.setOfferTitle("Instant discount of Rs.2");
 payUOfferDetails2.setOfferDescription("Get Instant dicount of Rs.2 on all NetBanking transactions");
 payUOfferDetails2.setOfferKey("TestOffer100@9229");

 ArrayList<PaymentType> offerPaymentTypes2 = new ArrayList<>();
 offerPaymentTypes2.add(PaymentType.NB);
 payUOfferDetails2.setOfferPaymentTypes(offerPaymentTypes2);

 offerDetails.add(payUOfferDetails1);
 offerDetails.add(payUOfferDetails2);
// After checkoutPro version 1.8.5 no integration code required for offer  
val offerDetails = ArrayList<PayUOfferDetails>()
 offerDetails.add(PayUOfferDetails().also {
            it.offerTitle = " Instant discount of Rs.2"
            it.offerDescription = "Get Instant dicount of Rs.2 on all Credit and Debit card transactions"
            it.offerKey = "OfferKey@9227"
            it.offerPaymentTypes = ArrayList<PaymentType>().also {
                it.add(PaymentType.CARD)
            }
        })
  offerDetails.add(PayUOfferDetails().also {
            it.offerTitle = " Instant discount of Rs.2"
            it.offerDescription = "Get Instant dicount of Rs.2 on all NetBanking transactions"
            it.offerKey = "TestOffer100@9229"
            it.offerPaymentTypes = ArrayList<PaymentType>().also {
                it.add(PaymentType.NB)
            }
        })

Step 2: Pass Offers List to SDK

To pass the Offers List created in the Create Offers List (till version 1.8.5)section to the SDK. Create an Object of PayUCheckoutProConfig and set Offers List similar to the following code block:

 PayUCheckoutProConfig checkoutProConfig = new PayUCheckoutProConfig();
 checkoutProConfig.setOfferDetails(offerDetails);
 val checkoutProConfig = PayUCheckoutProConfig()
 checkoutProConfig.offerDetails = offerDetails

This checkoutProConfig object should be passed in PayUCheckoutPro.open() method as mentioned in the reference document: SDK Integration.


MCP Integration

📘

Connect with your Key Account Manager at PayU to get the following credentials:

  • Merchant Access Key
  • Merchant Secret Key

Step 1: Pass Merchant Access Key

Pass Merchant Access Key in Additional Parameters in Payment Params. For more information on the Additional Parameters, refer to Additional Integrations.

HashMap<String, Object> additionalParams = new HashMap<>(); 
additionalParams.put(PayUCheckoutProConstants.CP_MERCHANT_ACCESS_KEY,<Merchant-Access-Key>)

Set these Additional parameters in the Payment Parameters.

Step 2: 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 HmacSHA1 signature. It requires a Merchant Secret key in calculating the hash. The below example code demonstrates the calculation of Lookup API Hash.

@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);
}
}

Custom Note Integration

This section describes how to integrate custom notes in PayUCheckoutPro SDK.

Step 1: Create a Custom Note List

Create a list of custom notes that you want to pass to the CheckoutPro SDK. For each custom note, custom_note and custom_note_category need to be passed.

  // for specific custom_note_category
  
  ArrayList<CustomNote> customNote = new ArrayList<>();
        ArrayList<PaymentType> noteCategory1 = new ArrayList<>();
        noteCategory1.add(PaymentType.CARD);
        CustomNote customNote1 = new CustomNote("Please welcome note", noteCategory1);
        customNote1.setCustom_note("Please welcome note");
        customNote1.setCustom_note_category(noteCategory1);
        
        ArrayList<PaymentType> noteCategory2 = new ArrayList<>();
        noteCategory2.add(PaymentType.CARD);
        CustomNote customNote2 = new CustomNote("Please welcome note", noteCategory1);
        customNote2.setCustom_note("Please welcome note");
        customNote2.setCustom_note_category(noteCategory2);
        customNote.add( customNote1);
        customNote.add( customNote2); 
        
        // when want to pass same custom note for multiple custom_note_category

        ArrayList<CustomNote> customNote = new ArrayList<>();
        ArrayList<PaymentType> noteCategory1 = new ArrayList<>();
        noteCategory1.add(PaymentType.CARD);
         noteCategory1.add(PaymentType.NB);
         noteCategory1.add(PaymentType.UPI);
        CustomNote customNote1 = new CustomNote("Please welcome note", noteCategory1);
        customNote1.setCustom_note("Please welcome note");
        customNote1.setCustom_note_category(noteCategory1);
        customNote.add( customNote1);
        
        // if do not want to pass any custom_note_category
        ArrayList<CustomNote> customNote = new ArrayList<>();
        CustomNote customNote1 = new CustomNote("Please welcome note", null);
        customNote1.setCustom_note("Please welcome note");
        customNote1.setCustom_note_category(null);
        
     // for specific custom_note_category
       val customNote = ArrayList<CustomNote>()
       
         customNote.add(CustomNote().also{
        it.custom_note = "Please welcome in Cards"
        it.custom_note_category = ArrayList<PaymentType>().also {
                it.add(PaymentType.CARD)
            }
        }
        // when want to pass same custom note for multiple custom_note_category
       
       val customNote = ArrayList<CustomNote>()
        customNote.add(CustomNote().also{
        it.custom_note = "Please welcome in Cards"
        it.custom_note_category = ArrayList<PaymentType>().also {
                it.add(PaymentType.NB)
                it.add(PaymentType.CARD)
            }
        } 
        // if do not want to pass any custom_note_category
        
        val customNote = ArrayList<CustomNote>()
        customNote.add(CustomNote().also{
        it.custom_note = "Please welcome in Cards"
        it.custom_note_category = null
        } 

Step 2: Pass Custom Note List to SDK

To pass the custom note list created in the above section to the SDK. Create a PayUCheckoutProConfig object and set the custom Note List similar to the following code block:

val checkoutProConfig = PayUCheckoutProConfig()
 checkoutProConfig.customNoteDetails = customNote
val checkoutProConfig = PayUCheckoutProConfig()
 checkoutProConfig.customNoteDetails = customNote