AM
JA
無料で始める
メニュー
機能

サブスクリプション

Stripe サブスクリプション連携(Checkout、Portal、同期、Webhook 処理)。

subscriptions サブスクリプション stripe payments 支払い

サブスクリプション

AccountMaker(以下「AM」)は Account 向けの Stripe サブスクリプションライフサイクルを管理し、Webhook 実装よりも価格設計とアクセス制御に集中できるようにします。

Checkout セッションを作成し、顧客にプラン管理を提供し、Stripe と Account のアクセス状態を同期します。

サブスクリプションフロー

StripeAMユーザーStripeAMユーザーチェックアウト開始チェックアウトセッションを作成Stripeへリダイレクト支払いを完了Webhook: checkout.session.completedサブスクリプションと機能を同期

エンドポイント

EndpointPurpose
POST /api/accounts/:account_id/subscriptions/stripe/checkout-sessionサブスクリプション Checkout を開始
POST /api/accounts/:account_id/subscriptions/stripe/portal-sessionCustomer Portal を開く
POST /api/accounts/:account_id/subscriptions/stripe/checkout-session-syncCheckout セッションを購読情報へ同期
POST /api/accounts/:account_id/subscriptions/syncStripe から購読情報を同期
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/identityStripe Customer Identity を取得
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/...";
}

サブスクリプション Identity

各 Account は Stripe Customer に対応する Subscription Identity を持ちます。Stripe Webhook の解決と課金状態同期で利用します。

Webhook イベント

AM は Stripe Webhook を処理し、失敗時はリトライします。

EventAction
checkout.session.completed顧客を紐付けてサブスクリプションを作成
customer.subscription.*サブスクリプションデータを同期
invoice.paid請求書同期とアクセス更新
invoice.payment_failedアクセス期間を更新

関連