Dynamically update line items
Learn how to modify pricing and the contents of a cart during checkout.
Private preview
Dynamic updates is in private preview. Request access to dynamic updates to checkout.
Learn how to dynamically add, remove, or update line items included in a Checkout Session.
Use cases 
This guide demonstrates how to update line items to upsell a subscription, but you can also:
- Check inventory: Run inventory checks and holds when customers attempt to change item quantities.
- Add new products: Add a complimentary product if the order total exceeds a specific amount.
- Update shipping rates: If the order total changes, update shipping rates by combining the method described in this guide with what’s out on Customize shipping options during checkout.
- Update tax rates: If you’re not using Stripe Tax, you can dynamically update tax rates on line items based on the shipping address entered.
Payment Intents API
If you use the Payment Intents API, you must manually track line item updates and modify the payment amount, or by creating a new PaymentIntent with adjusted amounts.
Set up the SDKServer-side
Use our official libraries to access the Stripe API from your application:
Update the server SDKServer-side
To use this beta, first update your SDK to use the checkout_
beta version header.
Configure update permissions for the Checkout SessionServer-side
When you create the Checkout Session, pass the permissions.update_line_items=server_only option to disable client-side updates and to enable updating line items, such as updateLineItemQuantity, from your server.
Dynamically update line itemsServer-side
Create an endpoint on your server to update the line items on the Checkout Session. You’ll call this from the front end in a later step.
Conseil en matière de sécurité
Client-side code runs in an environment that’s controlled by the user. A malicious user can bypass your client-side validation, intercept and modify requests, or create new requests to your server.
When creating an endpoint, we recommend the following:
- Create endpoints for specific customer interactions instead of making them generic. For example, “add cross-sell items” instead of a general “update” action. Specific endpoints can help with writing and maintaining validation logic.
- Don’t pass session data directly from the client to your endpoint. Malicious clients can modify request data, making it an unreliable source for determining the Checkout Session state. Instead, pass the session ID to your server and use it to securely retrieve the data from the Stripe API.
When updating line items, you must retransmit the entire array of line items.
- To keep an existing line item, specify its
id
. - To update an existing line item, specify its
id
along with the new values of the fields to update. - To add a new line item, specify a
price
andquantity
without anid
. - To remove an existing line item, omit the line item’s ID from the retransmitted array.
- To reorder a line item, specify its
id
at the desired position in the retransmitted array.