subscription-billing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Subscription Billing

订阅计费

Overview

概述

Subscription billing lets customers pay automatically on a recurring schedule — weekly, monthly, or annually. Shopify, WooCommerce, and BigCommerce each have dedicated subscription apps and plugins that handle the full lifecycle: initial checkout, recurring billing, failed payment recovery (dunning), plan changes, pausing, and cancellation. For headless storefronts, Stripe Subscriptions provides the same functionality via API with no need to build billing logic from scratch.
定期订阅计费让客户按定期计划自动付款——每周、每月或每年。Shopify、WooCommerce和BigCommerce各自都有专门的订阅应用和插件,可处理完整的生命周期:初始结账、定期计费、失败付款追回(催缴)、套餐变更、暂停和取消。对于无头店铺,Stripe Subscriptions通过API提供相同功能,无需从零开始构建计费逻辑。

When to Use This Skill

何时使用此技能

  • When building a subscription box, membership, or "Subscribe & Save" program
  • When the current subscription logic is manual and not scaling with customer count
  • When dunning (failed payment recovery) is not automated and causing unnecessary churn
  • When customers need self-serve plan upgrades, downgrades, pausing, and cancellation
  • 构建订阅盒子、会员服务或“订阅即省钱”项目时
  • 当前订阅逻辑为手动操作,无法随客户数量扩展时
  • 失败付款追回(催缴)未自动化,导致不必要的客户流失时
  • 客户需要自助进行套餐升级、降级、暂停和取消操作时

Core Instructions

核心操作指南

Step 1: Determine your platform and choose the right subscription tool

步骤1:确定平台并选择合适的订阅工具

PlatformRecommended ToolNotes
ShopifyRecharge or Seal Subscriptions or Bold Subscriptions (Shopify App Store)Shopify has a native Subscriptions API; Recharge is the most widely used third-party app; Seal is a newer lower-cost option
Shopify (simple)Shopify Subscriptions (built-in, free)For basic subscription needs — launched 2024; handles simple recurring orders
WooCommerceWooCommerce Subscriptions ($199/year, official WooCommerce extension)The official and most complete WooCommerce subscription solution; handles all billing, dunning, and management
BigCommerceRecurly (via BigCommerce App Marketplace) or RebillyBigCommerce does not have native subscriptions; third-party apps handle it
Custom / HeadlessStripe SubscriptionsStripe Subscriptions handles the complete recurring billing lifecycle with webhooks
平台推荐工具说明
ShopifyRechargeSeal SubscriptionsBold Subscriptions(Shopify应用商店)Shopify拥有原生Subscriptions API;Recharge是使用最广泛的第三方应用;Seal是成本更低的新选项
Shopify(简易版)Shopify Subscriptions(内置免费工具)适用于基础订阅需求——2024年推出;处理简单的定期订单
WooCommerceWooCommerce Subscriptions(199美元/年,官方WooCommerce扩展)官方且最完整的WooCommerce订阅解决方案;处理所有计费、催缴和管理工作
BigCommerceRecurly(通过BigCommerce应用市场)或 RebillyBigCommerce无原生订阅功能;由第三方应用处理
自定义/无头店铺Stripe SubscriptionsStripe Subscriptions通过webhooks处理完整的定期计费生命周期

Step 2: Set up subscriptions on your platform

步骤2:在你的平台上设置订阅服务



Shopify (Shopify Subscriptions — built-in, free)

Shopify(Shopify Subscriptions——内置免费工具)

For basic subscription products:
  1. Go to Settings → Apps and sales channels → Shopify Subscriptions (may need to install from App Store)
  2. Go to Products and open any product you want to make subscribable
  3. Under Purchase options, click Add subscription plan
  4. Configure:
    • Billing frequency: weekly, monthly, every X months
    • Discount for subscribers (e.g., 10% off vs. one-time purchase)
    • Free trial period (optional)
  5. The product page will show both "One-time purchase" and "Subscribe & Save" options
