Weird battery issues
It depends on the battery, most are not repairable - if it's anything internal in the battery then there is nothing you can do but get a new one. Batteries have a limited lifespan anyway, it's normal to replace instead of 'fix'.

It is possible the connector broke off the batteries logic board (the part where the thing you plug into the device's metal makes contact with some other metal thing connected to the battery - part that isn't covered on the battery) has been shifted/broken off of what it's connected to and can't make a clean connection. If this is the case, you can try soldering the connector back onto the logic board.

Not knowing what phone type you have I can't give you a specific video that shows how to do this, but you can do a google search on your device/battery on how to connect the connector to the logic board - from there you'll know what to look for on the battery to see it it's not connected as well.