Once Bilal brought Barni (i.e. a kind of dates) to the Prophet ﷺ and the Prophet ﷺ asked him, "From where have you brought these?" Bilal replied, "I had some inferior type of dates and exchanged two Sas of it for one Sa of Barni dates in order to give it to the Prophet; to eat." Thereupon the Prophet ﷺ said, "Beware! Beware! This is definitely Riba (usury)! This is definitely Riba (Usury)! Don't do so, but if you want to buy (a superior kind of dates) sell the inferior dates for money and then buy the superior kind of dates with that money."
أَنَّهُ سَمِعَ أَبَا سَعِيدٍ الْخُدْرِيَّ ؓ قَالَ جَاءَ بِلاَلٌ إِلَى النَّبِيِّ ﷺ بِتَمْرٍ بَرْنِيٍّ فَقَالَ لَهُ النَّبِيُّ ﷺ مِنْ أَيْنَ هَذَا قَالَ بِلاَلٌ كَانَ عِنْدَنَا تَمْرٌ رَدِيٌّ فَبِعْتُ مِنْهُ صَاعَيْنِ بِصَاعٍ لِنُطْعِمَ النَّبِيَّ ﷺ فَقَالَ النَّبِيُّ ﷺ عِنْدَ ذَلِكَ أَوَّهْ أَوَّهْ عَيْنُ الرِّبَا عَيْنُ الرِّبَا لاَ تَفْعَلْ وَلَكِنْ إِذَا أَرَدْتَ أَنْ تَشْتَرِيَ فَبِعِ التَّمْرَ بِبَيْعٍ آخَرَ ثُمَّ اشْتَرِهِ