Okay, now, it's time to give the user a feedback about the purchase operation that we are going to do using stripe. So we already set up the pay with token function, the pay with token method that is calling the e commerce API's through stripe pay with token that it's defined in this way. So we reject an error in case of error. And we are going to analyze the worst case first. So the error that you want that we want to display to the user. So if you remember, we already set the purchase error and purchase error message state variable according to the error message.
So it's time to show this feedback to the user. So what we can do is to use the alert component we are going to say that the collar would be a warning and it accepts the easel pen Param that is for in our case is the Portuguese error state variable and it accepts even a toggle that is defined as the this one error message toggle that basically just toggle the value of the purchaser or state variable and we are going to show inside this alert the poor chase error my such That we import again here our UI again, let's go to buy this pair of shoes. And we want to try with a card declined error just to see if our feedback works fine. So going to the testing cards section of stripe documentation, we can search for decline. And we can, for example, take this one and we can try with some other value and we do the pay now.
We click the Pay Now button and here are our feedback. Your card was declined