首页 文章

响应校验和或散列不匹配payumoney?

提问于
浏览
0

在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 回答

  • 0

    你在哪里为阵列中的字段提出了这个订单?

    PayU's Developer FAQ好像订单如下:

    key|txnid|amount|productinfo|firstname|email|||||||||||salt
    

    请确保以下列格式计算哈希值:hashSequence = key | txnid | amount | productinfo | firstname | email | udf1 | udf2 | udf3 | udf4 | udf5 |||||| salt请确保在以上序列请使用已发布到我们服务器的UDF . 如果您没有发布任何UDF,则哈希序列应如下所示:hashSequence = key | txnid | amount | productinfo | firstname | email ||||||||||| salt .

    请记住,在计算哈希时,即使单个字符不合适也会导致完全不同的校验和 .

  • 1

    好吧,这是我犯的一个愚蠢的错误 . 哈希不匹配的原因是因为我在PAYU测试密钥上输了一个错字 . 最后,当它是'U'时,我输入了小'u' . 图书馆很好,逻辑是正确的 . 错误在我身边使用了错误的密钥 .

  • 0

    哈希的实际顺序是:additionalCharges | SALT | status |||||| udf5 | udf4 | udf3 | udf2 | udf1 | email | firstname | productinfo | amount | txnid | key

相关问题