Glossary

Stripe Billing Scripts

Stripe billing scripts are small TypeScript functions that run on Stripe’s own infrastructure at fixed points in the billing flow, called extension points, and replace Stripe’s default logic there, such as how much customer balance an invoice uses, which items go on which invoice, or how a proration is calculated.

Also called: billing scripts, Stripe billing extensions, Billing customizations, Stripe-authored scripts, user-authored scripts, billing extension points

14-day free trial · card required · cancel anytime

Definition

Stripe describes scripts as a way to “program custom billing logic that runs directly on Stripe.” Each one targets a single decision in the billing flow. Stripe calls that point an extension point, and each extension point defines a typed interface: the inputs Stripe sends and the output your function must return. Stripe’s own example is the customer balance extension point, where Stripe passes the invoice total and the current balance, the script returns how much of the balance to apply, and Stripe “uses your result and continues the billing flow.”

There are two kinds. Stripe-authored scripts are prebuilt: you pick one in the Dashboard, set its parameters and activate it, with no code. User-authored scripts are written in TypeScript, packaged as a Stripe App and uploaded with the Stripe CLI. Stripe recommends starting with a Stripe-authored script before writing your own.

Whichever kind you use, a script applies to the whole account, and only one can run for each billing behavior at a time.

Key points

  • +Scripts are configured under Settings > Billing > Billing customizations in the Dashboard.
  • +Stripe groups them by billing behavior: customer balance, invoice item creation and routing, proration, and discount calculation.
  • +Stripe-authored scripts need no code. User-authored scripts are TypeScript, packaged as a Stripe App and reviewed by Stripe before install.
  • +Only one script can run per billing behavior or extension point at a time, and it applies account-wide.
  • +Most billing scripts run only on subscriptions in flexible billing mode, and none affect standalone invoices.
  • +If a user-authored script fails, Stripe falls back to its default behavior for that operation.
  • +Switching versions affects future billing only. Invoices already processed stay as they were.

The billing behaviors you can change

Stripe’s Billing customizations page lists each behavior a script can replace and the scripts available for it. The Stripe-authored set covers four.

Customer balance: Minimum amount before collection defers small invoices to the customer balance until the total owed reaches a threshold, and Maximum credit per invoice caps how much credit one invoice can use.

Invoice item creation and routing (the item handling extension point): Separate invoice for metered items puts metered usage on its own invoice, Skip creating a partial period proration item drops partial-period prorations for products you tag with metadata, and Remove zero-quantity metered items before creation drops usage lines with a quantity of exactly zero.

Proration: Prorate by custom interval rounds prorations to whole hours, days, weeks or months instead of seconds, and Credit and debit full product price bills chosen products in full when a subscription changes.

Discount calculation: scripts behind custom coupons, such as a percentage off up to a maximum amount, quantity promotions, and amount or percent off for prices selected by metadata. This extension point also supports classic billing mode, which the others don’t.

For code you write yourself, Stripe’s author-your-own page currently lists customer balance and recurring billing item handling as the billing extension points, and Stripe’s step-by-step build guide uses a prorations extension as its worked example.

How a script is built, reviewed and switched on

Scripts run on Stripe’s managed runtime, so there is nothing to host. At the billing extension points, Stripe says scripts “receive data from Stripe, run your logic, and return a result. External API calls aren’t permitted.” The runtime also rules out patterns such as fetch() and timer functions like setTimeout().

A user-authored script goes through a fixed path: create a Stripe App with the CLI, generate an extension for the extension point, write the TypeScript, upload the app, and wait for Stripe’s review before installing it, even in a sandbox. Stripe starts with an automated review and might require more. Approval for sandbox testing “doesn’t necessarily include live mode,” so a second approval comes before production.

Stripe-authored scripts skip all of that. The first time you set one up, Stripe installs the Stripe Billing Extensions app in the background. Either way, activating or changing a script needs the Super Administrator, Administrator or Developer role, and selecting Default on the same page reverts to Stripe’s standard behavior immediately.

Limits, failures and versions

