Accountmaker Docs
功能

订阅

Stripe 订阅集成,包含 checkout、门户、同步与 webhook。

subscriptions stripe payments

订阅

AM 为账户管理 Stripe 订阅生命周期,让你专注于定价与访问控制,而不是处理 webhook。

创建 checkout 会话,让客户自主管理套餐,并保持账户访问与 Stripe 同步。

订阅流程

StripeAMUserStripeAMUserStart checkoutCreate checkout sessionRedirect to StripeComplete paymentWebhook: checkout.session.completedSync subscription + features

Endpoints

Endpoint用途
POST /api/accounts/:account_id/subscriptions/stripe/checkout-session启动订阅 checkout
POST /api/accounts/:account_id/subscriptions/stripe/portal-session打开客户门户
POST /api/accounts/:account_id/subscriptions/stripe/checkout-session-sync同步 checkout 与订阅
POST /api/accounts/:account_id/subscriptions/sync从 Stripe 同步订阅
POST /api/accounts/:account_id/subscriptions/change更改套餐或价格
POST /api/accounts/:account_id/subscriptions/cancel取消订阅
GET /api/accounts/:account_id/subscriptions订阅列表
GET /api/accounts/:account_id/subscriptions/features激活功能列表
GET /api/accounts/:account_id/subscriptions/identity获取 Stripe 客户身份
POST /api/applications/:application_id/subscriptions/stripe/webhookStripe Webhook

Checkout 会话

创建 Stripe Checkout 会话用于新订阅:

// Request
{
  price_id: "price_...",
  success_url: "https://app.example.com/success",
  cancel_url: "https://app.example.com/cancel"
}

// Response
{
  url: "https://checkout.stripe.com/..."
}

将用户重定向到返回的 URL。支付完成后,Stripe 会跳转到你的成功 URL。

客户门户

允许客户自助管理:

  • 更新支付方式
  • 查看发票
  • 取消订阅
  • 切换套餐
// Request
{
  return_url: "https://app.example.com/settings";
}

// Response
{
  url: "https://billing.stripe.com/...";
}

订阅身份

每个账户都有订阅身份,将账户映射到 Stripe 客户。用于解析 webhook 并同步计费状态。

Webhook 事件

AM 处理 Stripe webhook,并在失败时重试:

事件动作
checkout.session.completed绑定客户并创建订阅
customer.subscription.*同步订阅数据
invoice.paid同步发票并更新访问
invoice.payment_failed更新访问窗口

相关