2017-04-27 103 views
0

我的工作MeteorJS(的NodeJS)。尝试将payUMoney集成到本地主机上。我有活的凭据和转发我的HTTP调用: POST URL:https://secure.payu.in/_payment。 在控制台上,我将状态代码设置为200.但不指向payu.com但是在控制台上,我能够看到“校验和失败”错误。我试着包: 1.jparker:加密SHA256 2.johnschult:加密SHA512MeteorJs:付款集成(PayUMoney)校验失败

这是我的一段代码:

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 } 

无法tr回答问题。提前致谢!

回答

0

根据payu integration document和配方,在那里,你的哈希值应该是:

var sha=sha512(key +'|' +txnid+ '|' +amount+'|'+productinfo+'|'+firstname+'|'+email+'|||||||||||' + salt+'|'); 
var hash=CryptoJS.enc.Hex.stringify(sha); 
+0

为了计算“SHA512”你用哪个包或JS?你能分享一下sha512的功能吗?我试过“johnschult:crypto-sha512”包。在我的情况下,sha和hash的结果是一样的。我没有得到什么问题。提前致谢。 – Rashmi

+0

我正在使用这个https://cdnjs.com/libraries/crypto-js。在那里使用sha512这个https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/sha512.js。并用于编码使用https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-hex.js – erhun