It is narrated from Sayyiduna Abdullah bin Umar (may Allah be pleased with them both): the Prophet (peace and blessings be upon him) said: "Whoever does you a good turn, repay him. If you are unable to repay him, then pray for him so much that he comes to know that you have thanked him, for Allah Almighty accepts thanks and He loves those who give thanks."
Al-Tabarani recorded it in al-Mu'jam al-Awsat; its chain contains a narrator, Abd al-Wahhab bin al-Dahhak, who is matruk (abandoned). Abu Dawud and al-Nasa'i (may Allah have mercy on them) recorded this narration with the words: "until you consider that you have repaid him" in place of the words: "until he knows that you have thanked him", and without the words that follow.