Fatturazione a consumo e prezzi basati sull’utilizzo
Addebiti ai clienti solo ciò che utilizzano effettivamente, comunicando l’utilizzo a Stripe, configurando prezzi a consumo e creando fasce basate sull’utilizzo per il Suo SaaS di IA.
Fatturazione a consumo e prezzi basati sull’utilizzo è una lezione AI Powered SaaS: Stripe + Auth + Billing + Deploy gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento AI Powered SaaS: Stripe + Auth + Billing + Deploy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso AI Powered SaaS: Stripe + Auth + Billing + Deploy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Why Usage-Based Pricing?
Flat subscriptions do not fit products where cost scales with consumption — like AI tokens or API calls. Metered billing charges customers for actual usage, aligning revenue with cost.
Licensed vs Metered Prices
Stripe prices come in two usage types:
- Licensed: a fixed quantity (e.g. 5 seats)
- Metered: quantity reported over time and billed at period end
Creating a Metered Price
Define a recurring price with usage_type: metered. Stripe sums reported usage for each billing cycle.
await stripe.prices.create({
product: productId,
currency: 'usd',
recurring: { interval: 'month', usage_type: 'metered' },
unit_amount: 2
});Subscribing Without a Quantity
For metered items you do not set a quantity at subscription time — Stripe learns it from usage reports.
await stripe.subscriptions.create({
customer: customerId,
items: [{ price: meteredPriceId }]
});Reporting Usage
As customers consume the product, report usage against the subscription item. Use action: increment to add to the running total.
await stripe.subscriptionItems.createUsageRecord(itemId, {
quantity: 1000,
timestamp: Math.floor(Date.now() / 1000),
action: 'increment'
});When to Report
Report at the moment usage happens — for example, after each AI completion count its tokens. Buffer high-frequency events and flush periodically to avoid hitting API limits.
async function onAiCall(itemId, tokens) {
await reportUsage(itemId, tokens);
}Idempotent Reporting
Avoid double-counting on retries by sending an idempotency key. Stripe ignores duplicate requests with the same key.
await stripe.subscriptionItems.createUsageRecord(
itemId,
{ quantity: 1000, action: 'increment' },
{ idempotencyKey: 'usage-' + eventId }
);Tiered Pricing
You can combine metering with tiers: the first 10,000 units cost more per unit, additional units less. Stripe computes the blended total automatically.
recurring: { usage_type: 'metered' },
billing_scheme: 'tiered',
tiers_mode: 'graduated'Showing Usage to Customers
Customers want transparency. Fetch the current period's usage and display it in their dashboard so there are no billing surprises.
const summaries = await stripe.subscriptionItems.listUsageRecordSummaries(itemId);Combining Plans
Many SaaS use a hybrid model: a fixed monthly base fee (licensed) plus metered overage. Add both prices as separate items on one subscription.
items: [
{ price: baseFeePriceId },
{ price: meteredPriceId }
]Best Practices
Run metered billing reliably:
- Use metered prices for consumption-based products
- Report usage with increment and idempotency keys
- Consider tiered pricing for volume
- Show usage to customers for transparency
Quick Check
Test your metered billing knowledge.
Recap
You added usage-based billing:
- Create
meteredprices and subscribe without a quantity - Report usage with
incrementand idempotency keys - Use tiered pricing and hybrid base-plus-overage models
- Surface usage to customers for transparency
Your AI SaaS now charges fairly for what users consume.
Domande Frequenti
La lezione «Fatturazione a consumo e prezzi basati sull’utilizzo» è gratuita?
Sì — il testo completo di «Fatturazione a consumo e prezzi basati sull’utilizzo» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso AI Powered SaaS: Stripe + Auth + Billing + Deploy, passa a CoddyKit PRO. Il corso AI Powered SaaS: Stripe + Auth + Billing + Deploy include 4 lezioni in totale.
Cosa imparerò in «Fatturazione a consumo e prezzi basati sull’utilizzo»?
Addebiti ai clienti solo ciò che utilizzano effettivamente, comunicando l’utilizzo a Stripe, configurando prezzi a consumo e creando fasce basate sull’utilizzo per il Suo SaaS di IA. Eserciti AI Powered SaaS: Stripe + Auth + Billing + Deploy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare AI Powered SaaS: Stripe + Auth + Billing + Deploy?
Non è richiesta alcuna esperienza precedente. AI Powered SaaS: Stripe + Auth + Billing + Deploy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Fatturazione a consumo e prezzi basati sull’utilizzo»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione AI Powered SaaS: Stripe + Auth + Billing + Deploy?
Sì. Ogni lezione AI Powered SaaS: Stripe + Auth + Billing + Deploy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Gestione degli abbonamenti
- Gestione dei webhook Stripe
- Portale clienti e cronologia di fatturazione
- Fatturazione a consumo e prezzi basati sull’utilizzo