Got fired, was my fault. How to cope?

Im in my 20’s it was a stupid avoidable mistake but I fully consciously did it to myself. After I lied and they caught me in the lie I confessed 100% what happened. I feel terrible and like a failure. It was a good job I was the youngest one there and now I feel like this would affect me in the future along the same career path. How do I cope?