API libraries
Client-side and UI libraries
Use Stripe on the web with Elements, a set of prebuilt UI components for collecting and validating card details. Elements uses Stripe.js, our foundational JavaScript library for building payment flows.
You need to include Stripe.js on your checkout page by either adding the script tag to the head
of your HTML file, or importing it from the stripe-js
module:
<script src="https://js.stripe.com/v3/"></script>
Next, create an instance of the Stripe object by providing your publishable API key as the first parameter:
var stripe = Stripe(
);'pk_test_TYooMQauvdEDq54NiTphI7jx'
Finally, create an instance of the Elements UI library:
var elements = stripe.elements();
Now you can use Elements to create payment forms with prebuilt input fields to collect payment method details. See accept a payment for detailed instructions.
Server-side libraries
# Available as a gem sudo gem install stripe
# If you use bundler, you can add this line to your Gemfile gem 'stripe'
For more details, check out the API reference or see the source code on GitHub.
Versioning
When backwards-incompatible changes are made to the API, a new, dated version is released. Read our API upgrades guide to see our API changelog and to learn more about backwards compatibility.
All requests use your account API settings, unless you override the API version. The changelog lists every available version. Note that by default webhook events are structured according to your account API version, unless you set an API version during endpoint creation.
To override the API version, assign the version to the Stripe.api_version
property:
require 'stripe' Stripe.api_key =
Stripe.api_version = '2020-08-27'sk_test_4eC39HqLyjWDarjtT1zdp7dc
Or set it per-request:
require 'stripe' intent = Stripe::PaymentIntent.retrieve( 'pi_1DlIVK2eZvKYlo2CW4yj5l2C', { stripe_version: '2020-08-27', } ) intent.capture
When overriding it per-request, methods on the returned object reuse the same Stripe version.
You can visit your Dashboard to upgrade your account API version.
Upgrading your server-side library
Minor updates to our libraries are backwards compatible and are generally safe to upgrade to. Major updates often include breaking changes, which may require changes to your code when upgrading. A major version upgrade is sometimes required to use new features.
Major version upgrades may contain breaking changes. When upgrading, carefully review the library changelog, read the relevant migration guide, and test your integration.
Before upgrading your API version in the Dashboard, review both the API changelog and the library changelog.
Update the version in your Gemfile
. You can find the latest library version at the top of the changelog file.
# If you use bundler, you can add this line to your Gemfile gem 'stripe', 'X.XX.X'
bundle install
Community libraries
Find some of the many community-supported libraries available for Stripe listed below.