The term “transfer” is a little misleading, in that the player’s current contract doesn’t just transfer over to the new club as it does with trades in American sports. What really happens is that the current team and the player rip up the existing contract and the player signs a new deal with the new club. That new deal includes both the new salary (generally referred to as “wages” and for some reason generally reported in terms of weekly pay, rather than annual) and any sign-on or other bonuses the player and the new team agree to. (It’ll also generally include more years, so unlike in, say, MLB where a player in the last year of their deal is considered a rental and less valuable in the trade market, a player in the last year of their deal in soccer can sign a new five or six year deal as part of the process, ensuring a long term commitment.) This is why you might see news that two teams have agreed to a transfer fee but the deal is still held up as the player and the new team are still working out the “personal terms” (that’s is, the new contract that will go into place upon the completion of the transfer), since all three parties (new team, old team, player) have to agree before the transfer is completed.
So, while the transfer fee itself goes solely to the old team, the player and the new team have to agree to the new structure of the player’s compensation before the deal is completed, which could include money to the player upfront. There’s also agent fees, which can be
massive and FIFA is currently attempting to curtail them, and even payments to the players family (reported in both the Neymar and Haaland deals, for example).