Skip to main content
Credit-Based Billing 允许您向客户授予一定额度的 credits——API 调用、tokens、compute units 或任何自定义指标——并在客户使用您的服务时从该余额中扣除。Credits 适用于所有产品类型:订阅、一次性购买和基于使用量的计费。

What is Credit-Based Billing?

Credit-Based Billing gives you a flexible system to issue credit entitlements to customers as part of your products. Instead of charging per-use or limiting access through feature flags, you allocate a pool of credits that customers draw from as they use your service. Credits 适用于:
  • AI and LLM platforms: Grant tokens or generation credits per plan tier
  • API services: Allocate API call credits with overage pricing
  • Infrastructure platforms: Issue compute hours or storage credits
  • Communication services: Provide message or minute credits per subscription
  • SaaS with consumption tiers: Bundle included usage into credit pools
Checkout showing included credits with the product purchase

Credits appear as entitlements on your products and show in checkout, customer portal, and subscription details.

Core Concepts

Credit Types

When creating a credit, you choose between two types:
使用您自己的单位定义 credits——tokens、API 调用、compute hours 或任何对您的产品有意义的指标。自定义单位使用您设置的精度(0 到 10 位小数)。Best for: API calls, AI tokens, compute hours, storage units, messages

Credit Lifecycle

Credits follow a clear lifecycle from issuance through consumption:
1

Credits Issued

当客户购买附带 credit 权益的产品(订阅或一次性产品)时,系统会授予 credits。对于订阅,credits 会在每个计费周期重新发放。
2

Credits Consumed

As customers use your service, credits are deducted. For usage-based products, meters automatically deduct credits based on real-time events. You can also deduct credits manually via the dashboard or API.
3

Credits Expire or Roll Over

At the end of the billing cycle (or after the configured expiry period), unused credits either expire or roll over to the next period based on your settings.
4

Overage Handling

如果 credits 在周期中途用尽,您可以允许超额使用(继续使用超过余额的额度),并选择如何处理超额使用:免除、计费或将欠额结转到下一周期。

Grant Sources

Credits can be granted from multiple sources:

Creating Credits

Create credit entitlements in the Products → Credits section of your dashboard. Each credit defines the unit, precision, expiry rules, and lifecycle behavior.
Credits listing page showing created credit entitlements

The Credits tab under Products shows all your credit entitlements.

1

Navigate to Credits

Go to Products in your dashboard and select the Credits tab. Click Create Credit to start.
2

Configure Basic Information

输入 Credit Name——这是 credit 的内部标识符。
Credit creation form showing basic info, general settings, and subscription settings

The credit creation form with all configuration sections.

3

Set General Settings

Configure the credit type and display properties:
string
必填
Choose Custom Unit or Fiat Credits.
  • Custom Unit:定义您自己的指标(tokens、API 调用、compute hours)。需要设置 Unit Name(例如,“Platform tokens”)和 Precision。
  • Fiat Credits:Credits 代表实际货币价值。需要选择 Unit Currency(USD、EUR、GBP、INR 等)。
string
仅适用于 Custom Unit credits。客户看到的 credit 标签(例如,“AI Tokens” 或 “API Calls”)。该标签会显示在结账页面和客户门户中。
number
Only for Custom Unit credits. Number of decimal places allowed, from 0 to 10:
  • 0:整数(适合 API 调用等可计数项目)
  • 1:一位小数(0.0)
  • 2:两位小数(0.00)——默认值
  • 3:三位小数(0.000)
  • 最多 10:适用于高精度单位(例如,分数 tokens 或微量使用量)
Precision cannot be changed after the credit is created.
string
How long credits remain valid after issuance:
  • 7 days, 30 days (default), 60 days, 90 days, Custom, or Never
Select Custom to specify a custom number of days (minimum 1).
4

Configure Subscription Settings (Optional)

These settings control credit behavior within recurring subscriptions:
boolean
Allow unused credits to carry forward to the next billing cycle. When enabled, configure:
  • Max Rollover Percentage(0–100%):限制可结转的额度
  • Rollover Timeframe:结转 credits 保持有效的时长(例如,1 Month)
  • Max Rollover Count:credits 被作废前允许连续结转的最大次数
When Credits Run Out or Subscription Expires:
boolean
Let customers continue using your service after their credit balance reaches zero. When enabled, configure:
  • Overage Limit:客户可在余额之外使用的最大 credits 数量
  • Price Per Unit:启用超额使用时每个额外 credit 的费用(带货币选择器)
string
必填
Controls how overage is handled at the end of the billing cycle:
  • Forgive overage at reset(默认):记录超过 credit 限额的使用量,但不计费。余额在每个周期重置。
  • Bill overage at billing:超过 credit 限额的使用量会在下一张发票中计费,随后余额重置。
  • Carry over deficit:超过 credit 限额的使用量会以负余额形式结转到下一周期。
  • Carry over deficit (auto-repay):欠额结转到下一周期,并自动从新 credits 中偿还。
