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
29. Sending a confirmation email to customers

Episodes

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

Transcript

00:00
Let's now send an email out to customers that have successfully purchased a product.
00:04
Now for this, we're going to need to configure email within Laravel, but ideally we want to use a fake email service. By default, Laravel is set up and configured for mail pit, but I'm going to be using a piece of software called Hello.
00:18
Now it doesn't matter what you use for this, even if you want to test this to your own email account, it doesn't really matter. But once you're set up for sending email locally, then we can go ahead and get started. So go ahead and follow the installation and configuration instructions for Hello.
00:34
If you want to use this, it's just a piece of software on my machine that allows me to receive emails into here, but not actually put these through any kind of public or third-party mail service. Okay, so I'm going to go ahead and configure this to work with Hello,
00:48
and I'm just going to choose my local host here. For the port, this is 2525, and for our username, we can just call this Laravel File Marketplace. That should be enough to get this working. Okay, so we're going to go ahead and generate out an email here,
01:03
which we're going to send down here when this webhook gets fired. So to generate a mail out in Laravel, we're going to use Artisan once again, and we're going to make out a mail. We're going to go ahead and call this Purchase Confirmation,
01:15
but of course you can call it whatever you want. Now for this, we're going to make this a markdown email, so we have a little bit of styling in here. So we're going to put that in an email directory,
01:25
and we're just going to call this Purchase Confirmation. Now you can create out a plain blade template for this if you want to make this a little bit more custom, but for now, we're just going to be using a markdown file
01:38
just to make this a little bit easier. Okay, so inside of here, we want to send out that email. To do this, we're going to go ahead and use the mail facade, and we're going to go ahead and say to,
01:48
and we want to pass in the email address of the person that we want to send this to. Now we can either reference the email here, or because we've already got this sale object up here, we can just pass the email that we get directly through from here.
02:02
Then we're going to go ahead and send this out. We're going to new up a Purchase Confirmation email, and we're going to pass the sale into that so we can extract the information from it.
02:11
So that's going to go ahead and send that email. We're going to test this out, and then we can go ahead and customize this inside of here. So let's go over to back again to purchase this,
02:24
and let's go through the flow again. Once again, I've just filled in my details here, and I'm going to hit Pay, and what we should get is an email sent to us with the default markdown template.
02:34
So let's go over to our email client, and there we go. We've got introduction, the body of your message, and a button. So the email is getting sent, which is great. Now we can go ahead and customize this.
02:44
So we know that we're passing the sale into here, so we're going to go ahead and accept in the sale into the constructor. That means that we can extract information about the product from this because we know over on the model here,
02:56
we've got the product as a relationship. So in here, we're going to say, thanks for purchasing x, that's the name of the product. So we can just go ahead and reference the sale, product, and title.
03:10
So this, sale, product, and title. If we head down on this email here, you can see this is the location to the markdown file. So we can go ahead and open up purchase confirmation,
03:22
which contains everything we just saw in our mail client. So let's change the introduction to thanks for your purchase. And I've got some copy over here, which also includes the sale, product, title in there,
03:35
which we can reference because sale is now part of this mail object. We can directly reference that inside of here. So you've bought, and then the product title, again, using asterisks here to bold this because it's markdown.
03:49
And it just says you can access the files for this product below, which is going to be this button just here. We'll change this over to access files, but we don't quite have a URL for this yet.
03:58
So we'll change this over later. OK, so we're going to go through the entire flow again, purchase this out, and we should see our new email in there with those new details.
04:09
So once again, just entered this fake card information in here. I'm going to hit pay, and we're going to keep an eye on our mail client to see that new email roll in. So we've got thanks for purchasing product one.
04:20
We've got thanks for your purchase. We see this in not bold, but italic. And we've got a button here that we'll eventually be able to click to access the files that we've just bought.
34 episodes3 hrs 32 mins

Overview

Build a marketplace where sellers can list and sell files, while we take a cut of each sale using Stripe Connect.

We'll cover onboarding users with Stripe Connect, creating products and uploading files, payments, and delivering purchased files to your customers.

Here's everything we'll cover:

  • The Stripe Connect onboarding flow
  • Effortlessly creating products (and uploading files) with Livewire forms
  • Subdomains for your user's marketplace
  • Stripe Checkout for a beautiful, secure payment flow
  • Securely delivering files with Signed URLs in Laravel
  • Showing sales stats on a dashboard
Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.