Laptop charging problem, what is likely tonne the issue?

I have a Lenovo G50 laptop. The hinge is slightly loose which has made the charging port slightly loose but it works fine.

For the past day, I have been having a problem. My laptop charges perfectly fine when off but does not charge when it is on.

It appears to change for a few seconds but then says "plugged in, not charging".

What can I do to resolve this issue?

Is it likely to be the port or the battery.

The battery was working well a few days ago but suddenly started working faulty.

With no clue of age of battery, might need a new one is a guess.
With no clue about firmness of socket and plug from charger, or charger quality, age, a damaged socket is a guess.
If everything else is okay, then the control board for charging might be failing. Needs a repair if you really need that laptop.
Guessing because Newegg sells about half a dozen different "Lenovo G50 models for a wide range of prices, equipment. Can't tell what might be wrong from your question.