0

我正在研究 MeteorJS(nodeJS)。试图在本地主机上集成 payUMoney。我有实时凭据并将我的 HTTP 调用转发到:POST URL:https ://secure.payu.in/_payment 。在控制台上,我得到的状态代码为 200。但没有指向 payu.com 但在控制台上,我可以看到“校验和失败”错误。我尝试打包: 1.jparker:crypto-sha256 2.johnschult:crypto-sha512

这是我的一段代码:

var string = key +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|||||||||||'+salt;
var SHA    = CryptoJS.SHA256(string);

也试过这样:

var string = key +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|'+'|'+'|'+'|'+'|'+'|'+'|'+'|'+'|'+'|'+'|'+salt;
    var SHA    = CryptoJS.SHA256(string);

    console.log("SHA :" + SHA);
    this.unblock();
    var payUMoneyInput = {
               "key"              :  key,
               "txnid"            :  txnid,
               "amount"           :  amount,
               "productinfo"      :  productinfo,
               "firstname"        :  firstname,
               "email"            :  email,
               "phone"            :  phone,
               "surl"            "http://localhost:3000/onlinePaymentSuccess",
               "furl"             :  "http://localhost:3000/onlinePaymentSuccess",
               "hash"             :  SHA,
               "service_provider" : "payu_paisa",
          };

    try {
      if (Meteor.isServer) {
        var result = HTTP.call("POST", "https://secure.payu.in/_payment",
                               {params: payUMoneyInput});

        console.log(result);
          return result;
         }else{
           return false;
         }
      }
    } catch (err) {
      console.log('range error');
      console.log(err)
      // Got a network error, time-out or HTTP error in the 400 or 500 range.
      return false;
    }

我的控制台如下所示:

0427-12:52:44.069(5.5)? SHA :f071c643368745b38f8b41851d6500743190aa79426e931a28ccfd65135d94ed
I20170427-12:52:44.237(5.5)? { statusCode: 200,
I20170427-12:52:44.237(5.5)?   content: '<!DOCTYPE html>\n<!--[if lt IE 7 ]> <html lang="en" class="no-js oldie ie6"> <![endif]-->\n<!--[if IE 7 ]>    <html lang="en" class="no-js oldie ie7"> <![endif]-->\n<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->\n<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->\n\n\n<!-- Custom Modernizr build (should always be on the top) -->\n<script src="js/modernizr-2.0.6.min.js"></script>\n    <script language="javascript">\n      document.title = "Transaction Error";\n    </script>\n\n<style>\n    body {font-family: \'Arial\'}\n    .container {width: 960px; margin: 0 auto; padding: 15px 0;}\n\n    #header {border-bottom: 1px solid #ccc;}\n    #content {padding: 100px;}\n    #content h1 {font-size: 70px; color: #358DCB; margin-bottom: 0; margin-top: 0; text-align: center}\n    #content h2 {font-size: 16px; margin-top: 0; text-align: center}\n    #content p {font-size: 14px; margin-top: 30px; line-height: 24px; padding: 0 150px;}\n\n    #footer {border-top: 1px solid #ddd; font-size: 12px;}\n    #footer p {margin-top: 0;}\n\n    #footer a {text-decoration: underline}\n</style>\n\n<div id="header">\n    <div class="container">\n        <img src="https://static.payu.in/images/payu_logo.png">\n    </div>\n</div>\n<div id="content" >\n    <div class="container">\n        <h1>SORRY!</h1>\n        <h2>We were unable to process your payment</h2>\n            <p style=\'text-align: center;font-size:13px;\'><br>Checksum Failed</p>    </div>\n\n    </div>\n\n<div id="footer">\n    <div class="container">\n        <!--<p style="float:left">&copy; 2015 PayUBiz. All rights reserved.</p>\n        <p style="float:right"><a target="_blank" href=https://www.payubiz.in/privacyPolicy >Privacy Policy</a></p>\n        <p style="clear:both"></p>-->\n        <p style="text-align: center">&copy; 2015 PayUBiz. All rights reserved.</p>\n    </div>\n</div>\n\n<script src="js/libs/jquery-custom.min.js"></script>\n<!-- <script src="./_js/plugins.js"></script> -->\n<script src="js/script.js?version=v2.0.10"></script>\n\n',
I20170427-12:52:44.237(5.5)?   headers: 
I20170427-12:52:44.238(5.5)?    { date: 'Thu, 27 Apr 2017 07:22:44 GMT',
I20170427-12:52:44.238(5.5)?      'content-type': 'text/html',
I20170427-12:52:44.238(5.5)?      'transfer-encoding': 'chunked',
I20170427-12:52:44.238(5.5)?      connection: 'close',
I20170427-12:52:44.239(5.5)?      vary: 'Accept-Encoding, Accept-Encoding',
I20170427-12:52:44.239(5.5)?      'set-cookie': [ 'PHPSESSID=bpgqhvng7blpk1fltvrohle0j0; path=/; secure' ],
I20170427-12:52:44.239(5.5)?      p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
I20170427-12:52:44.239(5.5)?      expires: 'Thu, 19 Nov 1981 08:52:00 GMT',
I20170427-12:52:44.240(5.5)?      'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
I20170427-12:52:44.241(5.5)?      pragma: 'no-cache',
I20170427-12:52:44.241(5.5)?      server: 'Payubiz',
I20170427-12:52:44.242(5.5)?      'x-xss-protection': '1; mode=block' },
I20170427-12:52:44.244(5.5)?   data: null }

无法追踪问题。提前致谢!

4

1 回答 1

1

根据payu 集成文档 和那里的公式,您的哈希应该是:

var sha=sha512(key +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|||||||||||' + salt+'|');
var hash=CryptoJS.enc.Hex.stringify(sha);
于 2017-04-27T11:42:58.507 回答