PayUMoney integration - How to calculate hash for comparing with response?

Sougata Bose picture Sougata Bose · Oct 28, 2014 · Viewed 19.1k times · Source

Generating Hash for Post request

    $hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|"
                    ."udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
    $hashVarsSeq  = explode('|', $hashSequence);
    $hashString   = '';  
    foreach ($hashVarsSeq as $hashVar) {
        $hashString .= isset($payObject['params'][$hashVar]) ? $payObject['params'][$hashVar] : '';
        $hashString .= '|';
    }
    $hashString .= $salt;
    //generate hash
    $hash = strtolower(hash('sha512', $hashString));

After getting successful response generating Hash

$retHashSeq = $salt.'|'.$status.'||||||||'.$udf3.'|'.$udf2.'|'.$udf1.'|'.$email.'|||'.$amount.'|'.$txnid.'|'.$key;
$hash = hash("sha512", $retHashSeq);

But the generated Hash doesn't match with the returned Hash by the PayU server. what could be the problem?? any help would be appreciated.

Answer

magnetik picture magnetik · Nov 3, 2014

It seems that you are trying to reimplement the PayU REST API. I can't find any reference to the pattern of your $hashSequence in the current version of the REST API.

Have you considered using the official SDK?