stripe-billing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStripe Billing
Stripe Billing
Implement subscriptions, invoicing, and flexible pricing models for recurring revenue.
为经常性收入实现订阅、发票和灵活定价模型。
Rule Priority
规则优先级
| Priority | Rule | Impact | Description |
|---|---|---|---|
| 1 | | HIGH | Create subscriptions via Checkout for built-in payment collection, SCA, and tax |
| 2 | | HIGH | Use |
| 3 | | HIGH | Expand |
| 4 | | HIGH | Always verify webhook signatures to prevent forged events |
| 5 | | HIGH | Sync state on every |
| 6 | | HIGH | Use |
| 7 | | HIGH | Design handlers for at-least-once delivery with event deduplication |
| 8 | | HIGH | Acknowledge webhooks immediately, process asynchronously |
| 9 | | HIGH | Use |
| 10 | | HIGH | Enable ML-powered Smart Retries for optimal payment recovery |
| 11 | | HIGH | Cancel at period end for better UX and win-back opportunity |
| 12 | | HIGH | Collect payment method during trial for higher conversion |
| 13 | | HIGH | Include idempotency keys with usage records to prevent double-counting |
| 14 | | HIGH | Flush usage buffers before period end to prevent revenue leakage |
| 15 | | HIGH | Explicitly list products/prices in portal configuration |
| 16 | | HIGH | Use |
| 17 | | MEDIUM | Preview upcoming invoice before applying subscription changes |
| 18 | | MEDIUM | Handle |
| 19 | | MEDIUM | Use Billing Meters over legacy usage records for new integrations |
| 20 | | MEDIUM | Use |
| 21 | | MEDIUM | Pause subscriptions instead of canceling for temporary stops |
| 22 | | MEDIUM | Escalate dunning communications over retry attempts |
| 23 | | MEDIUM | Deactivate old prices instead of deleting them |
| 优先级 | 规则 | 影响程度 | 描述 |
|---|---|---|---|
| 1 | | HIGH | 通过Checkout创建订阅,以利用内置的收款、SCA和税务功能 |
| 2 | | HIGH | 对于通过API创建的订阅,使用 |
| 3 | | HIGH | 展开 |
| 4 | | HIGH | 始终验证Webhook签名,防止伪造事件 |
| 5 | | HIGH | 在每次 |
| 6 | | HIGH | 使用 |
| 7 | | HIGH | 设计支持至少一次交付的处理器,实现事件去重 |
| 8 | | HIGH | 立即确认Webhook请求,异步处理业务逻辑 |
| 9 | | HIGH | 使用 |
| 10 | | HIGH | 启用基于机器学习的智能重试功能,优化付款回收率 |
| 11 | | HIGH | 在计费周期结束时取消订阅,以获得更好的用户体验和赢回客户的机会 |
| 12 | | HIGH | 在试用期间收集付款方式,提高转化率 |
| 13 | | HIGH | 在使用记录中包含幂等键,防止重复统计 |
| 14 | | HIGH | 在计费周期结束前刷新使用量缓冲区,防止收入流失 |
| 15 | | HIGH | 在门户配置中明确列出允许的产品/价格 |
| 16 | | HIGH | 对于低于1美分的定价,使用 |
| 17 | | MEDIUM | 在应用订阅变更前预览即将生成的发票 |
| 18 | | MEDIUM | 处理 |
| 19 | | MEDIUM | 对于新集成,优先使用Billing Meters而非旧版使用记录 |
| 20 | | MEDIUM | 使用 |
| 21 | | MEDIUM | 对于临时停用的情况,暂停订阅而非直接取消 |
| 22 | | MEDIUM | 在重试付款过程中逐步升级催款沟通方式 |
| 23 | | MEDIUM | 停用旧价格而非删除它们 |
Pricing Model Decision Tree
定价模型决策树
What pricing model fits your product?
|
+-- Fixed monthly/annual fee?
| -> Flat-rate pricing (references/pricing-models.md)
|
+-- Per-seat / per-unit?
| -> Per-unit pricing (references/pricing-models.md)
|
+-- Volume tiers (price decreases with quantity)?
| -> Tiered pricing (references/pricing-models.md)
|
+-- Pay for what you use (API calls, storage)?
| -> Usage-based / metered (references/usage-based.md)
|
+-- Hybrid (base fee + usage)?
-> Multiple prices on one subscription (references/pricing-models.md)你的产品适合哪种定价模型?
|
+-- 固定月费/年费?
| -> 固定费率定价(references/pricing-models.md)
|
+-- 按席位/按单位?
| -> 按单位定价(references/pricing-models.md)
|
+-- 阶梯式定价(购买量越大单价越低)?
| -> 分层定价(references/pricing-models.md)
|
+-- 按使用量付费(API调用、存储等)?
| -> 基于使用量/计量计费(references/usage-based.md)
|
+-- 混合模式(基础费用+使用量费用)?
-> 单个订阅关联多个价格(references/pricing-models.md)Quick Start: SaaS Subscription
快速开始:SaaS订阅
1. Create Product + Price (once, or via Dashboard)
1. 创建产品+价格(一次性操作,或通过控制台完成)
typescript
const product = await stripe.products.create({
name: 'Pro Plan',
description: 'Full access to all features',
});
const price = await stripe.prices.create({
product: product.id,
unit_amount: 2900, // $29/month
currency: 'usd',
recurring: { interval: 'month' },
lookup_key: 'pro_monthly',
});typescript
const product = await stripe.products.create({
name: 'Pro Plan',
description: 'Full access to all features',
});
const price = await stripe.prices.create({
product: product.id,
unit_amount: 2900, // $29/月
currency: 'usd',
recurring: { interval: 'month' },
lookup_key: 'pro_monthly',
});2. Create Subscription via Checkout
2. 通过Checkout创建订阅
typescript
const session = await stripe.checkout.sessions.create({
customer: 'cus_xxx', // or let Checkout create one
line_items: [{ price: price.id, quantity: 1 }],
mode: 'subscription',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://example.com/cancel',
});typescript
const session = await stripe.checkout.sessions.create({
customer: 'cus_xxx', // 或让Checkout自动创建客户
line_items: [{ price: price.id, quantity: 1 }],
mode: 'subscription',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://example.com/cancel',
});3. Or Create Subscription Directly (with existing payment method)
3. 或直接创建订阅(使用已有的付款方式)
typescript
const subscription = await stripe.subscriptions.create({
customer: 'cus_xxx',
items: [{ price: price.id }],
default_payment_method: 'pm_xxx',
payment_behavior: 'default_incomplete', // requires client confirmation
expand: ['latest_invoice.payment_intent'],
});
// Return subscription.latest_invoice.payment_intent.client_secret to frontendtypescript
const subscription = await stripe.subscriptions.create({
customer: 'cus_xxx',
items: [{ price: price.id }],
default_payment_method: 'pm_xxx',
payment_behavior: 'default_incomplete', // 需要客户端确认
expand: ['latest_invoice.payment_intent'],
});
// 将subscription.latest_invoice.payment_intent.client_secret返回给前端Subscription Lifecycle
订阅生命周期
incomplete -> active -> past_due -> canceled
-> canceled (immediate)
-> paused
trialing -> active (payment succeeds)
-> incomplete (payment fails)
-> canceled (trial ends, no payment method)incomplete -> active -> past_due -> canceled
-> canceled (立即取消)
-> paused
trialing -> active (付款成功)
-> incomplete (付款失败)
-> canceled (试用结束,无付款方式)Customer Portal (Self-Service)
客户门户(自助服务)
typescript
// One-time setup in Dashboard or API
const configuration = await stripe.billingPortal.configurations.create({
features: {
subscription_update: { enabled: true, products: [{ product: 'prod_xxx', prices: ['price_basic', 'price_pro'] }] },
subscription_cancel: { enabled: true, mode: 'at_period_end' },
payment_method_update: { enabled: true },
invoice_history: { enabled: true },
},
});
// Generate portal session per customer
const portalSession = await stripe.billingPortal.sessions.create({
customer: 'cus_xxx',
return_url: 'https://example.com/account',
});
// Redirect to portalSession.urltypescript
// 在控制台或API中完成一次性配置
const configuration = await stripe.billingPortal.configurations.create({
features: {
subscription_update: { enabled: true, products: [{ product: 'prod_xxx', prices: ['price_basic', 'price_pro'] }] },
subscription_cancel: { enabled: true, mode: 'at_period_end' },
payment_method_update: { enabled: true },
invoice_history: { enabled: true },
},
});
// 为每个客户生成门户会话
const portalSession = await stripe.billingPortal.sessions.create({
customer: 'cus_xxx',
return_url: 'https://example.com/account',
});
// 重定向到portalSession.urlCritical Webhooks
关键Webhook事件
| Event | Action |
|---|---|
| Provision access |
| Handle plan changes, cancellation scheduling, status transitions |
| Revoke access |
| Remind user (3 days before) |
| Confirm payment, extend access |
| Notify user, trigger dunning escalation |
| Preview next charge |
| 事件 | 操作 |
|---|---|
| 开通服务权限 |
| 处理计划变更、取消安排、状态转换 |
| 收回服务权限 |
| 提醒用户(到期前3天) |
| 确认付款,延长服务权限 |
| 通知用户,触发催款升级流程 |
| 预览下一次收费 |
Quick Reference
快速参考
| Topic | Key Concept | Reference |
|---|---|---|
| Flat/tiered pricing | Products have multiple Prices; use | references/pricing-models.md |
| Subscription creation | Prefer Checkout; use | references/subscription-lifecycle.md |
| Usage billing | Billing Meters (modern) or Usage Records (legacy) | references/usage-based.md |
| Trials | | references/trials.md |
| Invoices | | references/invoices.md |
| Customer portal | Configure products explicitly; use deep links | references/customer-portal.md |
| Dunning | Smart Retries + escalating communications | references/dunning.md |
| Coupons | Coupons (internal) + Promotion Codes (customer-facing) | references/coupons.md |
| Proration | | references/proration.md |
| Schedules | Phase-based automation; max 10 phases | references/schedules.md |
| 主题 | 核心概念 | 参考文档 |
|---|---|---|
| 固定/分层定价 | 产品可关联多个Price;使用 | references/pricing-models.md |
| 订阅创建 | 优先使用Checkout;API创建时使用 | references/subscription-lifecycle.md |
| 使用量计费 | Billing Meters(现代方案)或使用记录(旧版) | references/usage-based.md |
| 试用 | | references/trials.md |
| 发票 | | references/invoices.md |
| 客户门户 | 明确配置允许的产品;使用深度链接 | references/customer-portal.md |
| 催款 | 智能重试+逐步升级的沟通方式 | references/dunning.md |
| 优惠券 | 优惠券(内部)+促销代码(面向客户) | references/coupons.md |
| 按比例计费 | | references/proration.md |
| 订阅计划 | 基于阶段的自动化;最多10个阶段 | references/schedules.md |
References
参考文档
- references/pricing-models.md - Flat, tiered, per-unit, graduated, volume pricing
- references/subscription-lifecycle.md - Create, update, cancel, pause, resume
- references/usage-based.md - Metered billing, usage records, aggregation
- references/trials.md - Free trials with/without payment method, trial conversions
- references/invoices.md - Invoice generation, customization, hosted page
- references/customer-portal.md - Self-service configuration and customization
- references/dunning.md - Smart retries, failed payment emails, recovery
- references/coupons.md - Coupons, promotion codes, discounts
- references/proration.md - Mid-cycle upgrades/downgrades, proration behavior
- references/schedules.md - Subscription schedules for future changes
- references/pricing-models.md - 固定费率、分层、按单位、梯度、批量定价
- references/subscription-lifecycle.md - 创建、更新、取消、暂停、恢复
- references/usage-based.md - 计量计费、使用记录、聚合
- references/trials.md - 带/不带付款方式的免费试用、试用转换
- references/invoices.md - 发票生成、自定义、托管页面
- references/customer-portal.md - 自助服务配置和自定义
- references/dunning.md - 智能重试、付款失败邮件、恢复
- references/coupons.md - 优惠券、促销代码、折扣
- references/proration.md - 周期内升级/降级、按比例计费行为
- references/schedules.md - 用于未来变更的订阅计划