It is argued by Sam Shamoun and Jochen Katz that the Qur’an forbids messengers to take money from the people whereas at the same time, it orders the believers to pay money to Prophet Muhammad (ﷺ).
اتبعوا من لايسألكم اجرا وهم مهتدون
Follow those who do not ask of you [any] payment and they are [rightly] guided.
This and other similar verses show that prophets do not ask for money. It is claimed that the practice of Prophet Muhammad (ﷺ) contradicts the quoted verse.
Before looking at the practice of Prophet Muhammad (ﷺ) and the reasons behind it, let us understand this verse better. Taking a look at another similar verse provides further clarification.
وماتسألهم عليه من اجر ان هو الا ذكر للعالمين
And you do not ask of them for it any payment. It is not except a reminder to the worlds.
Prophet Muhammad (ﷺ) or any other messenger did not ask for any payment for the message that they convey. This means that the purpose behind their mission is not wealth or leadership but to convey the message. It does not mean that they cannot administer money as a state would and should. So why did Prophet Muhammad (ﷺ) took money? Prophet Muhammad (ﷺ) was the leader of the Muslims. He managed the affairs of the state and for that money is required. The above explanations say that a Prophet does not ask for his personal desires and this is exactly what Prophet Muhammad (ﷺ) did.
عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم كَانَ يُؤْتَى بِالرَّجُلِ الْمُتَوَفَّى عَلَيْهِ الدَّيْنُ، فَيَسْأَلُ ” هَلْ تَرَكَ لِدَيْنِهِ فَضْلاً ”. فَإِنْ حُدِّثَ أَنَّهُ تَرَكَ وَفَاءً صَلَّى، وَإِلاَّ قَالَ لِلْمُسْلِمِينَ ” صَلُّوا عَلَى صَاحِبِكُمْ ”. فَلَمَّا فَتَحَ اللَّهُ عَلَيْهِ الْفُتُوحَ قَالَ ” أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ، فَمَنْ تُوُفِّيَ مِنَ الْمُؤْمِنِينَ فَتَرَكَ دَيْنًا فَعَلَىَّ قَضَاؤُهُ، وَمَنْ تَرَكَ مَالاً فَلِوَرَثَتِهِ ”
Narrated Abu Huraira: A dead man in debt used to be brought to Allah’s Messenger (ﷺ) who would ask, “Has he left anything to re pay his debts?” If he was informed that he had left something to cover his debts the Prophet (ﷺ) would offer the funeral prayer for him; otherwise he would say to the Muslims present there), “Offer the funeral prayer for your friend:”but when Allah helped the Prophet (ﷺ) to gain victory (on his expeditions), he said, “I am closer to the Believers than themselves, so. if one of the Believers dies in debt, I will repay it, but if he leaves wealth, it will be for his heirs.
This was not just a saying of the Prophet (ﷺ) but also something which he did in practice as the companion of the Prophet (ﷺ) testifies.
قَالَ سَمِعْتُ جَابِرًا ـ رضى الله عنه ـ يَقُولُ مَا سُئِلَ النَّبِيُّ صلى الله عليه وسلم عَنْ شَىْءٍ قَطُّ فَقَالَ لاَ.
Narrated by Jabir: Never was the Prophet (ﷺ) asked for a thing to be given for which his answer was ‘no’.
The actions of the Prophet (ﷺ) did not contradict the Qur’an and nor were they unreasonable or unwise.
Indeed, Allah knows the best.
 Qur’an 36:21
 Sahih Bukhari, Book 69, Hadith 21