In this episode, we walk through getting Laravel Cashier set up in our project so we can start working with subscriptions. First up, we install Cashier via Composer, just following the official docs, and then we publish its migrations so we can update our database. This adds some new tables to handle subscriptions as well as some additional fields to the users table for things like Stripe IDs and payment method info.
Next, we take a quick look at Cashier's config file—mainly just seeing what's important to change, like the currency or Stripe keys. You'll see you can override stuff easily via your .env
file if you need to adjust anything. Then, we make our User model billable by adding the necessary trait, which gives us a bunch of handy methods for working with subscriptions.
We also cover which Stripe API keys are required and where to put them (pro tip: keep the secret key safe!). After pulling those from Stripe and pasting them into our .env
, we're pretty much ready to roll.
By the end of this episode, Cashier is all set up in our Laravel app. We’re now ready to move on to actually redirecting our users to the Stripe checkout to get their subscriptions started!