abh/node-stripe — Issue #24: Duplicate callbacks in stripe.customers.retrieve
Author: kishorenc
Created: 2012-02-01 16:40:56+00:00
State: open

When I call `stripe.customers.retrieve()` with a customer_id that's NOT a string, the callback is fired twice. Sample code that fails:

stripe.customers.retrieve(123, function(retrieveErr, retrieveRes) {
console.log("CALLBACK: ",retrieveErr);
});

Running the above code, produces:

CALLBACK: customer_id required
CALLBACK: 404

This is because (I think), you are not returning from the function on validation error, see:

retrieve: function(customer_id, cb) {
if (!(customer_id && typeof customer_id === 'string')) {
cb("customer_id required");
}
get("/v1/customers/" + customer_id, {}, cb);
},

You need to probably do:

return cb("customer_id required");

If my guess is right, I can send you a pull request.