What is wrong?
If MagSafe power supply is identified as null and zero, then MacBook embedded controller does not allow charging of main battery.
Open 'System Information.app', view 'Power' (subpage of 'Hardware'), look under heading 'AC Charger Information:'. For an idea of what 'AC Charger Information:' looks like, a clue as to what to look for, here is a screenshot. Pictured is a full 'Power' report; near bottom is 'AC Charger Information:'.
Does your Mac report information from its power adapter, or does it display all fields as zeros?
If your subject power adapter is misidentified, then it might need cleaning or repair. Inspect MagSafe plug pogo pins. If middle pogo pin is dirty or sticky, then clean it or exercise it until it operates as it should. Inspect also MagSafe socket-inlet. If middle pogo pin (in MagSafe tip) is clean and springy, and middle land (in MagSafe inlet) is clean, then MagSafe plug is at fault.
How to fix it?
Get a replacement MagSafe plug or cable assembly, and splice it on. If you cannot find a used Original Apple MagSafe tip, then a non-authorised replica is acceptable. One will be better-off with a counterfeit tip spliced onto genuine power supply, than a knock-off power supply.
Do not discard a misidentified MagSafe power supply. It is still useful.
very similar problem, cross reference: crwdns2936919:0MagSafe 2 is not charging, but keeps the powercrwdne2936919:0
crwdns2934105:0crwdne2934105:0
crwdns2934113:0crwdne2934113:0
crwdns2915270:0crwdne2915270:0
crwdns2889612:0crwdne2889612:0
1
crwdns2947414:01crwdne2947414:0
Apple power adapters are garbage, they fail all the time in my experience.
crwdns2934271:0crwdnd2934271:0 Dave P crwdne2934271:0