Development environment quickstarts
Quickstarts by language
Stripe’s server-side helper libraries (also known as server-side SDKs) and Command Line Interface (CLI) allow you to interact with Stripe’s REST APIs. Start with the Stripe CLI and make Stripe API calls without writing a line of code. 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 Ruby server-side SDK to get access to Stripe APIs from applications written in Ruby.
What you learn
In this quickstart, you’ll learn:
- How to call Stripe APIs without writing a line of code
- How to manage third-party dependencies using a bundler with RubyGems
- How to install the Stripe Ruby SDK v8.0.0
- How to send your first SDK request
Initial setup
Click the Sign in button to login to the Stripe docs site, and start using your test mode API keys for authenticated requests.
Setup the Stripe CLI
- From the command-line, use an install script or download and extract a versioned archive file for your operating system to install the CLI.
- 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)
- 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_LTenIrmp8Q67sa
).
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"
Manage third-party dependencies
We recommend managing third-party dependencies using the RubyGems command-line tool, which allows you to add new libraries and include them in your Ruby projects. Check whether RubyGems is installed:
Install RubyGems
gem --version
If you get gem: command not found
, download RubyGems from their downloads page.
Install the Ruby Server-side SDK
The latest version of the Stripe Ruby server-side SDK is v8.0.0. It supports Ruby versions 2.3+.
- Check your Ruby version:
ruby -v
Install the library
We recommend creating a gem file then installing the generated gem using a bundler with RubyGems.
- To add the latest version of the Stripe gem to a project, run the following command:
bundle add stripe
- Alternatively, you can add the latest version of the library as a gem dependency:
source 'https://rubygems.org' gem 'rails' gem 'stripe'
- Next, install the required gems from your specified sources:
bundle install
Global installation
- Alternatively, you can install the library globally with RubyGems:
gem install stripe
Manual installation
- Additionally, you can build the gem from source, and then install the library by running:
gem build stripe.gemspec
Run your first SDK request
Now that you have the Ruby SDK installed, you can create a subscription Product and attach a Price with a couple API requests. We’re using the product identifier returned in the response to create the price in this example.
require 'rubygems' require 'stripe' Stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" starter_subscription = Stripe::Product.create( name: 'Starter Subscription', description: '$12/Month subscription', ) starter_subscription_price = Stripe::Price.create( currency: 'usd', unit_amount: 1200, recurring: {interval: 'month'}, product: starter_subscription['id'], ) puts "Success! Here is your starter subscription product id: #{starter_subscription.id}" puts "Success! Here is your starter subscription price id: #{starter_subscription_price.id}"
- Save the file as
create_price.rb
. From the command line,cd
to the directory containing the file you just saved then run:
ruby create_price.rb
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: price_0KxBDl589O8KAxCG1alJgiA6 Success! Here is your starter subscription price id: price_0KxBDm589O8KAxCGMgG7scjb
See also
This wraps up the quickstart. See the links below for a few different ways to process a payment for the product you just created.