renoki-co / Jetstream Cashier Billing Portal
Projects that are alternatives of or similar to Jetstream Cashier Billing Portal
Jetstream Cashier Billing Portal
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!
🤝 Supporting
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.
🚀 Installation
This package assumes you have installed Jetstream in your project. If not, head over to Jetstream website for installation steps.
Scaffolding
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
Stripe Checkout
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>
Defining Plans
You will also have to prepare the plans in CashierRegisterServiceProvider
.
Import the created app/Providers/CashierRegisterServiceProvider
class into your app.php
:
$providers = [
// ...
\App\Providers\CashierRegisterServiceProvider::class,
];
🙌 Usage
In CashierRegisterServiceProvider
's boot method you may define the plans you need:
use RenokiCo\CashierRegister\CashierRegisterServiceProvider as BaseServiceProvider;
use RenokiCo\CashierRegister\Saas;
class CashierRegisterServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
// Define plans here.
}
}
By default, the subscriptions are accessible under /user/billing/subscription
, but you can change the /user/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.
Custom Billables
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 CashierRegisterServiceProvider
:
use Illuminate\Http\Request;
use RenokiCo\BillingPortal\BillingPortal;
class CashierRegisterServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
BillingPortal::setBillableOnRequest(function (Request $request) {
return $request->user()->currentTeam;
});
}
}
Modifying Checkout
You can intercept Checkout options on the fly:
use Illuminate\Http\Request;
use RenokiCo\BillingPortal\BillingPortal;
class CashierRegisterServiceProvider extends BaseServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
parent::boot();
// Modify the checkout model.
BillingPortal::onCheckout(function ($checkout, Request $request, $billable, $plan, $subscription) {
return $checkout->allowPromotionCodes();
});
// Intercept the Stripe Checkout options.
BillingPortal::setStripeCheckoutOptions(function (Request $request, $billable, $plan, $subscription) {
return [
'payment_method_types' => ['card'],
];
});
}
}
🐛 Testing
vendor/bin/phpunit
🤝 Contributing
Please see CONTRIBUTING for details.
🔒 Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.