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
06. Forwarding users to Stripe Connect

Episodes

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

Transcript

00:00
Now that our users have Stripe account and we are forcing the user over to this onboarding page, it's time to get started with the onboarding flow. This will involve hitting the Stripe API and getting a link back that we then redirect the user to. So it's actually pretty straightforward. So to achieve this, we're going to go ahead and create another method over in our controller here,
00:21
our Stripe onboarding controller called redirect. And we're going to go ahead and set up a route for that as well. So let's just copy the onboarding down here, and that's slash redirect. And remember, that's the link that we gave over here as well. So as soon as we click on this, we'll go through to here. So let's go ahead and switch the method over here to redirect.
00:41
And we'll set this as onboarding dot redirect, just so we have a reference to the name. Okay, so to do this, what we're going to do is go ahead and maybe just choose response here as the variable name. And we're going to go ahead and grab Stripe out of the container. We're then going to access the account links part of the API. And we're going to go ahead and create
01:02
one of these. What this will effectively do is give us back a link object, we can grab the URL from that and then just redirect the user over to that. So what do we need to pass into this, there's a couple of things. The first thing is the Stripe account of the user. So again, we can use our request if we just bring that into the controller here to grab the currently
01:24
authenticated user. And we can go ahead and grab their Stripe account ID. That's what we created in the last episode, when we registered. The type of link here is going to be an account onboarding link. So this is account underscore onboarding. And then we just need two more things to get this working. We need a refresh URL, which is going to be redirected to if something goes wrong,
01:47
that's just going to be redirecting us back to this onboarding flow. And we need a return URL, which is what happens when we have successfully gone through the whole onboarding process within Stripe. And we come back to our account to verify this. So the refresh URL is basically just the redirect that we've just created. So we're going to generate our route if we just head over
02:10
to our web route back to onboarding redirect. So if something goes wrong, we just put the user back into this redirect flow. The return URL, which we haven't got at the moment, is going to be something like onboarding and verify. So this is where when the user has successfully gone through the flow, we redirect them back to this page, we verify that they have successfully set up for payment,
02:33
and then we enable their account. So we'll create this page out now really quickly so we can see this entire flow just before we go ahead and redirect the user. So let's go ahead and create out another method inside of here called verify. And it's just die dump here and just say verify for now just so we know that this works. We'll go ahead and create a route for this as well. So
02:53
again, it's just a matter of copying and pasting this down, heading to verify, choosing verify as the name and switching the name over here as well so we can reference it. Okay, so now that we've done that, the response we get back from here, let's just die dump on this just so we can see what this contains. So if we head over here and we click connect with Stripe now, that makes a
03:13
request. And yeah, at the moment, I've probably spelled account onboarding wrong, a bit unboarding, so that would make sense. Let's try that one more time. And there we go, we get back this account link object. So this doesn't contain much, but the thing that we're interested in is the URL just here. So really, all we need to do at this point is just return here a redirect. And we want to
03:34
redirect to response and URL. So now effectively, when a user clicks on this, they are forwarded over to Stripe to complete the onboarding flow that we saw in the introduction. So I'm going to go ahead and click on this now. And once that gets generated, we get redirected over and you can see here exactly what we saw in the introduction. So I'm going to go ahead and fill this out. And I'll
03:57
be back with you in just a second before we see how this redirects back over to our app. Okay, so I've gone through all of the onboarding steps and we're at this page that we saw in the introduction where we can review our details and agree and submit this. So now when we agree and submit, we'll be forwarded back over to our app, to this verify page, which we've created out here
04:16
and registered a route for. But at the moment, obviously just dies and dumps and should just say verify. So there we go. Now it's at this point, we will hit the API again and verify that the user has payments enabled. So we can actually start to process payments and they can receive payments and we can receive a cut of that payment.
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.