Code Monkey home page Code Monkey logo

stripe-node's Introduction

Stripe node.js bindings

Version 2 Update Notice

This repo has just been transferred to Stripe. Alongside this transfer, Stripe has released version 2.x of the bindings. Read about Version 2 here. We'll be going through the backlogged issues in the next few days.

Installation

npm install stripe

Documentation

Documentation is available at https://stripe.com/docs/api/node.

API Overview

Every resource is accessed via your stripe instance:

var stripe = require('stripe')(' your stripe API key ');
// stripe.{ RESOURCE_NAME }.{ METHOD_NAME }

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

stripe.customers.create(
  { email: '[email protected]' },
  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:
stripe.customers.create({
  email: '[email protected]'
}).then(function(customer) {
  return stripe.charges.create({
    amount: 1600,
    currency: 'usd',
    customer: customer.id
  });
}).then(function(charge) {
  // New charge created on a new customer
}, function(err) {
  // Deal with an error
});

Available resources & methods

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

Configuration

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

More information / wikis

Development

To run the tests you'll need a Stripe Test API key (from your Stripe Dashboard):

$ npm install -g mocha
$ npm install
$ export STRIPE_TEST_API_KEY="sk_test_..."
$ mocha

Note: On Windows use SET isntead 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.

Author

Originally by Ask Bjørn Hansen ([email protected]). Development was sponsored by YellowBot. Now officially maintained by Stripe.

stripe-node's People

Contributors

2sidedfigure avatar abh avatar deltaepsilon avatar devongovett avatar gflandre avatar janl avatar kc-dot-io avatar m5m1th avatar michelle-stripe avatar padolsey avatar pchw avatar pkrumins avatar pksunkara avatar slexaxton avatar tanguylebarzic avatar thatemilio avatar willwhite avatar xavi- avatar zgsrc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.