braintree / braintree_node Goto Github PK
View Code? Open in Web Editor NEWBraintree Node.js library
Home Page: https://developer.paypal.com/braintree/docs/start/overview
License: MIT License
Braintree Node.js library
Home Page: https://developer.paypal.com/braintree/docs/start/overview
License: MIT License
I test following stream from sandbox.
var today = new Date();
var stream = gateway.transaction.search(function (search) {
search.createdAt().min(today.getDate() - 1);
});
but it keeps giving me 'downForMaintenanceError: Down for Maintenance' error.
It would be helpful if the node transaction search documentation included what the valid range fields are, specifically createdAt, updatedAt, etc. It seems the only reference for what you can search by is by looking at the code itself.
Additionally, the acceptable syntax is missing, specifically the potentially-important detail that search is sensitive down to minute precision while transactions are reported with seconds precision.
For example:
function searchTransactionsOnOrBefore(createdAtQuery) {
console.log("Getting transactions on or before createdAt: " + createdAtQuery);
var transactionsStream = gateway.transaction.search(function(search) {
search.createdAt().max(createdAtQuery);
});
var expectedMaxDate = new Date(createdAtQuery),
countBadTransactions = 0;
transactionsStream.on('data', function(tx) {
if ( (new Date(tx.createdAt)) > expectedMaxDate) {
console.log('BAD #' + (countBadTransactions++),
'got a transaction created AFTER expected max date: ', tx.createdAt);
} else {
console.log('Now seeing transactions at or below max date, done.');
transactionsStream.pause();
if (countBadTransactions)
console.log("ERROR: SAW " + countBadTransactions + " created AFTER specified max date!");
}
});
};
In my sandbox, I have a lot of transactions created close together (within a second or two).
An example transaction out of the library looks like:
{ id: 'fy5bqw',
status: 'settled',
type: 'sale',
currencyIsoCode: 'USD',
amount: '1071.91',
merchantAccountId: 'hfjjdfd2zvkq25yr',
orderId: null,
createdAt: '2014-10-03T23:15:00Z',
updatedAt: '2014-10-03T23:18:00Z',
...
}
Okay, lets feed the exact createdAt value back into the library:
> searchTransactionsOnOrBefore( '2014-10-03T23:15:00Z' )
Getting transactions on or before createdAt: 2014-10-03T23:15:00Z
BAD #0 got a transaction created AFTER expected max date: 2014-10-03T23:15:59Z
...
BAD #70 got a transaction created AFTER expected max date: 2014-10-03T23:15:45Z
...
BAD #126 got a transaction created AFTER expected max date: 2014-10-03T23:15:30Z
...
BAD #207 got a transaction created AFTER expected max date: 2014-10-03T23:15:15Z
...
BAD #265 got a transaction created AFTER expected max date: 2014-10-03T23:15:01Z
Now seeing transactions at or below max date, done.
ERROR: SAW 266 created AFTER specified max date!
Admittedly in a lot of cases the seconds-vs-minute precision doesn't matter, but well, I found this behavior because in my use-case it does.
At the very least, acceptable syntax and precision notes should be documented.
Hi guys,
I would like to know when it will be possible to submit a settlement with a partial amount.
Hi guys,
I’ve observed a somewhat inconsistent behavior of the responses for customer methods. The thing is, create
and update
will return the customer wrapped into a result
object. Using find
returns the customer directly.
Thanks for clarifying the implementation!
Hi
I was just trying braintree with the Nodejs version which got released yesterday (0.10.34). Trying to generate a client token leads to "Unexpected" error. I rollbacked to 0.10.33 and things work great. Thought this is something you might want to look at.
Thanks
I'm calling gateway.transaction.sale({ ... }, next)
And my environment is set to braintree.Environment.Development
.
Since I don't have a server set up on localhost:3000, when this code makes the request, it gets ECONNREFUSED
. But it doesn't forward this error to the next
callback. It just throws.
In http.coffee, you need something like:
theRequest.on('error', (err) =>
callback(err)
)
on line 75.
I am not sure if this is intentional, but I thought of letting you know the first_name of a customer is included inside an array next to the merchantId inside the result for gateway.customer.create
// gateway.customer.create result
result: {
"customer": {
"id": "some_id",
"firstName": "NAME",
"merchantId": [
"MY_MERCHANT_ID",
"NAME"
]
If I try to run that piece of code:
var gateway = braintree.connect({
environment: braintree.Environment[config.braintree.environment],
merchantId: config.braintree.merchantId,
publicKey: config.braintree.publicKey,
privateKey: config.braintree.privateKey
});
module.exports.gateway = gateway;
I got a TypeError:
TypeError: Cannot read property 'baseUrl' of undefined
at Config.baseUrl (***/node_modules/braintree/lib/braintree/config.js:36:28)
at Config.baseMerchantUrl (***/node_modules/braintree/lib/braintree/config.js:40:17)
at new TransparentRedirectGateway (***/node_modules/braintree/lib/braintree/transparent_redirect_gateway.js:39:34)
at new BraintreeGateway (***/node_modules/braintree/lib/braintree/braintree_gateway.js:69:32)
at Object.connect (***/node_modules/braintree/lib/braintree.js:42:10)
at Object.<anonymous> (***/helper/braintree.js:10:25)
Any ideas on that?
Result:
customer.creditcard : [creditcard obj]
customer.paymentMethods : [creditcard obj]
Result:
customer.creditcard : [creditcard obj]
customer.paymentMethods: null
Shouldn't both yield the same result?
I'm getting this error:
npm ERR! [email protected] not compatible with your version of node
npm ERR! Requires: node@~0.4.7
npm ERR! You have: [email protected]
npm not ok
O_o.
I am causing a failing transaction using these arbitrary amounts:
https://developers.braintreepayments.com/ios+ruby/reference/general/testing#test-amounts-for-unsuccessful-transactions
but for any amount I try deepErrors returns an empty array
// passing 2004
{ saleRequest:
{ amount: 2004,
merchantAccountId: '4tx62hp6hsrtzfkb',
creditCard:
{ number: '4111111111111111',
cvv: '123',
expirationMonth: '12',
expirationYear: '2020' },
customer:
{ id: 1413310867389,
firstName: 'Chris',
lastName: 'example',
email: '[email protected]' },
options: { storeInVaultOnSuccess: true } } }
// log
result.errors.deepErrors() => []
from this list:
https://developers.braintreepayments.com/ios+ruby/reference/general/processor-response
I can see the correct error should be Expired Card
, but nothing is returned
Only if I look into result.transaction.processorResponseCode
I can find the correct error code
Note: deepErrors() works for error in gateway.creditCard.create()
so one would expect it to work for any errors
In version 1.9.2 (and presumably previous versions), when updating the billing address of an existing customer to one with a property containing a null
value, the value for that property in the response is the string "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess {}"
rather than null
.
This is not a big issue, since the property can be set to the empty string with nearly the same effect, but it's not ideal since it does differ from the default/unspecified state.
A program which demonstrates the issue (with a gateway
variable initialized for the sandbox environment as in the Node.js examples):
gateway.customer.create({
id: "customer1",
creditCard: {
expirationDate: "04/2014",
number: "4111111111111111",
cvv: "111",
token: "customer1",
billingAddress: {
extendedAddress: "321 W First Street",
postalCode: "12345"
}
}
}, function(err, result) {
if (err) {
console.error(err);
return;
}
gateway.customer.update("customer1", {
creditCard: {
expirationDate: "05/2015",
number: "5555555555554444",
cvv: "112",
billingAddress: {
extendedAddress: null,
postalCode: "12345",
options: {
updateExisting: true
}
},
options: {
updateExistingToken: "customer1",
verifyCard: true
}
}
}, function(err, updated) {
if (err) {
console.error(err);
return;
}
console.log("Extended Address: " +
updated.customer.creditCards[0].billingAddress.extendedAddress);
});
});
I would expect the program to print "Extended Address: null". Instead, it prints "Extended Address: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess {}"
Thanks,
Kevin
This is effectively a clone of the same issue for the Ruby library (braintree/braintree_ruby#64). Overall I find the documentation lacking in example responses in many places, but this is one specifically that I am currently dealing with.
Knowing how much the user was charged can be a key reason for consuming a webhook notification for SubscriptionChargedSuccessfully (i.e. tracking revenue per use internally).
When generating a sample webhook notification for this using webhookTesting - a subscription comes back with the webhook payload, but no transactions are ever a part of that webhook.
This subscription within the notification payload should contain a fake Transaction that includes a charged amount.
https://www.braintreepayments.com/docs/node/transactions/details indicates that transaction records should include a bunch of vault fields like .vaultCustomer. I'm not seeing any of those.
REPRODUCE:
function createVaultedTransaction(vaultedPaymentMethodToken) {
gateway.transaction.sale({
paymentMethodToken: vaultedPaymentMethodToken,
amount: '200.34',
creditCard: { cvv: '100 '}
}, function(error, results) {
if (error) {
console.log("ERROR creating vaulted transaction:", error);
} else {
console.log("Transaction successfully created:", results);
}
});
};
function searchVaultedTransactions(vaultedPaymentMethodToken, callback) {
var searchResults = [];
var stream = gateway.transaction.search(function(search) {
search.paymentMethodToken().is(vaultedPaymentMethodToken);
});
stream.on('data', function(transaction) {
searchResults.push(transaction);
});
stream.on('end', function() {
console.log('DONE getting transactions');
callback(null, searchResults);
});
stream.on('error', function(error) {
console.log('ERROR searching transactions');
callback(error);
});
console.log('Starting search');
};
> createVaultedTransaction('d3adb33f');
// --> "Transaction successfully created ..."
> searchVaultedTransactions('d3adb33f', function(error, results) {
if (error) { return console.log("error"); }
console.log("vaultCustomer for first result: ", results[0].vaultCustomer);
console.log("first result's attributes: ", Object.keys(results[0]).sort());
});
// --> "vaultCustomer for first results: undefined"
// --> "first results' attributes: [ addOns', 'amount', 'avsErrorResponseCode', .... , 'updatedAt', 'voiceReferralNumber' ]
Note how none of the .vault* attributes are present in the result.
Could you please update example usage to reflect using paymentMethodNonce
and not deprecated creditCard
option?
I was testing out different cards on sandbox and while iterating through a customer's payment methods from the API, I noticed that a maestro card imageUrl
points to a 404 url: https://assets.braintreegateway.com/payment_method_logo/maestro.png?environment=sandbox
This issue doesn't show up on drop-ui (the dropui somehow knows not to show a card image for maestro cards).
Thanks!
gateway.transaction.sale({
amount: total,
merchantAccountId: <INVALID/NON EXISTENT>,
paymentMethodNonce: nonce,
serviceFeeAmount: service
}, function (err, result) {
console.log(result);
});
Should this be returning a proper result object with success = false, and a proper error message?
I.e
91513 – Merchant account ID is invalid. If you specify the merchant account ID to use to process a transaction and it does not match any of your merchant accounts, you'll get this error.
Docs
When I receive paymentMethodNonce from braintree widget, I use it first to create a customer and then to make an actual payment. But while creating customer is successful, making a payment causes an error "Payment method nonce is invalid". Previously it was possible. Is it an intended behaviour or a bug?
P.S. Didn't know where to post it, to braintree_node or braintree_web
Is it possible to create the payment method nonce using the node api? I want to do this for our testing framework.
The transaction paging function always gives you the same 50 results. The ids parameter is ignored.
var transactionSearch;
gateway.transaction.search(function(search) {
search.creditCardCardType.is(CreditCard.CardType.All());
}, function(error, results) {
if (error) {
console.log("Error on search: ", error);
} else {
console.log("Got " + results.ids.length + " transaction ids");
}
transactionSearch = results;
});
// wait for the results to come back. Make sure you have more than 50 ids. Then:
var transactionDetails = [];
transactionSearch.pagingFunction(transactionSearch.ids.slice(50, 100), function(error, details) {
if (error) {
console.log("Error getting transaction details: ", error);
} else {
console.log("Got details");
transactionDetails.push(details);
}
});
// Wait for all the callbacks to fire, then look at transactionDetails
// It contains the first 50 transactions, regardless of which ids you specify
Is there a roadmap or some sort of indicator of when the non-supported API functionality will be supported in the node module? For example, there are a number of pages in the documentation (like the plan page) that indicate certain functionality is not available. This kind of sucks... we have to use at least two different approaches for complete interaction with the API.
I don't believe this is a correct value. It does not include the full path (not taking into account the environment)
For example, the value for my account (with the merchant account masked) I get the following:
/merchants/XXX/transparent_redirect_requests
I'm assuming it should be prefixed with:
https://sandbox.braintreegateway.com
The search documentation pages give javascript examples like so:
var stream = gateway.transaction.search(function (search) {
search.creditCardCardType().is(CreditCard.CardType.Visa);
});
As far as I can tell, though, enum objects like CreditCard
are never exposed in the npm module / compiled coffeescript.
Using braintree as an npm module, user would expect to be able to start their node program like this:
var braintree = require('braintree'),
CreditCard = braintree.CreditCard;
but we actually need to hack through the lib files:
var braintree = require('braintree'),
CreditCard = require('braintree/lib/braintree/credit_card');
Enum objects like CreditCard should be programmatically exposed through the npm module.
var op = {
customerId: "customeridhere"
};
gateway.clientToken.generate(op, function (err, braintreeRes) {
if(err) {
// Ret; Handling Errors
} else if(!braintreeRes.clientToken) {
// Ret; Handling Errors
}
// Sending token
});
Results in
/Users/james/Documents/Github/*****/node_modules/braintree/lib/braintree/client_token_gateway.js:72
return callback(null, new ErrorResponse(response.apiErrorResponse));
^
ReferenceError: ErrorResponse is not defined
at /Users/james/Documents/Github/*****/node_modules/braintree/lib/braintree/client_token_gateway.js:72:35
at /Users/james/Documents/Github/*****/node_modules/braintree/lib/braintree/http.js:103:20
at Parser.<anonymous> (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:134:18)
at Parser.EventEmitter.emit (events.js:95:17)
at Object.saxParser.onclosetag (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:120:24)
at emit (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33)
at emitNode (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:620:3)
at closeTag (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:861:5)
at Object.write (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1294:29)
at Parser.exports.Parser.Parser.parseString (/Users/james/Documents/Github/*****/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:145:29)
Going off the docs, I was expecting either a graceful error, or a token. I really don't want to run a .find operation before running the generate method.
{ billingAddress:
{ id: '97',
customerId: '673fb568be29f6f5435ae7e04d7a73eb',
firstName: 'A',
lastName: 'Customer',
company: {},
streetAddress: '1 Mary St',
extendedAddress: {},
locality: 'Newtown',
region: 'NSW',
postalCode: '2042',
countryCodeAlpha2: 'AU',
countryCodeAlpha3: 'AUS',
countryCodeNumeric: '036',
countryName: 'Australia',
createdAt: '2011-11-11T04:57:56Z',
updatedAt: '2011-11-11T05:53:08Z' },
bin: '401288',
...
expirationDate: '05/2014' }
In the above company and extendedAddress are shown as empty strings in the web interface. This feels very wrong!
It would be super cool to receive a proper error code in the err object passed to the callback. So we can map the error message appropriately to the customer.
At the moment I receive this:
err: {
"message": "Not Found",
"type": "notFoundError"
}
Seems like the library is going into that direction mapping the entire error list: https://github.com/braintree/braintree_node/blob/master/src/braintree/validation_error_codes.coffee
but it seems to disregard such codes when mapping the error back the the user:
https://github.com/braintree/braintree_node/blob/master/src/braintree/validation_errors_collection.coffee
@lionelbarrow is this something in your roadmap?
Hi,
braintree_node doesn't install on v0.5.10. This is due to engine versioning in package.json, and also due to the o3-xml dependency engine versioning. package.json needs to be updated as well as o3-xml or the dependency for o3-xml should be removed. I will open a versioning issue for o3-xml as well.
This request was made because Node v0.6.0 is about to be released and it has great new functionality, such as windows support and child_process.fork
Hi guys,
really awesome support for node.js. One tiny request, to keep it more in line with the ecosystem. Please
pre-compile the coffeescript before pushing it to npm,
run the tests against the compiled versions instead of the coffeescript
move the coffeescript to /src and leave the compiled output in /lib
move coffeescript to dev dependencies
and finally enable travis-ci.org
Thanks
Trying to run v1.13.0
[email protected] node_modules/braintree
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])
I'm getting this error when running
Error: Cannot find module './lib/braintree'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/myproject/node_modules/braintree/index.js:1:80)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Is there a missing compilation script ? shouldn't the code be self contained ?
Hi.
I'm sending this customer info:
{ "id":"myCustomerId", "creditCard": { "cvv":"111", "number":"4009348888881881", "credit_card_exp":"11/2013", "cardholder":"Indiana Jones", "options":{ "makeDefault":true, "verifyCard":true, "updateExistingToken":"9774s" } } }
Per documentation, some attributes are misformatted:
credit_card_exp
should be expirationDate
cardholder
should be cardholderName
However, the BrainTree API then returns the following error:
{ message: 'Authorization Error', type: 'authorizationError' }
I'd expect the braintree API to return some specific error like 'unsupported attribute' but not an 'authorizationError' since the documentation on authorizationError is very misleading in this case:
You’ll receive an authorization exception if the API key that you’re using is not
authorized to perform the attempted action according to the roles assigned to the user
who owns the API key.
Testing out the new stream implementation in 1.11.1 using npm module.
Docs and coffeescript tests say you should be able to do something like this:
var stream = gateway.transaction.search(function (search) {
search.creditCardCardholderName().is("Patrick Smith");
});
stream.on("data", function (transaction) {
// ...
});
stream.on("end", function () {
// ...
});
stream.resume();
However, gateway.transaction.search(...)
is returning undefined, not a stream object.
var braintree = require('braintree'),
gateway = braintree.connected({ ... });
var stream = gateway.transaction.search(function (search) {
search.creditCardCardholderName().is("Patrick Smith");
});
stream === undefined; // --> true
Using [email protected] from npm.
Testing against the sandbox with an amount of $3000 trigger an error inside the braintree_node package:
/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:138
return cb(err);
^
TypeError: Cannot read property 'apiErrorResponse' of undefined
at /Users/jkrez/src/airpair.com/node_modules/braintree/lib/braintree/gateway.coffee:11:7
at /Users/jkrez/src/airpair.com/node_modules/braintree/lib/braintree/http.coffee:71:13
at Parser.<anonymous> (/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:138:18)
at Parser.emit (events.js:95:17)
at Object.saxParser.onerror (/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:51:24)
at emit (/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33)
at error (/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:644:3)
at strictFail (/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:662:22)
at Object.write (/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1000:11)
at Parser.exports.Parser.Parser.parseString (/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:145:29)
at Parser.parseString (/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:3:63)
at IncomingMessage.<anonymous> (//node_modules/braintree/lib/braintree/http.coffee:70:11)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
While using sandbox and creating a transaction.
/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/lib/braintree/gateway.js:23
if (response.apiErrorResponse) {
^
TypeError: Cannot read property 'apiErrorResponse' of undefined
at /Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/lib/braintree/gateway.js:23:19
at /Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/lib/braintree/http.js:103:20
at Parser. (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:138:18)
at Parser.EventEmitter.emit (events.js:95:17)
at Object.saxParser.onerror (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:51:24)
at emit (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33)
at error (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:644:3)
at strictFail (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:662:22)
at Object.write (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1000:11)
at Parser.exports.Parser.Parser.parseString (/Users/hindsricardo/Google_Drive/upon_imac/node_modules/braintree/node_modules/xml2js/lib/xml2js.js:145:29)
Promises have become reasonably popular in Node as a way to combat "callback hell" and overall is a pretty awesome thing.
It would be awesome if Braintree node had native support for Q or Bluebird.
The transaction paging function uses a bad callback idiom -- if multiple transaction details are returned, the callback is called once per individual result. To use it, you need to create your own transaction details accumulator like this:
var transactionSearch;
gateway.transaction.search(function(search) {
search.creditCardCardType.is(CreditCard.CardType.All());
}, function(error, results) {
if (error) {
console.log("Error on search: ", error);
} else {
console.log("Got " + results.ids.length + " transaction ids");
}
transactionSearch = results;
});
// wait for the results to come back. Make sure you have more than 50 ids. Then:
var transactionDetails = [];
transactionSearch.pagingFunction(transactionSearch.ids.slice(50, 100), function(error, details) {
if (error) {
console.log("Error getting transaction details: ", error);
} else {
console.log("Got details");
// accumulate each transaction detail like this:
transactionDetails.push(details);
}
});
Node callbacks are generally meant to be called only once.
Furthermore, with this implementation, it is impossible to know when your transaction details accumulator is done accumulating. This makes it impossible to do anything with the results because there is no flow control mechanism to tell you when you're done.
Recommend that the paging function semantics be changed such that it always passes an array of all the transaction results to the callback.
When submitting a sale with an invalid credit card:
gateway.transaction.sale({
amount: 2000, // simulate 'processor declined' on sandbox
options: { submitForSettlement: true },
orderId: <id>,
customerId: <customer_id>,
paymentMethodToken: <token>
})
this exception gets thrown:
TypeError: Cannot read property 'apiErrorResponse' of undefined
at .../braintree/lib/braintree/gateway.js:27:19
My initial efforts at debugging showed that the response handler doesn't seem to be receiving the expected arguments. The offending function in gateway.js
:
Gateway.prototype.createResponseHandler = function(attributeKlassMap, klass, callback) {
return function(err, response) {
console.log(err); // null
console.log(response); // undefined
var attributeName, unknown;
if (err) {
return callback(err, response);
}
if (response.apiErrorResponse) { // This is the line that throws the exception
return callback(null, new ErrorResponse(response.apiErrorResponse));
} else {
...
I've confirmed that this also happens in our production environment when submitting any bogus credit card.
It's particularly bad because the exception can't be caught in the calling context, since it's being thrown from an asynchronous block. Thus I so far I haven't been able to come up with a way to prevent this from crashing the server.
Any ideas?
I am looking for a way to expose the request and response objects for each api call. I want to be able to validate the object against it and return all the available attributes for a call. Wondering if you could add this functionality to the SDK.
Is there a reason for using underscore over lodash?
While creating a customer in sandbox mode:
on validate_errors.js toCamelCase() is called on undefined
TypeError: Cannot call method 'replace' of undefined
Function.Util.toCamelCase() ./node_modules/braintree/lib/braintree/util.js:118:19
ValidationErrorsCollection.buildErrors() ./node_modules/braintree/lib/braintree/validation_errors_collection.js:30:18
new() ValidationErrorsCollection ./node_modules/braintree/lib/braintree/validation_errors_collection.js:17:14
new() ValidationErrorsCollection ./node_modules/braintree/lib/braintree/validation_errors_collection.js:19:38
new() ErrorResponse ./node_modules/braintree/lib/braintree/error_response.js:17:19
./node_modules/braintree/lib/braintree/gateway.js:23:31()
./node_modules/braintree/lib/braintree/http.js:101:20()
Parser.<anonymous>() ./node_modules/braintree/node_modules/xml2js/lib/xml2js.js:255:20
Parser.EventEmitter.emit() events.js:95:17
Object.saxParser.onclosetag() ./node_modules/braintree/node_modules/xml2js/lib/xml2js.js:225:24
emit() ./node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:589:33
emitNode() ./node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:594:3
closeTag() ./node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:835:5
Object.write() ./node_modules/braintree/node_modules/xml2js/node_modules/sax/lib/sax.js:1254:29
Parser.exports.Parser.Parser.parseString() ./node_modules/braintree/node_modules/xml2js/lib/xml2js.js:273:29
Parser.parseString() ./node_modules/braintree/node_modules/xml2js/lib/xml2js.js:6:61
IncomingMessage.<anonymous>() ./node_modules/braintree/lib/braintree/http.js:100:31
IncomingMessage.EventEmitter.emit() events.js:117:20
_stream_readable.js:910:16()
process._tickCallback() node.js:415:13
Thrown: ./node_modules/braintree/lib/braintree/util.js:118
116:
117: Util.toCamelCase = function(string) {
✘ 118: return string.replace(/([\-\_][a-z0-9])/g, function(match) {
119: return match.toUpperCase().replace('-', '').replace('_', '');
120: });
Previous: ./node_modules/braintree/lib/braintree/validation_errors_collection.js:30
28: for (_i = 0, _len = errors.length; _i < _len; _i++) {
29: item = errors[_i];
✘ 30: key = Util.toCamelCase(item.attribute);
31: (_base = this.validationErrors)[key] || (_base[key] = []);
32: _results.push(this.validationErrors[key].push(new ValidationError(item)));
Had some issues when trying to run from source rather than from npm install.
I had to do var braintree = require('braintree_node/lib/braintree')
instead of var braintree = require('braintree-node/lib/braintree')
instead of README.
Also, had to run my_braintree_test.js (create a file with the example code from the README with this name) with
env NODE_PATH=`pwd` my_braintree_test.js
to get it to look in the directory I had git cloned for the braintree module.
Also, had to npm install underscore. This was not listed as a dependency.
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: [email protected]
npm ERR! Required: {"node":"~0.6.6"}
npm ERR! Actual: {"npm":"1.1.4","node":"0.8.3"}
We're about to launch, and now need to spend time downgrading.
node.js v0.10.31
npm 1.4.23
rake, version 10.0.4
It seems ClientTokenGateway
unit test doesn't pass
npm install
npm test
ClientTokenGateway
generate
✓ returns an error when credit card options are supplied without a customer ID
error responses
◦ responds with a ErrorResponse successfully: TypeError: Cannot read property 'message' of null
at client_token_gateway_spec.coffee:20:8
at client_token_gateway.coffee:33:13
at ClientRequest.<anonymous> (http.coffee:89:13)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
./node_modules/mocha/bin/mocha --timeout 62000 --reporter spec --slow 2000 spec_compiled/integration --recursive
AddressGateway
create
◦ handles a successful response: TypeError: Cannot read property 'customer' of null
at address_gateway_spec.coffee:9:10
at gateway.coffee:9:13
at ClientRequest.<anonymous> (http.coffee:89:13)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
shortcut
./node_modules/mocha/bin/mocha --timeout 62000 --reporter spec --slow 2000 spec_compiled/integration/braintree/client_token_gateway_spec.js
I am using customer.find.
I would like to be able to pull all the information that is on the
https://sandbox.braintreegateway.com/merchants/:merchid/customers/:customerid in your system in one call.
Here are my observations/questions.
Currently I only See Transactions that are associated with subscriptions on the customer find return.
Q1: is it possible to move the transactions out to the parent level (like addresses and credit cards) and include ALL transactions.
Q2: Is it possible to also move subscriptions out to the parent level as well?
Currently Subscriptions Returns the PLan ID but not the details. Can the details be added?
Thanks.
gateway.paymentMethod.create({
customerId: args.braintreeId,
paymentMethodNonce: args.nonce,
options: {
makeDefault: args.isPrimary,
failOnDuplicatePaymentMethod: true
}
}
When trying to create a payment method in a sandbox environment, with the failOnDuplicatePaymentMethod option set as true, using fake-valid-discover-nonce
or a nonce generated with the test Discover card number 6011111111111117
the process fails with the following: Error: Duplicate card exists in the vault.
. However, said payment method is not previously stored in the user's vault (it even happens with new customers with no saved payment methods).
The docs say that to check the search response length, you look at stream.searchResponse.length like so:
var stream = gateway.customer.search(function (search) {
search.company().is("Acme Inc.");
});
stream.searchResponse.length;
Two issues.
.length is actually a function. docs should be updated to say stream.searchResponse.length();
It is not initialized until sometime between the gateway.xxx.search() call and the first on('data') event. Calling it as per the docs results in an undefined error, and it strikes me as cludgey to do something like stream.once('data', function() { total = stream.searchResponse.length(); })
It would be nicer if you provided a custom event that fired when the searchResponse was ready but before the first transaction or customer or whatever streams in.
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
Right now it fails with newer versions of node, because you depend on a outdated base64 version ([email protected])
...
Hi,
We use the NodeJS sdk (specifically the card vaulting functionality) in a very crucial part of our new customer registration process. Unfortunately, there is a little-known limitation in the standard nodeJS http library which prevents ANY form of connection keep-alive when doing POST or PUT operations. The vault card is a POST and it therefore causes a closed connection (with its dangling TIME_WAIT socket) for each call. It is a pretty big deal for us because it slows down our system significantly.
Does the braintree API support method override (to turn those POSTs into GETs)? I would then be able to fork the nodeJS client and tweak the http request to send the correct parameters (totally at our own risk).
I understand how much against any REST principle this is, but we are being hit pretty hard by this lack of support of keep-alives by NodeJS and it's too late for us to switch technology. We don't really have another choice.
Thanks
Roberto
I wasn't trying to create a marketplace merchant, but there's this unknown variable.
merchantAccountParams = {
individual: {
firstName: "Jane",
lastName: "Doe",
email: "[email protected]",
phone: "5553334444",
dateOfBirth: "1981-11-19",
ssn: "456-45-4567",
address: {
streetAddress: "111 Main St",
locality: "Chicago",
region: "IL",
postalCode: "60622"
}
},
business: {
legalName: "Jane's Ladders",
dbaName: "Jane's Ladders",
taxId: "98-7654321",
address: {
streetAddress: "111 Main St",
locality: "Chicago",
region: "IL",
postalCode: "60622"
}
},
funding: {
descriptor: "Blue Ladders",
destination: MerchantAccount.FundingDestination.Bank,
email: "[email protected]",
mobilePhone: "5555555555",
accountNumber: "1123581321",
routingNumber: "071101307"
},
tosAccepted: true,
masterMerchantAccountId: "14ladders_marketplace",
id: "blue_ladders_store"
};
gateway.merchantAccount.create(merchantAccountParams, function (err, result) {
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.