WEBVTT

00:03.850 --> 00:04.800
Hey, did everyone.

00:04.810 --> 00:07.120
Thanks here and welcome to another section.

00:07.150 --> 00:08.750
Now, so far what we have seen.

00:08.770 --> 00:13.120
This is to be honestly the majority of what you'll be doing as a developer.

00:13.150 --> 00:15.820
Now, surely there can be more complexity that comes up.

00:15.820 --> 00:21.070
There might be more features, but this is majorly over all of the mongoose and MongoDB that works through.

00:21.130 --> 00:26.500
Now, one additional layer that comes up is handling the third party libraries or third party SDK is

00:26.500 --> 00:28.590
one of them is our topic.

00:28.610 --> 00:32.110
In fact, two of them is our next topic, which is working on the payment system.

00:32.320 --> 00:36.700
Now, the way how you work with the payment system, maybe there are some other third party services

00:36.700 --> 00:37.840
or SDK that come in.

00:37.870 --> 00:41.380
You simply go ahead, read their docs and just basically just follow them.

00:41.380 --> 00:42.560
And it's pretty easy.

00:42.580 --> 00:47.680
We have already discussed quite a lot about the Razorpay, but still we are going to inject that also.

00:47.680 --> 00:50.260
But we will also be working on the stripe as well.

00:50.710 --> 00:54.430
We haven't talked much in depth about the stripe, so we're going to do that in this video.

00:54.430 --> 00:56.530
Let's go ahead and talk on that one.

00:56.800 --> 00:59.800
So obviously, first, you will need an account on Stripe.

00:59.800 --> 01:01.510
It's free, so go ahead and create one.

01:01.510 --> 01:06.430
This is my dummy account that I use for all of the tutorial that I do up here, as well as in the in-person

01:06.430 --> 01:07.570
bootcamps as well.

01:07.630 --> 01:12.520
Now here you can see there is a simply publishable key's and secret available directly, but you can

01:12.520 --> 01:17.890
actually go into the developers and click on the API keys and they revamp their website quite a lot.

01:17.890 --> 01:22.510
So just go ahead, look for developers, an API key somewhere and you'll be able to find that and you

01:22.510 --> 01:24.070
can just click on it and it will copy that.

01:24.070 --> 01:26.110
And similarly for the secret key.

01:26.140 --> 01:32.140
Now the most important thing inside our code base, we have this dot E and V file and these keys need

01:32.140 --> 01:32.920
to go here.

01:32.920 --> 01:35.070
Absolutely no exception at all.

01:35.080 --> 01:43.510
So we're going to go ahead and say, this is my stripe and this is going to be API key and another one

01:43.510 --> 01:47.560
is going to be Stripe secret.

01:47.890 --> 01:48.600
There we go.

01:48.610 --> 01:50.860
Let's go ahead and put an equal sign and there we go.

01:51.700 --> 01:54.490
So this is the first one, which is my API key.

01:54.490 --> 01:59.650
And let's not forget our this test key as well, which is the secret.

01:59.650 --> 02:01.630
So this publishable key can go anywhere.

02:01.630 --> 02:06.340
This is like a public key and you can go ahead and add it on to the front end and wherever you like.

02:06.340 --> 02:10.390
The secret here actually always remains on our back end, so we are going to go ahead and reveal this

02:10.390 --> 02:10.840
one.

02:10.840 --> 02:12.790
And of course, I do change them quite often.

02:12.790 --> 02:13.810
So no big deal.

02:13.810 --> 02:18.010
We're going to go ahead, copy this and we're going to go ahead and paste that up here.

02:18.010 --> 02:18.820
So there we go.

02:18.820 --> 02:22.810
Now my application is all good enough, so it is having both the keys available.

02:22.810 --> 02:25.480
Similarly, we will be adding the Razorpay keys and all of that.

02:25.810 --> 02:27.430
So we're going to hide that now.

02:28.330 --> 02:31.930
So this part is all done and this is basically all we need from this page.

02:31.930 --> 02:35.650
And you can go back on to home page and see that how many payments have come in and all of that.

02:35.650 --> 02:42.400
So these are all part of the test being done from the previous courses or some other kind of tutorials

02:42.400 --> 02:43.390
that I was making.

02:43.780 --> 02:44.080
Okay.

02:44.080 --> 02:48.520
Moving on now we need to go ahead and look into the documentation of Stripe.

02:48.520 --> 02:53.080
So let's go ahead and see that how we can capture the payment, just like in the razorpay we did that

02:53.080 --> 02:54.040
exactly same.

02:54.040 --> 02:56.170
So it offers a whole bunch of services.

02:56.170 --> 02:59.950
What we are interested is in online payment and we want to just accept the payment.

03:00.100 --> 03:03.790
So at the time of accepting a payment, let's go ahead and see that how we can do that.

03:03.790 --> 03:05.680
Of course I want to do that on the Web.

03:05.680 --> 03:07.630
The rest of the others are available as well.

