In this episode, we're starting to hook up actual payments via Stripe! But before we can let users check out, we need to set up some plans that they can subscribe to.
We'll walk through setting up a fresh Stripe account (just for testing), and then create a product over there—like a "monthly" plan, complete with a Stripe price. The most important part here is grabbing the Stripe price ID—we'll need this for our own database.
Next, we'll build out a new plans
table in our database, including columns for the plan title (e.g., monthly or yearly), a unique slug for URLs, the Stripe price ID (so our app knows which Stripe product to charge for), and the price (stored as an integer, not a float, to avoid money precision issues!).
After migrating, we manually add a sample plan to test things out, linking it up with the actual Stripe price ID and entering the price in cents (e.g., 10000 for $100). Then, over on the dashboard, we iterate through all the available plans and display them. At this point, the price is just a big integer, which isn't pretty – so, we install the Laravel money package for proper currency formatting.
We show you how to cast the price column so that it automatically formats as dollars, making the site look much more professional and ready for the next steps.
By the end of this video, we've got plans in the database, prices tied to Stripe, and everything displayed nicely on the dashboard—ready to move on to setting up Laravel Cashier and actual checkout links in the next episode!