node.jspayment-gatewaypayumoney

PayuMoney India integration with Node js


I am trying to integrate an nodejs app to integrate with PayUMoney. I followed the instructions and example code for php and implemented in node.js, but I am getting checksum error.

Error. We are sorry we are unable to process your payment.

Checksum Failed. Please contact your merchant.

here is the code. frontend

<form method="post" id="payu-payment-form" action="https://test.payu.in/_payment">
    <input type="hidden" name="hash" value="hash"/>
    <input type="hidden" name="key" value="marchentKey"/>
    <input type="hidden" name="txnid" value="asc123"/>
    <input type="hidden" name="amount" value="1000" />
    <input type="hidden" name="productinfo" value="Product 1"/>
    <input type="hidden" name="firstname" value="Amit" />
    <input type="hidden" name="email" value="abc@gmail.com" />
    <input type="hidden" name="phone" value="123423233" />
    <input type="hidden" name="surl" value="http://localhost/success"/>
    <input type="hidden" name="furl" value="http://localhost/fail"/>
    <input type="hidden" name="service_provider" value="payu_paisa" />
    <button class="" type="submit" formtarget="_blank" >Buy</button>
</form>

Node.js

var txnid='asc123';
var amount=1000;
var produnctinfo='Product 1';
var firstname='Amit';
var email='abc@gmail.com';
var phone='123423233';
var surl='http://localhost/success';
var furl='http://localhost/fail';
var service_provider='payu_paisa';
var string = marchentKey +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|'+phone+'|'+ surl +'|'+furl+'|'+service_provider+'|||||||'+salt;
var hash=sha512(string);

Solution

  • The Test Key & Salt in PHP Integration kit was not working. So using my own test key and salt and calculating correct hash its working fine.

    Previously I was calculating hash with phone, surl, furl and service_provider. But it should be like

    var string = marchentKey +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|||||||||||'+salt;
    var hash=sha512(string);
    

    if you posting variables which are not mention in their documentation i.e user defined variables then you should include those varibles as udf1, udf2..

    var string = marchentKey +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|'+udf1+'|'+udf2+'|||||||||'+salt;
    var hash=sha512(string);