03:07.870 --> 03:09.910
And I want to set up this stripe.

03:09.910 --> 03:12.880
And again, yours might be selected on Ruby or Python or something.

03:12.880 --> 03:14.380
We are interested in Node.js.

03:14.380 --> 03:16.330
So step one is install the stripe.

03:16.330 --> 03:21.160
And again, in case you did notice earlier as well that yes, Stripe is already included.

03:21.160 --> 03:23.500
So Stripe and the Razorpay both are included.

03:23.500 --> 03:24.730
So we don't need to do this a step.

03:24.730 --> 03:26.050
We have already worked on that.

03:26.260 --> 03:32.440
Now next thing is you really want to study this diagram here that how and what happens when the entire

03:32.440 --> 03:33.700
payment flow actually goes on.

03:33.700 --> 03:36.670
This will help you to understand the entire architecture of the application.

03:36.670 --> 03:42.550
I highly recommend to spend probably 5 to 10 minutes onto this one once you are done with that.

03:42.550 --> 03:45.760
These are all the code that we are going to be writing and we'll be using.

03:45.760 --> 03:51.310
So first is obviously you require the stripe and provide all the configuration just right up here as

03:51.310 --> 03:52.300
soon as you call it.

03:52.300 --> 03:56.980
And after that, you have to simply say payment intent is going to be a red stripe payment intent and

03:56.980 --> 04:00.550
it's going to create it requires amount and the currency.

04:00.550 --> 04:03.370
And then you can add the payment method types as well.

04:03.370 --> 04:08.590
Maybe you want to accept a card, maybe you want to use P two for I don't know what that is.

04:08.590 --> 04:09.970
I don't really mention this one.

04:09.970 --> 04:15.250
So by default this is being handled by the frontend engineers itself that what kind of payment methods

04:15.250 --> 04:15.850
you accept.

04:15.880 --> 04:19.750
We usually just go ahead and say, hey, just go ahead and take these two things.

04:19.750 --> 04:20.350
That's it.

04:21.340 --> 04:23.890
And you can go ahead and check more onto this.

04:23.890 --> 04:26.350
They give you more example about how to create the app.

04:26.350 --> 04:30.670
You have to simply get the secret or something like this in case you want to check that up.

04:30.670 --> 04:33.040
There is a server side rendering as well available.

04:33.040 --> 04:34.360
We won't be needing that.

04:34.360 --> 04:37.900
We just needed that method that how to capture the payment and that's pretty much it.

04:37.990 --> 04:42.940
Now if you scroll a little bit up here, you will also notice that they also said that, okay, once

04:42.940 --> 04:47.650
you have taken the payment, then what to do next, what kind of data you are going to receive.

04:47.650 --> 04:52.060
So they say they are the parameters that you receive, the payment intent and payment intent client

04:52.060 --> 04:54.040
secret as what you'll be getting.

04:54.040 --> 04:56.980
And you can study more about this payment intent object up here.

04:56.980 --> 05:00.280
So this is the entire client secret that you receive.

05:00.640 --> 05:00.880
Let's.

05:00.960 --> 05:02.280
Go ahead and click on that.

05:02.460 --> 05:04.940
And it's going to give you the entire object.

05:04.950 --> 05:05.880
You can study that.

05:05.880 --> 05:10.350
So this is the entire payment intent object that we actually go ahead and get receive up here.

05:10.500 --> 05:16.020
So there is a lot that you can do, provide invoices and currencies and a whole bunch of other things.

05:16.290 --> 05:21.720
Majority of the time, people like to store this client, underscore secret into their database so that

05:21.720 --> 05:25.950
they know that this is actually a valid kind of a transaction that has happened.

05:25.950 --> 05:29.100
Maybe optionally, they want to store the ID of that payment as well.

05:29.100 --> 05:33.690
So again, you can extract as many objects as you want to or you can send it on to the front end, guys,

05:33.690 --> 05:35.640
that, hey, this is all being processed.

05:35.910 --> 05:37.140
This is all what we have done.

05:37.140 --> 05:38.790
So told you, it's really simple.

05:38.790 --> 05:39.990
Not a big deal at all.

05:39.990 --> 05:43.770
You just need to file up just one method and simply go ahead and grab that.

05:43.770 --> 05:46.620
Now the important thing is the key and the secret.

05:46.650 --> 05:48.540
Now public key goes on to the front end.

05:48.540 --> 05:50.340
The secret key always remain to us.

05:50.340 --> 05:54.270
So it's up to you that how you want to transfer that publishable key?

05:54.270 --> 05:58.830
You can either transfer it via sending it directly to your front end developer and say, Hey, just

05:58.830 --> 05:59.640
put this key.

05:59.640 --> 06:03.510
Or you can make a method that whenever somebody requests that method, I'll just transfer the key.

06:03.510 --> 06:05.070
So again, both are exactly same.

06:05.070 --> 06:06.270
No big deal at all.

06:06.300 --> 06:09.810
Let's go ahead and catch up in the next video and actually configure the stripe.
