IM
JA
ドキュメントホーム
メニュー
ガイド

サブスクリプション所有者コントロール

api.inbox-manager.com を通じて、アカウント所有者としてサブスクリプションのライフサイクル アクションを管理します。

inbox-manager subscriptions client-flow

サブスクリプション所有者コントロール

目的: アカウント所有者がプランを検査し、サブスクリプションのライフサイクル アクションを実行できるようにします。

UI フロー

  1. ユーザーは、トークンで選択されたアカウントの請求ページを開きます。
  2. UI は GET /api/subscriptions をロードします。
  3. UI は GET /api/subscriptions/features をロードします。
  4. UI は GET /api/subscriptions/identity をロードします。
  5. UI は GET /api/subscriptions/merchants をロードします。
  6. 所有者が請求アクションを開始すると、UI はチェックアウト セッションまたはポータル セッションを作成します。
  7. UI は、明示的な所有者のアクションから同期/変更/キャンセルのアクションを実行します。

クライアント ライブラリ フロー

const subs = await api.subscriptions.list();
const features = await api.subscriptions.features();
const merchants = await api.subscriptions.merchants();

const checkout = await api.subscriptions.createCheckoutSession({
  price_id,
  success_url,
  cancel_url,
});

await api.subscriptions.change(subscriptionId, {
  interval: "year",
});

HTTP/カールフロー

API_BASE_URL="https://api.inbox-manager.com"

curl -sS "${API_BASE_URL}/api/subscriptions" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/subscriptions/features" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/subscriptions/identity" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS "${API_BASE_URL}/api/subscriptions/merchants" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/stripe/checkout-session" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"price_id\":\"${PRICE_ID}\",\"success_url\":\"${SUCCESS_URL}\",\"cancel_url\":\"${CANCEL_URL}\"}"

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/stripe/portal-session" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"return_url\":\"${RETURN_URL}\"}"

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/sync?allow_deletes=false" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{}'

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/${SUBSCRIPTION_ID}/change" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"interval":"month"}'

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/${SUBSCRIPTION_ID}/cancel" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"timing":"period_end"}'

curl -sS -X POST "${API_BASE_URL}/api/subscriptions/stripe/checkout-session-sync" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data "{\"session_id\":\"${SESSION_ID}\"}"

注意事項

  • サブスクリプション ルートはアカウントレスです。アカウント コンテキストは JWT acc から取得されます。
  • 所有者の承認は、上流の認証サブスクリプション エンドポイントによって強制されます。
  • inbox-manager はユーザーベアラートークンを直接転送します。
  • Stripe Webhook コールバックは inbox-manager を通じてプロキシされません。