PayUMoney集成 - 如何计算哈希以便与响应进行比较? [英] PayUMoney integration - How to calculate hash for comparing with response?

查看:88
本文介绍了PayUMoney集成 - 如何计算哈希以便与响应进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

生成 Hash 用于发布请求

  $ 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;
//生成哈希
$ hash = strtolower(hash('sha512',$ hashString));

获得成功的响应后,生成 Hash

  $ retHashSeq = $ salt。'|'。$ status。'|||||||'。$ udf3。' 。$ udf2 '|'。$ udf1 '| '$量 '|'。$ txnid '|。|'。$电子邮件' |||' $键; 
$ hash = hash(sha512,$ retHashSeq);

但是生成的 Hash 不匹配并通过 PayU 服务器返回 Hash
可能是什么问题?任何帮助,将不胜感激。

解决方案

看来你正试图重新实现 PayU REST API
我无法在当前版本的REST API中找到对 $ hashSequence 的模式的引用。



您是否考虑过使用官方SDK


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.

解决方案

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?

这篇关于PayUMoney集成 - 如何计算哈希以便与响应进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