In this episode, we dive into setting up Laravel Cashier so we can handle subscriptions in our app. This is an important foundation, especially since we're going to connect subscription events with our referral system later on.
We kick things off by installing the Cashier package with Composer. After that, we run the migrations that Cashier provides. This adds things like the subscriptions
and subscription_items
tables to our database, and even tweaks the users table so it's ready for subscriptions. We talk about how the subscriptions
table is the key piece we'll use later when tying subscriptions to referral codes.
Next, we make sure our User
model is "billable" by adding the appropriate trait—that's what Cashier needs to handle subscription logic.
After that, we grab our Stripe API keys and update the .env file with them. We walk through exactly where to find those keys in the Stripe dashboard, and set them up in our project. For now, we're skipping webhooks (that's for later), and just focusing on the basics: integrating Cashier and Stripe so we can create subscriptions and link the right user data.
By the end of this video, we'll be ready to actually generate Stripe checkout links for specific plans or prices, which we'll tackle in the next episode. If you've followed along, your app is now set up to start processing subscriptions!