From: Rabbi Moshe Sofer
To: Rabbi Shmuel
The Chasam Sofer rules that if the kohen explicitly accepts the pidyon money on condition of return, the son is fully redeemed. However, if both parties merely intend the money to be returned without an explicit stipulation, he disagrees with the Taz's lenient ruling. Regarding the common practice of seeking generous kohanim who return the money voluntarily, he permits it because the father gives an unconditional gift and cannot demand it back, though he recommends educating people to give with full intent of genuine gifting.
Source: Shu"t Chasam Sofer YD §291