node.js - 与接受 INR 的 nodejs 一起使用的支付网关

标签 node.js payment-gateway

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

最佳答案

我认为 citruspay 是一个不错的选择。以下链接显示了与 Node 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 中包含这个签名

Then listen for post on the Return URL You have to generate signature and compare with the signature sent in the post data from citrus to make sure data is not tampered in the way.

 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);

关于node.js - 与接受 INR 的 nodejs 一起使用的支付网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28778651/

相关文章:

node.js - 使用 Node.js 连接到 Heroku 上的 postgres

javascript - 为什么这个带有 promise 的测试没有通过?

javascript - 在 NodeJS/JavaScript 中将函数源代码转换为字符串

ruby-on-rails - Recurly 与 SaaS 套件

paypal - 根据帐号/排序代码发送和接收资金

php - 自定义订单在 Woocommerce 中收到返回 URL 查询参数

asp.net - dot net mvc5 Controller 中的异步函数造成死锁

payment-gateway - 当前的 payUMoney 测试凭据是什么

performance - Node.js 控制台日志性能

node.js - 如何从 Mongo Atlas 触发器向 GCP PubSub 发出经过身份验证的请求