jeanfprado / cashier
Cashier provides a subscription billing services.
Requires
- php: ^7.3|^8.0|^8.1
- illuminate/database: ~5.0|~6.0|~7.0|^8.0|^9.0|^10.0
README
Cashier provides a subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle plans.
Documentation
Installation
You can pull in the package via composer:
composer require jeanfprado/cashier
The package will automatically register itself.
Configuration
Laravel without auto-discovery:
If you don't use auto-discovery, add the CashierServiceProvider to the providers array in config/app.php
Jeanfprado\Cashier\CashierServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
'Cashier' => Jeanfprado\Cashier\Support\Facade\Cashier::class,
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="Jeanfprado\Cashier\CashierServiceProvider"
Plan
Creating all plans from config/cashier.php
via artisan
php artisan cashier:seed-plans
Subscription
Before you create a subscription you need prepare what class will be subscribable
In config/cashier.php
change key model
to model that will be a subscribable
.
Now in this model you need implements a contract. see example:
<?php namespace App; use Jeanfprado\Cashier\Subscribable; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Jeanfprado\Cashier\Contracts\Subscribable as SubscribableContract; class User extends Model implements SubscribableContract { use Notifiable, Subscribable; ... }
Now you can to create a subscription.
$user->subscribe($plan);
Billing
Creating a billing is very easy, you only need run a command.
php artisan cashier:subscription-check
Than if has a billing to generate is done, and when the billing is paid, you need mark to paid.
$billing->markToPaid();
Contributing
Thank you for considering contributing to Cashier!
License
Cashier is open-sourced software licensed under the MIT license.