Mishkat al-Masabih 2909
Salama b. al-Akwa' said:
While we were sitting with the Prophet a bier was brought along and the Prophet was asked to pray over it. He asked whether the dead man owed anything and when he was told that he did not he prayed over it. Another bier was brought along later, and when he asked whether the dead man owed anything and was told that he did, he asked whether he had left anything. On being told that he had left three dinars he prayed over the bier. A third was brought along later, and when he asked whether the dead man owed anything and was told that he owed three dinars, he asked whether he had left anything. On being told that he had not, he ordered them to pray over their friend; but when Abu Qatada said, “Pray over him, Messenger of God, and I shall be responsible for his debt,” he prayed over him. 

Bukhari transmitted it.
وَعَن سَلمَة بن الْأَكْوَع قَالَ: كُنَّا جُلُوسًا عِنْدَ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذْ أُتِيَ بِجِنَازَةٍ فَقَالُوا: صَلِّ عَلَيْهَا فَقَالَ: «هَلْ عَلَيْهِ دَيْنٌ؟» قَالُوا: لَا فَصَلَّى عَلَيْهَا ثُمَّ أُتِيَ بِجِنَازَةٍ أُخْرَى فَقَالَ: «هَل عَلَيْهِ دين؟» قَالُوا: نعم فَقَالَ: «فَهَلْ تَرَكَ شَيْئًا؟» قَالُوا: ثَلَاثَةَ دَنَانِيرَ فَصَلَّى عَلَيْهَا ثمَّ أُتِي بالثالثة فَقَالَ: «هَلْ عَلَيْهِ دَيْنٌ؟» قَالُوا: ثَلَاثَةُ دَنَانِيرَ قَالَ: «هَلْ تَرَكَ شَيْئًا؟» قَالُوا: لَا قَالَ: «صلوا على صَاحبكُم» قَالَ أَبُو قَتَادَة: صلى الله عَلَيْهِ وَسلم عَلَيْهِ يَا رَسُولَ اللَّهِ وَعَلَيَّ دَيْنُهُ فَصَلَّى عَلَيْهِ. رَوَاهُ البُخَارِيّ