curl -X GET https://api.llmgenerator.com/api/v1/credits/verify-session/cs_test_a1b2c3d4e5f6 \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const sessionId = 'cs_test_a1b2c3d4e5f6';
const response = await fetch(
`https://api.llmgenerator.com/api/v1/credits/verify-session/${sessionId}`,
{
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
const data = await response.json();
if (data.success) {
console.log(`Added ${data.credits} credits`);
}
import requests
session_id = 'cs_test_a1b2c3d4e5f6'
response = requests.get(
f'https://api.llmgenerator.com/api/v1/credits/verify-session/{session_id}',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
print(f"Verified: {data['credits']} credits")
{
"success": true,
"credits": 500,
"sessionId": "cs_test_a1b2c3d4e5f6"
}
{
"success": false,
"message": "Payment not completed"
}
积分
校验结账会话
校验已完成的结账会话并确认积分已入账。
GET
/
credits
/
verify-session
/
{sessionId}
curl -X GET https://api.llmgenerator.com/api/v1/credits/verify-session/cs_test_a1b2c3d4e5f6 \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const sessionId = 'cs_test_a1b2c3d4e5f6';
const response = await fetch(
`https://api.llmgenerator.com/api/v1/credits/verify-session/${sessionId}`,
{
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
const data = await response.json();
if (data.success) {
console.log(`Added ${data.credits} credits`);
}
import requests
session_id = 'cs_test_a1b2c3d4e5f6'
response = requests.get(
f'https://api.llmgenerator.com/api/v1/credits/verify-session/{session_id}',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
print(f"Verified: {data['credits']} credits")
{
"success": true,
"credits": 500,
"sessionId": "cs_test_a1b2c3d4e5f6"
}
{
"success": false,
"message": "Payment not completed"
}
概述
支付成功后,可调用此接口确认付款已处理且积分已入账。适用于 Webhook 未及时触达等场景的手动校验。积分通常由 Stripe Webhook 自动入账。本接口用于边界情况或客户端侧的额外确认。
**第三方集成:**请改用
GET /credits/verify-session/{sessionId}/api 并以 API Key 鉴权。认证
string
必填
JWT 访问令牌(会话鉴权)。格式:
Bearer YOUR_ACCESS_TOKEN路径参数
string
必填
/credits/checkout 返回的 Stripe Checkout 会话 ID。curl -X GET https://api.llmgenerator.com/api/v1/credits/verify-session/cs_test_a1b2c3d4e5f6 \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const sessionId = 'cs_test_a1b2c3d4e5f6';
const response = await fetch(
`https://api.llmgenerator.com/api/v1/credits/verify-session/${sessionId}`,
{
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
const data = await response.json();
if (data.success) {
console.log(`Added ${data.credits} credits`);
}
import requests
session_id = 'cs_test_a1b2c3d4e5f6'
response = requests.get(
f'https://api.llmgenerator.com/api/v1/credits/verify-session/{session_id}',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
print(f"Verified: {data['credits']} credits")
{
"success": true,
"credits": 500,
"sessionId": "cs_test_a1b2c3d4e5f6"
}
{
"success": false,
"message": "Payment not completed"
}
响应字段
boolean
会话校验是否成功。
integer
本次购买对应的积分数。
string
已校验的会话 ID。
错误响应
错误请求——支付未完成或会话元数据无效。
未授权——令牌无效或缺失。
禁止访问——会话不属于当前认证用户。
幂等性
本接口具有幂等性。若积分已通过 Webhook 入账,不会重复增加;仍会返回成功及对应积分数量。典型流程
- 用户在 Stripe 完成结账
- Stripe 将用户重定向到你的
successUrl - 调用本接口校验并确认积分
- 向用户展示确认信息
- 在前端刷新积分余额展示
虽然可以使用本接口,推荐仍以 Stripe Webhook 为准,并结合
/credits/balance 更新界面。GET /credits/verify-session//api
使用 API Key 校验结账会话,适合第三方集成。认证
需要 API Key:Authorization: Bearer llmgen_your_api_key_here
路径参数
同上。响应
同上。curl -X GET https://api.llmgenerator.com/api/v1/credits/verify-session/cs_test_a1b2c3d4e5f6/api \
-H "Authorization: Bearer llmgen_your_api_key_here"
const sessionId = 'cs_test_a1b2c3d4e5f6';
const response = await fetch(
`https://api.llmgenerator.com/api/v1/credits/verify-session/${sessionId}/api`,
{
headers: {
'Authorization': 'Bearer llmgen_your_api_key_here'
}
}
);
const data = await response.json();
if (data.success) {
console.log(`Added ${data.credits} credits`);
}
import requests
session_id = 'cs_test_a1b2c3d4e5f6'
response = requests.get(
f'https://api.llmgenerator.com/api/v1/credits/verify-session/{session_id}/api',
headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
)
data = response.json()
print(f"Verified: {data['credits']} credits")
此页面对您有帮助吗?
⌘I