通过托管 OAuth 实现 Chargebee API 集成。仅在需要 Chargebee 账单管理时才安装。使用最小权限访问进行连接,并验证集成的...
Curgebee. 使用管理好的 OAuth 认证访问 Curgebee API. 管理订阅,客户,发票,以及计费工作流程.是一项面向实际任务的技能,主要用于QQ快速启动.;Base URL. 网关代理请求 {subdo}。
从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
通过受管 OAuth 认证访问 Chargebee API,用于管理订阅、客户、发票及计费工作流。
# 列出客户
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/chargebee/api/v2/customers?limit=10')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
https://api.maton.ai/chargebee/{endpoint-path}
网关将请求代理至 {subdomain}.chargebee.com(自动替换为您的连接配置),并注入认证信息。仅支持下方「API 参考」章节中明确记录的端点 —— 请始终使用该章节中列出的具体端点路径,而非自行构造任意路径。
所有请求均需在 Authorization 请求头中提供 Maton API 密钥:
Authorization: Bearer $MATON_API_KEY
环境变量:请将您的 API 密钥设置为 MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
您可在 https://api.maton.ai 管理您的 Chargebee 连接。
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections?app=chargebee&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'chargebee'}).encode()
req = urllib.request.Request('https://api.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应示例:
{
"connection": {
"connection_id": "{connection_id}",
"status": "ACTIVE",
"creation_time": "2025-12-08T07:20:53.488460Z",
"last_updated_time": "2026-01-31T20:03:32.593153Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "chargebee",
"metadata": {}
}
}
在浏览器中打开返回的 url,完成 OAuth 授权流程。
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
若您拥有多个 Chargebee 连接,请使用 Maton-Connection 请求头明确指定目标连接:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/chargebee/api/v2/customers')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '{connection_id}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
请始终包含 Maton-Connection 请求头,以确保请求路由至预期的 Chargebee 账户,尤其在执行任何写入操作前。若您拥有多个连接却未指定该请求头,网关将使用默认连接,这可能并非您期望的目标账户。
GET /chargebee/api/v2/customers?limit=10
GET /chargebee/api/v2/customers/{customerId}
POST /chargebee/api/v2/customers Content-Type: application/x-www-form-urlencoded first_name=John&last_name=Doe&email=john@example.com
POST /chargebee/api/v2/customers/{customerId}
Content-Type: application/x-www-form-urlencoded
first_name=Jane
GET /chargebee/api/v2/subscriptions?limit=10
GET /chargebee/api/v2/subscriptions/{subscriptionId}
POST /chargebee/api/v2/subscriptions Content-Type: application/x-www-form-urlencoded plan_id=basic-plan&customer[email]=john@example.com&customer[first_name]=John
POST /chargebee/api/v2/subscriptions/{subscriptionId}/cancel
Content-Type: application/x-www-form-urlencoded
end_of_term=true
GET /chargebee/api/v2/item_prices?limit=10
GET /chargebee/api/v2/items?limit=10
GET /chargebee/api/v2/invoices?limit=10
POST /chargebee/api/v2/invoices/{invoiceId}/pdf
POST /chargebee/api/v2/hosted_pages/checkout_new_for_items Content-Type: application/x-www-form-urlencoded subscription[plan_id]=basic-plan&customer[email]=john@example.com
POST /chargebee/api/v2/portal_sessions Content-Type: application/x-www-form-urlencoded customer[id]=cust_123
GET /chargebee/api/v2/subscriptions?status[is]=active GET /chargebee/api/v2/customers?email[is]=john@example.com GET /chargebee/api/v2/invoices?date[after]=1704067200
const response = await fetch(
'https://api.maton.ai/chargebee/api/v2/customers?limit=10',
{
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
}
}
);
import os
import requests
response = requests.get(
'https://api.maton.ai/chargebee/api/v2/customers',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
params={'limit': 10}
)
customer[email]next_offset 字段用于分页item_prices 和 itemsfields[]、sort[]、records[]),请添加 -g 参数禁用 glob 解析jq 或其他命令时,在部分 shell 环境中环境变量(如 $MATON_API_KEY)可能无法正确展开,导致出现“Invalid API key”错误| 状态码 | 含义 |
|---|---|
| 400 | 缺少 Chargebee 连接 |
| 401 | Maton API 密钥无效或缺失 |
| 429 | 请求频率超限(每账户 10 次/秒) |
| 4xx/5xx | Chargebee API 返回的透传错误 |
MATON_API_KEY 环境变量:echo $MATON_API_KEY
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
chargebee 开头。例如:https://api.maton.ai/chargebee/api/v2/customershttps://api.maton.ai/api/v2/customers相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章