WEBVTT

00:03.820 --> 00:07.960
Hey, did everyone that they share and this video we're going to work on the controllers, which will

00:07.960 --> 00:11.840
be associated for simply capturing the payment using Stripe.

00:12.220 --> 00:16.330
But before we move on there, I would like to bring your attention to one very important thing.

00:16.510 --> 00:21.490
This is all related to on which in which country actually you are located in.

00:21.490 --> 00:26.710
If you are located in India and you have made the currency as type of USD, this is not going to be

00:26.710 --> 00:27.040
allowed.

00:27.040 --> 00:28.900
Neither the euro is going to bail out.

00:28.930 --> 00:34.300
You have to make sure that the currency is INR for the Indian account that are associated with the stripe.

00:34.330 --> 00:38.740
In case you are watching it from outside of India, then you can make it a dollar or a euro.

00:38.740 --> 00:43.270
But again, it is very important for Indians to understand that our payment system works a little bit,

00:43.270 --> 00:45.850
behaves a little bit different than the rest of the other world.

00:45.850 --> 00:47.980
So having it an INR is really important.

00:47.980 --> 00:53.110
And on top of that it will open up an intent that it is going to be a success or is it going to be a

00:53.110 --> 00:53.800
failure?

00:54.010 --> 00:55.480
Let's go ahead and check it out.

00:55.480 --> 00:57.220
That how this is going to work.

00:57.220 --> 01:01.600
So first and foremost is let's go back up here and create some of the controllers.

01:01.600 --> 01:03.010
So let's go ahead and close this one.

01:03.010 --> 01:04.720
All the keys and everything are here.

01:04.930 --> 01:07.330
Let's go ahead and create a controller for that.

01:07.660 --> 01:12.550
So all of the payments related information are going to go into payment controller.

01:13.630 --> 01:16.450
Controller G is of course.

01:16.810 --> 01:17.620
There we go.

01:18.580 --> 01:23.110
All we need here is actually big promise and nothing more than that.

01:23.110 --> 01:24.700
So big promise.

01:24.730 --> 01:28.150
No, it's not going to suggest so I'll bring it from the product controller.

01:28.600 --> 01:32.200
Do we need anything else since we are not working on any model or anything like that.

01:32.200 --> 01:33.160
So we don't need that.

01:33.160 --> 01:34.630
We just need a big promise.

01:34.840 --> 01:40.030
So what we're going to do now, the first thing is that if somebody makes a request to us that, Hey,

01:40.030 --> 01:43.780
I want to grab the public key, I should be able to give him the public key.

01:43.810 --> 01:46.060
Now, this is not really compulsory.

01:46.060 --> 01:47.890
This is not really necessary.

01:47.890 --> 01:55.300
We're going to call this one s send stripe keys or key, rather.

01:55.300 --> 01:56.350
That would be accurate.

01:56.350 --> 02:03.010
So we're going to go ahead and say, hey, this one is going to be wrapped around the big promise just

02:03.010 --> 02:03.580
like that.

02:03.580 --> 02:07.120
And this is going to we don't need a sync code in this case.

02:07.120 --> 02:12.490
But still, since we are following the routine, let's go ahead and say request, response and the next.

02:12.970 --> 02:14.890
There we go, just like that.

02:14.890 --> 02:19.360
Now all we are going to do is directly anybody makes a get request on this, we are going to go ahead

02:19.360 --> 02:23.200
and simply send a resort status of 200.

02:23.200 --> 02:27.040
We don't need even need to send a success or any message like that.

02:27.040 --> 02:30.430
We're going to go ahead and directly send a JSON response like this.

02:30.430 --> 02:37.630
And in this JSON response, we are going to go ahead and say, hey, your stripe key is actually coming

02:37.720 --> 02:44.410
from process Dot and V and let's go ahead and see what did we call this one?

02:44.410 --> 02:47.500
So this is processed or D and V, so this is the stripe key.

02:47.500 --> 02:52.030
And again, remember and my bad, I forgot to add an equal sign there.

02:52.030 --> 02:53.410
So there we go.