5

Create Credit

Click Create Credit to save. The credit is now available to attach to any product.
Your credit entitlement is ready. Attach it to products to start issuing credits to customers.
Start with simple settings - no rollover, no overage - and add complexity as you learn how customers use credits. Most settings can be updated at any time without affecting existing grants. Note that precision cannot be changed after a credit is created.

Attaching Credits to Products

Credits are attached to products as entitlements in the product creation or editing flow. You can attach up to 5 credits per product. Credits work with all three pricing types.

Subscription Products

For subscriptions, credits are issued per billing cycle and can be configured with proration, trial credits, and cycle-specific settings.
1

Create or Edit a Subscription Product

Go to Products → Create Product or edit an existing product. Select Subscription as the pricing type and configure your recurring price.
2

Open Entitlements Section

Expand the Entitlements section and click the Attach button next to Credits.
Product entitlements section showing Credits attach button

The Entitlements section in the product form with Credits, License Key, and Digital Product Delivery options.

3

Select Credits to Attach

An Add Credits panel opens. You can select an existing credit from the dropdown or click Create new credit to define one on the spot.
Add Credits panel with credit selection dropdown

The Add Credits panel lets you select existing credits or create new ones.

You can attach up to 5 credits per product. Each credit can have its own configuration.
4

Configure Credit Settings

For each attached credit, configure:
number
必填
The number of credits granted to the customer each billing period.
number
当余额低于此百分比(0–100)时发送通知。在客户用尽余额之前提醒他们很有用。
number
Set a different credit amount for trial periods. Enable Expire trial credits after trial ends to revoke unused trial credits when the trial converts to a paid subscription.
boolean
Prorate remaining credits when a customer upgrades or downgrades their subscription plan.
boolean
Use the default rollover, overage, and expiry settings from the credit entitlement. Turn this off to customize settings specifically for this product.
Credit configuration form with billing cycle, trial, and proration settings

Credit configuration showing per-cycle amount, trial credits, proration, and custom settings.

5

Review and Add

Review the attached credit showing name, amount, and expiration. Click Add to Subscription to confirm.
Add Credits panel showing selected credit with details

Review attached credits before adding them to the subscription.

One-Time Payment Products

For one-time payments, credits are issued once at the time of purchase.
1

Create a One-Time Product

Create a product with Single Payment pricing type.
Product pricing section with Single Payment selected

Single Payment pricing selected for a one-time credit product.

2

Attach Credits

Open the Entitlements section and attach credits. Configure the number of credits issued (total one-time grant) on purchase.
One-time credit products are ideal for credit top-up packs, promotional bundles, or prepaid credit purchases.

Usage-Based Billing Products

For usage-based products, credits are linked to meters and automatically deducted based on real-time consumption events.
1

Create a Usage-Based Product

Select Usage Based Billing as the pricing type. Configure the base price and billing frequency.
Usage Based Billing pricing configuration

Usage Based Billing pricing type with meter configuration.

2

Add a Meter

点击 Select meter 部分中的 + 按钮以添加 meter。一个订阅最多可以有 50 个 meters。
Select Meter panel showing free threshold and credit toggle

The Select Meter panel with meter configuration and credit toggle.

3

Enable Credit Billing on the Meter

Toggle Bill usage in Credits to attach a credit to the meter. Select the credit entitlement from the dropdown.
number
仅适用于 meter 以货币计费的情况。当 meter 以 credits 计费时,每个单位都会从 credit 余额中扣除。
boolean
When enabled, meter usage deducts from the customer’s credit balance instead of charging per-unit.
number
必填
The number of usage units required to deduct 1 credit. For example, if set to 1000, then 1,000 API calls consume 1 credit.
Meter configuration with credit selection and meter units per credit

Credit attached to a meter with per-unit conversion rate.

4

Configure Credit Issuance

Set the number of credits issued and optionally customize the credit settings for this product.
Credit configuration for UBB product

Configure how many credits to issue and whether to use default settings.

5

Verify Attachment

Once configured, the meter shows the attached credit name, unit price, and free threshold.
Configured meter showing credit attachment details

Meter with credit attached showing price, threshold, and credit name.

当 credits 与 meters 关联后,系统会根据接收的使用事件自动扣除 credits。后台 worker 每分钟处理一次事件,按照 meter 的配置进行聚合,并使用 FIFO(先进先出)策略从客户未过期的 grants 中扣除,优先使用最早过期的 grant。

Credit Settings

Rollover

