It would be helpful for you if you posted the code that your scanner showed.
There is no trouble code that says that your fuel pump needs to be replaced and there is no such thing as a fuel pump code. There are fuel circuit codes but they don't tell you that any particular part needs to be replaced. They tell you that there's a problem in a certain circuit.
Clearly your fuel pump isn't the problem here and you have some other intermittent issue. I would guess that the FPDM, relay, FPS, wiring or connectors between any of these, or in rare cases the PCM is the issue.
There is no trouble code that says that your fuel pump needs to be replaced and there is no such thing as a fuel pump code. There are fuel circuit codes but they don't tell you that any particular part needs to be replaced. They tell you that there's a problem in a certain circuit.
Clearly your fuel pump isn't the problem here and you have some other intermittent issue. I would guess that the FPDM, relay, FPS, wiring or connectors between any of these, or in rare cases the PCM is the issue.