Dynamically update discountsPrivate preview
Update discounts in response to changes customers make during checkout.
Private preview
This feature is in private preview. Request access to dynamic updates to checkout.
Learn how to dynamically add or remove discounts on a Checkout Session.
Use cases 
This guide demonstrates how to integrate with your internal discounts system to create dynamic amount-off discounts, but you can also:
- Apply loyalty discounts: Automatically apply discounts based on customer loyalty tier or purchase history.
- Cart value promotions: Add discounts when the order total exceeds specific thresholds (for example, $10 off orders over $100).
- Time-sensitive offers: Apply limited-time promotional discounts or remove expired discount codes.
- Location-based discounts: Apply region-specific discounts based on the customer’s shipping address.
- Customer-specific offers: Create personalized discount amounts based on customer segments or previous purchase behavior.
Set up SDKServer-side
Use our official libraries to access the Stripe API from your application:
Update server SDKServer-side
To use this preview feature, first update your SDK to use the checkout_
beta version header.
Configure Checkout Session update permissionsServer-side
Pass in permissions.update_discounts=server_only when you create the Checkout Session to enable updating discounts from your server. Passing this option disables client-side discount application, ensuring that all discount logic passes through your server.
Dynamically update discountsServer-side
Create a new endpoint on your server to apply discounts on the Checkout Session. You’ll call this from the frontend in a later step.
Security tip
Client-side code runs in an environment fully controlled by the user. A malicious user can bypass your client-side validation, intercept, and modify requests, or even craft entirely new requests to your server.
When designing the endpoint, we recommend the following:
- Design endpoints for specific customer interactions instead of making them overly generic (for example, “apply loyalty discount” rather than a general “update” action). Specific endpoints help keep the purpose clear and make validation logic easier to write and maintain.
- 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 Stripe’s API.
Test the integration
Follow these steps to test your integration, and ensure your dynamic discounts work correctly.
Set up a sandbox environment that mirrors your production setup. Use your Stripe sandbox API keys for this environment.
Simulate various discount scenarios to verify that your
recomputeDiscounts
function handles different scenarios correctly.Verify server-side logic by using logging or debugging tools to confirm that your server:
- Retrieves the Checkout Session.
- Validates discount requests.
- Recomputes updated discounts based on your business logic.
- Updates the Checkout Session with the new discounts when your custom conditions are met. Make sure the update response contains the new discounts. By default, the response doesn’t contain the discounts field, unless the request expands the object.
Verify client-side logic by completing the checkout process multiple times in your browser. Pay attention to how the UI updates after applying a discount. Make sure that:
- The runServerUpdate function is called as expected.
- Discounts apply correctly based on your business logic.
- The checkout total updates to reflect the applied discount.
- Error messages display properly when a discount application failed.
Test various discount scenarios including invalid discount requests or simulate server errors to test error handling, both server-side and client-side.