Hilchos Bikkurim 11:4
If a father must redeem his son but the time has come to make the pilgrimage to Jerusalem and he can’t afford both, redeeming his son and takes precedence. This is derived from Exodus 34:20, which first says, “You shall redeem all your firstborn sons” and only after says, “Do not appear before Me emptyhanded.”
Hilchos Bikkurim 11:5
One who redeems his son recites the bracha that Hashem has sanctified us with His commandments and commanded us concerning the redemption of a son. He then recites Shehechiyanu and then gives the redemption money to a kohein. If a son redeems himself, he recites the bracha that Hashem has commanded us to redeem the firstborn, followed by Shehechiyanu.