Will NOT using User as Billable Model make Cashier & Stripe subscriptions harder to code?

In short yes – At least for me. So I set my Stripe checkout up with User as Billable Model first, check that I can make that work. Then I change to for example Team as Billable Model.

Check out Cashier docs about billable model they're tidy.

Here is my checklist for Stripe checkout

  1. I add Billable trait to User model (Team model is the billable entity, not User, but I'm waiting with that.)
  2. I install the Cashier package for Stripe composer require laravel/cashier
  3. I publish Cashier's migrations using php artisan vendor:publish --tag="cashier-migrations"
  4. Then, I migrate our database: php artisan migrate
  5. I add Stripe Checkout session via $request->user()->newSubscription()->checkout()
  6. I add 'success-route' and 'cancel-route'
  7. I copy paste in my price from Stripe here ->newSubscription('default', 'price_1Sw...6Fy') 
  8. I copy paste my STRIPE_SECRET=pk_test_... and STRIPE_KEY=sk_test_... inside my .env. from my Stripe.
  9. I copy paste http://galleon.test/subscription-checkout into my browser.
  10. I "pay" with my "42" credit card, it worked as advertised, now
  11. I Add Billable trait to Team model (Team model is the billable entity, not User)
  12. in the boot method of our AppServiceProvider class: I add this use App\Models\Cashier\User; and this use App\Models\Cashier\User;
  13. Then, I also add this inside the boot() function Cashier::useCustomerModel(User::class);
  14. Then, I migrate our database again: php artisan migrate:fresh
  15. Cashier migration (adds stripe columns to teams table)
  16. Now change this $request->user()->newSubscription()->checkout() to $team->newSubscription()->checkout() with this above it $team = Team::current();
  17. Several things have gone wrong for me at this stage, this link will show you a few of them in the future ... (another post is coming closer to the summer)
  18. Stripe Billing Portal via $team->redirectToBillingPortal()
  19. Cashier webhook route (handles subscription lifecycle automatically)
  20. Middleware: gate dashboard features behind $team->subscribed()
  21. Billing page in dashboard: current plan status, manage subscription link
  22. Redirect to checkout after registration