Rollover lets unused credits carry forward to the next billing cycle instead of expiring. Example: A customer has 200 unused credits at cycle end. With 75% rollover, 150 credits carry forward and 50 are forfeited.

Overage

Overage controls what happens when a customer’s credit balance reaches zero mid-cycle. Overage Behavior options:
Dodo Payments 不会在余额达到零时阻止使用。如果您不希望客户在没有 credits 的情况下继续使用服务,请在处理请求前于您的应用程序中检查余额。选择符合您计费模式的超额使用行为。Forgive at reset 是默认且最简单的选项。

过期

过期的 credits 会创建一个 credit_expired ledger 条目。如果启用了 rollover,则会在过期前应用结转百分比,只有剩余部分会过期。

使用 Credits 的用量计费

当 credits 与 usage meters 关联后,系统会创建强大的基于消耗量的计费模式。客户获得 credit 配额,使用事件会自动从其余额中扣除 credits。
显示已消耗 credits 的事件表的 Usage Billing 仪表板

The Usage Billing dashboard shows meter events with units consumed, credits consumed, and customer details.

基于 Meter 的 Credit 扣除方式

  1. 您的应用程序发送使用事件:每个事件包含客户 ID、事件名称和 metadata
  2. Meters 聚合事件:使用 Count、Sum、Max 或 Last 聚合方式
  3. Credits 自动扣除:后台 worker 每分钟处理一次事件,使用您配置的费率将 meter 单位转换为 credits,并按照 FIFO 顺序(最早过期的 grants 优先)从客户余额中扣除
  4. 跟踪超额使用量:如果 credit 余额达到零且启用了超额使用,系统会跟踪超额使用量,以便在周期结束时计费

Meters 面板

Usage Billing 仪表板包含一个 Meters 面板,其中列出所有已定义的 meters 及其聚合类型:

客户体验

结账

当客户购买附带 credits 的产品时,结账页面会将包含的 credits 显示为产品权益的一部分。
显示包含 API call credits 的产品的结账页面

Checkout shows included credits with the product, making the value proposition clear.

Credits 会显示在产品描述下方的 Includes 部分,其中包含 credit 数量和类型(例如,“$1000 API calls”)。

Customer Portal

客户可以在 Customer Portal 的 Credits 部分查看和管理其 credit 余额。
显示余额和交易历史的 Customer Portal credits 视图

The Customer Portal shows available balance and full transaction history.

门户显示:
  • Available Balance:醒目显示当前 credit 余额
  • Credit Tabs:在不同 credit 类型之间切换(例如,“OpenAI Credits” 或 “Usage Tokens”)
  • Recent Transactions:完整历史记录,包括日期、交易 ID、类型、金额和实时余额
向客户显示的交易类型包括:

订阅详情

订阅详情页会在其他计划信息旁显示 credit 权益。
显示权益和使用历史的订阅详情页面

Subscription details show credit allocation, remaining balance, and renewal date.

显示的关键信息:
  • 每个计费周期的 Credit allocation(例如,“每个周期 1000 credits”)
  • Remaining balance(例如,“剩余 7500 credits”)
  • 下一次发放 credits 的 Renewal date
  • Usage History 标签页,其中包含 meter 级别的明细,包括已消耗单位、阈值、单位价格和总费用

交易详情

Payment transaction 页面包含 Entitlements 部分,其中显示付款交付的所有权益,包括 credits。
显示 credit 权益的交易详情页面

Transaction details show credits alongside other entitlements like license keys and digital downloads.


管理 Credits

仪表板视图

Credit 权益列表

在 Products → Credits 中查看所有 credit 权益。表格显示 credit 名称和过期设置,并提供编辑或归档的快捷操作。
Products 部分中的 Credits 列表页面

Credits listing with total count, creation button, and management actions.

客户 Credit 详情

从 Customers → [Customer Name] → Credits 查看特定客户的 credit 余额和交易历史。
带有显示余额和交易的 Credits 标签的客户详情页面

Customer detail page showing credit balance and full transaction ledger.

客户 credit 视图包括:
  • Credit Selector - 在不同 credit 权益之间切换
  • Available Balance - 以醒目的大尺寸显示当前余额
  • Apply Credit/Debit - 手动调整客户余额的按钮
  • Recent Transactions - 完整 ledger,包括日期、交易 ID、类型、金额和实时余额

手动调整

您可以直接从仪表板手动为客户余额增加或扣除 credits:
1

Navigate to Customer

前往 Customers 并选择客户。
2

Open Credits Tab

点击 Credits 标签页,并从 wallet selector 中选择适当的 credit 权益。
3

Apply Credit or Debit

点击 Apply Credit/Debit 以打开调整界面。
string
必填
选择 Credit 以增加 credits,或选择 Debit 从客户余额中扣除 credits。
number
必填
要增加或扣除的 credits 数量。
string
可选的调整说明(例如,“Service compensation” 或 “Promotional bonus”)。
4

Confirm

审核并应用调整。更改会立即反映在客户余额中,并记录在 credit ledger 中。
手动调整会创建一个 manual_adjustment ledger 条目,并包含完整的审计轨迹。

Credit Ledger

每项 credit 操作都会记录在 credit ledger 中,从而提供完整的审计轨迹: 每个 ledger 条目都会记录交易前后的余额、交易前后的超额使用量、描述,以及来源引用(付款、订阅等)。

Webhooks

Credit-Based Billing 会为每项 credit 生命周期变更触发 webhook 事件。您可以使用这些事件使应用程序与 credit 余额保持同步、触发通知或构建自定义计费工作流。 所有 ledger 事件(除 credit.balance_low 外的每个 credit.* 事件)都包含完整的 CreditLedgerEntry payload,其中包含交易前后的余额、交易前后的超额使用量、来源引用,以及 grant 来源订阅或付款的 metadata(直接通过 API 创建的 grant 为空)。credit.balance_low 事件包含阈值配置和当前余额。

Credit Webhook Payloads

查看所有 credit webhook 事件的完整 payload schema、字段说明和集成示例。

API 管理

使用 API 以编程方式创建 credit 权益,并全面控制 rollover、overage 和 expiration 设置。

Create Credit Entitlement

创建新的 credit 权益,并配置 rollover、overage 和 expiry。

List Credit Entitlements

获取您企业的所有 credit 权益。
获取、更新或删除 credit 权益。已删除的权益可以恢复。

Get Credit Entitlement

通过 ID 获取特定的 credit 权益。

Update Credit Entitlement

更新 rollover、overage、expiry 或其他设置。

Delete Credit Entitlement

软删除 credit 权益。

Undelete Credit Entitlement

恢复之前删除的 credit 权益。
直接向客户余额授予 credits,无需购买;或创建用于计费调整的手动扣除条目。

Create Ledger Entry

增加或扣除客户余额中的 credits,并提供完整的审计轨迹和幂等性支持。
获取客户当前的 credit 余额、grant 历史记录,以及任意 credit 权益的完整交易 ledger。

List Balances

列出某项 credit 权益的所有客户余额。

Get Customer Balance

获取特定客户的余额。

List Customer Grants

查看客户的所有 credit grants。

List Customer Ledger

客户的完整交易历史。

集成示例

初始化 Dodo Payments 客户端:
在结账期间将 credits 附加到订阅产品:
发送会自动扣除 credits 的使用事件:

实际应用示例

定价结构:配置:
  • Credit Type:Custom Unit(“AI Tokens”)
  • Precision:0(整数 tokens)
  • Rollover:最多 25%,结转期限为 1 个月
  • Overage:已启用,在计费时收取超额费用
  • Meter:ai.generation,在 tokens 字段上使用 Sum 聚合
定价结构:配置:
  • Credit Type:Custom Unit(“API Calls”)
  • Precision:0(整数调用次数)
  • Rollover:已禁用
  • Overage:Developer+ 计划允许超额使用(在重置时免除),Free 计划禁用超额使用
  • Meter:api.request,使用 Count 聚合
定价结构:配置:
  • 额度类型:自定义单位(“GB-hours”)
  • 精度:2(两位小数)
  • 结转:最多 50%,结转一次
  • 超额用量:已启用,并设置了以 GB-hours 为单位的超额用量上限
  • 计量器:storage.usage,使用 Sum 聚合

最佳实践

  • 从简单开始:从单一 credit 类型且不启用 rollover 开始。根据客户反馈和使用模式逐步增加复杂性。
  • 设定清晰预期:在产品页面和客户门户中醒目显示 credit 配额、剩余余额和超额使用价格。
  • 使用有意义的单位:根据 credits 所代表的内容命名(例如,“API Calls” 或 “AI Tokens”),而不是使用通用术语。这有助于客户理解其价值。
  • 谨慎配置过期时间:较短的过期窗口(7 天)可以带来紧迫感,但可能让客户感到沮丧。对于大多数 SaaS 产品,较长的窗口(30–90 天)对客户更加友好。
  • 监控低余额:设置低余额阈值,在客户用尽 credits 前发出提醒,减少意外的超额费用。
  • 在测试模式中测试:创建 credits,将其附加到测试产品,并在正式上线前模拟完整的购买 → 使用 → 扣除 → 过期周期。
Credit-Based Billing 与其他所有 Dodo Payments 功能兼容:带试用期的订阅、带按比例计费的计划变更,以及 Customer Portal。从基础设置开始,并随着定价模式的发展逐步扩展。
最后修改于 2026年9月28日