为 Post
请求生成 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;
//generate hash
$hash = strtolower(hash('sha512', $hashString));
成功响应后生成 Hash
$retHashSeq = $salt.'|'.$status.'||||||||'.$udf3.'|'.$udf2.'|'.$udf1.'|'.$email.'|||'.$amount.'|'.$txnid.'|'.$key;
$hash = hash("sha512", $retHashSeq);
但生成的 Hash
与 PayU
服务器返回的 Hash
不匹配 . 可能是什么问题呢??任何帮助,将不胜感激 .
4 回答
看来你正试图重新实现PayU REST API . 我在当前版本的REST API中找不到对
$hashSequence
模式的任何引用 .你考虑过使用official SDK吗?
此代码用于服务器端的android hashcodegeneration
我知道它很晚才回答这个问题,但这个答案可能有助于未来的搜索者 . 只需从官方网站下载最新的PayUMoney Kit,并将SALT键放在
success.php
页面中 .这是我最近的成功.php
Hash Calculation in Request and Response in PayUMoney C# API
hashSequence =
关键| txnid |量源|产品|姓|电子邮件| udf1 | udf2 | udf3 | udf4 | udf5 ||||||盐;
$ hash = hash(“sha512”,$ hashSequence);
PayUMoney仪表板上的盐可用 .
注意:计算hashSequence时将使用空白udf字段,即使商家未在输入请求中传递任何udf字段 .
对于响应散列,与支付请求散列相比,变量序列的顺序相反 . 此外,在salt和udf1之间添加了一个状态变量
序列
hashSequence = salt | status |||||| udf5 | udf4 | udf3 | udf2 | udf1 | email | firstname | productinfo | amount | txnid | key;
$ hash = hash(“sha512”,$ hashSequence);
PayUMoney仪表板上的盐可用 .
以下是响应哈希计算的示例代码: -