Shopify Subscriptions handles: recurring billing, payment failure emails, and a customer portal for managing subscriptions. For advanced dunning, analytics, and subscriber portals, use Recharge or Seal Subscriptions.
针对基础订阅产品:
  1. 前往 设置 → 应用和销售渠道 → Shopify Subscriptions(可能需要从应用商店安装)
  2. 进入 产品 并打开任何要设置为可订阅的产品
  3. 购买选项 下,点击 添加订阅计划
  4. 配置:
    • 计费频率:每周、每月、每X个月
    • 订阅用户折扣(例如:比一次性购买优惠10%)
    • 免费试用期(可选)
  5. 产品页面将同时显示“一次性购买”和“订阅即省钱”选项
Shopify Subscriptions处理:定期计费、付款失败邮件,以及供用户管理订阅的客户门户。如需高级催缴、分析和订阅者门户,请使用Recharge或Seal Subscriptions。

Shopify (Recharge — recommended for scale)

Shopify(Recharge——推荐用于规模化场景)

  1. Install Recharge from the Shopify App Store
  2. Connect your Shopify store and Stripe account in Recharge → Settings → Payment Processors
  3. Configure subscription products in Recharge → Products → Add product:
    • Select which Shopify products can be purchased as subscriptions
    • Set billing intervals (weekly, monthly, every 2 months, etc.)
    • Configure subscriber discounts
  4. Set up the customer portal: go to Recharge → Customer Portal to configure what subscribers can manage themselves (pause, skip, change date, cancel, swap product)
  5. Configure dunning: go to Recharge → Settings → Dunning and set up the retry schedule and email sequence for failed payments
Recharge dunning defaults:
  • Day 0: First payment failure → email customer
  • Day 3: Retry payment → email customer
  • Day 7: Retry payment → final warning email
  • Day 14: Retry payment → subscription cancelled if still failed
  1. 从Shopify应用商店安装 Recharge
  2. Recharge → 设置 → 支付处理器 中连接你的Shopify店铺和Stripe账户
  3. Recharge → 产品 → 添加产品 中配置订阅产品:
    • 选择哪些Shopify产品可按订阅方式购买
    • 设置计费间隔(每周、每月、每2个月等)
    • 配置订阅用户折扣
  4. 设置客户门户:前往 Recharge → 客户门户,配置订阅者可自行管理的操作(暂停、跳过、更改日期、取消、更换产品)
  5. 配置催缴:前往 Recharge → 设置 → 催缴,设置失败付款的重试计划和邮件序列
Recharge催缴默认设置:
  • 第0天:首次付款失败 → 发送邮件通知客户
  • 第3天:重试付款 → 发送邮件通知客户
  • 第7天:重试付款 → 发送最终警告邮件
  • 第14天:重试付款 → 若仍失败则取消订阅

WooCommerce (WooCommerce Subscriptions)

WooCommerce(WooCommerce Subscriptions)

  1. Purchase and install WooCommerce Subscriptions from woocommerce.com/products/woocommerce-subscriptions
  2. Create a subscription product: go to Products → Add New and set product type to Simple subscription or Variable subscription
  3. Configure under Subscription data:
    • Billing period: daily, weekly, monthly, annually
    • Billing interval: every 1, 2, 3... periods
    • Subscription length: ongoing or limited (e.g., 12 months)
    • Sign-up fee (optional)
    • Free trial period (optional)
    • Subscriber discount (set via regular/sale price comparison)
  4. Configure payment methods: go to WooCommerce → Settings → Payments and ensure your gateway supports recurring payments (Stripe via WooCommerce Stripe plugin, PayPal via WooCommerce PayPal Payments)
  5. Configure dunning: go to WooCommerce → Settings → Subscriptions → Failing payments and set retry rules and email templates
