New iphone keeps restarting when I try to charge it
I got my iPhone 15 two days ago and all has been fine until today. This morning it got really hot and overheated twice but it was fine after I restarted it. I realised in the afternoon that the battery was going down incredibly quickly, it is now at five percent and when I try to charge it, it gets to six percent and then powers off, it turns back on by itself and goes back to five percent. My phone is new to me but was slightly used before by someone else so I’m wondering if maybe a faulty battery was put in. I don’t know what to do.
iPad Pro, iPadOS 18