StripeAnjali GolaAnnouncement
Billing customizations: change how discounts are applied
Summary
Stripe Billing now lets developers customize discount calculation through extension points, replacing workarounds like managing multiple coupons or restructuring product catalogs. The discount calculation extension point runs a TypeScript script in Stripe’s runtime, making the logic readable, testable, and maintainable. Scripts can target discounts by price metadata or native properties such as recurring interval, usage type, or unit amount. The same coupon can behave differently for different prices, for example giving annual subscribers a full discount while splitting it across months for monthly subscribers. Configurable fields in the script allow non-technical users to set parameters like discount percent or seat caps through the Stripe Dashboard without changing code.
Approach / What changed
Stripe now offers discount calculation extension points where developers can write TypeScript scripts that replace the default discount logic. Scripts are bundled in a Stripe App, defined as an extension targeting the discount calculation point, and made available in the coupon creation page. The script receives the invoice request and a config object, and returns a discount amount. Config fields are rendered in the Stripe Dashboard so non-technical users can set parameters without changing code.
Takeaways
Stripe’s discount calculation extension point lets you replace default discount logic with a custom TypeScript script that runs in Stripe’s runtime, making it readable, testable, and maintainable.
Scripts can target discounts by price metadata (e.g., plan_type, region) or native price properties (e.g., recurring interval, usage type, unit_amount), avoiding product catalog restructuring.
Configurable fields in the script are rendered in the Stripe Dashboard, allowing non-technical users to set parameters like discount percent or seat caps without editing code.
FAQ
How does the discount calculation extension point work?
The discount calculation extension point lets you replace Stripe's default discount logic with a custom TypeScript script. The script runs in Stripe's runtime and receives the invoice request and a configuration object, then returns a discount amount.
Can non-developers configure custom discount scripts?
Yes. You can define config fields in the script (e.g., discountPercent, tier1MaxSeats) that are rendered in the Stripe Dashboard at coupon creation time. Non-technical users can then set these values without editing the script or using the Stripe CLI.
What price properties can a script use to target discounts?
The script can use native price properties such as price.recurring.interval, price.recurring.usage_type, price.type, price.unit_amount, and price.billing_scheme. It can also read custom metadata on the price object, such as plan_type or region, to target discounts selectively.
Source and freshness
- Source
- stripe.dev
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.