Customer portal for WooCommerce: Customers manage subscriptions from their My Account → Subscriptions page. WooCommerce Subscriptions provides pause, cancel, and payment method update functionality there by default.
  1. 从woocommerce.com/products/woocommerce-subscriptions购买并安装 WooCommerce Subscriptions
  2. 创建订阅产品:前往 产品 → 添加新品,将产品类型设置为 简单订阅可变订阅
  3. 订阅数据 下配置:
    • 计费周期:每日、每周、每月、每年
    • 计费间隔:每1、2、3...个周期
    • 订阅时长:持续或有限期(例如12个月)
    • 注册费(可选)
    • 免费试用期(可选)
    • 订阅用户折扣(通过常规价格/促销价格对比设置)
  4. 配置支付方式:前往 WooCommerce → 设置 → 支付,确保你的支付网关支持定期付款(通过WooCommerce Stripe插件使用Stripe,通过WooCommerce PayPal Payments使用PayPal)
  5. 配置催缴:前往 WooCommerce → 设置 → 订阅 → 失败付款,设置重试规则和邮件模板
WooCommerce客户门户: 客户可从 我的账户 → 订阅 页面管理订阅。WooCommerce Subscriptions默认在此提供暂停、取消和更新支付方式的功能。

BigCommerce (Recurly)

BigCommerce(Recurly)

  1. Sign up at recurly.com and create a plan (monthly, annual, etc.) with your pricing
  2. Install the Recurly app from the BigCommerce App Marketplace and connect your store
  3. Create subscription products that link to your Recurly plans
  4. Recurly handles: checkout, recurring billing, dunning, invoicing, and the subscriber portal
  5. Configure dunning in Recurly → Configuration → Dunning Campaigns: set retry schedule and email content

  1. recurly.com 注册并创建套餐(月度、年度等)及定价
  2. 从BigCommerce应用市场安装Recurly应用并连接你的店铺
  3. 创建关联Recurly套餐的订阅产品
  4. Recurly处理:结账、定期计费、催缴、发票和订阅者门户
  5. Recurly → 配置 → 催缴活动 中配置催缴:设置重试计划和邮件内容

Custom / Headless

自定义/无头店铺

Use Stripe Subscriptions for the full recurring billing lifecycle:
Create a subscription plan: In the Stripe Dashboard → Products, create a product with a recurring price (e.g., "Monthly Plan — $29/month"). Copy the Price ID (starts with
price_
).
Subscribe a customer:
javascript
// Create or retrieve the Stripe customer
const customer = await stripe.customers.create({
  email: customerEmail,
  payment_method: paymentMethodId,
  invoice_settings: { default_payment_method: paymentMethodId },
});

// Create the subscription
const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: 'price_monthly_pro_29' }], // Price ID from Stripe Dashboard
  payment_behavior: 'default_incomplete', // Create subscription, then confirm payment
  payment_settings: { save_default_payment_method: 'on_subscription' },
  expand: ['latest_invoice.payment_intent'],
  trial_period_days: 14, // Optional trial
  metadata: { customer_id: customerId },
});

// Return client_secret for 3DS confirmation if needed
const clientSecret = subscription.latest_invoice?.payment_intent?.client_secret;
res.json({ subscriptionId: subscription.id, clientSecret });
Sync subscription status via webhooks:
javascript
// Webhook handler for subscription events
async function handleSubscriptionWebhook(event) {
  switch (event.type) {
    case 'customer.subscription.updated':
      await syncSubscriptionStatus(event.data.object);
      break;

    case 'customer.subscription.deleted':
      // Subscription cancelled — revoke access
      await db.subscriptions.update({
        where: { stripeSubscriptionId: event.data.object.id },
        data: { status: 'cancelled', cancelledAt: new Date() },
      });
      break;

    case 'invoice.payment_succeeded':
      await recordSuccessfulBillingCycle(event.data.object);
      break;

    case 'invoice.payment_failed':
      // Send dunning email — Stripe retries automatically per your settings
      await sendDunningEmail(event.data.object);
      break;

    case 'customer.subscription.trial_will_end':
      // Send trial ending email 3 days before trial ends
      await sendTrialEndingEmail(event.data.object);
      break;
  }
}
Configure dunning in Stripe Dashboard: Go to Stripe Dashboard → Billing → Settings → Smart Retries. Enable Smart Retries — Stripe's ML-based retry timing outperforms fixed schedules. Also configure automatic subscription cancellation after all retries fail under Stripe Dashboard → Billing → Settings → Automatic collection.
Plan changes with prorations:
javascript
// Upgrade or downgrade a subscription
const subscription = await stripe.subscriptions.retrieve(stripeSubscriptionId);

