(Al-Mujadila) 58 : 12
يَا أَيُّهَا الَّذِينَ آمَنُوا إِذَا نَاجَيْتُمُ الرَّسُولَ فَقَدِّمُوا بَيْنَ يَدَيْ نَجْوَاكُمْ صَدَقَةً ۚ ذَٰلِكَ خَيْرٌ لَكُمْ وَأَطْهَرُ ۚ فَإِنْ لَمْ تَجِدُوا فَإِنَّ اللَّهَ غَفُورٌ رَحِيمٌ
Oh, you who believed! If you are intending to consult with the Messenger privately, then you offer a charity before your consultation; it is best for you and is the purest; then if you can’t afford it, then indeed, Allah is the Forgiving, the Merciful.
The Messenger didn’t accept any compulsory or optional charity for his needs, but only accepted ‘Hadya’—a gift. So the object behind commanding to offer charity to the Messenger is to reduce the number of consultations with Messenger Muhammad and to make earnings for the public treasury. See explanation 49: 4-7.