WEBVTT

00:03.640 --> 00:07.600
Hey, did everyone that they share in this video, we're going to be working on The Roots and we'll

00:07.600 --> 00:10.090
be adding these roots on the dogs.

00:10.090 --> 00:10.900
Pretty simple.

00:10.900 --> 00:16.420
So we have created four of these methods and we need to just send them into the root itself.

00:16.420 --> 00:21.280
So let's go ahead and close this one, this one, and let's open up.

00:22.120 --> 00:24.100
Let's create a new file, not open up.

00:24.100 --> 00:26.470
So in the roots or geez, we are going to create a new file.

00:26.470 --> 00:32.290
Let's call this one as payment dot js and we'll borrow some code from the product itself.

00:32.290 --> 00:35.380
So let's go ahead and say we will be needing express.

00:35.380 --> 00:37.930
So copy that, paste that up here.

00:37.930 --> 00:39.310
Express is needed.

00:39.340 --> 00:44.110
We are also going to need the router, so copy that and paste that up here.

00:44.290 --> 00:45.730
What else we are going to need?

00:45.730 --> 00:50.470
We are going to need this middleware so as well copy that and paste that as well.

00:50.830 --> 00:52.240
What else we are going to need?

00:52.240 --> 00:53.830
We need to send the router as well.

00:53.830 --> 01:01.000
So let's go ahead and copy that even and extract the router and that's all what we are going to need.

01:01.000 --> 01:03.040
I guess that's pretty much it.

01:03.070 --> 01:08.170
Now let's for the sake of saving some time, copy one router itself and let's modify that up here.

01:08.470 --> 01:08.640
Okay.

01:08.770 --> 01:15.040
So how this route is going to work first is somebody actually says, hey, give me the API keys for

01:15.040 --> 01:16.480
Stripe or the Razer paste.

01:16.480 --> 01:22.060
So we're going to go ahead and say slash stripe key.

01:22.270 --> 01:27.280
And anybody who says that I want to have a get let's go ahead and import the methods as well.

01:27.430 --> 01:33.430
So let's go ahead and say I want to say that const bring some methods and these methods are going to

01:33.430 --> 01:42.400
come in from require one directory back inside the controllers not like that inside the codes and we

01:42.400 --> 01:47.650
need to go one directory back inside the controllers and we have this payment controller.

01:49.180 --> 01:53.070
Now the two methods that we have got it send Razorpay Ki and sen stripe ki.

01:53.080 --> 01:54.700
Let's go ahead and paste them up here.

01:54.700 --> 01:58.300
Send Razorpay ki and we got the sen stripe key.

01:58.570 --> 02:02.620
So the only thing that we have to worry about is copy that and paste them up here.

02:02.620 --> 02:04.780
So this one is my read.

02:05.020 --> 02:07.360
This one is going to be handling this one.

02:07.360 --> 02:09.040
So anybody says slash stripe.

02:09.040 --> 02:10.240
KI We will give him the stripe.

02:10.240 --> 02:11.170
KI Just like that.

02:11.170 --> 02:12.970
But he should also be authenticated.

02:12.970 --> 02:14.260
We don't need to make him admin.

02:14.260 --> 02:18.520
In fact, in all of the payment, we don't need to make anybody as an admin.

02:18.520 --> 02:20.080
So we're going to remove the custom role.

02:20.080 --> 02:21.190
We won't be needing it.

02:21.310 --> 02:22.110
So there we go.

02:22.120 --> 02:25.870
Person should be logged in and we will send him the stripe key just like that.

02:25.870 --> 02:26.920
And similar to that.

02:26.920 --> 02:34.900
If somebody says, Hey, I need a razorpay key, then we are going to go ahead and send the Razorpay

02:34.930 --> 02:35.770
Ki to him.

02:36.190 --> 02:36.790
There we go.

02:36.790 --> 02:37.510
Nice and easy.

02:37.510 --> 02:38.590
No problem at all.

02:38.710 --> 02:40.270
Now, these are the key routes.

02:40.270 --> 02:42.760
Now we need to actually capture the payment as well.

