"A man said" 'I am going to give some charity.' So he went out with his charity and put it in the hand of a thief. The next morning they started talking about how charity had been given to a thief. Then he said: 'O Allah, to You be praise for the thief. I am going to give some charity.' So he went out with his charity and put it in the hand of a prostitute. The next morning they started talking about how charity had been given to a prostitute. He said: 'O Allah, to You be praise for the prostitute. I am going to give some charity. So he went out with his charity and put it in the hand of a rich man. The next morning they started talking about how charity had been given to a rich man. He said: 'O Allah, th You be praise for the prostitute, the thief and the rich man. 'Then the message came to him: As for your charity, it is accepted. As for the prostitute, perhaps it will keep her from committing Zina. As for the thief, perhaps it will stop him from stealing. And as for the rich man, perhaps he will learn a lesson, and will spend from that which Allah, the Mighty and Sublime, has given him."' (Using translation from Nasāʾī 2523)
قَالَ رَسُولُ اللهِ ﷺ قَالَ رَجُلٌ لَأَتَصَدَّقَنَّ اللَّيْلَةَ بِصَدَقَةٍ فَأَخْرَجَ صَدَقَتَهُ فَوَضَعَهَا فِي يَدِ زَانِيَةٍ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ اللَّيْلَةَ عَلَى زَانِيَةٍ ثُمَّ قَالَ لَأَتَصَدَّقَنَّ اللَّيْلَةَ بِصَدَقَةٍ فَأَخْرَجَ صَدَقَتَهُ فَوَضَعَهَا فِييَدِ سَارِقٍ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ اللَّيْلَةَ عَلَى سَارِقٍ ثُمَّ قَالَ لَأَتَصَدَّقَنَّ اللَّيْلَةَ بِصَدَقَةٍ فَأَخْرَجَ الصَّدَقَةَ فَوَضَعَهَا فِي يَدِ غَنِيٍّ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ اللَّيْلَةَ عَلَى غَنِيٍّ فَقَالَ الْحَمْدُ لِلَّهِ عَلَى سَارِقٍ وَعَلَى زَانِيَةٍ وَعَلَى غَنِيٍّ قَالَ فَأُتِيَ فَقِيلَ لَهُ أَمَّا صَدَقَتُكَ فَقَدْ تُقُبِّلَتْ أَمَّا الزَّانِيَةُ فَلَعَلَّهَا يَعْنِي أَنْ تَسْتَعِفَّ بِهِ وَأَمَّا السَّارِقُ فَلَعَلَّهُ أَنْ يَسْتَغْنِيَ بِهِ وَأَمَّا الْغَنِيُّ فَلَعَلَّهُ أَنْ يَعْتَبِرَ فَيُنْفِقَ مِمَّا آتَاهُ اللهُ