curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
サブスクリプション
請求ポータルセッションの作成
契約や支払い方法を管理する Stripe Billing Portal のセッションを作成します。
POST
/
subscriptions
/
portal
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
概要
Stripe Customer Portal のセッションを作成します。ユーザーはそこで次の操作ができます。- 支払い方法の更新
- 請求履歴の確認
- プラン変更
- 請求書のダウンロード
- 契約の解約
サードパーティ連携: API キー認証で
POST /subscriptions/portal/api を利用してください。認証
string
必須
JWT アクセストークン。形式:
Bearer YOUR_ACCESS_TOKENリクエストボディ
string
ポータル終了後のリダイレクト URL。既定はアプリのダッシュボードです。
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
レスポンスフィールド
string
ユーザーがアクセスする URL。Stripe がホストする Billing Portal です。
ポータルでできること
Stripe Customer Portal ではユーザーは次が行えます。| 機能 | 説明 |
|---|---|
| 支払い方法 | カードの追加・更新・削除 |
| 請求書 | 過去の請求書の閲覧とダウンロード |
| プラン変更 | サブスクのアップグレード/ダウングレード |
| 解約 | サブスクの解約 |
| 請求履歴 | すべての請求・取引の閲覧 |
エラーレスポンス
不正なリクエスト — 請求用アカウントが見つからない場合。先に購入が必要です。
未認証 — トークンが無効または未指定です。
Billing Portal は、過去に購入済みまたはアクティブな契約があるユーザーのみ利用できます。新規ユーザーは Checkout エンドポイントを利用してください。
POST /subscriptions/portal/api
API キー認証で Stripe Customer Portal セッションを作成します。サードパーティ連携向けです。認証
API キー認証が必要です。Authorization ヘッダーに API キーを付与します。
Authorization: Bearer llmgen_your_api_key_here
リクエストボディ
/subscriptions/portal と同一です。
レスポンス
/subscriptions/portal と同一です。
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal/api \
-H "Authorization: Bearer llmgen_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal/api', {
method: 'POST',
headers: {
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal/api',
headers={
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
運用上のヒント
- 設定へのリンク: アプリ設定に「請求を管理」ボタンを置く
- Checkout 後: 契約購入直後はポータルへ誘導するとよい
- サポート: 請求に関するセルフサービスとしてポータルを案内する
このページは役に立ちましたか?
⌘I