renoki-co / thunder
Thunder 是一款先进的 Laravel 工具,用于跟踪用户消费,它使用 Stripe 的 Cashier 计量计费。⚡
0.2.0
2021-11-09 06:12 UTC
Requires
- php: ^8.0
- laravel/cashier: ^13.5.6
- stripe/stripe-php: ^7.100
Requires (Dev)
- laravel/legacy-factories: ^1.1
- mockery/mockery: ^1.4
- orchestra/database: ^6.0
- orchestra/testbench: ^6.22
- vimeo/psalm: 4.12.0
This package is auto-updated.
Last update: 2024-08-27 02:14:31 UTC
README
Thunder 是一款先进的 Laravel 工具,用于跟踪用户消费,它使用 Stripe 的 Cashier 计量计费。⚡
🤝 支持
如果你在生产应用、演示、爱好项目、学校项目等中使用一个或多个 Renoki Co. 开源包,请通过 Github Sponsors 赞助我们的工作。📦
🚀 安装
您可以通过 composer 安装此包
composer require renoki-co/thunder
此项目包含 Cashier,在深入了解文档之前,安装它非常重要 安装。
🙌 使用
Thunder 通过 Stripe 计量计费跟踪您的用户资源配额。
您可能只能定义与 Stripe 通过 IDs 连接的具有特定功能的计划,在整个代码中只声明一次。
使用情况报告是通过您定义的 IDs 完成的,而不是每个部署应用的环境都不同的唯一定价 ID,从而确保代码的一致性。
这样,您就可以像调用使用情况报告一样 Cashier 的计量计费,但您使用的是定义的 IDs 而不是 Stripe IDs。
use RenokiCo\Thunder\Thunder; Thunder::plan('Unlimited Plan', 'stripe_product_id', [ Thunder::meteredFeature('Build Minutes', 'build.minutes', 'stripe_build_minutes_price_id'), Thunder::meteredFeature('Seats', 'seats', 'stripe_seats_price_id'), ]); $subscription = $user->subscription('main'); Thunder::reportUsageFor('build.minutes', $subscription, 50); Thunder::reportUsageFor('build.minutes', $subscription, 100); Thunder::usage('build.minutes', $subscription); // 150
🐛 测试
vendor/bin/phpunit
🤝 贡献
有关详细信息,请参阅 CONTRIBUTING。
🔒 安全
如果您发现任何与安全相关的问题,请通过电子邮件 alex@renoki.org 而不是使用问题跟踪器。