await stripe.subscriptions.update(stripeSubscriptionId, {
  items: [{ id: subscription.items.data[0].id, price: newPriceId }],
  proration_behavior: 'create_prorations', // Charge/credit the difference immediately
});
// Stripe creates a prorated invoice automatically
Cancellation with end-of-period access:
javascript
// Cancel at period end — customer retains access until the next billing date
await stripe.subscriptions.update(stripeSubscriptionId, {
  cancel_at_period_end: true,
});

// Immediate cancellation
await stripe.subscriptions.cancel(stripeSubscriptionId);
使用 Stripe Subscriptions 处理完整的定期计费生命周期:
创建订阅套餐:Stripe控制台 → 产品 中,创建带有定期定价的产品(例如“月度套餐——29美元/月”)。复制价格ID(以
price_
开头)。
为客户订阅:
javascript
// 创建或获取Stripe客户
const customer = await stripe.customers.create({
  email: customerEmail,
  payment_method: paymentMethodId,
  invoice_settings: { default_payment_method: paymentMethodId },
});

// 创建订阅
const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: 'price_monthly_pro_29' }], // 来自Stripe控制台的价格ID
  payment_behavior: 'default_incomplete', // 创建订阅,然后确认付款
  payment_settings: { save_default_payment_method: 'on_subscription' },
  expand: ['latest_invoice.payment_intent'],
  trial_period_days: 14, // 可选试用期
  metadata: { customer_id: customerId },
});

// 若需要3DS验证则返回client_secret
const clientSecret = subscription.latest_invoice?.payment_intent?.client_secret;
res.json({ subscriptionId: subscription.id, clientSecret });
通过webhooks同步订阅状态:
javascript
// 订阅事件的webhook处理器
async function handleSubscriptionWebhook(event) {
  switch (event.type) {
    case 'customer.subscription.updated':
      await syncSubscriptionStatus(event.data.object);
      break;

    case 'customer.subscription.deleted':
      // 订阅已取消——撤销权限
      await db.subscriptions.update({
        where: { stripeSubscriptionId: event.data.object.id },
        data: { status: 'cancelled', cancelledAt: new Date() },
      });
      break;

    case 'invoice.payment_succeeded':
      await recordSuccessfulBillingCycle(event.data.object);
      break;

    case 'invoice.payment_failed':
      // 发送催缴邮件——Stripe会根据你的设置自动重试
      await sendDunningEmail(event.data.object);
      break;

    case 'customer.subscription.trial_will_end':
      // 试用期结束前3天发送提醒邮件
      await sendTrialEndingEmail(event.data.object);
      break;
  }
}
在Stripe控制台配置催缴: 前往 Stripe控制台 → 计费 → 设置 → 智能重试。启用智能重试——Stripe基于机器学习的重试时间安排比固定计划恢复更多失败付款。同时在 Stripe控制台 → 计费 → 设置 → 自动收款 下配置所有重试失败后的自动订阅取消规则。
带按比例计费的套餐变更:
javascript
// 升级或降级订阅
const subscription = await stripe.subscriptions.retrieve(stripeSubscriptionId);

await stripe.subscriptions.update(stripeSubscriptionId, {
  items: [{ id: subscription.items.data[0].id, price: newPriceId }],
  proration_behavior: 'create_prorations', // 立即收取/抵扣差额
});
// Stripe会自动生成按比例计费的发票
到期后取消(保留权限至周期结束):
javascript
// 周期结束时取消——客户保留权限至下一个计费日期
await stripe.subscriptions.update(stripeSubscriptionId, {
  cancel_at_period_end: true,
});

// 立即取消
await stripe.subscriptions.cancel(stripeSubscriptionId);

Best Practices