02:54.840 --> 03:00.270
So let's go ahead and save this one and go ahead and say that process dot E and V dot strip key.

03:00.270 --> 03:00.900
So that's it.

03:00.900 --> 03:01.650
That's all.

03:01.650 --> 03:05.460
And again, I know this, this sounds really weird that why even we are doing it.

03:05.460 --> 03:07.380
In fact, I don't do it in much of the cases.

03:07.380 --> 03:11.040
I directly like to inject these keys because it's totally safe to give this key.

03:11.070 --> 03:14.430
Don't panic out in case this secret actually goes up.

03:14.430 --> 03:16.560
That's the time to panic, not anything else.

03:16.560 --> 03:17.100
So totally.

03:17.100 --> 03:19.170
This is not really a method to work on it.

03:19.170 --> 03:20.580
This is really the simplest of all.

03:20.580 --> 03:21.090
The one.

03:21.510 --> 03:23.580
Okay, so let's go ahead and make a copy of this one.

03:23.580 --> 03:25.830
So this is kind of a boring stuff that we have done.

03:25.830 --> 03:28.170
Let's go ahead and now capture the payment.

03:28.170 --> 03:32.850
So this one is going to be simply, hey, anybody who wants to capture the payment, so this is going

03:32.850 --> 03:33.360
to be that out.

03:33.360 --> 03:38.460
So we're going to say capture stripe payment.

03:38.460 --> 03:42.930
Now why I'm calling it as capture stripe payments, because we will be having a raise or pay payment

03:42.930 --> 03:46.140
as well and we'll be similarly sending the reserve keys as well.

03:46.140 --> 03:49.560
So this is how it's going to work now for capturing the Razorpay payment.

03:49.560 --> 03:51.030
First we need to bring in the Razer pay.

03:51.030 --> 03:54.900
Let's go ahead and see how to do that from the documentation as well.

03:56.040 --> 03:59.370
So we're going to go ahead and say, hey, we need to bring up like this.

03:59.370 --> 04:07.920
Let's go ahead and at the very top, let's go ahead and say this comes up like this and this is a stripe

04:07.920 --> 04:08.880
is going to be required.

04:08.880 --> 04:11.490
And then it says, hey, I need a key value up here.

04:11.490 --> 04:14.310
This is actually a your secret key.

04:14.310 --> 04:16.140
So let's go ahead and remove that.

04:16.140 --> 04:21.090
And the good thing that I like about is it says ask for secret key and pay for public key.

04:21.210 --> 04:29.550
So let's go ahead and say we are going to say process dot, E and V dot and we need to change this one

04:30.360 --> 04:31.740
into the stripe secret.

04:31.740 --> 04:33.960
So let's copy this and there we go.

04:34.170 --> 04:38.370
So now as just exactly as a stripe said, we have worked exactly on that.

04:38.370 --> 04:40.140
Let's go ahead and C move on there.

04:40.140 --> 04:41.910
So let's copy the next step.

04:41.910 --> 04:44.880
This is the exact step that we need to go ahead and copy that.

04:45.300 --> 04:49.170
Let's go ahead and remove everything from the inside, from capturing the stripe payment.

04:49.170 --> 04:50.970
This is how we are going to work on that.

04:50.970 --> 04:56.220
So we basically need to actually capture this payment intent and send and work on with that.

04:56.220 --> 04:58.650
In fact, we don't need this line at all.

04:58.680 --> 05:03.840
Let's go ahead and cut this out, make sure this changes to inner this is really, really important.

05:03.840 --> 05:07.230
But I cannot actually go ahead and just put an amount like this.

05:07.230 --> 05:08.940
This is going to be a hardcoded value.

05:08.970 --> 05:13.380
The amount will be sent to us by request, body, dot amount.

05:13.470 --> 05:20.010
Now again, as I mentioned, the whole job of this entirety of the thing is to simply go ahead and just

05:20.010 --> 05:24.630
capture the amount, capture the payment, whatever the amount is being mentioned further down the road,

05:24.630 --> 05:29.490
you can actually match the values that whatever is being sent to us is only that the thing which is