02:42.760 --> 02:45.190
So let's go ahead and make a copy of this one.

02:45.190 --> 02:46.180
Move it up here.

02:46.390 --> 02:50.860
And this one is going to be just a process, the payment.

02:50.860 --> 02:56.110
So this one is going to be razorpay and another one razorpay payment.

02:56.140 --> 02:58.090
Another one is going to be stripe payment.

02:58.090 --> 03:03.550
So let's go ahead and call this one as Stripe payment.

03:04.390 --> 03:07.990
And yeah, this seems okay anyways.

03:07.990 --> 03:11.410
Not running out, not really getting good names for this one.

03:11.410 --> 03:12.820
So this one is.

03:12.820 --> 03:14.470
Let me go ahead and copy that.

03:15.310 --> 03:18.210
Capture Stripe payment and capture razorpay payment.

03:18.220 --> 03:19.510
These are good names, actually.

03:21.400 --> 03:22.840
So capture stripe.

03:22.840 --> 03:30.040
In fact, we're going to call this same capture stripe because I think this is a better name.

03:30.040 --> 03:35.590
So Capture Stripe is going to be handled by the capture stripe just like that.

03:35.590 --> 03:39.400
It should be logged in and this should be a post request because you are sending me data at least the

03:39.400 --> 03:41.530
amount and we'll be sending this one.

03:41.530 --> 03:42.970
So this one is going to be captured.

03:42.970 --> 03:43.840
Razorpay.

03:46.260 --> 03:47.580
CAPTCHA razorpay.

03:48.180 --> 03:51.810
And if I am correct, this is going to be CAPTCHA razorpay.

03:52.770 --> 03:52.900
Okay.

03:53.040 --> 03:53.370
Nice.

03:53.370 --> 03:55.860
Now copy that and paste them up here.

03:55.860 --> 04:00.750
So he should be logged in and if he sends it up, we'll be processing this right from here.

04:00.750 --> 04:01.620
So no big deal.

04:01.620 --> 04:02.670
We have done with that.

04:02.700 --> 04:04.590
Now this payment is all done.

04:04.590 --> 04:05.940
Now we need to export this.

04:05.940 --> 04:07.440
We are already exporting this router.

04:07.440 --> 04:13.860
This router needs to go into JS, so the router import is going to work like that and we are going to

04:13.860 --> 04:22.320
call this one as simply payment and this one is going to be slash roots, slash payment, slash payment.

04:22.470 --> 04:28.080
Again, we cannot actually test them out because that's the reason why I got into the separate section.

04:28.080 --> 04:32.520
An entire, entire chapter was dedicated to show you that how payments are being captured.

04:32.520 --> 04:37.020
It takes a little bit while to set up on the front end, but our job at the back end is probably the

04:37.020 --> 04:38.430
simplest one in this case.

04:38.460 --> 04:41.130
The rest all is really complicated, but in this one it is easier.

04:41.160 --> 04:47.190
Not because it is easier on our side because these SD cards were given to us by Razorpay and the stripe.

04:47.190 --> 04:48.750
So we don't have to worry that much.

04:48.840 --> 04:50.100
And that is it.

04:50.100 --> 04:51.600
That is all you need to do.

04:51.600 --> 04:57.030
And in case there are issues being transferred from the front end guy, we obviously can handle those

04:57.030 --> 04:59.850
and we can actually debug the session as well in this.

04:59.850 --> 05:04.320
Also, even in the simplest of the code, I expect that there might be some debugging session that happens,

05:04.320 --> 05:09.390
but that needs to be happen after when the frontend guy comes in, he is using React View, Angular,

05:09.390 --> 05:13.860
Razorpay or whatever he wants to use that comes after that.

05:13.860 --> 05:16.020
So that's pretty much it from our end.

05:16.020 --> 05:19.530
As of now, this part is all done, so payments are being captured.

05:19.530 --> 05:24.210
Now once the payments are being captured now we need to work on how to place an order because without

05:24.210 --> 05:26.340
capturing the payment we won't be placing the order.

05:26.340 --> 05:31.500
So in the next section onwards, we are going to work on how to capture the orders or place the orders.
