You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am testing adding and deleting customers in my Sandbox before going live.
First, I query my database to find the customers I want to delete. The user ID in my database is the same as the customer ID in braintree. My query returns a result which is an array of users:
if (result.length > 0) {
for (i = 0 ; i < result.length ; i++) {
console.log('deleting ' + result[i]['id'] + ' from braintree');
gateway.customer.delete(result[i]['id'], function (err) {
if (err) {
console.log(err);
} else {
console.log('deleted customer from braintree');
};
});
};
};
It seems to work fine at first - I see the correct console messages. But then a few moments later it throws (doesn't just log but crashes on) this error:
10:18:53 web.1 | /.../node_modules/braintree/lib/braintree/customer.js:27
10:18:53 web.1 | if (attributes.creditCards) {
10:18:53 web.1 | ^
10:18:53 web.1 | TypeError: Cannot read property 'creditCards' of undefined
10:18:53 web.1 | at new Customer (/.../node_modules/braintree/lib/braintree/customer.js:27:19)
10:18:53 web.1 | at /.../node_modules/braintree/lib/braintree/gateway.js:121:35
10:18:53 web.1 | at /.../node_modules/braintree/lib/braintree/http.js:103:20
10:18:53 web.1 | at Parser. (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:134:18)
10:18:53 web.1 | at Parser.emit (events.js:107:17)
10:18:53 web.1 | at Object.saxParser.onclosetag (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:120:24)
10:18:53 web.1 | at emit (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:625:33)
10:18:53 web.1 | at emitNode (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:630:3)
10:18:53 web.1 | at closeTag (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:874:5)
10:18:53 web.1 | at Object.write (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1314:29)
10:18:53 web.1 | at Parser.exports.Parser.Parser.parseString (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:145:29)
10:18:53 web.1 | at Parser.parseString (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:3:63)
10:18:53 web.1 | at IncomingMessage. (/.../node_modules/braintree/lib/braintree/http.js:102:31)
10:18:53 web.1 | at IncomingMessage.emit (events.js:129:20)
10:18:53 web.1 | at _stream_readable.js:908:16
10:18:53 web.1 | at process._tickCallback (node.js:355:11)
10:18:53 web.1 | exited with code 1
The text was updated successfully, but these errors were encountered:
I guess the problem was that I had another call to the gateway that was still running while the customer deletions were taking place, creating a race condition.
I am testing adding and deleting customers in my Sandbox before going live.
First, I query my database to find the customers I want to delete. The user ID in my database is the same as the customer ID in braintree. My query returns a result which is an array of users:
It seems to work fine at first - I see the correct console messages. But then a few moments later it throws (doesn't just log but crashes on) this error:
10:18:53 web.1 | /.../node_modules/braintree/lib/braintree/customer.js:27
10:18:53 web.1 | if (attributes.creditCards) {
10:18:53 web.1 | ^
10:18:53 web.1 | TypeError: Cannot read property 'creditCards' of undefined
10:18:53 web.1 | at new Customer (/.../node_modules/braintree/lib/braintree/customer.js:27:19)
10:18:53 web.1 | at /.../node_modules/braintree/lib/braintree/gateway.js:121:35
10:18:53 web.1 | at /.../node_modules/braintree/lib/braintree/http.js:103:20
10:18:53 web.1 | at Parser. (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:134:18)
10:18:53 web.1 | at Parser.emit (events.js:107:17)
10:18:53 web.1 | at Object.saxParser.onclosetag (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:120:24)
10:18:53 web.1 | at emit (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:625:33)
10:18:53 web.1 | at emitNode (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:630:3)
10:18:53 web.1 | at closeTag (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:874:5)
10:18:53 web.1 | at Object.write (/.../node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1314:29)
10:18:53 web.1 | at Parser.exports.Parser.Parser.parseString (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:145:29)
10:18:53 web.1 | at Parser.parseString (/.../node_modules/braintree/node_modules/xml2js/lib/xml2js.js:3:63)
10:18:53 web.1 | at IncomingMessage. (/.../node_modules/braintree/lib/braintree/http.js:102:31)
10:18:53 web.1 | at IncomingMessage.emit (events.js:129:20)
10:18:53 web.1 | at _stream_readable.js:908:16
10:18:53 web.1 | at process._tickCallback (node.js:355:11)
10:18:53 web.1 | exited with code 1
The text was updated successfully, but these errors were encountered: