Skip to main content
Credit-Based Billing cho phép bạn cấp cho khách hàng một số dư credit—lượt gọi API, token, đơn vị điện toán hoặc bất kỳ chỉ số tùy chỉnh nào—và khấu trừ từ số dư đó khi họ sử dụng dịch vụ của bạn. Credit hoạt động trên tất cả loại sản phẩm: gói đăng ký, giao dịch mua một lần và billing dựa trên mức sử dụng.

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. Credit phù hợp với:
  • 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:
Xác định credit theo đơn vị riêng của bạn—token, lượt gọi API, giờ điện toán hoặc bất kỳ chỉ số nào có ý nghĩa đối với sản phẩm của bạn. Đơn vị tùy chỉnh sử dụng độ chính xác mà bạn thiết lập (từ 0 đến 10 chữ số thập phân).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 được cấp khi khách hàng mua sản phẩm (gói đăng ký hoặc mua một lần) có kèm quyền lợi credit. Đối với gói đăng ký, credit được cấp lại sau mỗi chu kỳ thanh toán.
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

Nếu credit hết giữa chu kỳ, bạn có thể cho phép overage (tiếp tục sử dụng vượt quá số dư) và chọn cách xử lý overage: miễn phí, tính phí hoặc chuyển phần thiếu sang kỳ tiếp theo.

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

Nhập Credit Name—đây là mã định danh nội bộ của 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
bắt buộc
Choose Custom Unit or Fiat Credits.
  • Custom Unit: Xác định chỉ số riêng của bạn (token, lượt gọi API, giờ điện toán). Yêu cầu Unit Name (ví dụ: “Platform tokens”) và thiết lập Precision.
  • Fiat Credits: Credit đại diện cho giá trị tiền tệ thực. Yêu cầu chọn Unit Currency (USD, EUR, GBP, INR, v.v.).
string
Chỉ áp dụng cho credit Custom Unit. Đây là nhãn khách hàng nhìn thấy cho credit này (ví dụ: “AI Tokens” hoặc “API Calls”). Nhãn được hiển thị trong checkout và Customer Portal.
number
Chỉ áp dụng cho credits của Custom Unit. Số chữ số thập phân được phép, từ 0 đến 10:
  • 0: Số nguyên (phù hợp nhất với các mục có thể đếm như lượt gọi API)
  • 1: Một chữ số thập phân (0.0)
  • 2: Hai chữ số thập phân (0.00)—mặc định
  • 3: Ba chữ số thập phân (0.000)
  • Tối đa 10: Dành cho các đơn vị yêu cầu độ chính xác cao (ví dụ: token phân số hoặc mức sử dụng rất nhỏ)
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%): Giới hạn lượng credit được chuyển sang kỳ tiếp theo
  • Rollover Timeframe: Khoảng thời gian credit được chuyển tiếp còn hiệu lực (ví dụ: 1 Month)
  • Max Rollover Count: Số lần chuyển tiếp liên tiếp tối đa trước khi credit bị mất
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: Số credit tối đa khách hàng có thể sử dụng vượt quá số dư
  • Price Per Unit: Chi phí cho mỗi credit bổ sung khi bật overage (kèm bộ chọn tiền tệ)
string
bắt buộc
Controls how overage is handled at the end of the billing cycle:
  • Forgive overage at reset (mặc định): Mức sử dụng vượt quá giới hạn credit được ghi nhận nhưng không tính phí. Số dư được đặt lại sau mỗi chu kỳ.
  • Bill overage at billing: Mức sử dụng vượt quá giới hạn credit được tính vào hóa đơn tiếp theo, sau đó số dư được đặt lại.
  • Carry over deficit: Mức sử dụng vượt quá giới hạn credit được chuyển sang chu kỳ tiếp theo dưới dạng số dư âm.
  • Carry over deficit (auto-repay): Phần thiếu được chuyển sang kỳ tiếp theo và tự động hoàn trả bằng credit mới trong chu kỳ đó.
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

Tín dụng được gắn vào sản phẩm như các quyền lợi trong quá trình tạo hoặc chỉnh sửa sản phẩm. Bạn có thể gắn tối đa 5 tín dụng cho mỗi sản phẩm. Tín dụng hoạt động với cả ba loại giá.

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.

Bạn có thể gắn tối đa 5 tín dụng cho mỗi sản phẩm. Mỗi tín dụng có thể có cấu hình riêng.
4

Configure Credit Settings

For each attached credit, configure:
number
bắt buộc
The number of credits granted to the customer each billing period.
number
Thông báo khi số dư giảm xuống dưới tỷ lệ phần trăm này (0–100). Hữu ích để cảnh báo khách hàng trước khi họ sử dụng hết.
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

Nhấp vào nút + trong phần Select meter để thêm meter. Một gói đăng ký có thể có tối đa 50 meter.
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
Chỉ áp dụng khi meter tính phí bằng tiền. Khi meter tính phí bằng credit, mỗi đơn vị sẽ được khấu trừ khỏi số dư credit.
boolean
When enabled, meter usage deducts from the customer’s credit balance instead of charging per-unit.
number
bắt buộc
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.

Khi credit được liên kết với meter, hệ thống sẽ tự động khấu trừ credit dựa trên các sự kiện mức sử dụng đã được tiếp nhận. Một background worker xử lý sự kiện mỗi phút, tổng hợp chúng theo cấu hình của meter và áp dụng khấu trừ FIFO (first-in, first-out) từ các grant chưa hết hạn của khách hàng, bắt đầu với grant hết hạn sớm nhất.

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 không chặn việc sử dụng khi số dư bằng 0. Nếu không muốn khách hàng tiếp tục sử dụng dịch vụ khi không còn credit, hãy kiểm tra số dư trong ứng dụng của bạn trước khi xử lý request. Chọn hành vi overage phù hợp với mô hình billing của bạn. Forgive at reset là tùy chọn mặc định và đơn giản nhất.

Hết hạn

Credit hết hạn tạo một mục ledger credit_expired. Nếu bật rollover, phần trăm rollover được áp dụng trước khi hết hạn và chỉ phần còn lại mới hết hạn.

Billing dựa trên mức sử dụng với Credit

Khi credit được liên kết với usage meter, hệ thống tạo ra mô hình billing dựa trên mức tiêu thụ mạnh mẽ. Khách hàng nhận được một hạn mức credit và các sự kiện mức sử dụng sẽ tự động khấu trừ vào số dư của họ.
Bảng điều khiển Usage Billing hiển thị bảng sự kiện với credit đã sử dụng

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

Cách khấu trừ Credit dựa trên Meter hoạt động

  1. Ứng dụng của bạn gửi các sự kiện mức sử dụng: Mỗi sự kiện bao gồm customer ID, event name và metadata
  2. Meter tổng hợp các sự kiện: Sử dụng phép tổng hợp Count, Sum, Max hoặc Last
  3. Credit được khấu trừ tự động: Một background worker xử lý sự kiện mỗi phút, chuyển đổi đơn vị meter thành credit theo rate đã cấu hình và khấu trừ khỏi số dư của khách hàng theo thứ tự FIFO (grant hết hạn sớm nhất trước)
  4. Overage được theo dõi: Nếu số dư credit bằng 0 và overage được bật, hệ thống theo dõi mức sử dụng overage để tính phí cuối chu kỳ

Bảng Meters

Bảng điều khiển Usage Billing có bảng Meters liệt kê tất cả meter đã xác định cùng loại tổng hợp của chúng:

Trải nghiệm khách hàng

Checkout

Khi khách hàng mua sản phẩm có kèm credit, trang checkout hiển thị credit đi kèm như một phần của gói sản phẩm.
Trang checkout hiển thị sản phẩm kèm credit cho lượt gọi API

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

Credit xuất hiện trong phần Includes bên dưới mô tả sản phẩm, hiển thị số lượng và loại credit (ví dụ: “$1000 API calls”).

Customer Portal

Khách hàng có thể xem và quản lý số dư credit trong Customer Portal, tại phần Credits.
Mục xem credit trong Customer Portal với số dư và lịch sử giao dịch

The Customer Portal shows available balance and full transaction history.

Portal hiển thị:
  • Available Balance: Số dư credit hiện tại được hiển thị nổi bật
  • Credit Tabs: Chuyển đổi giữa các loại credit khác nhau (ví dụ: “OpenAI Credits” hoặc “Usage Tokens”)
  • Recent Transactions: Lịch sử đầy đủ gồm ngày, transaction ID, loại, số lượng và số dư lũy kế
Các loại giao dịch hiển thị với khách hàng gồm:

Chi tiết gói đăng ký

Trang chi tiết gói đăng ký hiển thị các quyền lợi credit cùng với thông tin khác của gói.
Trang chi tiết gói đăng ký hiển thị quyền lợi và lịch sử sử dụng

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

Thông tin chính được hiển thị:
  • Credit allocation cho mỗi chu kỳ thanh toán (ví dụ: “1000 credits each cycle”)
  • Remaining balance (ví dụ: “7500 credits remaining”)
  • Renewal date cho lần cấp credit tiếp theo
  • Tab Usage History với phân tích theo từng meter, hiển thị đơn vị đã tiêu thụ, ngưỡng, giá mỗi đơn vị và tổng chi phí

Chi tiết giao dịch

Các trang giao dịch thanh toán có phần Entitlements hiển thị tất cả quyền lợi được cung cấp cùng khoản thanh toán, bao gồm credit.
Trang chi tiết giao dịch hiển thị quyền lợi credit

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


Quản lý Credit

Chế độ xem trên Dashboard

Danh sách quyền lợi Credit

Xem tất cả quyền lợi credit tại Products → Credits. Bảng hiển thị tên credit, thiết lập hết hạn và cung cấp các thao tác nhanh để chỉnh sửa hoặc lưu trữ.
Trang danh sách credit trong phần Products

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

Chi tiết Credit của khách hàng

Xem số dư credit và lịch sử giao dịch của một khách hàng cụ thể tại Customers → [Customer Name] → Credits.
Trang chi tiết khách hàng với tab Credits hiển thị số dư và giao dịch

Customer detail page showing credit balance and full transaction ledger.

Chế độ xem credit của khách hàng bao gồm:
  • Credit Selector - Chuyển đổi giữa các quyền lợi credit khác nhau
  • Available Balance - Số dư hiện tại được hiển thị lớn và nổi bật
  • Apply Credit/Debit - Nút điều chỉnh thủ công số dư của khách hàng
  • Recent Transactions - Ledger đầy đủ gồm ngày, transaction ID, loại, số lượng và số dư lũy kế

Điều chỉnh thủ công

Bạn có thể cộng hoặc trừ số dư của khách hàng theo cách thủ công trực tiếp từ dashboard:
1

Navigate to Customer

Đi tới Customers và chọn khách hàng.
2

Open Credits Tab

Nhấp vào tab Credits và chọn quyền lợi credit phù hợp từ bộ chọn wallet.
3

Apply Credit or Debit

Nhấp Apply Credit/Debit để mở giao diện điều chỉnh.
string
bắt buộc
Chọn Credit để thêm credit hoặc Debit để trừ credit khỏi số dư của khách hàng.
number
bắt buộc
Số credit cần thêm hoặc trừ.
string
Phần giải thích tùy chọn cho việc điều chỉnh (ví dụ: “Service compensation” hoặc “Promotional bonus”).
4

Confirm

Xem lại và áp dụng điều chỉnh. Thay đổi được phản ánh ngay lập tức trong số dư của khách hàng và được ghi lại trong credit ledger.
Điều chỉnh thủ công tạo một mục ledger manual_adjustment với audit trail đầy đủ.

Credit Ledger

Mọi thao tác credit đều được ghi lại trong credit ledger, cung cấp audit trail đầy đủ: Mỗi mục ledger ghi lại số dư trước và sau giao dịch, overage trước và sau giao dịch, mô tả và tham chiếu đến nguồn (payment, subscription, v.v.).

Webhooks

Credit-Based Billing phát webhook event cho mọi thay đổi trong vòng đời credit. Sử dụng các event này để đồng bộ ứng dụng với số dư credit, kích hoạt thông báo hoặc xây dựng workflow billing tùy chỉnh. Tất cả ledger event (mọi event credit.* ngoại trừ credit.balance_low) đều bao gồm payload CreditLedgerEntry đầy đủ với số dư trước/sau, overage trước/sau, tham chiếu nguồn và metadata của subscription hoặc payment nguồn của grant (để trống đối với grant được tạo trực tiếp qua API). Event credit.balance_low bao gồm cấu hình ngưỡng và số dư hiện tại.

Credit Webhook Payloads

Xem đầy đủ schema payload, mô tả field và ví dụ tích hợp cho tất cả credit webhook event.

Quản lý API

Sử dụng API để tạo quyền lợi credit theo cách lập trình, với toàn quyền kiểm soát các thiết lập rollover, overage và hết hạn.

Create Credit Entitlement

Tạo quyền lợi credit mới với cấu hình rollover, overage và hết hạn.

List Credit Entitlements

Lấy tất cả quyền lợi credit của doanh nghiệp.
Lấy, cập nhật hoặc xóa quyền lợi credit. Quyền lợi đã xóa có thể được khôi phục.

Get Credit Entitlement

Lấy một quyền lợi credit cụ thể theo ID.

Update Credit Entitlement

Cập nhật rollover, overage, thời hạn hoặc các thiết lập khác.

Delete Credit Entitlement

Xóa mềm một quyền lợi credit.

Undelete Credit Entitlement

Khôi phục quyền lợi credit đã bị xóa trước đó.
Cấp credit trực tiếp vào số dư của khách hàng mà không yêu cầu giao dịch mua, hoặc tạo các mục debit thủ công để điều chỉnh billing.

Create Ledger Entry

Cộng hoặc trừ số dư của khách hàng với audit trail đầy đủ và hỗ trợ idempotency.
Lấy số dư credit hiện tại, lịch sử grant và ledger giao dịch đầy đủ của khách hàng cho bất kỳ quyền lợi credit nào.

List Balances

Liệt kê tất cả số dư khách hàng cho một quyền lợi credit.

Get Customer Balance

Lấy số dư của một khách hàng cụ thể.

List Customer Grants

Xem tất cả grant credit của một khách hàng.

List Customer Ledger

Lịch sử giao dịch đầy đủ của một khách hàng.

Ví dụ tích hợp

Khởi tạo client Dodo Payments:
Đính kèm credit vào sản phẩm gói đăng ký trong checkout:
Gửi các sự kiện mức sử dụng để tự động khấu trừ credit:

Ví dụ thực tế

Cấu trúc giá:Cấu hình:
  • Loại credit: Custom Unit (“AI Tokens”)
  • Precision: 0 (token nguyên)
  • Rollover: tối đa 25%, thời hạn 1 tháng
  • Overage: Đã bật, tính phí overage tại thời điểm billing
  • Meter: ai.generation với phép tổng hợp Sum trên field tokens
Cấu trúc giá:Cấu hình:
  • Loại credit: Custom Unit (“API Calls”)
  • Precision: 0 (lượt gọi nguyên)
  • Rollover: Đã tắt
  • Overage: Gói Developer trở lên cho phép overage (miễn phí khi reset), gói Free tắt overage
  • Meter: api.request với phép tổng hợp Count
Cấu trúc giá:Cấu hình:
  • Loại tín dụng: Đơn vị tùy chỉnh (“GB-hours”)
  • Độ chính xác: 2 (hai chữ số thập phân)
  • Chuyển số dư: tối đa 50%, chuyển sang một lần
  • Vượt mức: Đã bật, với giới hạn vượt mức được đặt theo GB-hours
  • Meter: storage.usage với phép tổng hợp Sum

Phương pháp hay nhất

  • Bắt đầu đơn giản: Bắt đầu với một loại credit duy nhất và không rollover. Thêm độ phức tạp dựa trên phản hồi của khách hàng và mẫu sử dụng.
  • Đặt kỳ vọng rõ ràng: Hiển thị nổi bật hạn mức credit, số dư còn lại và giá overage trên các trang sản phẩm và Customer Portal.
  • Sử dụng đơn vị có ý nghĩa: Đặt tên credit theo ý nghĩa của chúng (ví dụ: “API Calls” hoặc “AI Tokens”) thay vì các thuật ngữ chung chung. Điều này giúp khách hàng hiểu giá trị.
  • Cấu hình thời hạn một cách thận trọng: Thời hạn ngắn (7 ngày) tạo cảm giác cấp bách nhưng có thể khiến khách hàng khó chịu. Thời hạn dài hơn (30–90 ngày) thân thiện với khách hàng hơn đối với hầu hết sản phẩm SaaS.
  • Theo dõi số dư thấp: Đặt ngưỡng số dư thấp để cảnh báo khách hàng trước khi credit hết, giúp giảm các khoản phí overage bất ngờ.
  • Kiểm thử trong test mode: Tạo credit, đính kèm vào sản phẩm thử nghiệm và mô phỏng toàn bộ chu kỳ mua → sử dụng → khấu trừ → hết hạn trước khi triển khai chính thức.
Credit-Based Billing hoạt động với tất cả tính năng khác của Dodo Payments: gói đăng ký có trial, thay đổi gói có proration và Customer Portal. Hãy bắt đầu với thiết lập cơ bản rồi mở rộng khi mô hình giá của bạn phát triển.
Lần sửa đổi cuối 26 tháng 9, 2026