Don’t want to migrate? You can continue to use your current integration, but new features are not supported. Any new plans or recurring prices you create can be used in the plan parameter of your existing API calls.
Products and prices overview
Prices are a new, core entity within Stripe that works with subscriptions, invoices, and Checkout. Each price is tied to a single Product, and each product can have multiple prices. Different physical goods or levels of service should be represented by products. Pricing of that product should be represented by prices.
Prices define the base price, currency, and—for recurring products—the billing cycle. This allows you to change and add prices without needing to change the details of what you offer. For example, you might have a single “gold” product that has prices for 10 USD/month, 100 USD/year, 9 EUR/month, and 90 EUR/year. Or you might have a blue t-shirt with 20 USD and 15 EUR prices.
Plans and SKUs (client-only) may be used with the new integration wherever Prices are accepted. You can either create a product and price through the API or through the Dashboard.
One-time payments
The client and server integration has the following changes for one-time payments:
Instead of ad-hoc line items (that is, setting the name, amount, and currency), creating a Checkout Session requires creating a product and, usually, a price.
Instead of defining each field on line_items, Checkout uses the underlying product and price objects to determine name, description, amount, currency, and images. You can create products and prices with the API or Dashboard.
Without prices
With prices
line_items.name
product.name
line_items.description (to set a description that is different from the product name)
line_items.description
product.description
line_items.amount
price.unit_amount
price_data.unit_amount (if defined when the Checkout Session is created)
line_items.currency
price.currency
price_data.currency (if defined when the Checkout Session is created)
line_items.images
product.images (displays the first image supplied)
Server-side code for inline items
Previously, you could only create one-time items inline. With prices, you can continue to configure your items inline, but you can also define your prices dynamically with price_data when you create the Checkout Session.
When you create the Checkout Session with price_data, reference an existing product ID with price_data.product, or define your product details dynamically using price_data.product_data. The following example demonstrates the flow for creating a one-time item.
With this new integration, you can create a product and price catalog upfront instead of needing to define the amount, currency, and name each time you create a Checkout Session.
You can either create a product and price with the Prices API or through the Dashboard. You will need the price ID to create the Checkout Session. The following example demonstrates how to create a product and price through API:
The client and server integration has the following changes for recurring payments:
All items are passed into a single line_items field, instead of subscription_data.items.
mode is now required. Set mode=subscription if the session includes any recurring items.
The client-side code remains the same. Existing plans can be used wherever recurring prices are accepted.
Server-side code with plans
Here is a before and after example of creating a Checkout Session with a trial and using an existing plan, which can be used interchangeably with a price. The plan is now passed into line_items instead of subscription_data.items.
Server-side code for recurring price with setup fee
If you have recurring plans with a one-time setup fee, create the product and price representing the one-time fee before creating the Checkout Session. See the mapping table for how the old line_items fields map to the new integration. You can either create a product and price through the Prices API or through the Stripe Dashboard. You can also create the one-time item inline. The following example uses an existing price ID:
Instead of listing items with display_items, the Checkout Session object uses line_items. The line_items field does not render by default as display_items did, but you can include it using expand when creating a Checkout Session:
Since line_items is includable, the checkout.session.completedwebhook response no longer list items by default. The smaller response object enables you to receive your Checkout webhooks faster. You can retrieve items with the new line_items endpoint:
Welcome to the Stripe Shell!
Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Login to your
Stripe account and press Control + Backtick on your keyboard to start managing your Stripe
resources in test mode.
- View supported Stripe commands:
- Find webhook events:
- Listen for webhook events:
- Call Stripe APIs: stripe [api resource] [operation] (e.g. )