跳转到主要内容
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"
  }'
{
  "url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}

Documentation Index

Fetch the complete documentation index at: https://docs.llmgenerator.com/llms.txt

Use this file to discover all available pages before exploring further.

概述

创建 Stripe Customer Portal 会话,用户可在此:
  • 更新支付方式
  • 查看账单历史
  • 更换订阅套餐
  • 下载发票
  • 取消订阅
需要 JWT 访问令牌(会话鉴权)。
**第三方集成:**请改用 POST /subscriptions/portal/api 并以 API Key 鉴权。

认证

Authorization
string
必填
JWT 访问令牌。格式:Bearer YOUR_ACCESS_TOKEN

请求体

returnUrl
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"
  }'
{
  "url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}

响应字段

url
string
用户需跳转到的 Stripe 托管账单门户 URL。

门户能力

Stripe Customer Portal 支持用户:
功能说明
支付方式添加、更新或移除银行卡
发票查看并下载历史发票
套餐变更升级或降级订阅
取消订阅取消订阅
账单历史查看历史交易

错误响应

400
错误请求——未找到账单账户,用户需先完成购买。
401
未授权——令牌无效或缺失。
账单门户仅对已发生过购买或拥有活跃订阅的用户可用;新用户请使用结账接口。

POST /subscriptions/portal/api

使用 API Key 创建 Stripe Customer Portal 会话,适合第三方集成。

认证

需要 API Key:
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"
  }'

最佳实践

  • 设置页入口:在应用设置中提供「管理账单」按钮
  • 结账后:订阅购买完成后可引导用户进入门户
  • 客服:将门户作为账单问题的自助渠道