All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Scholars differed over the ruling on someone who gives charity to a certain person who does not accept it. Some held the view that such a person should still give that amount of money in charity to another poor person and refrain from using it. Some others were of the opinion that he may benefit from it.
Ad-Dusooqi, a Maaliki scholar, quoting Ibn Yunus, said that Maalik said:
"If you go out with a piece of bread or dirham to give to a certain person and you do not find him, I hold that you should give it to another poor person to complete the good act. Hence, it is more likely to give the second poor one who is eager to receive your charity."
There is difference over whether he may keep it for himself in either case. Some are of the opinion that he may not keep it at all; and others say he may in either case. Some others hold that if it was intended for a specific person, he may keep it; otherwise, he may not.
No doubt it is safer not to keep it and to give it as charity to other poor people or donate it for the construction of a mosque, as suggested by the questioner.