Skip to content
This repository

Duplicate callbacks in stripe.customers.retrieve #24

Closed
kishorenc opened this Issue February 01, 2012 · 2 comments

2 participants

Kishore Nallan Ask Bjørn Hansen
Kishore Nallan

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.

Kishore Nallan

I also noticed that the rest of the methods on customers, don't impose this validation, for e.g.

update_subscription: function(customer_id, data, cb) {
  post("/v1/customers/" + customer_id + '/subscription', data, cb);
},
Ask Bjørn Hansen abh referenced this issue from a commit February 01, 2012
Ask Bjørn Hansen Fix duplicate callbacks from some functions when called incorrectly
(closes bug #24, reported by Kishore Nallan)
86e5307
Ask Bjørn Hansen

Thanks Kishore! I published version 1.1.0 with these things fixed (and a new coupons API).

Ask Bjørn Hansen abh closed this February 01, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.