commet/commet-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

commet/commet-php

最新稳定版本:v3.1.0

Composer 安装命令:

composer require commet/commet-php

包简介

Commet PHP SDK - Billing and usage tracking for SaaS applications

README 文档

README

Billing and usage tracking for SaaS applications.

Installation

composer require commet/commet-php

Quick start

use Commet\Commet;

$commet = new Commet(apiKey: 'ck_xxx');

// Create a customer
$commet->customers->create(email: 'user@example.com', externalId: 'user_123');

// Create a subscription
$commet->subscriptions->create(externalId: 'user_123', planCode: 'pro');

// Track usage
$commet->usage->track(feature: 'api_calls', externalId: 'user_123');

// Track AI token usage
$commet->usage->track(
    feature: 'ai_generation',
    externalId: 'user_123',
    model: 'claude-sonnet-4-20250514',
    inputTokens: 1000,
    outputTokens: 500,
);

Customer context

Scope all operations to a customer to avoid repeating externalId:

$customer = $commet->customer('user_123');

$customer->usage->track('api_calls');
$customer->features->check('custom_branding');
$customer->seats->add('editor', count: 3);
$customer->portal->getUrl();

Webhook verification

use Commet\Webhooks;

$webhooks = new Webhooks();

$payload = $webhooks->verifyAndParse(
    rawBody: $requestBody,
    signature: $_SERVER['HTTP_X_COMMET_SIGNATURE'] ?? null,
    secret: 'whsec_xxx',
);

if ($payload === null) {
    throw new \RuntimeException('Invalid webhook signature');
}

if ($payload['event'] === 'subscription.activated') {
    // handle activation
}

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固