Strange it only does it when plugged in. I'm thinking it could be 1 of 2 things, or maybe both - but you need to confirm one before moving on to the next.
(1) First, leave it plugged in (and turned off if you can) for at least an hour but longer if you can. Unplug it and see if it boots up, or if it just gets stuck on bootloader, or what. Is it taking the charge? If yes, but still bootlooping, see (2) below. Not taking charge? Try using a different wall charger, different outlet, different USB cable, charge it off your computer (or any combination or those) until you can confirm that it will or will not charge. If no matter what combination you try and it still doesn't charge - there are 2 possibilities. One is that the USB port on the phone is broken/damaged. The other is that it's the battery or other internal problem. If your phone won't take and keep a charge, you need to get that fixed first before doing anything else
(2) you may have to flash the factory image back on, unroot, relock bootloader, and return it to 100% factory - this will wipe your apps, photos, data, files, everything off the phone. So if you're cool with that, it's another option - but the first is to make sure the phone is charging. There are "toolkits" available for download that will automate this process for you, and all you have to do is click on buttons in the program. It's highly recommended to learn/use ADB commands (which is what these toolkits do, but they do it for you instead of forcing you to type commands in).
Last thought, do some research. Read the forums and see if there are others with similar problems and how they solved them. Read how to root/unroot your phone, how to install ROMs and factory images, and how to lock/unlock the bootloader.
As for buying off eBay - if you have a defective device that was advertised as fully functional you may be able to get your money back with eBay's buyer protection. You'll have to look into that as well.