Skip to content


tabulardata edited this page Oct 25, 2013 · 3 revisions

Alongside the version 2 release we added support for promises. Every resource method now returns a Promises/A+ compliant promise in addition to supporting the conventional callback:

Using a regular callback:

stripe.customers.create({...}, function(err, customer) {...});

Using a promise:

  .then(function(customer){...}, function(err) {...});

Here's an example of creating a customer and then a new charge for that customer:

  email: ''
}).then(function(customer) {
  return stripe.charges.create({
    amount: 1600,
    currency: 'usd',
}).then(function(charge) {
  // New charge created on a new customer
}, function(err) {
  // Deal with an error
You can’t perform that action at this time.