SDK Integration
  • Getting Started
  • Onboarding Requirements
  • Hash Generation
  • Test Merchant list
  • Android
    • Android SDK Offering
    • PayUCheckoutPro
      • Integration
      • Build the Payment Params
        • Additional Params
      • Hash Generation
      • Set up the payment hashes
      • Initiate the Payment
      • Customized Integration
        • Set Webview Properties
        • SDK Configuration
        • Additional Offerings
      • Offers Integration
      • Convenience Fee Integration
      • Custom Note Integration
      • MCP Integration
    • Core
      • Supported Payment Types
      • TPV Integration
      • Merchant Web Services
        • Getting Enabled Payment Options
        • GetCheckoutDetails API
        • Lookup API
    • Custom Browser
      • Integration
        • CustomBrowser Config
        • CustomBrowserCallback
        • Supporting below Lollipop Versions
        • Third-Party Payments Support
      • Sample App
      • Change Logs
    • Native OTP Assist
      • Integration
      • Customization
      • Change Logs
    • UPI
      • Integration
      • TPV Integration in UPI
      • Sample App
      • Change Logs
    • Google Pay™
      • Integration
      • Sample App
    • PhonePe
      • Integration
      • Sample App
      • Change Logs
    • OlaMoney
    • PayU OTP Parser
      • Integration
    • FAQ Android
  • iOS
    • PayUCheckoutPro
      • Integration
      • Advanced Integration
      • Set up the payment hashes
      • Convenience Fee Integration
      • MCP Integration
      • Custom Note Integration
    • Core
      • POD Integration
      • Seamless
      • Web Services
      • Objective C-Non-Seamless
      • Standing Instructions
      • TPV Integration
      • Sample App
    • Custom Browser
      • Sample App
    • OlaMoney
    • Native OTP Assist
      • Integration
      • Customization
    • UPI
      • Integration
      • Sample App
    • PayUParams
      • PayUSIParams
      • PayUBeneficiaryParams
  • Releasing to Apple
  • React-Native
    • PayUCheckoutPro
      • Integration
      • Set up the payment hashes
      • Advanced Integration
      • Change Logs
    • Core
    • Non-Seamless Wrapper
    • TPV (beta)
      • Integration
  • FAQ iOS
Powered by GitBook
On this page
  • Passing static hashes
  • Passing dynamic hashes
  • Getting Hash Data to calculate hash
  • Passing generated hash to SDK

Was this helpful?

  1. Android
  2. PayUCheckoutPro

Set up the payment hashes

(Mandatory Step)

PreviousHash GenerationNextInitiate the Payment

Last updated 4 years ago

Was this helpful?

For details on static and dynamic hashes check .

Passing static hashes

For passing static hashes during integration, use below code:

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> 

Passing dynamic hashes

For generating and passing dynamic hashes, merchant will receive a call on the method generateHash 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 -> Once the hash is generated at merchant end. Pass the generated hash in method onHashGenerated() 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.

Getting Hash Data to calculate hash

Checkout Pro SDK will give a callback in generateHash() method whenever any hash is needed by it. The merchant need to calculate that hash and pass back to the SDK. Below is the process of doing so:

To extract hash string and hash name from map received in generateHash() method, use below keys -

CP_HASH_STRING -> This will contain complete hash string excluding salt. For eg, for vas for mobile sdk hash, the hash string will contain “<key>|<command>|<var1>|”. Merchant can append their salt at end of hash string to calculate the hash.

CP_HASH_NAME -> This will contain the hash name.

Passing generated hash to SDK

Prepare a map, where key should be hash name in step 2.1 and value should be generated hash value and pass this map in onHashGenerated() method above.

@Override 
public void generateHash(@NotNull HashMap<String, String> 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<String, String> hashMap = new HashMap<>(); 
            hashMap.put(hashName, hash); 
            hashGenerationListener.onHashGenerated(hashMap); 
        } 
    } 
}
override fun generateHash( 
    map: HashMap<String, String?>, 
    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<String, String?> = HashMap() 
            hashMap[hashName!!] = hash!! 
            hashGenerationListener.onHashGenerated(hashMap) 
        } 
    } 
} 

here