So last time we had almost a complete transaction, just wasn't saving the expiry date in the form of
expiry month and expiry year, and that's because in insert transaction in Model Stojko, we didn't
actually tell us to do so.
So let's fix that expiry month and expiry year.
And I want to put the comma in there this time and I will add the two placeholders.
Question mark, question mark.
And I'm putting those right after bank return code.
So let's put in TAIEX and expiry month and then dot expiry year.
OK, so that's a good start.
So once I actually save this and start the application and run a test transaction, I should have the
expiry month and expiry year.
I also have the bank return code and I'm saving this in transactions.
But if we go back and look at what we're displaying here, there's two other things we probably want
to save as well.
For example, getting this payment intent, that might be something.
Well, it's almost certainly something we're going to have to do if we want to do a refund at some point.
We're not saving that and we're also not saving payment method.
So let's go back and update our database, our models and so forth to capture both payment method and
payment intent.
And we'll store those in the transaction tables.
That seems like a logical place to put it.
So back to our idea and let's open our terminal and clear the screen, make sure we're in the right
directory.
I am.
I mean, the level of my directory and I'll type to migrate fears or so to generate fees
and calls to transaction.
That should be sufficient.
That will create my two migrations.
So I hope my terminal opened my migration's folder and open the two new ones.
There's the up and there's the down and we have code we can copy here from up and down for when we added
customer ID to a table.
So this will add the column and I'll go back to my up migration newly generated.
We're going to add this to transactions
and I'll just call it payment content
and it will be a string and we'll make it default to an empty string.
That way we won't get an error is we have existing rows in.
And our down migration or copy that down from this one and open my newly generated down migration and
again, that's Transaction's.
And we're going to drop payment intent
and we also need payment method, so I'll just add it right now.
Payment method and from my outmigration of duplicate that and call it payment method.
Now, if we did everything right, I should be able to run from the terminal, so to migrate and there
it is.
Let's go look at the database and make sure those columns are in there.
Look at the structure.
Refresh this and their payment intent and payment method.
Two hundred and thirty five characters should be sufficient.
So let's go to our models and add those.
So models that go find transaction or a.
Where is it?
There it is.
OK, and we will add and I'll put them right here.
It doesn't matter where they go, payment intent will be a string.
Strings and in Jason, I'll call that Hamit intent,
duplicate that line and make it payment method.
Payment method.
And format, the whole thing.
Now let's go find that insert payment or insert transaction and add those two columns to it, insert
transaction, so I'll put them right after expiry here.
Payment, intent
and payment method at a comma, and that's coming right after expiry year.
So tax and payment, intent and tax and payment method and a comma.
OK, so now we need to update our handlers.
So let's go to our handlers and find the part where we're actually building that transaction, which
is right here.
So after bank return, Kotal payment.
Intent, and that will be equal to, I believe, payment of intent.
That's a string, yes, and then payment method
and payment method.
So if I format this and open my terminal and clear the screen and type make start.
Everything is running, let's go back to our Web browser and run one more transaction so products buy
one widget.
This will be for Bruce Wayne Bruce at Wayne Enterprises dot com, Bruce Wayne and his credit card,
zero for twenty nine four four four.
So now I want to charge the card.
I have an error.
Let's find the error.
It's always an error with skill when I'm working.
Column count doesn't match value at row one.
And this is from handler Stocco eighty nine.
So I know where that is right here.
Save transaction.
Let's go to insert transaction and see what we have.
One, two, three, four, five, six, seven, eight, nine, 10, 11.
And there's going to be nine, one, two, three, four, five, six, seven, eight, nine.
Something else I always forgot to do was to update the placeholders.
So let's stop the application.
Start the application.
Actually, I have to stop it this way.
Make stop.
Make start.
And it's now running good.
So let's go try that again back one screen and we'll just refresh this page to make sure everything's
current JavaScript error so I can close this, OK?
Clark Kent
Clark at Daily Planet dot com.
Clark Kent working for two zero three twenty nine or five six.
And now when I look in the database, if everything goes well, we should have all of the information
we need, including the expiry month, expiry year payment method and payment intent.
So let's check that out.
Back to the database.
Look at transactions, look at the content.
Refresh this and we should have this one.
Very good.
OK, and we have the expire month.
We have the expire year, the payment intent and the payment method.
Perfect.
So now we have all the information we need to do things like refunding a transaction.
And we've saved all of the necessary information that we're capturing from our front end.
OK, so it's time to move on.