支付网关,用于接受INR的nodejs

时间:2015-02-28 05:55:29

标签: node.js payment-gateway

我正在寻找支持INR的支付网关,我可以使用nodejs应用程序。找不到有效的东西。任何建议和指示都会有所帮助。

1 个答案:

答案 0 :(得分:2)

我认为citruspay是一个不错的选择。以下链接显示了与节点js的集成。

  

Merchant Hosted Checkout (Citrus.js)

 var crypto = require('crypto');
    function generateSignature(merchantTxnId, request) {
        //Need to change with your Secret Key
        var secret_key = "***SEcRETKey***"; 

        //Need to change with your Access Key
        var accesskey = "***Access Key***"; 

        //Should be unique for every transaction
        var txn_id = merchantTxnId; 

        //Need to change with your Order Amount
        var amount = "1.00";
        var data = 'merchantAccessKey=' + accesskey + '&transactionId=' + txn_id + '&amount=' + amount;

        // generate hmac
        var hmac = crypto.createHmac('sha1', secret_key);
        hmac.update(data);
        return hmac.digest('hex');
    }

现在在PaymentObject中包含此签名

  

然后在Return URL上发帖子   您必须生成签名并与来自柑橘的后期数据中发送的签名进行比较,以确保数据不会被篡改。

 var http = require("http");
 var qs = require('querystring');
 var crypto = require('crypto');
 var secret_key = "MERCHANT_SECRET_KEY";

 http.createServer(function(request, response) {
 var body = "";

 if (request.method = "POST") {
     request.on("data", function(data) { body += data; });
     request.on("end", function() {
         var post = qs.parse(body);

         var data_string =  post['TxId'] + post['TxStatus'] + post['amount']
             + post['pgTxnNo'] + post['issuerRefNo'] + post['authIdCode']
             + post['firstName'] + post['lastName'] + post['pgRespCode']
             + post['addressZip'];

         var signature = crypto.createHmac('sha1', 
                         secret_key).update(data_string).digest('hex');

         if (signature == post['signature']) {
             response.writeHead(200, {"Content-Type": "application/json"});
             console.log(post);
             response.write(JSON.stringify(post));
         }
         else {
             response.writeHead(403, {"Content-Type": "application/json"});
             var error = {error : 'Transaction Failed', message: 'Signature                                    Verification Failed'};
             response.write(JSON.stringify(error));
         }

         response.end();
     });
 }
 }).listen(3000);