# Let customers decide what to pay Accept tips and donations, or sell pay-what-you-want products and services. # Stripe-hosted page > This is a Stripe-hosted page for when payment-ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/checkout/pay-what-you-want?payment-ui=stripe-hosted. If you maintain your product catalog outside of Stripe, you might want to use [inline pricing](https://docs.stripe.com/products-prices/how-products-and-prices-work.md#inline-pricing). With inline pricing, you set inline prices for products or services when you create a Checkout Session. You can also use inline pricing to collect donations. However, unlike pay-what-you-want pricing, you can’t reuse or update inline prices, and they’re only available through the API. You can use this feature to collect a tip for a service provided, accept donations for a cause, or give your customers the option to pay what they want for your product or service. Go to Stripe Support to learn more about Stripe’s [requirements for accepting tips or donations](https://support.stripe.com/questions/requirements-for-accepting-tips-or-donations). Pay-what-you-want payments have the following limitations: - You can’t add any other line items and the quantity can only be 1. - You can’t use promotion codes or discounts with them. - They don’t support recurring payments or optional items. ![Custom amounts](https://b.stripecdn.com/docs-statics-srv/assets/custom-amount.4e76797d1a181222160b2754643e4ee1.png) ## Set up your product catalog Stripe Checkout uses *Products* (Products represent what your business sells—whether that's a good or a service) and *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) to structure pay-what-you-want payments. In the following example, Togethere is selling tickets to a fundraising dinner and wants to allow their customers to pay what they want for their tickets. #### Dashboard To create a pay-what-you-want model on Stripe through the Dashboard, complete these steps: 1. Create the `Fundraising dinner` product. 1. Go to **More** > **Product catalog**. 1. Click **+Add product**. 1. Enter the **Name** of the product (`Fundraising dinner`). 1. (Optional) Add a **Description**. The customer sees the description at checkout. 1. Create the price for the `Fundraising dinner` product: 1. Click on **More pricing options** at the bottom. 1. Select **One-off**. 1. Select **Customer chooses price** in the **Choose your pricing model** dropdown. 1. (Optional) Add a suggested price. 1. (Optional) Specify limits that the customer can input. 1. Click **Next** and **Add product**. #### API To create a pay-what-you-want pricing model on Stripe through the [Products](https://docs.stripe.com/api/products.md) and [Prices](https://docs.stripe.com/api/prices.md) APIs: 1. Create the `Fundraising dinner` product. ```curl curl https://api.stripe.com/v1/products \ -u "<>:" \ -d name="Fundraising dinner" ``` ```cli stripe products create \ --name="Fundraising dinner" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' product = Stripe::Product.create({name: 'Fundraising dinner'}) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") product = client.v1.products.create({name: 'Fundraising dinner'}) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" product = stripe.Product.create(name="Fundraising dinner") ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. product = client.v1.products.create({"name": "Fundraising dinner"}) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $product = $stripe->products->create(['name' => 'Fundraising dinner']); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; ProductCreateParams params = ProductCreateParams.builder().setName("Fundraising dinner").build(); Product product = Product.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); ProductCreateParams params = ProductCreateParams.builder().setName("Fundraising dinner").build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Product product = client.v1().products().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const product = await stripe.products.create({ name: 'Fundraising dinner', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.ProductParams{Name: stripe.String("Fundraising dinner")} result, err := product.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.ProductCreateParams{Name: stripe.String("Fundraising dinner")} result, err := sc.V1Products.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new ProductCreateOptions { Name = "Fundraising dinner" }; var service = new ProductService(); Product product = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new ProductCreateOptions { Name = "Fundraising dinner" }; var client = new StripeClient("<>"); var service = client.V1.Products; Product product = service.Create(options); ``` 1. Create a price for the customer input. You can optionally specify a `preset` price, which is the initial amount on the payment page that your customer can update. You can also set a `minimum` and `maximum` bound for the price. ```curl curl https://api.stripe.com/v1/prices \ -u "<>:" \ -d currency=usd \ -d "custom_unit_amount[enabled]"=true \ -d product="{{PRODUCT_ID}}" ``` ```cli stripe prices create \ --currency=usd \ -d "custom_unit_amount[enabled]"=true \ --product="{{PRODUCT_ID}}" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' price = Stripe::Price.create({ currency: 'usd', custom_unit_amount: {enabled: true}, product: '{{PRODUCT_ID}}', }) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") price = client.v1.prices.create({ currency: 'usd', custom_unit_amount: {enabled: true}, product: '{{PRODUCT_ID}}', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" price = stripe.Price.create( currency="usd", custom_unit_amount={"enabled": True}, product="{{PRODUCT_ID}}", ) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. price = client.v1.prices.create({ "currency": "usd", "custom_unit_amount": {"enabled": True}, "product": "{{PRODUCT_ID}}", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $price = $stripe->prices->create([ 'currency' => 'usd', 'custom_unit_amount' => ['enabled' => true], 'product' => '{{PRODUCT_ID}}', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; PriceCreateParams params = PriceCreateParams.builder() .setCurrency("usd") .setCustomUnitAmount( PriceCreateParams.CustomUnitAmount.builder().setEnabled(true).build() ) .setProduct("{{PRODUCT_ID}}") .build(); Price price = Price.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); PriceCreateParams params = PriceCreateParams.builder() .setCurrency("usd") .setCustomUnitAmount( PriceCreateParams.CustomUnitAmount.builder().setEnabled(true).build() ) .setProduct("{{PRODUCT_ID}}") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Price price = client.v1().prices().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const price = await stripe.prices.create({ currency: 'usd', custom_unit_amount: { enabled: true, }, product: '{{PRODUCT_ID}}', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.PriceParams{ Currency: stripe.String(stripe.CurrencyUSD), CustomUnitAmount: &stripe.PriceCustomUnitAmountParams{Enabled: stripe.Bool(true)}, Product: stripe.String("{{PRODUCT_ID}}"), } result, err := price.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.PriceCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), CustomUnitAmount: &stripe.PriceCreateCustomUnitAmountParams{Enabled: stripe.Bool(true)}, Product: stripe.String("{{PRODUCT_ID}}"), } result, err := sc.V1Prices.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new PriceCreateOptions { Currency = "usd", CustomUnitAmount = new PriceCustomUnitAmountOptions { Enabled = true }, Product = "{{PRODUCT_ID}}", }; var service = new PriceService(); Price price = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new PriceCreateOptions { Currency = "usd", CustomUnitAmount = new PriceCustomUnitAmountOptions { Enabled = true }, Product = "{{PRODUCT_ID}}", }; var client = new StripeClient("<>"); var service = client.V1.Prices; Price price = service.Create(options); ``` ## Create a Checkout Session To enable customers to change the amount on the payment page, use the price ID when you create a Checkout Session. If you select **Customer chooses price** as your pricing model, you can’t add any other line items and the quantity can only be 1. ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ --data-urlencode cancel_url="https://example.com" \ -d "line_items[0][price]"="{{PRICE_ID}}" \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ --data-urlencode success_url="https://example.com/success" ``` ```cli stripe checkout sessions create \ --cancel-url="https://example.com" \ -d "line_items[0][price]"="{{PRICE_ID}}" \ -d "line_items[0][quantity]"=1 \ --mode=payment \ --success-url="https://example.com/success" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ cancel_url: 'https://example.com', line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', success_url: 'https://example.com/success', }) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") session = client.v1.checkout.sessions.create({ cancel_url: 'https://example.com', line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', success_url: 'https://example.com/success', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( cancel_url="https://example.com", line_items=[{"price": "{{PRICE_ID}}", "quantity": 1}], mode="payment", success_url="https://example.com/success", ) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. session = client.v1.checkout.sessions.create({ "cancel_url": "https://example.com", "line_items": [{"price": "{{PRICE_ID}}", "quantity": 1}], "mode": "payment", "success_url": "https://example.com/success", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'cancel_url' => 'https://example.com', 'line_items' => [ [ 'price' => '{{PRICE_ID}}', 'quantity' => 1, ], ], 'mode' => 'payment', 'success_url' => 'https://example.com/success', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .setCancelUrl("https://example.com") .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID}}") .setQuantity(1L) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .build(); Session session = Session.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); SessionCreateParams params = SessionCreateParams.builder() .setCancelUrl("https://example.com") .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID}}") .setQuantity(1L) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setSuccessUrl("https://example.com/success") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Session session = client.v1().checkout().sessions().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ cancel_url: 'https://example.com', line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', success_url: 'https://example.com/success', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ CancelURL: stripe.String("https://example.com"), LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), }, }, Mode: stripe.String(stripe.CheckoutSessionModePayment), SuccessURL: stripe.String("https://example.com/success"), } result, err := session.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.CheckoutSessionCreateParams{ CancelURL: stripe.String("https://example.com"), LineItems: []*stripe.CheckoutSessionCreateLineItemParams{ &stripe.CheckoutSessionCreateLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), }, }, Mode: stripe.String(stripe.CheckoutSessionModePayment), SuccessURL: stripe.String("https://example.com/success"), } result, err := sc.V1CheckoutSessions.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { CancelUrl = "https://example.com", LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, }, }, Mode = "payment", SuccessUrl = "https://example.com/success", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Checkout.SessionCreateOptions { CancelUrl = "https://example.com", LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, }, }, Mode = "payment", SuccessUrl = "https://example.com/success", }; var client = new StripeClient("<>"); var service = client.V1.Checkout.Sessions; Stripe.Checkout.Session session = service.Create(options); ``` # Embedded form > This is a Embedded form for when payment-ui is embedded-form. View the full page at https://docs.stripe.com/payments/checkout/pay-what-you-want?payment-ui=embedded-form. If you maintain your product catalog outside of Stripe, you might want to use [inline pricing](https://docs.stripe.com/products-prices/how-products-and-prices-work.md#inline-pricing). With inline pricing, you set inline prices for products or services when you create a Checkout Session. You can also use inline pricing to collect donations. However, unlike pay-what-you-want pricing, you can’t reuse or update inline prices, and they’re only available through the API. You can use this feature to collect a tip for a service provided, accept donations for a cause, or give your customers the option to pay what they want for your product or service. Go to Stripe Support to learn more about Stripe’s [requirements for accepting tips or donations](https://support.stripe.com/questions/requirements-for-accepting-tips-or-donations). Pay-what-you-want payments have the following limitations: - You can’t add any other line items and the quantity can only be 1. - You can’t use promotion codes or discounts with them. - They don’t support recurring payments or optional items. ![Custom amounts](https://b.stripecdn.com/docs-statics-srv/assets/custom-amount.4e76797d1a181222160b2754643e4ee1.png) ## Set up your product catalog Stripe Checkout uses *Products* (Products represent what your business sells—whether that's a good or a service) and *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) to structure pay-what-you-want payments. In the following example, Togethere is selling tickets to a fundraising dinner and wants to allow their customers to pay what they want for their tickets. #### Dashboard To create a pay-what-you-want model on Stripe through the Dashboard, complete these steps: 1. Create the `Fundraising dinner` product. 1. Go to **More** > **Product catalog**. 1. Click **+Add product**. 1. Enter the **Name** of the product (`Fundraising dinner`). 1. (Optional) Add a **Description**. The customer sees the description at checkout. 1. Create the price for the `Fundraising dinner` product: 1. Click on **More pricing options** at the bottom. 1. Select **One-off**. 1. Select **Customer chooses price** in the **Choose your pricing model** dropdown. 1. (Optional) Add a suggested price. 1. (Optional) Specify limits that the customer can input. 1. Click **Next** and **Add product**. #### API To create a pay-what-you-want pricing model on Stripe through the [Products](https://docs.stripe.com/api/products.md) and [Prices](https://docs.stripe.com/api/prices.md) APIs: 1. Create the `Fundraising dinner` product. ```curl curl https://api.stripe.com/v1/products \ -u "<>:" \ -d name="Fundraising dinner" ``` ```cli stripe products create \ --name="Fundraising dinner" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' product = Stripe::Product.create({name: 'Fundraising dinner'}) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") product = client.v1.products.create({name: 'Fundraising dinner'}) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" product = stripe.Product.create(name="Fundraising dinner") ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. product = client.v1.products.create({"name": "Fundraising dinner"}) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $product = $stripe->products->create(['name' => 'Fundraising dinner']); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; ProductCreateParams params = ProductCreateParams.builder().setName("Fundraising dinner").build(); Product product = Product.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); ProductCreateParams params = ProductCreateParams.builder().setName("Fundraising dinner").build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Product product = client.v1().products().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const product = await stripe.products.create({ name: 'Fundraising dinner', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.ProductParams{Name: stripe.String("Fundraising dinner")} result, err := product.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.ProductCreateParams{Name: stripe.String("Fundraising dinner")} result, err := sc.V1Products.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new ProductCreateOptions { Name = "Fundraising dinner" }; var service = new ProductService(); Product product = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new ProductCreateOptions { Name = "Fundraising dinner" }; var client = new StripeClient("<>"); var service = client.V1.Products; Product product = service.Create(options); ``` 1. Create a price for the customer input. You can optionally specify a `preset` price, which is the initial amount on the payment page that your customer can update. You can also set a `minimum` and `maximum` bound for the price. ```curl curl https://api.stripe.com/v1/prices \ -u "<>:" \ -d currency=usd \ -d "custom_unit_amount[enabled]"=true \ -d product="{{PRODUCT_ID}}" ``` ```cli stripe prices create \ --currency=usd \ -d "custom_unit_amount[enabled]"=true \ --product="{{PRODUCT_ID}}" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' price = Stripe::Price.create({ currency: 'usd', custom_unit_amount: {enabled: true}, product: '{{PRODUCT_ID}}', }) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") price = client.v1.prices.create({ currency: 'usd', custom_unit_amount: {enabled: true}, product: '{{PRODUCT_ID}}', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" price = stripe.Price.create( currency="usd", custom_unit_amount={"enabled": True}, product="{{PRODUCT_ID}}", ) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. price = client.v1.prices.create({ "currency": "usd", "custom_unit_amount": {"enabled": True}, "product": "{{PRODUCT_ID}}", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $price = $stripe->prices->create([ 'currency' => 'usd', 'custom_unit_amount' => ['enabled' => true], 'product' => '{{PRODUCT_ID}}', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; PriceCreateParams params = PriceCreateParams.builder() .setCurrency("usd") .setCustomUnitAmount( PriceCreateParams.CustomUnitAmount.builder().setEnabled(true).build() ) .setProduct("{{PRODUCT_ID}}") .build(); Price price = Price.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); PriceCreateParams params = PriceCreateParams.builder() .setCurrency("usd") .setCustomUnitAmount( PriceCreateParams.CustomUnitAmount.builder().setEnabled(true).build() ) .setProduct("{{PRODUCT_ID}}") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Price price = client.v1().prices().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const price = await stripe.prices.create({ currency: 'usd', custom_unit_amount: { enabled: true, }, product: '{{PRODUCT_ID}}', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.PriceParams{ Currency: stripe.String(stripe.CurrencyUSD), CustomUnitAmount: &stripe.PriceCustomUnitAmountParams{Enabled: stripe.Bool(true)}, Product: stripe.String("{{PRODUCT_ID}}"), } result, err := price.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.PriceCreateParams{ Currency: stripe.String(stripe.CurrencyUSD), CustomUnitAmount: &stripe.PriceCreateCustomUnitAmountParams{Enabled: stripe.Bool(true)}, Product: stripe.String("{{PRODUCT_ID}}"), } result, err := sc.V1Prices.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new PriceCreateOptions { Currency = "usd", CustomUnitAmount = new PriceCustomUnitAmountOptions { Enabled = true }, Product = "{{PRODUCT_ID}}", }; var service = new PriceService(); Price price = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new PriceCreateOptions { Currency = "usd", CustomUnitAmount = new PriceCustomUnitAmountOptions { Enabled = true }, Product = "{{PRODUCT_ID}}", }; var client = new StripeClient("<>"); var service = client.V1.Prices; Price price = service.Create(options); ``` ## Create a Checkout Session To enable customers to change the amount on the payment page, use the price ID when you create a Checkout Session. If you select **Customer chooses price** as your pricing model, you can’t add any other line items and the quantity can only be 1. ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price]"="{{PRICE_ID}}" \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d ui_mode=embedded \ --data-urlencode return_url="https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}" ``` ```cli stripe checkout sessions create \ -d "line_items[0][price]"="{{PRICE_ID}}" \ -d "line_items[0][quantity]"=1 \ --mode=payment \ --ui-mode=embedded \ --return-url="https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}" ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key = '<>' session = Stripe::Checkout::Session.create({ line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}', }) ``` ```ruby # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = Stripe::StripeClient.new("<>") session = client.v1.checkout.sessions.create({ line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}', }) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys import stripe stripe.api_key = "<>" session = stripe.checkout.Session.create( line_items=[{"price": "{{PRICE_ID}}", "quantity": 1}], mode="payment", ui_mode="embedded", return_url="https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}", ) ``` ```python # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys client = StripeClient("<>") # For SDK versions 12.4.0 or lower, remove '.v1' from the following line. session = client.v1.checkout.sessions.create({ "line_items": [{"price": "{{PRICE_ID}}", "quantity": 1}], "mode": "payment", "ui_mode": "embedded", "return_url": "https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}", }) ``` ```php // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys $stripe = new \Stripe\StripeClient('<>'); $session = $stripe->checkout->sessions->create([ 'line_items' => [ [ 'price' => '{{PRICE_ID}}', 'quantity' => 1, ], ], 'mode' => 'payment', 'ui_mode' => 'embedded', 'return_url' => 'https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}', ]); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys Stripe.apiKey = "<>"; SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID}}") .setQuantity(1L) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}") .build(); Session session = Session.create(params); ``` ```java // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeClient client = new StripeClient("<>"); SessionCreateParams params = SessionCreateParams.builder() .addLineItem( SessionCreateParams.LineItem.builder() .setPrice("{{PRICE_ID}}") .setQuantity(1L) .build() ) .setMode(SessionCreateParams.Mode.PAYMENT) .setUiMode(SessionCreateParams.UiMode.EMBEDDED) .setReturnUrl("https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}") .build(); // For SDK versions 29.4.0 or lower, remove '.v1()' from the following line. Session session = client.v1().checkout().sessions().create(params); ``` ```node // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys const stripe = require('stripe')('<>'); const session = await stripe.checkout.sessions.create({ line_items: [ { price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', ui_mode: 'embedded', return_url: 'https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}', }); ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys stripe.Key = "<>" params := &stripe.CheckoutSessionParams{ LineItems: []*stripe.CheckoutSessionLineItemParams{ &stripe.CheckoutSessionLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), }, }, Mode: stripe.String(stripe.CheckoutSessionModePayment), UIMode: stripe.String(stripe.CheckoutSessionUIModeEmbedded), ReturnURL: stripe.String("https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}"), } result, err := session.New(params) ``` ```go // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys sc := stripe.NewClient("<>") params := &stripe.CheckoutSessionCreateParams{ LineItems: []*stripe.CheckoutSessionCreateLineItemParams{ &stripe.CheckoutSessionCreateLineItemParams{ Price: stripe.String("{{PRICE_ID}}"), Quantity: stripe.Int64(1), }, }, Mode: stripe.String(stripe.CheckoutSessionModePayment), UIMode: stripe.String(stripe.CheckoutSessionUIModeEmbedded), ReturnURL: stripe.String("https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}"), } result, err := sc.V1CheckoutSessions.Create(context.TODO(), params) ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, }, }, Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); ``` ```dotnet // Set your secret key. Remember to switch to your live secret key in production. // See your keys here: https://dashboard.stripe.com/apikeys var options = new Stripe.Checkout.SessionCreateOptions { LineItems = new List { new Stripe.Checkout.SessionLineItemOptions { Price = "{{PRICE_ID}}", Quantity = 1, }, }, Mode = "payment", UiMode = "embedded", ReturnUrl = "https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}", }; var client = new StripeClient("<>"); var service = client.V1.Checkout.Sessions; Stripe.Checkout.Session session = service.Create(options); ``` # Embedded components > This is a Embedded components for when payment-ui is embedded-components. View the full page at https://docs.stripe.com/payments/checkout/pay-what-you-want?payment-ui=embedded-components. Custom amounts aren’t supported when using Elements.