Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在NodeJS中设置Braintree API?_Javascript_Node.js_Express_Braintree - Fatal编程技术网

Javascript 如何在NodeJS中设置Braintree API?

Javascript 如何在NodeJS中设置Braintree API?,javascript,node.js,express,braintree,Javascript,Node.js,Express,Braintree,我想使用braintree作为网站paymentgateway,不幸的是,当我在线遵循指南时,代码无法在NodeJS中使用。少了什么吗 Index.js: //send token to clients app.get("/client_token", function (req, res) { gateway.clientToken.generate({}, function (err, response) { res.send(response.client

我想使用braintree作为网站paymentgateway,不幸的是,当我在线遵循指南时,代码无法在NodeJS中使用。少了什么吗

Index.js:

//send token to clients

app.get("/client_token", function (req, res) {
  gateway.clientToken.generate({}, function (err, response) {
    res.send(response.clientToken);
  });
});

//Receive payment from clients

app.post("/checkout", function (req, res) {
  var nonceFromTheClient = req.body.payment_method_nonce;
  // Use payment method nonce here
});

//Test sandbox
gateway.transaction.sale({
  amount: "10.00",
  paymentMethodNonce: nonceFromTheClient,
  options: {
    submitForSettlement: true
  }
}, function (err, result) {

  if (err) {
    console.error(err);
    return;
  }

  if (result.success) {
    console.log('Transaction ID: ' + result.transaction.id);
  } else {
    console.error(result.message);
  }
});
错误:无法传递节点js npm start:

支付方式nonce:nonefromtheclient,

IDE中的详细信息:

引用错误:未定义非引用客户端

at Object.<anonymous> (/Users/desmondkam/codecampvn/index.js:37:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:445:3
您的代码是:

gateway.transaction.sale({
  amount: "10.00",
  paymentMethodNonce: "fake-valid-nonce",
  options: {
    submitForSettlement: true
  }
}, function (err, result) {
});

你已经在路由器中定义了
非EFROM客户端
,这就是为什么你的沙盘中出现了未定义的错误。对了,我明白你的意思了。
gateway.transaction.sale({
  amount: "10.00",
  paymentMethodNonce: "fake-valid-nonce",
  options: {
    submitForSettlement: true
  }
}, function (err, result) {
});