Hi,
I had the same problem with my surface 2 straight out of the box about a week ago. After much forum research and frustration trying different options and advice including all the refresh options and updates I got Microsoft Technical Support to call me and they managed to fix the problem using the below steps (Surface only switched on when plugged in).
Go to the Desktop, press and hold on the start icon in bottom left until the square appears. Let go and select Device Manager. Under batteries press/hold on each battery driver until the box appears, let go then select uninstall.
Once the battery drivers are uninstalled hold down the power button and take the power lead out. The device switches off. Do not release the power button, keep it held down for 30 seconds and then put the power lead back in - don't let go of the power button until "Surface" appears on the screen.
For me, the above steps changed the message from "Battery not detected" to "Plugged in not charging". I was then told to repeat the above steps and the next time it powered up it started charging.
Haven't had had any problems since this fix so would recommend trying it before sending back. Microsoft rep did say that this doesn't work for all devices, some have to be replaced but that for the people it did work for they have so far not had any complaints about the issue returning again.
goodluck!