返回顶部
c

chargebee收费蜜蜂

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.5
安全检测
已通过
5,096
下载量
免费
免费
3
收藏
概述
安装方式
版本历史

chargebee

Chargebee

通过托管OAuth认证访问Chargebee API。管理订阅、客户、发票和计费工作流。

快速开始

bash

列出客户


python < import urllib.request, os, json
req = urllib.request.Request(https://gateway.maton.ai/chargebee/api/v2/customers?limit=10)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

基础URL

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

获取您的API密钥

  1. 1. 在maton.ai登录或创建账户
  2. 前往maton.ai/settings
  3. 复制您的API密钥

连接管理

在https://ctrl.maton.ai管理您的Chargebee连接。

列出连接

bash
python < import urllib.request, os, json
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 < import urllib.request, os, json
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 < import urllib.request, os, json
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 < import urllib.request, os, json
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 < import urllib.request, os, json
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

如果省略,网关将使用默认(最早)的活动连接。

API参考

客户

列出客户

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

商品价格(产品目录2.0)

列出商品价格

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

下载发票PDF

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

javascript
const response = await fetch(
https://gateway.maton.ai/chargebee/api/v2/customers?limit=10,
{
headers: {
Authorization: Bearer ${process.env.MATONAPIKEY}
}
}
);

Python

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}
)

注意事项

  • - POST请求使用form-urlencoded数据格式
  • 嵌套对象使用括号表示法:customer[email]
  • 时间戳为Unix时间戳
  • 列表响应包含用于分页的nextoffset
  • 产品目录2.0:使用itemprices和items
  • 重要提示:使用curl命令时,如果URL包含括号(fields[]、sort[]、records[]),请使用curl -g禁用通配符解析
  • 重要提示:将curl输出通过管道传递给jq或其他命令时,某些shell环境中环境变量(如$MATONAPIKEY)可能无法正确展开。管道传递时可能会收到Invalid API key错误。

错误处理

状态码含义
400缺少Chargebee连接
401
API密钥无效或缺失 | | 429 | 请求频率限制(每个账户10次/秒) | | 4xx/5xx | 从Chargebee API透传的错误 |

故障排除:API密钥问题

  1. 1. 检查是否设置了MATONAPIKEY环境变量:

bash
echo $MATONAPIKEY

  1. 2. 通过列出连接验证API密钥是否有效:

bash
python < import urllib.request, os, json

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 chargebee-1776200648 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 chargebee-1776200648 技能

通过命令行安装

skillhub install chargebee-1776200648

下载

⬇ 下载 chargebee v1.0.5(免费)

文件大小: 3.91 KB | 发布时间: 2026-4-15 10:27

v1.0.5 最新 2026-4-15 10:27
- Added a new `clawdbot` metadata section with required environment variable declaration for `MATON_API_KEY` and an emoji indicator.
- No changes to skill features or usage.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部