The Torah teaches that tainted money cannot be used in the Temple. Thus, neither an animal given as payment to a prostitute for her services (etnan zona), nor money paid for purchase of a dog (mekhir kelev) can be used to bring a sacrifice in the Temple (see Sefer 23:19).
The Gemara brings a that teaches that if payment was made to the prostitute but he did not make use of her services, or if they engaged in relations but he did not pay her – in both of these cases the money could be used in the Temple. Since this teaching is difficult to understand, the Gemara restates the law – if there was a time lapse between when the money was given and when the act of prostitution took place, e.g., if payment was made beforehand, then the money can be used, assuming that she immediately consecrated it (for otherwise when the act of prostitution takes place, the payment would be forbidden retroactively).
One problem with this explanation is that a person can only donate a sacrifice to the Temple if he owns it. If payment is given to the prostitute before anything happened between them, then it is not an etnan zona – it is simply a present – and would be permitted, but if payment was made on the condition that the prostitute take possession only at the moment that relations take place, how could the sacrifice be set aside beforehand?
The Rashba argues that the animal given to the prostitute should belong to her immediately, since when a purchaser takes possession of an object, halakha considers it as belonging to him even if the money has not yet been paid.
The Ritva suggests that the law that allows the purchaser to take possession of the object even though he has yet to pay for it, is based on the fact that the original owner chooses to transfer ownership knowing that he can demand payment in court. Since the man cannot demand that the prostitute supply “payment” this law would not apply. According to the Meiri, the Rashba’s question is based on a misunderstanding. In fact, the act of prostitution is the service that is purchased and the animal is payment for those services, which the “seller” cannot take possession of before services are performed.