05:29.490 --> 05:33.960
being captured, or maybe you want to match it, some of the products and all of the logic that goes

05:33.960 --> 05:35.040
into the order itself.

05:35.040 --> 05:35.730
Not here.

05:35.970 --> 05:40.800
Okay, now optionally what you can do, although you don't need it, but this is optional.

05:40.800 --> 05:45.180
So I'm going to go ahead and add an optional here that you can actually make sure that the integration

05:45.180 --> 05:46.140
check can also be done.

05:46.140 --> 05:48.630
So there are a lot of meta properties in this one.

05:48.630 --> 05:50.610
I'm going to go ahead and say, hey, metadata.

05:50.910 --> 05:51.720
And there we go.

05:51.720 --> 05:53.940
This one is known as the integration check.

05:53.940 --> 06:00.210
So integration underscore check and this is actually a good thing.

06:00.210 --> 06:05.370
You'll find a lot of documentation actually talk about this that go ahead and provide some of the metadata

06:05.370 --> 06:05.910
as well.

06:06.690 --> 06:07.530
Payment, that's it.

06:07.530 --> 06:10.530
And this is something that you're going to find on StackOverflow and everywhere.

06:10.530 --> 06:11.430
Again, this is optional.

06:11.430 --> 06:12.330
You don't need this.

06:12.330 --> 06:13.680
And that's basically it.

06:13.680 --> 06:16.470
You have got this payment intent and we already studied that.

06:16.470 --> 06:20.220
This payment intent is actually a big, gigantic object.

06:20.220 --> 06:23.490
So payment intent object and you can extract any value that you like.

06:23.490 --> 06:28.350
As I said, this client secret is one of the favorite values and this ID is one of the favorite values.

06:28.350 --> 06:34.080
You can either dump and load the entirety of this object onto the front end or whoever is handling the

06:34.080 --> 06:35.130
remaining of the process.

06:35.130 --> 06:36.450
But I won't be doing it.

06:36.450 --> 06:39.150
I would rather be just grabbing this client secret.

06:39.150 --> 06:40.350
But again, it's up to you.

06:40.350 --> 06:43.020
You want to send the entirety of the object, go ahead and do that.

06:43.260 --> 06:46.020
Now, once this is all done, that means payment has been captured.

06:46.020 --> 06:51.570
Otherwise, it's going to give you a response that, hey, payment was not captured and the the metadata

06:51.570 --> 06:53.640
is not being going to be created there.

06:53.640 --> 06:56.550
So let's go ahead go ahead and say it as status.

06:56.550 --> 07:00.300
And this is going to be a status of 200 if everything goes right.

07:00.300 --> 07:04.470
And then we're going to go ahead and say JSON and inside that an object.

07:04.470 --> 07:07.860
So we're going to go ahead and success is going to be true.

07:08.280 --> 07:14.460
And once the success is true, let's go ahead and simply go ahead and send a client underscore secret.

07:14.460 --> 07:18.300
And that client underscore secret will be coming from the same payment intent.

07:18.330 --> 07:21.030
Feel free to load or unload the entirety of that.

07:21.030 --> 07:21.930
It's up to you.

07:21.930 --> 07:23.910
Or maybe you want to send an ID as well.

07:23.910 --> 07:32.670
So let me write that you you can optionally send ID as well.

07:32.670 --> 07:37.710
And I'm pretty sure that by this point of the time since you have watched the entirety of the course,

07:37.710 --> 07:39.060
it shouldn't be a big deal.

07:39.060 --> 07:42.600
So totally you capturing the payment is like really as simple as it could be.

07:42.600 --> 07:43.110
And that's it.

07:43.110 --> 07:44.910
We have done with the payment.

07:44.910 --> 07:46.200
That's all what it takes.

07:46.200 --> 07:52.260
Now let's go ahead and move on and simply work with the Razorpay APIs as well and how we can create

07:52.260 --> 07:53.670
a method from the Razorpay as well.

07:53.970 --> 07:55.890
Let's go ahead and catch up in the next video.
