So before we go on to the next section, there's just a couple of things we need to clean up.
So I'm looking at the terminal page dot go HTML file, and I'm in the JavaScript block at the bottom
of the template.
And right now we have our stripe publishable key hard coded into this template.
In the same way, if you scroll down a bit where we have our fetch statement, I have the API URL hard
coded into this as well.
And of course, this is fine for development, but when we go to production, we're going to have a
different URL and we probably don't want a hard code that publishable key into the template because
we're using a test publishable key and we want our production key in there when we go live.
So let's fix that up.
So back in the render file render ago, we have this template data, which is data that's actually passed
to any template and we also have this default data function.
So let's take advantage of this and set a few things.
So right now we have a member or a field in template data called API and that's the API URL.
So I can add that in the default data function by saying something as simple as TD or API is equal to
app DOT, Config API and now our API, which is set when we start the application, will be added in
the same way.
If we need to, we can actually add that publishable key.
Now, if we wanted to, we could also add the publishable key as a field in this this type.
But we also have this string that we can just take advantage of that.
So if I open my roots file just so I can get where I need to be quickly and go to virtual terminal,
I can click on that.
And that brings me to this.
And I can add that data right here like this.
I can say string map is a sign the value of make a map, string, string, and then I can add a value
to that string map.
Publishable key is equal to
app dot config dot stripe.
I don't want the secret.
I want the key.
And I'll just pass that as data by putting a reference to template data and putting in a string map
and making that string map.
Now, I have that street map available in this template, so if I go back to the terminal page, I can
replace this.
I do eating it and just saying index dot, string map, publishable key.
And that should substitute a publishable key right in there, if I got it right now, if we go back
up here where we initialize this, we can simply delete this
and put in the AP or.
All right, so if we make sure that this has been recompile, it has and we go back to our Web browser
and reload this page.
Let's run a test transaction.
So ten dollars me me at here for two four two four two four two four two four two zero one twenty nine
three three three or four for four.
And I'll open my JavaScript console just to make sure that we don't get any errors and try running this.
And we got it, and that's much cleaner, so time to move on to the next section of the course, when
we begin to make things a little more sophisticated, we add some database functionality and we'll start
working on selling products online.