Billing
Products and Prices

Products and Prices

Learn how to create and use products and prices.

You can now model your business and product offerings in one place. Products define what you sell and Prices track how much and how often to charge. They can be used for recurring or one-time purchases and support various business structures from tiers to usage based billing. This is a core entity within Stripe that works with subscriptions, invoices, and Checkout.

Prices enable the following use cases:

  • A software provider who charges a one-time setup fee whenever a new subscription is created
  • An eCommerce store who sends a recurring box of goods for $10 / month and wants to allow customers to purchase one-time add-ons
  • A professional services firm that can now create a standard list of services and choose from that list per invoice instead of typing out each line item by hand
  • A non-profit organization who allows donors to define a custom recurring donation amount per customer

1 Create a product

Products are what you sell and you need to create at least one product before you can charge for it. This guide uses a SaaS analytics business as an example. If you only have a few products, you should create and manage them in the Dashboard but you can use the API too. If you set up your business model in the Dashboard in test mode, you can copy each of your products over to live mode using the Copy to live mode button in the product details page.

The basic product for this SaaS business is an analytics dashboard. You can use the examples below to create a product using the API or the Stripe CLI:

curl https://api.stripe.com/v1/products \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d name="Starter Dashboard"
stripe products create \ --name="Starter Dashboard"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' product = Stripe::Product.create({ name: 'Starter Dashboard', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' product = stripe.Product.create( name='Starter Dashboard', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $product = \Stripe\Product::create([ 'name' => 'Starter Dashboard', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; ProductCreateParams params = ProductCreateParams.builder() .setName("Starter Dashboard") .build(); Product product = Product.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const product = await stripe.products.create({ name: 'Starter Dashboard', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.ProductParams{ Name: stripe.String("Starter Dashboard"), } p, _ := product.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new ProductCreateOptions { Name = "Starter Dashboard", }; var service = new ProductService(); var product = service.Create(options);

When customers first sign up, they’re also charged a setup fee which is tracked as a second product:

curl https://api.stripe.com/v1/products \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d name="Starter Setup"
stripe products create \ --name="Dashboard Setup"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' product = Stripe::Product.create({ name: 'Starter Setup', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' product = stripe.Product.create( name='Starter Setup', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $product = \Stripe\Product::create([ 'name' => 'Starter Setup', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; ProductCreateParams params = ProductCreateParams.builder() .setName("Starter Setup") .build(); Product product = Product.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const product = await stripe.products.create({ name: 'Starter Setup', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.ProductParams{ Name: stripe.String("Starter Setup"), } p, _ := product.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new ProductCreateOptions { Name = "Starter Setup", }; var service = new ProductService(); var product = service.Create(options);

2 Create prices

Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the interval if the price is for subscriptions. Like products, if you only have a few prices it’s preferable to manage them in the Dashboard.

The price for the analytics dashboard is 10 USD per month. To create the price and assign it to the product, pass the product ID, unit amount, currency, and interval:

curl https://api.stripe.com/v1/prices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d product="{{PRODUCT_ID}}" \ -d unit_amount=1000 \ -d currency=usd \ -d recurring[interval]=month
stripe prices create \ -d product={{PRODUCT_ID}} \ -d unit_amount=1000 \ -d currency=usd \ -d recurring[interval]=month
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = Stripe::Price.create({ product: '{{PRODUCT_ID}}', unit_amount: 1000, currency: 'usd', recurring: { interval: 'month', }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = stripe.Price.create( product='{{PRODUCT_ID}}', unit_amount=1000, currency='usd', recurring={ 'interval': 'month', }, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $price = \Stripe\Price::create([ 'product' => '{{PRODUCT_ID}}', 'unit_amount' => 1000, 'currency' => 'usd', 'recurring' => [ 'interval' => 'month', ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; PriceCreateParams params = PriceCreateParams.builder() .setProduct("{{PRODUCT_ID}}") .setUnitAmount(1000L) .setCurrency("usd") .setRecurring( PriceCreateParams.Recurring.builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build()) .build(); Price price = Price.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const price = await stripe.prices.create({ product: '{{PRODUCT_ID}}', unit_amount: 1000, currency: 'usd', recurring: { interval: 'month', }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.PriceParams{ Product: stripe.String("{{PRODUCT_ID}}"), UnitAmount: stripe.Int64(1000), Currency: stripe.String("usd"), Recurring: &stripe.PriceRecurringParams{ Interval: stripe.String("month"), }, } p, _ := price.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new PriceCreateOptions { Product = "{{PRODUCT_ID}}", UnitAmount = 1000, Currency = "usd", Recurring = new PriceRecurringOptions { Interval = "month", }, }; var service = new PriceService(); var price = service.Create(options);

The setup fee for new customers is 20 USD. Because this charge is separate from the subscription and is only charged once, you don’t need to pass the interval:

curl https://api.stripe.com/v1/prices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d product="{{PRODUCT_ID}}" \ -d unit_amount=2000 \ -d currency=usd
stripe prices create \ -d product={{PRODUCT_ID}} \ -d unit_amount=2000 \ -d currency=usd
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = Stripe::Price.create({ product: '{{PRODUCT_ID}}', unit_amount: 2000, currency: 'usd', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = stripe.Price.create( product='{{PRODUCT_ID}}', unit_amount=2000, currency='usd', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $price = \Stripe\Price::create([ 'product' => '{{PRODUCT_ID}}', 'unit_amount' => 2000, 'currency' => 'usd', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; PriceCreateParams params = PriceCreateParams.builder() .setProduct("{{PRODUCT_ID}}") .setUnitAmount(2000L) .setCurrency("usd") .build(); Price price = Price.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const price = await stripe.prices.create({ product: '{{PRODUCT_ID}}', unit_amount: 2000, currency: 'usd', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.PriceParams{ Product: stripe.String("{{PRODUCT_ID}}"), UnitAmount: stripe.Int64(2000), Currency: stripe.String("usd"), } p, _ := price.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new PriceCreateOptions { Product = "{{PRODUCT_ID}}", UnitAmount = 2000, Currency = "usd", }; var service = new PriceService(); var price = service.Create(options);

3 Create a customer

Before billing a customer, you need to create a Customer object that you can configure with a name, email, and payment method. You can read more about this in our subscription guide, but a basic example might look like this:

curl https://api.stripe.com/v1/customers \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d email="jenny.rosen@example.com" \ -d payment_method=pm_card_visa \ -d "invoice_settings[default_payment_method]"=pm_card_visa
stripe customers create \ -d email=jenny.rosen@example.com \ -d payment_method=pm_card_visa \ -d invoice_settings[default_payment_method]=pm_card_visa
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' customer = Stripe::Customer.create({ email: 'jenny.rosen@example.com', payment_method: 'pm_card_visa', invoice_settings: { default_payment_method: 'pm_card_visa', }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' customer = stripe.Customer.create( email='jenny.rosen@example.com', payment_method='pm_card_visa', invoice_settings={ 'default_payment_method': 'pm_card_visa', }, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $customer = \Stripe\Customer::create([ 'email' => 'jenny.rosen@example.com', 'payment_method' => 'pm_card_visa', 'invoice_settings' => [ 'default_payment_method' => 'pm_card_visa', ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; CustomerCreateParams params = CustomerCreateParams.builder() .setEmail("jenny.rosen@example.com") .setPaymentMethod("pm_card_visa") .setInvoiceSettings( CustomerCreateParams.InvoiceSettings.builder() .setDefaultPaymentMethod("pm_card_visa") .build()) .build(); Customer customer = Customer.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const customer = await stripe.customers.create({ email: 'jenny.rosen@example.com', payment_method: 'pm_card_visa', invoice_settings: { default_payment_method: 'pm_card_visa', }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.CustomerParams{ Email: stripe.String("jenny.rosen@example.com"), PaymentMethod: stripe.String("pm_card_visa"), InvoiceSettings: &stripe.CustomerInvoiceSettingsParams{ DefaultPaymentMethod: stripe.String("pm_card_visa"), }, } c, _ := customer.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new CustomerCreateOptions { Email = "jenny.rosen@example.com", PaymentMethod = "pm_card_visa", InvoiceSettings = new CustomerInvoiceSettingsOptions { DefaultPaymentMethod = "pm_card_visa", }, }; var service = new CustomerService(); var customer = service.Create(options);

4 Bill the customer

You can bill customers using invoices, subscriptions, or Checkout. Examples for each of these methods is explained below.

Using invoices

If you need to invoice a customer for a one-time charge like your setup fee, create an invoice item by passing the customer ID, currency, and price:

curl https://api.stripe.com/v1/invoiceitems \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}" \ -d price="{{PRICE_ID}}"
stripe invoiceitems create \ --customer={{CUSTOMER_ID}} \ -d price={{PRICE_ID}}
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' invoice_item = Stripe::InvoiceItem.create({ customer: '{{CUSTOMER_ID}}', price: '{{PRICE_ID}}', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' invoice_item = stripe.InvoiceItem.create( customer='{{CUSTOMER_ID}}', price='{{PRICE_ID}}', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $invoice_item = \Stripe\InvoiceItem::create([ 'customer' => '{{CUSTOMER_ID}}', 'price' => '{{PRICE_ID}}', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; InvoiceItemCreateParams params = InvoiceItemCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .setPrice("{{PRICE_ID}}") .build(); InvoiceItem invoiceItem = InvoiceItem.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const invoiceItem = await stripe.invoiceItems.create({ customer: '{{CUSTOMER_ID}}', price: '{{PRICE_ID}}', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.InvoiceItemParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Price: stripe.String("{{PRICE_ID}}"), } i, _ := invoiceitem.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new InvoiceItemCreateOptions { Customer = "{{CUSTOMER_ID}}", Price = "{{PRICE_ID}}", }; var service = new InvoiceItemService(); var invoiceItem = service.Create(options);

You can then create an invoice for your customer and the invoice item will be added automatically:

curl https://api.stripe.com/v1/invoices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}"
stripe invoices create \ --customer={{CUSTOMER_ID}}
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' invoice = Stripe::Invoice.create({ customer: '{{CUSTOMER_ID}}', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' invoice = stripe.Invoice.create( customer='{{CUSTOMER_ID}}', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $invoice = \Stripe\Invoice::create([ 'customer' => '{{CUSTOMER_ID}}', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; InvoiceCreateParams params = InvoiceCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .build(); Invoice invoice = Invoice.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const invoice = await stripe.invoice.create({ customer: '{{CUSTOMER_ID}}', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.InvoiceParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), } i, _ := invoice.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new InvoiceCreateOptions { Customer = "{{CUSTOMER_ID}}", }; var service = new InvoiceService(); var invoice = service.Create(options);

Using Subscriptions

To create a subscription, combine a recurring price with a customer. If you would like to bundle one-time purchases with a recurring purchase, you can do so by using add_invoice_items:

curl https://api.stripe.com/v1/subscriptions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}" \ -d items[0][price]={{RECURRING_PRICE_ID}} \ -d add_invoice_items[0][price]={{PRICE_ID}}
stripe subscriptions create \ -d customer={{CUSTOMER_ID}} \ -d items[0][price]={{RECURRING_PRICE_ID}} \ -d add_invoice_items[0][price]={{PRICE_ID}}
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.create({ customer: '{{CUSTOMER_ID}}', items: [{ price: '{{RECURRING_PRICE_ID}}', }], add_invoice_items: [{ price: '{{PRICE_ID}}', }], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.create( customer='{{CUSTOMER_ID}}', items=[{ 'price': '{{RECURRING_PRICE_ID}}', }], add_invoice_items=[{ 'price': '{{PRICE_ID}}', }], )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::create([ 'customer' => '{{CUSTOMER_ID}}', 'items' => [[ 'price' => '{{RECURRING_PRICE_ID}}', ]], 'add_invoice_items' => [[ 'price' => '{{PRICE_ID}}', ]], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SubscriptionCreateParams params = SubscriptionCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .addItem( SubscriptionCreateParams.Item.builder() .setPrice("{{RECURRING_PRICE_ID}}") .build()) .addInvoiceItem( SubscriptionCreateParams.AddInvoiceItem.builder() .setPrice("{{PRICE_ID}}") .build()) .build(); Subscription subscription = Subscription.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.create({ customer: '{{CUSTOMER_ID}}', items: [{ price: '{{RECURRING_PRICE_ID}}', }], add_invoice_items: [{ price: '{{PRICE_ID}}', }], });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SubscriptionParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Items: []*stripe.SubscriptionItemsParams{ &stripe.SubscriptionItemsParams{ Price: stripe.String("{{RECURRING_PRICE_ID}}"), }, }, AddInvoiceItems: []*stripe.SubscriptionAddInvoiceItemParams{ &stripe.SubscriptionAddInvoiceItemParams{ Price: stripe.String("{{PRICE_ID}}"), }, }, } s, _ := sub.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SubscriptionCreateOptions { Customer = "{{CUSTOMER_ID}}", Items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { Price = "{{RECURRING_PRICE_ID}}", }, }, AddInvoiceItems = new List<SubscriptionAddInvoiceItemOptions> { new SubscriptionAddInvoiceItemOptions { Price = "{{PRICE_ID}}", }, }, }; var service = new SubscriptionService(); var subscription = service.Create(options);

This creates a 10 USD/month subscription for the prices analytics dashboard and charges a one-time set up fee of 20 USD. The customer will be charged 30 USD for their first month and then 10 USD each month after that.

You can also use add_invoice_items when updating subscriptions, including with pending updates. All invoice items configured in add_invoice_items will be created immediately. If the update results in an invoice, the invoice items will be included on that invoice. Otherwise, the invoice items will remain pending on the customer and will be picked up by the next invoice. If your business charges additional fees when upgrading to a new service, you would pass the price for that fee in add_invoice_items.

Using subscription schedules

Some of your customers may want to schedule their analytics dashboard service to start in the future or only sign up for a year of service at a time. Using subscription schedules, you can configure phases with a recurring price to start in the future and/or end on a particular date. If you would like to bundle one-time purchases with the beginning of a phase, you can do so by using add_invoice_items on a phase:

curl https://api.stripe.com/v1/subscription_schedules \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}" \ -d start_date=1604188800 \ -d phases[0][items][0][price]={{RECURRING_PRICE_ID}} \ -d phases[0][add_invoice_items][0][price]={{PRICE_ID}}
stripe subscription_schedules create \ -d customer={{CUSTOMER_ID}} \ -d start_date=1604188800 \ -d phases[0][items][0][price]={{RECURRING_PRICE_ID}} \ -d phases[0][add_invoice_items][0][price]={{PRICE_ID}}
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' schedule = Stripe::SubscriptionSchedule.create({ customer: '{{CUSTOMER_ID}}', start_date: 1604188800, phases: [{ items: [{ price: '{{RECURRING_PRICE_ID}}', }], add_invoice_items: [{ price: '{{PRICE_ID}}', }], }], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' schedule = stripe.SubscriptionSchedule.create( customer='{{CUSTOMER_ID}}', start_date=1604188800, phases=[{ 'items': [{ 'price': '{{RECURRING_PRICE_ID}}', }], 'add_invoice_items': [{ 'price': '{{PRICE_ID}}', }], }], )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $schedule = \Stripe\SubscriptionSchedule::create([ 'customer' => '{{CUSTOMER_ID}}', 'start_date' => 1604188800, 'phases' => [ [ 'items' => [ [ 'price' => '{{RECURRING_PRICE_ID}}', ], ], 'add_invoice_items' => [ [ 'price' => '{{PRICE_ID}}', ], ], ], ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SubscriptionScheduleCreateParams params = SubscriptionScheduleCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .setStartDate(1604188800L) .addPhase( SubscriptionScheduleCreateParams.Phase.builder() .addItem( SubscriptionScheduleCreateParams.Phase.Item.builder() .setPrice("{{RECURRING_PRICE_ID}}") .build()) .addInvoiceItem( SubscriptionScheduleCreateParams.Phase.AddInvoiceItem.builder() .setPrice("{{PRICE_ID}}") .build()) .build()) .build(); SubscriptionSchedule schedule = SubscriptionSchedule.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const schedule = await stripe.subscriptionSchedules.create({ customer: '{{CUSTOMER_ID}}', start_date: 1604188800, phases: [{ items: [{ price: '{{RECURRING_PRICE_ID}}', }], add_invoice_items: [{ price: '{{PRICE_ID}}', }], }], });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SubscriptionScheduleParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), StartDate: stripe.Int64(1604188800), Phases: []*stripe.SubscriptionSchedulePhaseParams{ { Items: []*stripe.SubscriptionSchedulePhaseItemParams{ { Price: stripe.String("{{RECURRING_PRICE_ID}}"), }, }, AddInvoiceItems: []*stripe.SubscriptionSchedulePhaseAddInvoiceItemParams{ { Price: stripe.String("{{PRICE_ID}}"), }, }, }, }, } s, _ := subschedule.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SubscriptionScheduleCreateOptions { Customer = "{{CUSTOMER_ID}}", StartDate = 1604188800, Phases = new List<SubscriptionSchedulePhaseOptions> { new SubscriptionSchedulePhaseOptions { Items = new List<SubscriptionSchedulePhaseItemOptions> { new SubscriptionSchedulePhaseItemOptions { Price = "{{RECURRING_PRICE_ID}}", }, }, AddInvoiceItems = new List<SubscriptionSchedulePhaseAddInvoiceItemOptions> { new SubscriptionSchedulePhaseAddInvoiceItemOptions { Price = "{{PRICE_ID}}", }, }, }, }, }; var service = new SubscriptionScheduleService(); var schedule = service.Create(options);

This will schedule a 10 USD/month subscription to begin in the future and its first invoice will include a one-time fee of 20 USD.

If add_invoice_items is configured on future phases, invoice items will not be generated until that phase begins. If you set add_invoice_items on the current phase, invoice items will be generated immediately.

Using Checkout

Checkout creates a secure, Stripe-hosted payment page that lets you collect payments quickly. As a busy entrepreneur, you focus on improving your analytics dashboard product rather than your checkout flow.

A Checkout Session represents the details of your customer’s intent to purchase. You create a session when your customer wants to pay for something. After redirecting your customer to a Checkout Session, Stripe presents a payment form where your customer can complete their purchase. Once your customer has completed a purchase, they are redirected back to your site.

Checkout supports recurring and one-time purchases using prices:

curl https://api.stripe.com/v1/checkout/sessions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}" \ -d payment_method_types[]=card \ -d line_items[0][price]={{PRICE_ID_1}} \ -d line_items[0][quantity]=1 \ -d line_items[1][price]={{PRICE_ID_2}} \ -d line_items[1][quantity]=1 \ -d success_url="https://example.com/success" \ -d cancel_url="https://example.com/cancel"
stripe checkout sessions create \ -d customer={{CUSTOMER_ID}} \ -d payment_method_types[]=card \ -d line_items[0][price]={{PRICE_ID_1}} \ -d line_items[0][quantity]=1 \ -d line_items[1][price]={{PRICE_ID_2}} \ -d line_items[1][quantity]=1 \ -d success_url="https://example.com/success" \ -d cancel_url="https://example.com/cancel"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = Stripe::Checkout::Session.create({ customer: '{{CUSTOMER_ID}}', payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID_1}}', quantity: 1, }, { price: '{{PRICE_ID_2}}', quantity: 1, }], success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' session = stripe.checkout.Session.create( customer='{{CUSTOMER_ID}}', payment_method_types=['card'], line_items=[{ 'price': '{{PRICE_ID_1}}', 'quantity': 1, }, { 'price': '{{PRICE_ID_2}}', 'quantity': 1, }], success_url='https://example.com/success', cancel_url='https://example.com/cancel', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $session = \Stripe\Checkout\Session::create([ 'customer' => '{{CUSTOMER_ID}}', 'payment_method_types' => ['card'], 'line_items' => [[ 'price' => '{{PRICE_ID_1}}', 'quantity' => 1, ], [ 'price' => '{{PRICE_ID_2}}', 'quantity' => 1, ]], 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SessionCreateParams params = SessionCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .setPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD) .setMode(SessionCreateParams.Mode.PAYMENT) .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID_1}}") .setQuantity(1) .build()) .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID_2}}") .setQuantity(1) .build()) .setSuccessUrl("https://example.com/success") .setCancelUrl("https://example.com/cancel") .build(); Session session = Session.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const session = await stripe.checkout.sessions.create({ customer: '{{CUSTOMER_ID}}', payment_method_types: ['card'], line_items: [{ price: '{{PRICE_ID_1}}', quantity: 1, }, { price: '{{PRICE_ID_2}}', quantity: 1, }], success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.CheckoutSessionParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), PaymentMethodTypes: stripe.StringSlice([]string{ "card", }), LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID_1}}"), Quantity: stripe.Int64(1), }, &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID_2}}"), Quantity: stripe.Int64(1), }, }, SuccessURL: stripe.String("https://example.com/success"), CancelURL: stripe.String("https://example.com/cancel"), } s, _ := session.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SessionCreateOptions { Customer = "{{CUSTOMER_ID}}", PaymentMethodTypes = new List<string> { "card", }, LineItems = new List<SessionLineItemOptions> { new SessionLineItemOptions { Price = "{{PRICE_ID_1}}", Quantity = 1, }, new SessionLineItemOptions { Price = "{{PRICE_ID_2}}", Quantity = 1, }, }, SuccessUrl = "https://example.com/success", CancelUrl = "https://example.com/cancel", }; var service = new SessionService(); var session = service.Create(options);

Similar to the subscriptions example, this Checkout session creates a 10 USD/month subscription and charges a one-time fee of 20 USD. The customer will be charged 30 USD for their first month and then 10 USD each month after that.

Ad-hoc prices

In some cases, you might want to use a custom price that has not been preconfigured. For example, donation sites often allow customers to specify the amount they want to donate. In this case, you’re offering a limited time promotion to “choose what you pay” for your analytics dashboard. You can pass in price_data instead of a price ID. For example, subscribing a customer to a monthly subscription with a custom price might look like this:

curl https://api.stripe.com/v1/subscriptions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer="{{CUSTOMER_ID}}" \ -d items[0][price_data][unit_amount]=5000 \ -d items[0][price_data][currency]=usd \ -d items[0][price_data][product]={{PRODUCT_ID}} \ -d items[0][price_data][recurring][interval]=month
stripe subscriptions create \ -d customer={{CUSTOMER_ID}} \ -d items[0][price_data][unit_amount]=5000 \ -d items[0][price_data][currency]=usd \ -d items[0][price_data][product]={{PRODUCT_ID}} \ -d items[0][price_data][recurring][interval]=month
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.create({ customer: '{{CUSTOMER_ID}}', items: [{ price_data: { unit_amount: 5000, currency: 'usd', product: '{{PRODUCT_ID}}', recurring: { interval: 'month', }, }, }], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.create( customer='{{CUSTOMER_ID}}', items=[{ 'price_data': { 'unit_amount': 5000, 'currency': 'usd', 'product': '{{PRODUCT_ID}}', 'recurring': { 'interval': 'month', }, }, }], )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::create([ 'customer' => '{{CUSTOMER_ID}}', 'items' => [[ 'price_data' => [ 'unit_amount' => 5000, 'currency' => 'usd', 'product' => '{{PRODUCT_ID}}', 'recurring' => [ 'interval' => 'month', ], ], ]], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SubscriptionCreateParams params = SubscriptionCreateParams.builder() .setCustomer("{{CUSTOMER_ID}}") .addItem( SubscriptionCreateParams.Item.builder() .setPriceData( SubscriptionCreateParams.PriceData.builder() .setUnitAmount(5000L) .setCurrency("usd") .setProduct("{{PRODUCT_ID}}") .setRecurring( SubscriptionCreateParams.Recurring.builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build()) .build()) .build()) .build(); Subscription subscription = Subscription.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.create({ customer: '{{CUSTOMER_ID}}', items: [{ price_data: { unit_amount: 5000, currency: 'usd', product: '{{PRODUCT_ID}}', recurring: { interval: 'month', }, }, }], });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SubscriptionParams{ Customer: stripe.String("{{CUSTOMER_ID}}"), Items: []*stripe.SubscriptionItemsParams{ &stripe.SubscriptionItemsParams{ PriceData: &stripe.PriceDataParams{ UnitAmount: stripe.Int64(5000), Currency: stripe.String("usd"), Product: stripe.String("{{PRODUCT_ID}}"), Recurring: &stripe.RecurringParams{ Interval: stripe.String("month"), }, }, }, }, } s, _ := sub.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SubscriptionCreateOptions { Customer = "{{CUSTOMER_ID}}", Items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { PriceData = new SubscriptionItemPriceDataOptions { UnitAmount = 5000, Currency = "usd", Product = "{{PRODUCT_ID}}", Recurring = new SubscriptionItemPriceDataRecurringOptions { Interval = "month", }, }, }, }, }; var service = new SubscriptionService(); var subscription = service.Create(options);

This creates an ad-hoc active=false recurring price of 50 USD for the Starter Dashboard product and creates a subscription with the new price. These ad-hoc prices cannot be updated once they have been created.

You can also pass price_data into the Checkout, Invoice Items, and Subscription Schedule APIs.

Optional Managing prices

Most businesses display pricing information on their website. If these prices are hardcoded and you want to change them, the process is often manual and requires you to deploy new code. To better manage these scenarios, you can use the lookup_key attribute on the Price object. This key allows you to:

  • Render different prices in your frontend.
  • Use the rendered price to bill customers.

You can pass a lookup_key when you create a price:

curl https://api.stripe.com/v1/prices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d product="{{PRODUCT_ID}}" \ -d unit_amount=1000 \ -d currency=usd \ -d "recurring[interval]"=month \ -d lookup_key=standard_monthly
stripe prices create \ -d product={{PRODUCT_ID}} \ -d unit_amount=1000 \ -d currency=usd \ -d recurring[interval]=month \ -d lookup_key=standard_monthly
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = Stripe::Price.create({ product: '{{PRODUCT_ID}}', unit_amount: 1000, currency: 'usd', recurring: { interval: 'month', }, lookup_key: 'standard_monthly', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = stripe.Price.create( product='{{PRODUCT_ID}}', unit_amount=1000, currency='usd', recurring={ 'interval': 'month', }, lookup_key='standard_monthly', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $price = \Stripe\Price::create([ 'product' => '{{PRODUCT_ID}}', 'unit_amount' => 1000, 'currency' => 'usd', 'recurring' => [ 'interval' => 'month', ], 'lookup_key' => 'standard_monthly', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; PriceCreateParams params = PriceCreateParams.builder() .setProduct("{{PRODUCT_ID}}") .setUnitAmount(1000L) .setCurrency("usd") .setRecurring( PriceCreateParams.Recurring.builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build()) .setLookupKey("standard_monthly") .build(); Price price = Price.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const price = await stripe.prices.create({ product: '{{PRODUCT_ID}}', unit_amount: 1000, currency: 'usd', recurring: { interval: 'month', }, lookup_key: 'standard_monthly', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.PriceParams{ Product: stripe.String("{{PRODUCT_ID}}"), UnitAmount: stripe.Int64(1000), Currency: stripe.String("usd"), Recurring: &stripe.PriceRecurringParams{ Interval: stripe.String("month"), }, LookupKey: stripe.String("standard_monthly"), } p, _ := price.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new PriceCreateOptions { Product = "{{PRODUCT_ID}}", UnitAmount = 1000, Currency = "usd", Recurring = new PriceRecurringOptions { Interval = "month", }, LookupKey = "standard_monthly", }; var service = new PriceService(); var price = service.Create(options);

Instead of harcoding text like $10/month on your pricing page and using a price ID on your backend, you can query for the price using the standard_monthly key and then render that in your frontend:

curl https://api.stripe.com/v1/prices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d lookup_keys[]=standard_monthly \ -G
stripe prices retrieve \ -d lookup_keys[]=standard_monthly
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' prices = Stripe::Price.list({ lookup_keys: ['standard_monthly'], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' prices = stripe.Price.list( lookup_keys=['standard_monthly'], )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $prices = \Stripe\Price::list([ 'lookup_keys' => ['standard_monthly'], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; PriceListParams params = PriceListParams.builder() .addLookupKey("standard_monthly") .build(); PriceCollection prices = Price.list(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const prices = await stripe.prices.list({ lookup_keys: ['standard_monthly'], });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.PriceParams{ LookupKeys: []*stripe.String{ &stripe.String("standard_monthly"), }, } p, _ := price.List(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new PriceListOptions { LookupKeys = new List<String> { "standard_monthly", }, }; var service = new PriceService(); var prices = service.List(options);

When a customer clicks your subscribe or pay button, you pass the price from the GET request above into the Subscriptions API.

Now that you can render different prices, let’s say you want to start charging new users 20 USD/month rather than 10 USD/month. To update your price for new customers, you just need to create a new price and transfer the lookup key to that new price using transfer_lookup_key=true:

curl https://api.stripe.com/v1/prices \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d product="{{PRODUCT_ID}}" \ -d unit_amount=2000 \ -d currency=usd \ -d "recurring[interval]"=month \ -d lookup_key=standard_monthly \ -d transfer_lookup_key=true
stripe prices create \ -d product={{PRODUCT_ID}} \ -d unit_amount=2000 \ -d currency=usd \ -d recurring[interval]=month \ -d lookup_key=standard_monthly \ -d transfer_lookup_key=true
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = Stripe::Price.create({ product: '{{PRODUCT_ID}}', unit_amount: 2000, currency: 'usd', recurring: { interval: 'month', }, lookup_key: 'standard_monthly', transfer_lookup_key: true, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' price = stripe.Price.create( product='{{PRODUCT_ID}}', unit_amount=2000, currency='usd', recurring={ 'interval': 'month', }, lookup_key='standard_monthly', transfer_lookup_key=True, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $price = \Stripe\Price::create([ 'product' => '{{PRODUCT_ID}}', 'unit_amount' => 2000, 'currency' => 'usd', 'recurring' => [ 'interval' => 'month', ], 'lookup_key' => 'standard_monthly', 'transfer_lookup_key' => true, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; PriceCreateParams params = PriceCreateParams.builder() .setProduct("{{PRODUCT_ID}}") .setUnitAmount(2000L) .setCurrency("usd") .setRecurring( PriceCreateParams.Recurring.builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build()) .setLookupKey("standard_monthly") .setTransferLookupKey(true) .build(); Price price = Price.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const price = await stripe.prices.create({ product: '{{PRODUCT_ID}}', unit_amount: 2000, currency: 'usd', recurring: { interval: 'month', }, lookup_key: 'standard_monthly', transfer_lookup_key: true, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.PriceParams{ Product: stripe.String("{{PRODUCT_ID}}"), UnitAmount: stripe.Int64(2000), Currency: stripe.String("usd"), Recurring: &stripe.PriceRecurringParams{ Interval: stripe.String("month"), }, LookupKey: stripe.String("standard_monthly"), TransferLookupKey: stripe.Bool(true), } p, _ := price.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new PriceCreateOptions { Product = "{{PRODUCT_ID}}", UnitAmount = 2000, Currency = "usd", Recurring = new PriceRecurringOptions { Interval = "month", }, LookupKey = "standard_monthly", TransferLookupKey = true, }; var service = new PriceService(); var price = service.Create(options);
Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.