Jetstream Cashier Billing Portal is a simple scaffolding billing portal to manage subscriptions, invoices and payment methods, built on top of Jetstream & Cashier Register.
Currently, only Inertia with Stripe are supported. For Paddle and/or Livewire, any PR is welcomed!
Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.
If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.
This package assumes you have installed Jetstream in your project. If not, head over to Jetstream website for installation steps.
Make sure to have installed Cashier as explained in the Cashier documentation, including the billable traits and tables, because Jetstream Cashier Billing Portal WILL NOT install them for you.
You can install the package via composer:
composer require renoki-co/jetstream-cashier-billing-portal
You shall install the Cashier Billing Portal in one command, just like Jetstream. This will install Cashier, Cashier Register and Billing Portal.
$ php artisan billing-portal:install inertia stripe
Starting with Laravel Cashier v12.7.0, you can now use Stripe Checkout for easier implementation. Jetstream Cashier Billing Portal supports this and will send the user directly to the Checkout portal for new subscriptions.
Starting with package version 2.x, you will also need to set up Stripe Webhooks in your own project to benefit from Stripe Checkout, that is used by default. If not, check the 1.x
branch or 1.x
releases that do not use Stripe Checkout.
The only thing you should do is to add the Stripe Javascript SDK code before the app.js
import in your app.blade.php
file:
<script src="https://js.stripe.com/v3/"></script>
<script src="{{ mix('js/app.js') }}" defer></script>
You will also have to prepare the plans in CashierRegisterServiceProvider
.
Manual import of the app/Providers/CashierRegisterServiceProvider
class is no longe required. The install commandd did that for you.
Below you will find plenty of examples.
In BillingPortalServiceProvider
's boot method you may define the plans you need:
use RenokiCo\CashierRegister\BillingPortalServiceProvider as BaseServiceProvider;
use RenokiCo\CashierRegister\Saas;
class BillingPortalServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
// Define plans here.
}
}
By default, the subscriptions are accessible under /billing
, but you can change the /billing
prefix easily in config/billing-portal.php
.
For more information about defining plans and quotas, check Cashier Register documentation and check Laravel Cashier for Stripe documentation on handling the billing.
By default, the billing is made directly on the currently authenticated model. In some cases like using billable trait on the Team model, you may change the model that will be retrieved from the current request. You may define it in the boot()
method of BillingPortalServiceProvider
:
use Illuminate\Http\Request;
use RenokiCo\BillingPortal\BillingPortal;
class BillingPortalServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
BillingPortal::resolveBillable(function (Request $request) {
return $request->user()->currentTeam;
});
}
}
Even if the scaffolding comes with basic controller logic to handle new subscriptions or manage existing ones, you are free to change the Billing Portal's actions in app/Actions/BillingPortal
.
You just have to re-write your logic in the action classes.
By default, Billing Portal prorates the swap between plans. If you wish to not prorate the subscription between swaps, you can specify this in your service provider:
use RenokiCo\BillingPortal\BillingPortal;
class BillingPortalServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
BillingPortal::dontProrateOnSwap();
}
}
Because Jetstream Cashier Billing Portal is written on top of Cashier Register, a complete subscription manager for your Laravel application, you are free to follow the Cashier Register examples in the repository.
You are free to leverage the power of subscriptions in your app. Billing Portal just makes it easier for your app to handle subscriptions.
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.