Dear Samsung Member,
Greetings from Samsung Customer Support!
Please visit this mentioned link to resolve your charging related issue: https://www.samsung.com/in/support/mobile-devices/battery-not-charged-charging-related-issue/#:~:tex...
For further assistance, register your concern in Samsung Members Application (Open Samsung Members Application > Get help > Send Feedback > Error report/Ask questions).
Thank you for writing to Samsung.
Samsung Customer Support
I was having this issue recently as well. I went into the Battery and Device Care and clicked on the Optimize Now button. this closed down background apps and my phone was able to charge again. I still haven't figured out which app is causing the issue but this helped a ton. hope it helps you too.