Your phone and Apple ID was not hacked.
Unfortunately, you received a scam message that tricked you into providing your Apple ID and Password to criminals, who are now trying to extort money from you.
There is absolutely no guarantee that you will regain access to your phone if you pay the ransom. Instead, it is much more likely that the criminals will demand even more money from you.
You need to notify any banks or credit card companies that you had stored on your phone to avoid unauthorized use of your financial information.
Personally, my opinion would be that you will never regain access to the phone, so you should treat it as if it was lost or stolen. Notify the police. Ask Apple to void the information on your phone.
Set up a new Apple ID and Password on your replacement phone and do not respond to any messages that ask you to provide personal information.
I have offered my opinion. Other users may have other advice, so you might want to wait for more responses.