Sahih al-Bukhari, Book 24, Hadith 48 (In-Book)

Narrated Abu Burda: from his father from his grandfather that the Prophet said, "Every Muslim has to give in charity." The people asked, "O Allah's Prophet! If someone has nothing to give, what will he do?" He said, "He should work with his hands and benefit himself and also give in charity (from what he earns)." The people further asked, "If he cannot find even that?" He replied, "He should help the needy who appeal for help." Then the people asked, "If he cannot do that?" He replied, "Then he should perform good deeds and keep away from evil deeds and this will be regarded as charitable deeds."

حَدَّثَنَا مُسْلِمُ بْنُ إِبْرَاهِيمَ، حَدَّثَنَا شُعْبَةُ، حَدَّثَنَا سَعِيدُ بْنُ أَبِي بُرْدَةَ، عَنْ أَبِيهِ، عَنْ جَدِّهِ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏"‏ عَلَى كُلِّ مُسْلِمٍ صَدَقَةٌ ‏"‏‏.‏ فَقَالُوا يَا نَبِيَّ اللَّهِ فَمَنْ لَمْ يَجِدْ قَالَ ‏"‏ يَعْمَلُ بِيَدِهِ فَيَنْفَعُ نَفْسَهُ وَيَتَصَدَّقُ ‏"‏‏.‏ قَالُوا فَإِنْ لَمْ يَجِدْ قَالَ ‏"‏ يُعِينُ ذَا الْحَاجَةِ الْمَلْهُوفَ ‏"‏‏.‏ قَالُوا فَإِنْ لَمْ يَجِدْ‏.‏ قَالَ ‏"‏ فَلْيَعْمَلْ بِالْمَعْرُوفِ، وَلْيُمْسِكْ عَنِ الشَّرِّ فَإِنَّهَا لَهُ صَدَقَةٌ ‏"‏‏.‏

sunnah.com