This episode is for members only

Sign up to access "Build a File Marketplace with Laravel" right now.

Get started
Already a member? Sign in to continue
Playing
25. Creating the checkout success page

Episodes

0%
Your progress
  • Total: 3h 32m
  • Played: 0m
  • Remaining: 3h 32m
Join or sign in to track your progress

Transcript

00:00
So in the next episode, we're going to be implementing the entire checkout flow, where we can click on this button, go over to Stripe and start to enter our card details to pay for this. But before we do that, we're going to need to implement the success page that the user lands back on once they have purchased a product. So we're going to build
00:17
that out now and then we can integrate that into the checkout flow in the next episode. So this is going to be really simple. It's just going to be a controller within the user's subdomain, and it's just going to basically show a confirmation that the product was purchased successfully. So the first thing that we're going to do is generate our a controller
00:35
for this. And let's go ahead and call this subdomain. We'll put this under the subdomain directory as well. And let's call this product checkout success controller. Okay, so let's go ahead and just register this out. We'll just copy this down here. And this is going to be under a, well, we could leave this under the product slug and we could say checkout and success,
01:00
at least then we'll be able to get information about the product that the checkout was successful for. And again, we'll go ahead and pull in that controller. And let's just call this products checkout and then success. And of course, you can tidy this up to your style. But for me, just keeping these really long names, categorizing them really well, makes a lot more sense.
01:21
Okay, so we'll create an invoke magic method in here. And we're going to go ahead and just head over to this page. So we can do this directly in here, we can say product one, checkout, and success, and we should see nothing great. Okay, so we can build this page out now. So let's go ahead and create a view for this. We're going to put this under the products here,
01:40
checkout, we can even put that under its own directory outside of products. But let's go ahead and just leave this as it is for now keep the routing structure the same as the view structure. And again, we're just going to take a really simple page here like this one, put it here, and we can get rid of what we don't need. So let's just get rid of everything in this
02:00
h1. And just say okay for now. Okay, so let's go ahead and return this view from our controller. So return view. And this is going to be under the sub domain directory, products, and checkout, and success. And we can pass that product down, we can take the user here as well in case we need to use any of that information, take the product, and we'll pass these both down to here, kind of like
02:28
what we did with the other page. So user, product, and we should be good. Okay, let's come over. And there we go, we have our okay page. Now we don't actually need to pass this user down, because if you think about it, we can grab the user's information directly from this product, there's nothing wrong with passing the user down here, but let's do it a slightly different way
02:46
just to keep things a little bit cleaner. So we're going to say thanks for purchasing the product name from, and then the user's name. So the product name is pretty straightforward, we already have that passed in, product and title. And here, we just need to access the relationship on the product, which is the user and just grab their name. So if we come over,
03:08
thank you for purchasing product one from Alex. Let's go ahead and just really roughly style this up by adding some emphasis around the product title. And what we will also do is link up this back to the user's marketplace as well. So let's go ahead and just apply a class on here of text indigo 500. And we already know the route for this. If we go over to routes, it's subdomain
03:35
home. And then we just need to pass the product user and subdomain into that. Okay, let's go over. There we go. So let's just add a little bit of information down here in a paragraph. And we'll just say we've sent a download link to your email address, which is exactly what we are going to do as we carry on.

Episode summary

In this episode, we focus on creating the checkout success page—the page users land on after successfully purchasing a product. Before diving into the full checkout flow with Stripe (which is coming up in the next episode), we take care of this essential step so the user has somewhere to be redirected after payment.

We start by generating a dedicated controller under the user’s subdomain, naming it something descriptive so it’s clear what it handles. The idea is to keep everything organized and easy to maintain. Once the controller is set up, we make sure the routing structure matches the view structure, keeping things tidy and intuitive.

Next, we build a simple view for the success page. The page is straightforward: it thanks the user for their purchase, shows the product name, and mentions who they bought it from. We pull in the relevant product and user info, handling relationships cleanly to display accurate details. A bit of styling goes a long way here to make the success message stand out, and we even add a link back to the user's marketplace for easy navigation.

To wrap up, we add a confirmation message letting the user know that a download link has been sent to their email address—a little touch that sets the stage for the follow-up features we’ll implement soon.

Episode discussion

No comments, yet. Be the first!