I'm using Braintree nodejs Sdk for one of my project,
I have problem to use customer.find() function.
origina link is here
when I passed a user id like '207' directly in this way, it's working.
var braintree = require("braintree");
var gateway = require("./bt");
gateway.customer.find('207', function(err, customer) {
console.log("customer:",customer);
});
but when I tried to pass dynamic id, it's not working;
btuserID = data.userId;
gateway.customer.find(btuserID, function(err, customer) {
console.log("customer:",customer);
});
I think it's argument type is string, so how I can pass argument without double quote?
Complete error:
/home/api/node_modules/loopback-connector-mysql/node_modules/mysql/lib/protocol/Parser.js:82
throw err;
^
TypeError: undefined is not a function
at CustomerGateway.find (/home/api/node_modules/braintree/lib/braintree/customer_gateway.js:37:20)
If you try
console.log(typeof(btuserID));
I suspect you will see that the type is a Number, if so then try the suggestion below.
Change your assignment to this to convert the number to as string.
btuserID = data.userId.toString();
If you look in the source for the braintree Node.js library, you will see that it tries to trim the string first. You would expect this to fail if you do this on a number.
https://github.com/braintree/braintree_node/blob/master/src/braintree/customer_gateway.coffee
I run into the same problem today. You just need to do:
gateway.customer.find(JSON.stringify(btuserID), function(err,customer){
console.log("customer:",customer);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With