サブスクリプション所有者コントロール
目的: アカウント所有者がプランを検査し、サブスクリプションのライフサイクル アクションを実行できるようにします。
UI フロー
- ユーザーは、トークンで選択されたアカウントの請求ページを開きます。
- UI は
GET /api/subscriptionsをロードします。 - UI は
GET /api/subscriptions/featuresをロードします。 - UI は
GET /api/subscriptions/identityをロードします。 - UI は
GET /api/subscriptions/merchantsをロードします。 - 所有者が請求アクションを開始すると、UI はチェックアウト セッションまたはポータル セッションを作成します。
- 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を通じてプロキシされません。