I think I don't need to replace the charger. The thing is, my father has a Samsung a50. His charger is also not working with my phone but works on him.
These are the steps that I did to land on the conclusion that it's the software:
1. If the port is the problem, then other cables should not work. I used a different adapter and used a different charger for a few seconds. It worked. So the port is not defective.
2. I tried to check if the adapter of my charger is not working. I tested it on other phones and it worked well. So, not the adapter.
3. I tried to check if it's the cable, it worked on other devices as well.
Also, the problem started when I updated the system of my Samsunf A20.