It sounds like something you should take to the Apple Store or an Apple dealer, because it's either the charging cable or the battery, and it's better to get it dealt with before the battery goes completely. It's not that old, so I'd get it looked at. When did you buy it on eBay? Too late to return it?
iMac Pro review