copiato direttamente dal tutorial di Braintree, è possibile creare un token di client con un ID cliente come questo:Impossibile creare token di client Braintree con ID cliente
gateway.clientToken.generate({
customerId: aCustomerId
}, function (err, response) {
clientToken = response.clientToken
});
Dichiaro var aCustomerId = "customer"
ma node.js si chiude con l'errore
new TypeError('first argument must be a string or Buffer')
Quando provo a generare un token senza il customerId, tutto funziona bene (anche se non ho mai ottenere un nuovo cliente pedina ma questa è un'altra questione).
EDIT: Ecco il codice completo di prova, come richiesto:
var http = require('http'),
url=require('url'),
fs=require('fs'),
braintree=require('braintree');
var clientToken;
var gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: "xxx", //Real ID and Keys removed
publicKey: "xxx",
privateKey: "xxx"
});
gateway.clientToken.generate({
customerId: "aCustomerId" //I've tried declaring this outside this block
}, function (err, response) {
clientToken = response.clientToken
});
http.createServer(function(req,res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(clientToken);
res.end("<p>This is the end</p>");
}).listen(8000, '127.0.0.1');
può fornire un po 'più di contesto attorno al codice che si sta utilizzando? –