So this time around, we want to adjust the way that the price is displayed on our widget page because
right now it's displaying one thousand, which is 1000 cents or ten dollars, and we want that to show
up the way that a customer would expect it to appear.
And that's really easy.
So let's go back to our code and let's do a couple of things.
So right now, I'm looking at the buy once page Jorgo HTML and I'm going to delete this comment it out
amount.
But you will notice before I do it that that actually has the idea of amount which I neglected to put
on my hidden amount field.
So I'll have to add that.
So let's delete this.
Let's add the actual I.B. here, Heidi, equals come out and we want that because over in our stripe,
just partial.
We're actually looking for that right here in my code.
It's online 48.
We're getting element by ID amount.
So if we didn't do that, we wouldn't be able to charge a credit card.
So that's the first thing.
The second thing we want to do is to write a simple little function that will format currency the way
that we want.
And I'm going to do that in my render Dongo file.
So in rendered ogo, we have this variable and in my code it's on the line twenty five.
It's a template funk map and it's empty right now.
So what we'll do is very simple.
We'll create a new function, call that function func format, currency.
It will take one parameter which I'll call and it's an end and four number and it will return a string.
And all we have to do to make this work is to create a variable which I'll call for float.
That's assign the value of cast to float thirty two and I'm going to cast and divide it by one, which
should give me exactly what I want for a float value.
And then we'll just format or return from the format package as print F and we'll use the format string
of.
I'll start with a dollar sign then I'll put in percent dot to F to F so to two decimal places with a
dollar sign in front of it.
And my substitution is just F so that is the function, but it's not used.
So we'll add that to the folk map.
So I'll click in between the curly brackets here return and I simply in my template I'll call the function
format currency and that has the value of format currency and ended with a comma and no parentheses
and now that should be available to my functions.
So let's make sure everything recompile it did OK and let's go to our template by once page HTML.
Let's find out where we're printing the price and instead call that function and we'll just call.
Format, currency.
And it expects an end and that's an it, so let's make sure everything recompile looks like it did.
Let's find out.
So back to my Web browser, reload this page and now it shows as ten dollars.
OK, so that's just a little bit of cosmetic change.
But it was absolutely critical because I don't want people to not buy my widget because they think it's
a thousand dollars.
All right.
In the next lecture, we'll start working on getting a transaction through.