Oh, boy, am I giddy, we're about to pay.
We're about to pay with a credit card and process the payment on stripe, that is the whole point of
this part of the.
And so the way that we're going to achieve this is we're going to implement the Stripe SDK software
development kit in our firebase functions.
That's how we're going to do this.
And so the payment gateway that we're talking about here, right?
We have our checkout, we have our payment button, but our payment button right now isn't connected
to anything.
Just console lock.
We want to change that console, log into a console charge.
OK, bad joke, bad dad joke.
But you know what I mean, right?
We want to pay and we want to be able to see our payments on the payments screen.
We want to see this happen.
We want we want all of this good stuff.
Right.
And so right now, what we're seeing is that some of the payments that I've done in the other app.
Right.
The production app have trickled through.
And so what we're going to look at now is how exactly we're going to get this payment for all of stripey.
Now, if we go to the no gess implementation of Stripe on October 24th, 2013, they officially launched
what was, I believe, the official stripe node J.
S package.
OK, so obviously it's been updated since then and improved.
But during that time period, right, 2013 to now, that's eight years, a lot of improvements must
have happened.
So this package is the package that we're going to use to talk on our behalf to Stripe.
So you know what to do.
We over the meals to go, we see into our functions folder and we do yarn add stripe.
And by doing this inside of the functions folder, what we're achieving here is the ability to bootstrap
just like straight client in the front end, a stripe client in the back end.
Now they're different.
They're different because on the front end, it's a limited subset of the stripe SDK that's available
to us.
But on the back end, in our firebase functions, we have a whole world open to us.
We can do anything.
It's kind of like Charlie and the Chocolate Factory.
It's up to your imagination.
So with that said, what we need to do now is create that stripe client.
So over here we have our Google client, obviously.
And what we want to do now is const Strib client.
Is equal to the require of stripe.
But what we're going to do with this is we're going to say functions, config, dot stripe, dot key,
and that is what we're going to use.
Now, if you're unaware of how to add a configuration key or you don't remember how to do this, please
refer back to the Google videos in order to get this running locally.
If you've lost the ability or you forget which functions we ran and so forth.
But the key that you're going to want to set on the striped key, if we go over here and we go into
developers and then we go into Epic's, where you're going to want to do is you're going to want to
take the secret key.
This is the key that you're going to want to copy paste into your stripe, that key.
And so once you've done that, then you want to, of course, take those secrets and put them locally.
And again, we showed that in the Google Firebase Config series when we were doing our Google implementation.
So just refer back to those videos if you're having a hard time remembering.
And so just as a quick reminder, once you've set up your firebase key, you can do firebase functions,
config get and you can do this little sign over here.
Right.
The greater then sign.
And so if you if you run this whole line, rather I'll show it on one line, if you run firebase functions
config get greater then and then to runtime that config.
This is going to take all of the config that is in your firebase functions and put them in a local file
and that way you can run it locally.
So now what we need to do is quickly restart our firebase functions and now we have a stripe client
that is bootstrapped.
Now, the other thing that I want to do is I quickly want to rename all of these clients to Google client
because we want to create a clear separation here between the Google client and the client that we're
passing it.
And then what we want to do is we want to export a new function and we want to call it pay.
And then when we export pay, we're going to do something called a pay request and we're going to use
the stripe client.
Now, pay request is going to come from, well, you guessed it, pay.
So that's pay.
And so over here in our firebase functions, we're going to create a new folder and we're going to call
that pay and then pay.
We're going to put an index box and we're going to export CONSED pay request.
Rather, no, we don't want to use that type of syntax, we're going to do module that exports.
So we're going to do a module that exports.
And module that exports that pay request and then what we're going to do and you can see here, I get
tripped up between the different types of syntax I need to use between different libraries.
It happens all of these different types of infrastructure can expect different types of syntax.
So over here, we're using the modules, in fact.
So what we're getting is request response and then we're getting the strapline right.
And so with that now, we can go ahead and we can do a rest.
But send.
This is my payment.
And with that comes the ability for us to.
Be able to, well, response thoughts and first of all, with that comes the ability for us to talk
to our response.
Now, if we look over here, if we go to meals to go pay, we'll see.
This is my payment gateway.