Stripe lists the limits on every billing script. Only one script can run per billing behavior or extension point. Billing scripts run for subscriptions in flexible billing mode (API version 2025-06-30.basil and later) and for pricing plan and license fee subscriptions, with discount calculation the exception that also supports classic mode. Scripts don’t affect standalone invoices that aren’t tied to a subscription, can’t be shared to connected accounts through Stripe Connect, and don’t support INR invoices that need e-mandates for off-session payments. In Checkout, scripts that need flexible billing mode run only when the session’s mode is subscription and its billing_mode is flexible.

For scripts you write, a run fails if it takes longer than 500 milliseconds, throws an exception, or returns a result that breaks the extension point’s validation rules. Then “Stripe defaults to standard functionality for the operation that caused the failure.” Stripe-authored scripts are worded more broadly: if they fail, Stripe “reserves the right to default to standard functionality or pause subscription processing.” Stripe emails the account when a billing script fails, at most once per extension per UTC calendar day, and every run is visible in Workbench under Extension runs.

Versions only move forward in effect. A version switch applies to all future billing operations for that extension point, and invoices already processed under the earlier version “aren’t retroactively affected.”

What billing scripts mean for QuickBooks

A script never writes to your books. It changes the invoices Stripe produces, and your QuickBooks file is built from those invoices and the payments against them. Each behavior changes something different.

A customer balance script changes when cash is collected, not what was sold. An invoice can be finalized with little or nothing charged while the amount moves to the customer’s balance, which belongs on the balance sheet until a later invoice collects it.

An item handling script changes how many invoices a cycle produces and what is on each one. Splitting metered usage onto its own invoice turns one invoice and one payment into two for the same revenue. Deferring an item leaves it as a pending invoice item that isn’t billed yet, which matters at an accrual-basis month end.

Proration and discount scripts change amounts: the size of the credit and debit lines when a subscription changes, and the discount on an invoice. The revenue and contra-revenue figures in QuickBooks follow them.

Two habits keep the books honest. Note the date any script is activated, changed or reverted in your close notes, because months before and after will not look alike and no earlier invoice changes. And when a cycle looks wrong, check the Extension runs on that subscription before editing anything in QuickBooks. A failed run means Stripe used its default for that operation.

Frequently asked questions

What are Stripe billing scripts?

They are TypeScript functions that run inside Stripe Billing at fixed points called extension points and replace Stripe’s default logic there. Stripe offers prebuilt Stripe-authored scripts you configure in the Dashboard, and you can write your own and upload them as a Stripe App. They cover customer balance, invoice item creation and routing, proration, and discount calculation.

Do I need to write code to use a Stripe billing script?

No. Stripe-authored scripts are selected and configured under Settings > Billing > Billing customizations, and Stripe installs its Stripe Billing Extensions app in the background the first time. Writing your own means TypeScript, a Stripe App uploaded with the CLI, and a review by Stripe before you can install it.

Can I run more than one billing script at a time?

Only one per billing behavior. Stripe says you can only run one script for each billing behavior or extension point at a time, so you could have a customer balance script and an item handling script together, but not two customer balance scripts. Each one applies to the whole account.

What happens if a Stripe billing script fails?

For a script you wrote, Stripe defaults to standard functionality for the operation that failed. A run fails on a timeout over 500 milliseconds, an exception, or an invalid result. For Stripe-authored scripts, Stripe reserves the right to use the default or pause subscription processing. Stripe emails the account about failures, and every run is listed in Workbench.

Do billing scripts change invoices that were already created?

No. Switching to a different script version affects future billing operations only, and Stripe says invoices already processed under a previous version aren’t retroactively affected. Your existing QuickBooks records stay as they were, so note the change date in your close notes.

What customers say about running Stripe through Acodei

Stripe Verified Partner BadgeIntuit QuickBooks
★★★★★
“If you're testing out all the different Stripe/QuickBooks integration apps right now, let me save you some time. This one is the best one by far.”
RyanOwner at Indie Music Academy
★★★★★
“Works well and is really helpful for massive transactions. The support is really fast and helpful. 100% recommended.”
AndresCo-founder and CEO at Kanguro Collections and Reinsurance

Related reading

More glossary terms

See the full glossary

Ready to try Acodei?

Connect Stripe to QuickBooks Online in minutes and let the fees, refunds, and payouts land where your accountant expects them.

14-day free trial · card required · cancel anytime