In my view, "pain" is a sensation that is felt by the body as an advace warning system, allowing it to react to a potentially damaging event. For instance, if you touch a hot saucepan on the hob with your fingers - your skin registers the pain, and the brain processes the stimuli as "this sensation I am feeling means the body will be damaged" and takes actiob to avoid the stimulus by jerking the hand away from the source of the pain (the hot pan). Obviously not everyone can react like that - drop a lobster into a pan of boiling water and it will feel pain, until it cook, but it's not in any position to go running away from it.
Any creature with a nervous system has the system for communication between groups of cells and organs. As an aside, "pain" is not like "fear" - fear is an emotion, and likely connected to higher brain functions, but until someone gets into an oysters brain and tells us that "no, oysters conclusively do not feel emotions" I'm not going to say anything esle about that. Pain, on the other hand, is carried in specialised nerve fibres (so far as I've been able to gather from my lectures in physiology, anyway - not oyster physiology, but you get the idea...

) which can be seen and identified.