最佳实践

  • Use platform-native subscription tools — WooCommerce Subscriptions, Recharge on Shopify, and Stripe Subscriptions are all production-hardened and handle edge cases (failed payments, prorations, tax changes) correctly
  • Never store subscription state only in Stripe — always sync subscription status to your database via webhooks; do not call Stripe on every page load to check status
  • Configure Smart Retries in Stripe — enable under Stripe Dashboard → Billing → Settings; ML-based retry timing recovers significantly more failed payments than fixed schedules
  • Send dunning emails at each retry — escalate urgency: "payment failed" → "account at risk" → "access will be suspended"; include a direct link to update payment method
  • Let customers self-serve — build a customer portal (or use Stripe's hosted Customer Portal at Stripe Dashboard → Billing → Customer portal) for plan changes, pausing, and cancellation; reduces support load
  • Prorate upgrades immediately; apply downgrades at period end — upgrades should charge the difference now; downgrades should apply at the next renewal to avoid complex partial refunds
  • 使用平台原生订阅工具——WooCommerce Subscriptions、Shopify上的Recharge以及Stripe Subscriptions均经过生产环境验证,可正确处理边缘情况(失败付款、按比例计费、税费变更)
  • 切勿仅在Stripe中存储订阅状态——始终通过webhooks将订阅状态同步到你的数据库;不要在每次页面加载时调用Stripe检查状态
  • 在Stripe中配置智能重试——在 Stripe控制台 → 计费 → 设置 下启用;基于机器学习的重试时间安排比固定计划恢复的失败付款数量显著更多
  • 每次重试时发送催缴邮件——逐步提升紧急程度:“付款失败”→“账户存在风险”→“权限将被暂停”;包含更新支付方式的直接链接
  • 允许客户自助操作——构建客户门户(或使用Stripe托管的客户门户,位于 Stripe控制台 → 计费 → 客户门户)用于套餐变更、暂停和取消;减少支持工作量
  • 立即按比例收取升级费用;降级在周期结束时生效——升级应立即收取差额;降级应在下一次续订时生效,以避免复杂的部分退款

Common Pitfalls

常见陷阱

ProblemSolution
Subscription shows as active after cancellationSync status via webhooks —
customer.subscription.deleted
must trigger a database update; never poll Stripe for status on page load
WooCommerce Subscriptions not retrying failed paymentsVerify the payment gateway supports tokenized recurring payments; Stripe via the WooCommerce Stripe plugin supports this; basic PayPal Standard does not
Trial converts to paid without customer knowingSend the
trial_will_end
email 3 days before (Stripe fires the webhook automatically; Recharge and WooCommerce Subscriptions do this by default)
Duplicate dunning emails on retried webhooksCheck that the invoice attempt count matches the last dunning email you sent before sending another; use the invoice ID + attempt count as the idempotency key
Proration charges customer unexpectedly on upgradeShow the upcoming invoice preview before applying plan changes (Stripe: use
stripe.invoices.retrieveUpcoming()
); show the proration amount to the customer first
问题解决方案
取消后订阅仍显示为活跃状态通过webhooks同步状态——
customer.subscription.deleted
必须触发数据库更新;切勿在页面加载时轮询Stripe获取状态
WooCommerce Subscriptions未重试失败付款验证支付网关支持令牌化定期付款;通过WooCommerce Stripe插件使用Stripe支持此功能;基础PayPal标准版不支持
试用期未经客户知晓转为付费在试用期结束前3天发送
trial_will_end
邮件(Stripe会自动触发webhook;Recharge和WooCommerce Subscriptions默认执行此操作)
重试webhook时发送重复催缴邮件发送新邮件前检查发票尝试次数是否与上次发送的催缴邮件匹配;使用发票ID+尝试次数作为幂等键
升级时按比例计费意外向客户收费应用套餐变更前显示即将生成的发票预览(Stripe:使用
stripe.invoices.retrieveUpcoming()
);先向客户展示按比例计费的金额

Related Skills

相关技能

  • @stripe-integration
  • @order-processing-pipeline
  • @tax-calculation
  • @invoice-generation-automation
  • @stripe-integration
  • @order-processing-pipeline
  • @tax-calculation
  • @invoice-generation-automation