Set up your development environment
Get familiar with the Stripe CLI and our server-side SDKs.
Stripe’s server-side SDKs and command-line interface (CLI) allow you to interact with Stripe’s REST APIs. Start with the Stripe CLI to streamline your development environment and make API calls.
Use the SDKs to avoid writing boilerplate code. To start sending requests from your environment, choose a language to follow a quickstart guide.
In this quickstart, you install the Stripe CLI—an essential tool that gets you command line access to your Stripe integration. You also install the Stripe Node.js server-side SDK to get access to Stripe APIs from applications written in Node.js.
What you learn![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
In this quickstart, you’ll learn:
- How to call Stripe APIs without writing a line of code
- How to manage third-party dependencies using the npm or yarn package manager
- How to install the latest Stripe Node SDK v16.0.0
- How to send your first SDK request
Initial setup![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
First, create a Stripe account or sign in.
Set up the Stripe CLI![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Install![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
From the command-line, use an install script or download and extract a versioned archive file for your operating system to install the CLI.
Authenticate![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Login and authenticate your Stripe user Account to generate a set of restricted keys. To learn more, see Stripe CLI keys and permissions.
stripe login
Press the Enter key on your keyboard to complete the authentication process in your browser.
Your pairing code is: enjoy-enough-outwit-win This pairing code verifies your authentication with Stripe. Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=THQdJfL3x12udFkNorJL8OF1iFlN8Az1 (^C to quit)
Confirm setup![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Now that you’ve installed the CLI, you can make a single API request to Create a product.
stripe products create \ --name="My First Product" \ --description="Created with the Stripe CLI"
Look for the product identifier (in id
) in the response object. Save it for the next step.
If everything worked, the command-line displays the following response.
{ "id":
, "object": "product","prod_LTenIrmp8Q67sa"
Next, call Create a price to attach a price of 30 USD. Swap the placeholder in product
with your product identifier (for example, prod_
).
stripe prices create \ --unit-amount=3000 \ --currency=usd \ --product=
{{PRODUCT_ID}}
If everything worked, the command-line displays the following response.
{ "id":
, "object": "price","price_1KzlAMJJDeE9fu01WMJJr79o"
Install the Node.js server-side SDK![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
The latest version of the Stripe Node.js server-side SDK is v16.0.0. It supports Node.js versions 12+.
Check your Node version:
node --version
Initialize Node![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
npm init
Install the library![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Install the library with npm, a package manager for Node:
npm install stripe --save
After you install the library with npm, the library is automatically added as a dependency in your project’s package.json file. For example:
{ "name": "stripe-node-example", "version": "1.0.0", "description": "A Stripe demo", "main": "index.js", "scripts": { "node ": "node create_price.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "stripe": "^16.0.0" } }
Installation alternatives![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Run your first SDK request![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
Now that you have the Node.js SDK installed, you can create a subscription Product and attach a Price with a couple API requests. The Node.js SDK returns promises which can be used as chainable callbacks. To demonstrate, we’re passing the product identifier returned in the Product response to create a Price in this example.
Note
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); stripe.products.create({ name: 'Starter Subscription', description: '$12/Month subscription', }).then(product => { stripe.prices.create({ unit_amount: 1200, currency: 'usd', recurring: { interval: 'month', }, product: product.id, }).then(price => { console.log('Success! Here is your starter subscription product id: ' + product.id); console.log('Success! Here is your starter subscription price id: ' + price.id); }); });
Save the file as create_
. From the command line, cd
to the directory containing the file you just saved and run:
node create_price.js
If everything worked, the command line shows the following response. Save these identifiers so you can use them while building your integration.
Success! Here is your starter subscription product id: prod_0KxBDl589O8KAxCG1alJgiA6 Success! Here is your starter subscription price id: price_0KxBDm589O8KAxCGMgG7scjb
See also![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)
This wraps up the quickstart. See the links below for a few different ways to process a payment for the product you just created.