Overview
Larafast Multi-Tenancy uses Laravel Cashier to integrate with Stripe for team subscriptions. This guide shows you exactly where everything is configured and how to set it up.Environment Configuration
Add these Stripe credentials to your.env file:
Getting Your Stripe Keys
- Sign up for Stripe - https://dashboard.stripe.com/register
- Go to Developers → API keys
- Copy your keys:
- Publishable key (starts with
pk_) - Secret key (starts with
sk_)
- Publishable key (starts with
- Create a webhook (Developers → Webhooks):
- URL:
https://yourapp.com/stripe/webhook - Events: Select all (Cashier handles filtering)
- Copy webhook secret (starts with
whsec_)
- URL:
Creating Stripe Products
You need to create products and prices in Stripe that match your pricing plans:In Stripe Dashboard
- Go to Products - https://dashboard.stripe.com/products
- Click “Add product”
- Create each plan:
Example: Starter Plan
- Name: Starter Plan
- Description: For growing teams
- Pricing:
- Price: $29.99
- Billing period: Monthly
- Currency: USD
- Click “Save product”
- Copy the Price ID - Looks like
price_1ABC...xyz
Example: Pro Plan
- Name: Pro Plan
- Description: For large organizations
- Pricing:
- Price: $99.99
- Billing period: Monthly
- Currency: USD
- Click “Save product”
- Copy the Price ID
Configuring Your Plans
Update your pricing configuration with the Stripe Price IDs: Location:lang/en/prices.php
slug field must match your Stripe Price ID exactly!
Billing Provider Configuration
The Stripe billing provider is already configured in the panel: Location:app/Providers/Filament/AppPanelProvider.php
Billing Provider Implementation
Location:app/Filament/App/Billing/Providers/StripeBillingProvider.php
- Where to redirect when users click “Billing”
- What middleware to use for subscription checks
Subscription Middleware
Location:app/Http/Middleware/RedirectIfTeamNotSubscribed.php
This middleware checks if the team has an active subscription:
bootstrap/app.php
Team Model Setup
Your Team model needs theBillable trait for Cashier:
Location: app/Models/Team.php
$team->subscribed()- Check if subscribed$team->subscription()- Get active subscription$team->newSubscription()- Create new subscription$team->invoicesIncludingPending()- Get invoices
Routes Configuration
The billing routes are already set up: Location:routes/web.php
Plans Display Page
The pricing plans are displayed using a Livewire component: Location:app/Livewire/Plans.php
resources/views/livewire/plans.blade.php
This displays your pricing cards with:
- Plan names and prices
- Feature lists
- “Subscribe” buttons that link to Stripe checkout
Testing Stripe Integration
Using Test Mode
- Use test API keys - Keys starting with
pk_test_andsk_test_ - Test card numbers:
- Success: 4242 4242 4242 4242
- Decline: 4000 0000 0000 0002
- 3D Secure: 4000 0027 6000 3184
- Any future expiry date - e.g., 12/34
- Any 3-digit CVC - e.g., 123
Test the Flow
- Create a team
- Click “Upgrade” or “Billing”
- Select a plan
- Complete checkout with test card
- Verify subscription in:
- Your app’s database
- Stripe dashboard
- Admin panel
Database Tables
Cashier automatically creates these tables:subscriptions- Team subscriptionssubscription_items- Subscription line itemspayment_methods- Stored payment methods
Webhooks
Setting Up Webhooks
- Go to Stripe Dashboard → Developers → Webhooks
- Add endpoint:
https://yourapp.com/stripe/webhook - Select events (or select all - Cashier filters):
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
- Copy webhook signing secret → Add to
.envasSTRIPE_WEBHOOK_SECRET
Testing Webhooks Locally
Use Stripe CLI to forward webhooks to localhost:Switching to Live Mode
When you’re ready for production:- Activate your Stripe account - Complete business verification
- Create live products - Recreate your products in live mode
- Update environment variables:
- Update price IDs - In
lang/en/prices.phpwith live Price IDs - Create live webhook - Point to your production URL
- Test thoroughly - Use a real card in test environment first
Troubleshooting
Subscription not showing as active
Check:- Team has
subscribed()method returning true - Subscription exists in database
- Stripe webhook is configured
.envhas correct keys
Webhook not working
- Verify
STRIPE_WEBHOOK_SECRETis set - Check webhook URL is accessible
- Verify webhook is receiving events in Stripe dashboard
- Check Laravel logs for webhook errors
Payment failing
- Verify Stripe account is activated (for live mode)
- Check card is valid (use test cards in test mode)
- Verify currency matches (USD vs EUR, etc.)
- Check Stripe dashboard for error details
Next Steps
- Plans Configuration - Customize your pricing
- Subscription Features - Implement gated features
- Billing Portal - Customer billing management

