AM
ZH-TW
免費開始
選單
功能

訂閱

Stripe 訂閱整合,包含 checkout、portal、同步與 webhook 處理。

subscriptions stripe payments

訂閱

AM 代管帳戶的 Stripe 訂閱生命週期,讓你專注在定價與存取控制,而不是 webhook 處理細節。

你可以建立 checkout session、讓客戶自行管理方案,並將帳戶權限狀態與 Stripe 保持同步。

訂閱流程

StripeAM使用者StripeAM使用者開始結帳建立結帳工作階段重新導向至 Stripe完成付款Webhook: checkout.session.completed同步訂閱 + 功能

端點

Endpoint用途
POST /api/accounts/:account_id/subscriptions/stripe/checkout-session啟動訂閱 checkout
POST /api/accounts/:account_id/subscriptions/stripe/portal-session開啟客戶 portal
POST /api/accounts/:account_id/subscriptions/stripe/checkout-session-sync將 checkout session 同步為訂閱資料
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 Session

建立新的 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 會導回你的 success URL。

Customer Portal

讓客戶自行管理:

  • 更新付款方式
  • 檢視發票
  • 取消訂閱
  • 變更方案
// Request
{
  return_url: "https://app.example.com/settings";
}

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

訂閱身分

每個帳戶都有一個 subscription identity,將帳戶對應到 Stripe customer。此資料用於解析 Stripe webhook 並同步計費狀態。

Webhook 事件

AM 會處理 Stripe webhook,失敗時自動重試:

Event動作
checkout.session.completed連結 customer 並建立訂閱
customer.subscription.*同步訂閱資料
invoice.paid同步發票並更新存取狀態
invoice.payment_failed更新可用存取期間

相關