在payumoney处理之后将通知传递给应用程序时,它会发送响应哈希值,我们需要计算哈希值并将其与传入的响应哈希值匹配 .
我使用以下代码来计算预期的响应哈希值 .
Digest::SHA512.hexdigest([
PAYU_SALT,
notification.transaction_status,
notification.user_defined,
notification.customer_email,
notification.customer_first_name,
notification.product_info,
notification.gross,
notification.invoice,
PAYU_KEY].join("|"))
计算以下字符串的哈希值
"salt|success|||||||||||||Payment|100.0|1|key"
当我打印下面的哈希时,它给出了
Digest::SHA512.hexdigest([
PAYU_SALT,
notification.transaction_status,
notification.user_defined,
notification.customer_email,
notification.customer_first_name,
notification.product_info,
notification.gross,
notification.invoice,
PAYU_KEY].join("|"))
#⇒ e7b3c5ba00b98aad9186a5e6eea65028a[...]
而 notification.checksum
给出了
#⇒ 546f5d23e0cadad2d4158911ef72f095d[...]
所以这两个哈希不匹配 .
我使用以下宝石:https://github.com/payu-india/payuindia
我感谢任何帮助,为什么响应哈希不匹配 . 我的逻辑中是否有任何错误来计算响应哈希值?谢谢!
3 回答
你在哪里为阵列中的字段提出了这个订单?
看PayU's Developer FAQ好像订单如下:
请记住,在计算哈希时,即使单个字符不合适也会导致完全不同的校验和 .
好吧,这是我犯的一个愚蠢的错误 . 哈希不匹配的原因是因为我在PAYU测试密钥上输了一个错字 . 最后,当它是'U'时,我输入了小'u' . 图书馆很好,逻辑是正确的 . 错误在我身边使用了错误的密钥 .
哈希的实际顺序是:additionalCharges | SALT | status |||||| udf5 | udf4 | udf3 | udf2 | udf1 | email | firstname | productinfo | amount | txnid | key