Hey there, everyone that they share.
And in this video we're going to work through with the Razer pay, we've already gone through with a
quite in-depth detail about the Razer pay once already.
So it's time to speed up the things.
So the very first thing that I would know is go ahead and sign up on the Razer pay of course, and then
into the settings.
We need the API keys, so go ahead and grab your API keys.
I'll add new variables into this one so I'll just call them as simply razer pay.
And the first one is actually just the key.
So let's call this also as API key.
So this is razorpay pay API key.
And then we have got similarly the razer pay secret.
So razer pay secret.
There we go.
Secret always remains with us.
API key can go and travel.
So in case you want to get that anyways via a method or anyways it's all okay.
Let's go ahead and regenerate the key.
Yes, please deactivate my old key and generate.
So this is my ID.
Go ahead and copy that.
And of course by the time you will be getting these files, they all will be deactivated and won't be
usable anymore.
I'm going to go ahead and copy The Secret and there we go.
So both are there.
I'm going to go ahead and save that now.
I don't need to download that.
Okay.
So this is all done.
Now let's go ahead and take a look on how the documentation works.
In fact, first, what we can do is we can actually create a similar method to what we have done in
the sense trip key.
So in fact, we can actually copy this and make another method that hey, this time we are going to
send razorpay ki razorpay ki.
Now again, it's not something that we should be doing, like it's not necessary, but still, let's
just say somebody is demanding instead of saying that, hey, just get it again and again, we're going
to go ahead and give him like the method.
There we go.
That's all it takes.
Now, we are going to go ahead and duplicate this method one more time so that we can actually create
a method for capturing a payment with the stripes.
So we're going to go ahead and copy this, paste this here, and this time this one is going to be CAPTCHA
razorpay payment.
Razer pay payment.
Okay, we can just go ahead and remove all of this and we can bring in some code from the one that we
saw previously.
So go into the documentation of razor page, just click on the view documentation.
It will take you to the documentation again, the documentation for payment gateways and all of that.
It has a lot of things to work on with that and you can click on that.
So this is the slash doc slash payments and pretty easy way to find the documentation in fact.
And we are interested in creating an order and we'll be creating an order.
So of course creating an order via the API itself.
So this is all what we need to take.
Go ahead and scroll it a little bit and you're going to find that you can pass on a whole lot of things
that you want to.
But we are interested in just creating an order via the code itself and we'll be looking for the Node.js.
Let's go ahead and bring in all of this data and copy that and let's move up here and paste this up
here.
Okay.
Let's go ahead and hit an enter here.
And in fact, I would love to create an enter just right here.
There we go.
Now it needs an ID as well as a secret.
So let's go ahead and give it that.
We can actually bring this one guy from here.
So process e v dot razer pay key.
So let's copy that.
This is my key id or the key itself and the last one is the secret.
So I'm going to go ahead and bring that from Razer pay secret.
Copy that.
And pace them up here.
So as just like the documentation instructed to us that go ahead and create an instance of the razorpay.
We have done that.
Now we have got these options that how you are going to go ahead and accept the options up here.
So we're going to go ahead and say, hey, I have an option of requesting this.
So this one is going to come up as request, dot body, dot amount.
Okay.
Now coming up is the receipt.
So you can actually go ahead and use that asset like this or we can go ahead and generate a random number
all the time.
And in case you do remember, we have the way of generating the random number in the user controller,
not controller, the model itself.
So in the user model we saw that how we can actually go ahead and generate it's kind of a similar token
up here.
So we're going to go ahead and call this one as token.
So let's go ahead and bring this one so that it gives us this same kind of a token or we can use actually
a UUID better approach would be to create.
In fact, let me just show you and you can do this later on.
I wouldn't be doing this.
So let's go ahead and we can actually use that part as well.
This is just a just a kind of order received and you can use a nano ID in this case and then the ID
and nano ID.
I hope this can search it.
There we go.
So what nano ID can do it for you is give you some of the random string and your your invoice is going
to look like this.
I'm not interested in generating the invoice as of now.
So this is already being too much of work.
I am pretty sure you can go ahead and do that.
So we're going to go ahead and create these options.
And once these options are done, all I'm interested in capturing the order.
So instead of saying that, hey, go ahead and instance, dot order, dot create, let's hold this into
a variable and not pass on a function like this.
So we're going to remove this function entirely and there we go, just like that and pass on the option.
And let's hold this into a variable, this entire response that is coming up.
So we're going to call this one as simply my order and this one is going to take some time.
So let's go ahead and await this one.
Once this is all done, let's go ahead and send this my order on the different end.
And maybe whoever the guy is handling the front end can actually extract what comes back into the order
itself.
So let's go ahead and say it as status.
The status is obviously going to be 200 and then we are going to go ahead and send a JSON response like
this.
And in this, we are going to go ahead and say success is true.
And we can also optionally send that whatever the amount we have captured.
So amount can actually be coming from request, dot, body, dot amount.
Maybe he wants to further down the road that confirm that whatever the amount was captured or not.
And finally, we want to pass on this order as well.
So order is going to be my order.
There we go.
And we can actually just pass on this response to this guy as well.
Maybe somebody wants to do a further thorough check that whether all the values are being getting properly
or not.
Okay.
So that's all it takes to work on with the payment gateways, that's all.
Pretty much it.
In the next video we'll be creating routes for them and we'll be injecting these routes into the app
is pretty simple.
Let's go ahead and catch up in the next video.