|
通过托管OAuth认证访问Chargebee API。管理订阅、客户、发票和计费工作流。
bash
https://gateway.maton.ai/chargebee/{native-api-path}
将{native-api-path}替换为实际的Chargebee API端点路径。网关将请求代理到{subdomain}.chargebee.com(自动替换为您的连接配置)并自动注入认证信息。
所有请求都需要在Authorization标头中包含Maton API密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的API密钥设置为MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在https://ctrl.maton.ai管理您的Chargebee连接。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=chargebee&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
data = json.dumps({app: chargebee}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: chargebee,
metadata: {}
}
}
在浏览器中打开返回的url以完成OAuth授权。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个Chargebee连接,请使用Maton-Connection标头指定要使用的连接:
bash
python <
req = urllib.request.Request(https://gateway.maton.ai/chargebee/api/v2/customers)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最早)的活动连接。
bash
GET /chargebee/api/v2/customers?limit=10
bash
GET /chargebee/api/v2/customers/{customerId}
bash
POST /chargebee/api/v2/customers
Content-Type: application/x-www-form-urlencoded
firstname=John&lastname=Doe&email=john@example.com
bash
POST /chargebee/api/v2/customers/{customerId}
Content-Type: application/x-www-form-urlencoded
first_name=Jane
bash
GET /chargebee/api/v2/subscriptions?limit=10
bash
GET /chargebee/api/v2/subscriptions/{subscriptionId}
bash
POST /chargebee/api/v2/subscriptions
Content-Type: application/x-www-form-urlencoded
planid=basic-plan&customer[email]=john@example.com&customer[firstname]=John
bash
POST /chargebee/api/v2/subscriptions/{subscriptionId}/cancel
Content-Type: application/x-www-form-urlencoded
endofterm=true
bash
GET /chargebee/api/v2/item_prices?limit=10
bash
GET /chargebee/api/v2/items?limit=10
bash
GET /chargebee/api/v2/invoices?limit=10
bash
POST /chargebee/api/v2/invoices/{invoiceId}/pdf
bash
POST /chargebee/api/v2/hostedpages/checkoutnewforitems
Content-Type: application/x-www-form-urlencoded
subscription[plan_id]=basic-plan&customer[email]=john@example.com
bash
POST /chargebee/api/v2/portal_sessions
Content-Type: application/x-www-form-urlencoded
customer[id]=cust_123
bash
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
javascript
const response = await fetch(
https://gateway.maton.ai/chargebee/api/v2/customers?limit=10,
{
headers: {
Authorization: Bearer ${process.env.MATONAPIKEY}
}
}
);
python
import os
import requests
response = requests.get(
https://gateway.maton.ai/chargebee/api/v2/customers,
headers={Authorization: fBearer {os.environ[MATONAPIKEY]}},
params={limit: 10}
)
| 状态码 | 含义 |
|---|---|
| 400 | 缺少Chargebee连接 |
| 401 |
bash
echo $MATONAPIKEY
bash
python <
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 chargebee-1776200648 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 chargebee-1776200648 技能
skillhub install chargebee-1776200648
文件大小: 3.91 KB | 发布时间: 2026-4-15 10:27