Stripe API for node.js
Latest commit bd4bd44 Sep 27, 2016 @kyleconroy kyleconroy committed on GitHub Add tests for items encoding (#271)
* Add tests for encoding

* Add a utility function for converting arrays to objects

Add documentation for the new `encode` parameter

Stripe node.js bindings Build Status

Version 2 Update Notice

Read about Version 2 here (Released October 18th, 2013)


npm install stripe


Documentation is available at

API Overview

Every resource is accessed via your stripe instance:

var stripe = require('stripe')(' your stripe API key ');

Every resource method accepts an optional callback as the last argument:

  { email: '' },
  function(err, customer) {
    err; // null if no error occurred
    customer; // the created customer object

Additionally, every resource method returns a promise, so you don't have to use the regular callback. E.g.

// Create a new 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
}).catch(function(err) {
  // Deal with an error

To use the Stripe-Account header, simply pass an extra options hash:

// Retrieve the balance for a connected account:
  stripe_account: "acct_foo"
}).then(function(balance) {
  // The balance object for the connected account
}).catch(function(err) {
  // Error

Available resources & methods

Where you see params it is a plain JavaScript object, e.g. { email: '' }


  • stripe.setApiKey(' your secret api key ');
  • stripe.setTimeout(20000); // in ms (default is node's default: 120000ms)

More information / wikis


Run the tests using npm:

$ npm install
$ npm test

If you wish, you may run tests using your Stripe Test API key by setting the environment variable STRIPE_TEST_API_KEY before running tests:

$ export STRIPE_TEST_API_KEY='sk_test....'
$ npm test

Note: On Windows use SET instead of export for setting the STRIPE_TEST_API_KEY environment variable.

If you don't have a prefixed key (in the form sk_test_...) you can get one by rolling your "Test Secret Key". This can be done under your dashboard (Account Setting -> API Keys -> Click the roll icon next to the "test secret key"). This should give you a new prefixed key ('sk_test_..'), which will then be usable by the node mocha tests.


Originally by Ask Bjørn Hansen ( Development was sponsored by YellowBot. Now officially maintained by Stripe.