在nodejs中快速付款

时间:2017-01-09 07:01:49

标签: node.js mongodb quickpay

在nodejs中使用Quickpay API如何整合付款?我试了一下,但它返回错误。 卡的详细信息如下:数字:1000 0000 0008,到期时间:1122,cvv:158,"输入":" Visa"

这是我的代码

function processCreatePayment(req, res, next) {
    if (req.session.checkout) {
        if (req.session.checkout.total === 0) {
            return res.send("please checkout before making payment ");
        }
    }

    var parameters = {
        "version": "v10",
        "merchant_id": "12345",
        "agreement_id": "e72fc85b87d2b342f53e64a3492ee43322283aa8",
        "amount": "100",
        "currency": "dkk",
        "order_id": moment().unix()
    };
    quickPay.post("payments/", version, parameters)
        .then(function(result) {
            res.send(result);
            transaction_id = result.id;
            date = result.created_at;
        })
        .catch(function(err) {
            res.send(err.response);
        });
}

function processAuthorize(req, res, next) {
    var card ={
        "card[number]" : req.body.number,
        "card[expiration]" : req.body.expiry,
        "card[cvd]" : req.body.cvv,
        "acquirer" : "clearhaus",
        "card[type]":req.body.type
    }
    console.log(card);
    //req.session.transaction_id = transaction_id;
    console.log("cards/"+ transaction_id + "/authorize", version, card);
    quickPay.post("cards/"+ transaction_id + "/authorize", version, card)
        .then(function(result) {
            res.send(result);
        })
        .catch(function(err) {
            res.send(err.response);
        });
}
 getting this error 
output:
{
  "statusCode": 404,
  "body": {
    "error": "Not found: NotFoundError"
  },
  "headers": {
    "content-type": "application/json",
    "date": "Mon, 09 Jan 2017 06:39:53 GMT",
    "server": "nginx",
    "x-content-type-options": "nosniff",
    "content-length": "36",
    "connection": "Close"
  },
  "request": {
    "uri": {
      "protocol": "https:",
      "slashes": true,
      "auth": null,
      "host": "api.quickpay.net",
      "port": 443,
      "hostname": "api.quickpay.net",
      "hash": null,
      "search": null,
      "query": null,
      "pathname": "/cards/78122144/authorize",
      "path": "/cards/78122144/authorize",
      "href": "https://api.quickpay.net/cards/78122144/authorize"
    },
    "method": "POST",
    "headers": {
      "Accept-Version": "v10",
      "Authorization": "Basic OmU3MmZjODViODdkMmIzNDJmNTNlNjRhMzQ5MmVlNDMzMjIyODNhYTgyMWRkOTNjYTI1Mjc4ZDI1MzcxNWE5MDI=",
      "accept": "application/json",
      "content-type": "application/json",
      "content-length": 118
    }
  }
}

如何获得正确的结果?

0 个答案:

没有答案