Please keep in mind that this package is for use with server-side Node that uses Stripe secret keys. To maintain PCI compliance, tokenization of credit card information should always be done with Stripe.js on the client side. This package should not be used for that purpose.
See the Node API docs.
Install the package with:
npm install stripe --save
The package needs to be configured with your account's secret key which is available in your Stripe Dashboard. Require it with the key's value:
var stripe = 'sk_test_...';stripecustomers;
On ES6, this looks more like:
;const stripe = ;
Every method returns a chainable promise which can be used instead of a regular callback:
// Create a new customer and then a new charge for that customer:stripecustomers;
Request timeout is configurable (the default is Node's default of 120 seconds):
stripe; // in ms (this is 20 seconds)
Stripe-Account header for use with Stripe Connect
can be added to any method:
// Retrieve the balance for a connected account:stripebalance;
An https-proxy-agent can be configured with
To use stripe behind a proxy you can pass to sdk:
if processenvhttp_proxyconst ProxyAgent = ;stripe;
Some information about the response which generated a resource is available
chargelastResponserequestId // see:chargelastResponsestatusCode
Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it here.
event = stripewebhooks;
If you're writing a plugin that uses the library, we'd appreciate it if you identified using
This information is passed along when the library makes calls to the Stripe API.
Run all tests:
$ npm install$ npm test
Run a single test suite:
$ npm run mocha -- test/Error.spec.js
Run a single test (case sensitive):
$ npm run mocha -- test/Error.spec.js --grep 'Populates with type'
If you wish, you may run tests using your Stripe Test API key by setting the
STRIPE_TEST_API_KEY before running the tests:
$ export STRIPE_TEST_API_KEY='sk_test....'$ npm test