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: Re: MagSafe 2 is not charging, but keeps the power