Stripe Customer Balance Scripts and QuickBooks
Stripe customer balance scripts control how much of a balance each subscription invoice uses. Thresholds, credit caps, failures, and QuickBooks.
By default, Stripe applies a customer's whole invoice balance to their next invoice. A credit gets used up as fast as invoices arrive to absorb it, and a debit gets charged as soon as the next invoice is finalized. For most subscription businesses that's fine. It goes wrong when you don't want a $3 charge on a card, or when a $1,500 goodwill credit wipes out the next three months of revenue in one invoice.
Stripe's customer balance application scripts change that one step. A script looks at each subscription invoice, sees the invoice total and the customer's balance, and decides how much of the balance to apply. Stripe has written two scripts you can switch on in the Dashboard, and you can write your own in TypeScript.
The books are where this gets interesting. A script can leave an invoice with $0 due even though the sale happened, or pay half of an invoice from a credit while the rest of the credit waits. This guide covers how the scripts work, the limits Stripe sets on them, and what each pattern means for the invoice, the customer balance and your QuickBooks file. Start a free trial.
What Stripe does without a script
Every Stripe customer has an invoice balance. Stripe's customer balance guide describes adjustments to it as either "a credit (meaning you owe them money) or a debit (meaning they owe you money)." The balance builds up from a few places:
- Manual adjustments you make in the Dashboard or the API, recorded as customer balance transactions with the type
adjustment. - Downgrade prorations, which Stripe says "can indirectly create credits to reduce the amount due on the next invoice."
- Invoices that are too small to charge. When the amount due is below the minimum chargeable amount, "the invoice is marked as paid and the amount owed moved to the invoice balance as a debit." Its transaction type is
invoice_too_small.
By default the whole balance goes into the next invoice. Stripe's comparison table says an invoice balance adjustment "applies to the next finalized invoice in the matching currency, after taxes and billing credits." Two words in that sentence matter for accounting: after taxes. The balance changes what gets collected. It doesn't change the taxable amount or the invoice total.
Two invoice fields record what happened. Stripe's invoice object reference defines starting_balance as the "Starting customer balance before the invoice is finalized" and ending_balance as the "Ending customer balance after the invoice is finalized." The difference between them is the amount of balance this invoice used. In Stripe's sign convention a positive balance is a debit (the customer owes you) and a negative one is a credit.
What a customer balance script changes
Stripe's script guide says it in one sentence: "Your script receives the invoice total and current customer balance, then returns how much of that balance to apply." Stripe lists the uses:
- "Choose whether to apply the balance to specific invoices."
- "Apply only a portion of the balance based on your business rules."
- "Implement conditional logic that determines when to settle balances."
- "Defer charges until accumulated balances reach a threshold."
The script returns one number, appliedCustomerBalance, with a currency. Positive values apply a debit and raise the amount due. Negative values apply a credit and lower it. Zero applies nothing. Stripe handles the rest: "Your script only needs to return how much balance to apply. The system handles the accounting to conserve the balance." Whatever the script doesn't apply stays on the customer's balance, and whatever it applies beyond the balance gets added to the balance.
Stripe enforces four rules, and a script that breaks one fails validation:
- Every result needs both an amount and a currency.
- The currency has to match the invoice currency.
- "A debit application must be less than or equal to the available debit balance."
- "Negative applications are allowed only on positive invoices and can't exceed the invoice amount."
Rule 4 is the one that makes a threshold script possible. A script can apply a credit equal to the whole invoice even when the customer has no credit at all. The customer balance then moves the other way and absorbs the invoice as a debit.
The two scripts Stripe wrote for you
Both are in the Dashboard under Settings > Billing > Billing customizations, next to Customer balance. You pick one, enter an amount in the currency's minor unit (so 10000 in USD means 100 USD), and save. Stripe's page for its own scripts walks through both.
Minimum amount before collection
This one sets your own floor for collecting. When the invoice total plus the customer's balance is below your threshold, Stripe zero-charges the invoice and moves its amount onto the customer's balance. When the total reaches the threshold, Stripe applies the full balance and charges everything at once.
Stripe's example, with a 100 USD threshold:
| Cycle 1 | Cycle 2 | |
|---|---|---|
| Invoice total | 20 USD | 80 USD |
| Customer balance before | 30 USD debit | 30 USD debit |
| Total owed | 50 USD (below threshold) | 110 USD (above threshold) |
| Balance applied | 20 USD credit | 30 USD debit |
| Customer charged | 0 USD | 110 USD |
| Customer balance after | 50 USD debit | 0 USD |
Stripe treats the two columns as separate scenarios, but read them as consecutive months and you get the pattern a usage business wants. Small months roll forward and nobody's card gets hit for 20 dollars. Stripe's own minimum chargeable amount does something similar at a much lower level. This script lets you pick the level.
Maximum credit per invoice
This one caps how much credit a single invoice can use. Stripe's example: a 150 USD credit balance, a 200 USD invoice and a 100 USD cap.
| Default | With the script | |
|---|---|---|
| Credit applied | 150 USD | 100 USD |
| Customer pays | 50 USD | 100 USD |
| Credit left on the balance | 0 USD | 50 USD |
Use it when a large credit should be spread out, for example a service credit you promised "over the next few months" rather than all on the next bill.
Writing your own
If neither fits, you can write a TypeScript class that implements computeAppliedCustomerBalance, package it as a Stripe App and upload it with the Stripe CLI. Stripe reviews each upload before you can install it, even in a sandbox. Stripe's own example is a configurable version of the threshold script, and its best practices are worth copying: check that currencies match ("Fall back to default behavior when they don't") and test zero balances, credit balances and balances larger than the invoice.
The limits to know before you switch one on
Scripts are a narrow feature, and most of what trips people up is the scope. From Stripe's script authoring guide and the customer balance guide:
- Subscription invoices only. "Scripts don't affect standalone invoices that aren't associated with a subscription." A one-off invoice still uses the whole balance.
- Flexible billing mode. Billing scripts run for subscriptions using flexible billing mode, which needs API version 2025-06-30.basil or later, and for pricing plan and license fee subscriptions.
- One script per extension point. You can't run the threshold script and the credit cap together. If you need both, you write one script that does both.
- No Connect sharing. "Scripts can't be shared to connected accounts through Stripe Connect."
- Not for INR e-mandate invoices. Invoices that need e-mandates for Indian off-session payments are excluded.
- Tiered pricing side effect. With a customer balance script active, the Invoice Line Items Update and Bulk Update endpoints "will return 4xx error codes" for invoices containing tiered-pricing line items. If your integration edits lines on draft invoices, test this first.
- Versions apply going forward. Switching script versions "takes effect immediately on all future billing operations." Invoices already processed under an older version stay as they were.
When a script fails, Stripe uses the default
This is the line to remember for reconciliation: "If your script raises an error (for example, returns an invalid result, throws an exception, or times out), Stripe defaults to standard functionality for the operation that caused the failure." For the Stripe-authored scripts, Stripe adds that in preview it "reserves the right to default to standard functionality and/or pause subscription processing."
So a threshold script that errors on one invoice applies the whole balance to it and collects. A credit cap that errors lets the whole credit through. Nothing breaks, but that one invoice doesn't follow your rule, and anything you built on top of the rule (a revenue forecast, a promise to a customer, a QuickBooks entry you made by hand) is now wrong for that month.
Two habits catch this. Turn on Stripe's real-time failure notifications for Billing scripts. And reconcile from what Stripe actually did, which is in the customer balance transactions and in starting_balance and ending_balance on each invoice, never from what the script was supposed to do.
What each pattern means in QuickBooks
The accounting principle under all of this is simple: a script changes when cash is collected, not what was sold. The invoice total, the revenue and the sales tax are fixed before the balance is applied. What the balance changes is how much of that total the card or bank pays today, and how much sits on the customer's balance.
That means your QuickBooks file needs somewhere for the balance to live. If customer balances are material for you, a balance-sheet account for Stripe customer balances does the job. A debit balance (the customer owes you) is an asset, and a credit balance (you owe them) is a liability, so some teams use one account that can carry either sign and others split it in two. What matters is that an applied balance moves money in and out of that account and never touches revenue.
The threshold script
Walk Stripe's two cycles through the books.
Cycle 1: the customer is billed 20 USD and nothing is collected. The sale is real, so revenue is 20 USD. If the invoice was taxed, the tax was calculated on the full invoice, since the balance applies after tax. The 20 USD the customer now owes is part of their Stripe balance, not cash. So the entry is revenue of 20 against the customer balance account, which now holds a 50 USD debit if the earlier 30 USD was booked there too.
Cycle 2: the customer is billed 80 USD and the threshold is reached. Revenue is 80. The rest of the charge clears the balance. In Stripe's example that's a 30 USD debit and a 110 USD charge. Run the two months back to back and it's the 50 USD from cycle 1 and a 130 USD charge. Either way, the cash equals the month's revenue plus the balance cleared, and the customer balance account goes back to zero.
The mistake is letting the zero-charged invoice reduce revenue. If an applied-balance line on the invoice is mapped to an income account, cycle 1 nets to 0 USD of revenue and cycle 2 shows more than you sold. Over time it evens out. In any one month it doesn't, and a business with lots of small usage invoices can see a real swing.
The credit cap
Here the balance starts as a credit, a liability: you owe the customer 150 USD of future service. The 200 USD invoice is 200 USD of revenue. The script applies 100 USD of the credit, so the liability drops to 50 USD, and the customer pays 100 USD. Next month the remaining 50 USD of credit (or another 100 if they get more) comes off the next invoice the same way.
Without the cap, the same 200 USD of revenue would be paid with 150 of credit and 50 of cash. The revenue doesn't change in either case. Only the cash and the liability do.
Sales tax on deferred invoices
Because the balance applies after tax, a zero-charged invoice still carries its full tax. On an accrual-basis file, that tax is a liability once the invoice is issued, even though the customer hasn't paid anything yet. That's correct, and it's the same thing that happens with any invoice paid late. Just don't expect your sales tax payable to line up with the month's cash collections while a threshold script is deferring invoices.
How Acodei's Invoice Sync handles applied balances
Acodei's Invoice Sync mirrors each finalized Stripe invoice into QuickBooks as an Invoice, reproducing its line items and the tax lines your mapping settings allow. It's one way: Stripe to QuickBooks.
For a customer balance that Stripe applied to an invoice, such as one from a manual adjustment in the Stripe Dashboard, Acodei by default adds the applied balance as a line item on the QuickBooks invoice, so the invoice shows exactly what Stripe charged. There's an alternative setting, Skip 'Applied Balance' as line item on Invoice, enabled through Acodei's admin portal. With it on, Acodei creates the invoice at the full gross amount (subtotal plus tax), so QuickBooks A/R shows the full value of the sale. Which one suits you depends on whether you want QuickBooks invoices to match Stripe's charges or Stripe's sales, and it's a setting you ask the Acodei team for rather than a checkbox.
When a Stripe invoice is paid by a successful charge, Acodei creates a QuickBooks payment and applies it to the invoice it already created. That relies on QuickBooks Automatic Application being turned on.
There is no two-way credit balance sync. If you adjust a customer's balance in QuickBooks, nothing flows back to Stripe. Stripe stays the system of record for the balance itself.
Scripts are new and change how much balance an invoice uses, so test the round trip before you rely on it. In a Stripe sandbox, or on a small live account, finalize one invoice under each pattern you plan to use: one below your threshold, one above it, and one capped credit. Then compare each QuickBooks invoice with the Stripe invoice. The amount the Stripe invoice used from the balance is starting_balance minus ending_balance. With the default setting, the QuickBooks invoice should show what Stripe charged. With the skip setting, it should show the full gross amount. Also check which account the applied-balance line posts to. If it's an income account, a threshold script will move revenue between months as described above.
A checklist before you activate a script
- Confirm your subscriptions are on flexible billing mode, or the script won't run.
- Decide on one rule. You get one script for the customer balance extension point.
- Decide where customer balances live in QuickBooks: a balance-sheet account, not revenue.
- Run one invoice through each path in a sandbox and compare Stripe's
starting_balance,ending_balanceand amount due with the QuickBooks invoice. - Turn on real-time failure notifications for Billing scripts.
- At month-end, reconcile the QuickBooks customer balance account against the customer balances in Stripe, not against what the script should have done.
- If anything edits draft invoice lines through the API, test it against an invoice with tiered pricing.
Frequently asked questions
What is a Stripe customer balance application script?
It's a small piece of logic that runs inside Stripe Billing when a subscription invoice is about to use a customer's balance. Stripe gives the script the invoice total and the customer's current balance, and the script returns how much of the balance to apply. By default Stripe applies all of it. A script can apply part, none, or (for a threshold) a credit equal to the whole invoice.
Can I stop Stripe from charging customers small amounts every month?
Yes, for subscription invoices. Stripe's Minimum amount before collection script lets you set a threshold. When the invoice plus the customer's balance is below it, Stripe zero-charges the invoice and moves the amount onto the customer's balance as a debit. When the total reaches the threshold, Stripe applies the full balance and charges once.
Can I limit how much credit Stripe applies to one invoice?
Yes. Stripe's Maximum credit per invoice script caps the credit a single subscription invoice can use. With a 100 USD cap, a 150 USD credit and a 200 USD invoice, the customer pays 100 USD and keeps 50 USD of credit for later invoices.
Do customer balance scripts work on one-off invoices?
No. Stripe says scripts don't affect standalone invoices that aren't associated with a subscription. They also need subscriptions on flexible billing mode, can't be shared to connected accounts, and don't cover INR invoices that need e-mandates for off-session payments.
What happens if my Stripe billing script fails?
Stripe falls back to its standard behavior for that invoice. If a script errors, returns an invalid result or times out, Stripe applies the customer balance the default way, usually all of it. Reconcile from the customer balance transactions and the invoice's starting_balance and ending_balance, not from what the script was meant to do.
Does a zero-charged Stripe invoice still count as revenue in QuickBooks?
Yes. The script changes when cash is collected, not what was sold. The invoice total and its tax are fixed before the balance is applied, so the revenue belongs to the month of the invoice. The uncollected amount is a debit on the customer's balance, which belongs in a balance-sheet account until a later invoice collects it.
The short version
Stripe's customer balance scripts decide how much of a customer's balance each subscription invoice uses. Stripe ships two: a minimum amount before collection, which rolls small invoices onto the balance until a threshold is reached, and a maximum credit per invoice, which spreads big credits out. You can also write your own. They only run on subscription invoices in flexible billing mode, one script at a time, and if one fails Stripe quietly uses the default for that invoice. In QuickBooks, none of this changes revenue. It changes when cash arrives and what sits on the customer's balance, so give that balance a home on the balance sheet and test the full round trip before you rely on a script. See also our guides to the Stripe customer balance in QuickBooks, applying Stripe credit to a specific open invoice, Stripe billing credits and the Stripe minimum charge amount. Start a free trial to see how Acodei brings your Stripe invoices into QuickBooks.
Automate your Stripe to QuickBooks sync
Save hours every month. Acodei automatically syncs your Stripe transactions, invoices, and payouts to QuickBooks Online.
14-day free trial · card required · cancel anytime
How Acodei handles this in your stack
Stripe QuickBooks Integration
See how Acodei syncs Stripe payments, fees, refunds, invoices, and payouts into QuickBooks Online automatically.
Or go straight to a capability
Advanced Product Mapping
Map Stripe products to QuickBooks with rule-based logic on product ID, price ID, metadata, and account. Set rule priority and extend mapping to refunds and fees.
Automated Invoice Sync
Bring Stripe invoices into QuickBooks and auto-apply payments and credit memos, with invoice numbering suffixes and quantity tracking to cut double-entry.
Multi-Currency Mastery
Sync Stripe transactions across currencies with automatic exchange rate handling and currency-specific customer records. Our team enables multicurrency on request, and zero-decimal currencies such as JPY are not supported.
Class Mapping
Map Stripe products to QuickBooks classes for scalable categorization and multi-entity reporting. Class tracking requires QuickBooks Online Plus or Advanced.
Historical Data Import
Backfill historical Stripe data into QuickBooks by month range. Preview volume and cost before syncing so reporting starts from a complete baseline.
How to Connect Stripe to QuickBooks Online
Connect Stripe to QuickBooks Online in minutes. Acodei links both accounts with secure OAuth and syncs payments, fees, refunds, and payouts automatically.
Reconcile Stripe Payments in QuickBooks
Reconcile Stripe in QuickBooks Online automatically. Acodei splits out fees, matches payouts to deposits, and keeps every charge audit-ready.
Get more operational finance guides like this one
We will only send high-value product and finance content.