πŸš€
Installation

Setting up Jetstream

This package assumes you have installed Jetstream in your project. If not, head over to the Jetstream website for installation steps.

Installing Cashierstream

You can install the package via composer:
1
composer require renoki-co/jetstream-cashier-billing-portal
Copied!
Next, publish the stubs, Laravel Cashier, Cashier Register, Cashierstream, and other related files for your choice:
1
php artisan billing-portal:install inertia stripe
Copied!

Installing Laravel Cashier

Make sure to have prepared your models to use Cashier as explained in the Cashier documentation, including the billable traits and tables. Cashierstream will only install the appropriate packages in your composer file.

Adding Stripe Checkout scripts

Cashierstream uses Stripe Checkout to ease the process of handling subscriptions.
You should do is to add the Stripe Javascript SDK code before the app.js import in your app.blade.php file:
1
<script src="https://js.stripe.com/v3/"></script>
2
<script src="{{ mix('js/app.js') }}" defer></script>
Copied!

Setting up webhooks

Since Cashierstream uses Stripe Checkout, it's a must to have webhooks enabled so you can catch incoming subscriptions and modifications that happen in the Stripe Billing Portal.
Cashierstream already implements it for you. The default path is /billing-portal/stripe/webhook and you can modify it from the config file.
1
php artisan vendor:publish --provider="RenokiCo\BillingPortal\BillingPortalServiceProvider" --tag="config"
Copied!
You will also need to specify the following events for the webhook in the Stripe Dashboard:
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted
  • customer.updated
  • customer.deleted
  • invoice.payment_action_required
  • invoice.payment_succeeded
Make sure you will also set the webhook secret env variable when running the app in production to better secure the exposed webhook endpoint:
1
STRIPE_KEY=stripe_key
2
STRIPE_SECRET=stripe_secret
3
STRIPE_WEBHOOK_SECRET=webhook_secret
Copied!