jeanfprado/cashier
Composer 安装命令:
composer require jeanfprado/cashier
包简介
Cashier provides a subscription billing services.
README 文档
README
Cashier provides subscription billing for Laravel applications. It handles the recurring billing flow and now uses a product-based catalog (plans, add-ons, and other billable items) attached to each subscription.
Table of Contents
Installation
Install via Composer:
composer require jeanfprado/cashier
The package supports auto-discovery. If auto-discovery is disabled, register the service provider manually:
Jeanfprado\Cashier\CashierServiceProvider::class,
Optional facade alias:
'Cashier' => Jeanfprado\Cashier\Support\Facade\Cashier::class,
Publishing Config and Migrations
Publish only the config:
php artisan vendor:publish --tag=cashier-config
Publish only the migrations:
php artisan vendor:publish --tag=cashier-migrations
Then run migrations:
php artisan migrate
Products
Define your products in config/cashier.php under cashier.products.
Each product supports:
namedescription(optional)type(Plan,Add-on,Other)amount(decimal)value(metric value, optional business meaning)operation(incrementordecrement)settings(optional JSON)options(optional JSON)
Seed products from config:
php artisan cashier:seed-products
Subscribable Model
Set the subscribable model in config/cashier.php:
'model' => App\Models\User::class,
Your model must implement the contract and use the trait:
<?php namespace App\Models; use Illuminate\Foundation\Auth\User as Authenticatable; use Jeanfprado\Cashier\Subscribable; use Jeanfprado\Cashier\Contracts\Subscribable as SubscribableContract; class User extends Authenticatable implements SubscribableContract { use Subscribable; }
Subscriptions
Create a subscription by passing one or more Product models:
use Jeanfprado\Cashier\Models\Product; use Jeanfprado\Cashier\Models\Subscription; $products = Product::whereIn('slug_name', ['extra-storage', 'additional-seats'])->get(); $subscription = $user->subscribe( $products, Subscription::TYPE_MONTHLY, // monthly, triennial, semestrial, yearly 7 // optional trial days; falls back to config('cashier.trial_days') );
Add or remove products on an existing subscription:
$subscription->addProduct($product, 2); // attach or increment quantity $subscription->removeProduct($product); // detach
Cancel the current subscription:
$user->cancelSubscription();
Billing
Generate due billings for all subscriptions:
php artisan cashier:subscription-check
Or generate from code for a single subscription:
if ($subscription->canGenerateBilling() && ! $subscription->hasBillingPending()) { $billing = $subscription->generateBilling(); }
Mark a billing as paid:
$billing->markToPaid();
Upgrade Notes (Plan to Product)
Recent migrations replaced the old plans relation with a product catalog + pivot (subscription_products).
- Existing plan records are migrated into
products. - Existing subscriptions are linked to migrated products.
subscriptions.plan_idis replaced bysubscriptions.type.- The legacy
planstable is removed.
If you are upgrading an existing installation, publish/update migrations and run:
php artisan migrate
After migrating, review config/cashier.php and run cashier:seed-products to add any new catalog items.
Contributing
Thank you for considering contributing to Cashier.
License
Cashier is open-sourced software licensed under the MIT license.
jeanfprado/cashier 适用场景与选型建议
jeanfprado/cashier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「billing」 「recurring」 「plans」 「subscriptions」 「cashier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeanfprado/cashier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeanfprado/cashier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeanfprado/cashier 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple Laravel 5 service provider for including the Recurly PHP client.
Rich payment solutions for zend framework2. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Laravel Eloquent RRULE tools
MaxAl Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Laravel Cashier provides an expressive, fluent interface to Braintree's subscription billing services.
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-07