The Messenger of Allah ﷺ used to accept gifts and give something in return for them.
حدثنا علي بن بحر حدثنا عيسى بن يونس قال حدثنا هشام بن عروة عن أبيه
كان رسول الله ﷺ يقبل الهدية ويثيب عليها
Its isnad is sahih. Bukhari narrated it, 5/210, no. 2585, in Fath al-Bari, in the chapter on gifts, Abu Dawud, 3/290, no. 3536, in business transactions, and Tirmidhi, in righteousness, 4/338, no. 1953, and he said, hasan gharib.