ruby-on-railsrubypayment-gatewaypayumoney

response checksum or hash not matching in payumoney?


When notification is passed to the app after payumoney processing it sends response hash and we need to compute the hash and match it with the passed in response hash.

I use the following code to compute the expected response hash.

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("|"))  

The hash of the following string is computed

"salt|success|||||||||||||Payment|100.0|1|key"

When I print the following hash it gives

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[...]

whereas notification.checksum gives

  #⇒ 546f5d23e0cadad2d4158911ef72f095d[...] 

So the two hashes don’t match.

I am using the following gem: https://github.com/payu-india/payuindia

I appreciate any help as to why the response hash is not matching. Is there any error in my logic to compute the response hash? Thanks!


Solution

  • ok this was a silly mistake i made. The reason the hash didn't match was beacuse i had a typo with the PAYU test key. At the end i typed small 'u' when it was 'U'. The library is fine and the logic is right. The error was in my side with using wrong key.