In this episode, we're taking your subscription-based app up a notch by showing users the actual details of their plan directly in the UI. We kick things off by displaying the user's current subscription plan (like "Monthly" or "Yearly") once they're logged in and subscribed. The goal is to move beyond just knowing if a user is subscribed, and actually show meaningful info about their plan and billing details.
But here's the catch: the plan name isn't stored as a simple field in our database—there's just a bunch of Stripe IDs and references! So, we need to figure out how to map the Stripe price ID from a user's subscription to the user-friendly data we defined in our Laravel config.
To make this process clean and reusable, you'll see how we build a decorator class (the StripeSubscriptionDecorator
) that wraps around the raw Stripe subscription object. This way, we extract whatever data we want—like the plan name, currency, or anything else Stripe gives us—without polluting our blade templates or controllers with raw Stripe logic. A big benefit is you can add as many helper methods as you want here to keep your codebase maintainable.
Through Laravel's powerful collection methods and some config lookups, you're shown how to efficiently pull the right plan details each time (and cache them in the request for speed). By the end of the video, you'll have a neat system for showing users clear info about their subscription, all powered by data from Stripe but shaped just how you want it in your Laravel app.