Should I change my iPhone battery or replace the phone?

I have a iPhone 6 I bought off of amazon that works perfectly fine, except no matter how much I charge it the phone shut off and says it needs battery which I know isn't right because I charge it. My first thought was that it's the phone's battery that needs to be replaced so checked a local repair shop and it costs $50 dollars to change it in 16 minutes. Do you think it's the battery or something more. Everything else is functional, audio, charging port, buttons, screen, camera. It just won't hold a charge and turns on and off suddenly for no reason at all. Should I send it back or get it fixed up?

Personally I would make a try with the battery.

Compare the local repair cost to what Apple would charge for the battery replacement, and then decide which fits your wallet better.

The nice thing with having Apple do the swap, is if the is any recall for the battery in your phone, it will be free, even if you're not the original owner of the phone. The bad thing is, if there's any moisture damage, they can refuse to do the replacement or any other work on the phone, stating the reason for the issue is the moisture damage.

Have the battery replaced.