Fix it quick, first and foremost.
As someone who has experienced several strange occurrences involving smartphone batteries (one of which was vaguely supernatural), I’ve developed a spot of paranoia that rears its head whenever my phone has battery issues. It feels like it should be a fairly straightforward process; you stick the thing in the port, it charges. But sometimes, life just isn’t that simple. If your iPhone refuses to charge, and you’re pretty sure it’s not possessed (don’t rule it out), there’s a few things you can try to get it back in gear.
First order of business, restart your phone. Sometimes, for reasons I don’t claim to understand, your phone’s software gets a little confused with charging processes. A quick restart will usually remedy this. Alternatively, check to see if your mobile OS has any updates available. Updates are good for alleviating weird bugs, and they usually entail a restart anyway, so it should fix the problem one way or the other.
If it’s not a software thing, it might be a hardware thing. Before you start tearing your phone open, check your Lightning cable. If you’ve owned your phone for a long time, your charging cable has likely endured some wear and tear. Being squished and jostled around can wear on the rubber coating. If you see any frayed or exposed wires, or the gold-colored connectors have gone dull, your cable might have gone kaput. Recycle it and get a new one. You should also check the charging adapter that plugs into your wall. Try connecting your phone to it with a different cable if you have one lying around. You can also test it with any other USB-connecting device like a tablet or wireless game controller.
If it’s not the cable or adapter, there might be something afoot in your phone. Before you assume it’s broken, check the charging port. There might just be some accumulated crud in there that’s preventing the connectors from meeting. You can attempt to remove it with a toothpick, but I wouldn’t advise it, since you could damage the connectors. You should also refrain from using compressed air, as that’ll just push the crud in deeper. Take it to a specialist or an Apple store for a careful cleaning.
If the connector looks fine and all of the other hardware is working, well, I’m officially stumped. Call up Apple tech support (preferably with a different phone from the busted one) or go visit your local Apple store. Hopefully, your phone doesn’t have any gremlins in it, because that’s not a fun experience. I can say that with confidence.