Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bukhari:2312Isḥāq > Yaḥyá b. Ṣāliḥ > Muʿāwiyah > Ibn Salāam > Yaḥyá > ʿUqbah b. ʿAbd al-Ghāfir > Abū Saʿīd al-Khudrī

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."  

البخاري:٢٣١٢حَدَّثَنَا إِسْحَاقُ حَدَّثَنَا يَحْيَى بْنُ صَالِحٍ حَدَّثَنَا مُعَاوِيَةُ هُوَ ابْنُ سَلاَّمٍ عَنْ يَحْيَى قَالَ سَمِعْتُ عُقْبَةَ بْنَ عَبْدِ الْغَافِرِ

أَنَّهُ سَمِعَ أَبَا سَعِيدٍ الْخُدْرِيَّ ؓ قَالَ جَاءَ بِلاَلٌ إِلَى النَّبِيِّ ﷺ بِتَمْرٍ بَرْنِيٍّ فَقَالَ لَهُ النَّبِيُّ ﷺ مِنْ أَيْنَ هَذَا قَالَ بِلاَلٌ كَانَ عِنْدَنَا تَمْرٌ رَدِيٌّ فَبِعْتُ مِنْهُ صَاعَيْنِ بِصَاعٍ لِنُطْعِمَ النَّبِيَّ ﷺ فَقَالَ النَّبِيُّ ﷺ عِنْدَ ذَلِكَ أَوَّهْ أَوَّهْ عَيْنُ الرِّبَا عَيْنُ الرِّبَا لاَ تَفْعَلْ وَلَكِنْ إِذَا أَرَدْتَ أَنْ تَشْتَرِيَ فَبِعِ التَّمْرَ بِبَيْعٍ آخَرَ ثُمَّ اشْتَرِهِ  


See similar narrations below:

Collected by Muslim
muslim:1594a[Chain 1] Isḥāq b. Manṣūr > Yaḥyá b. Ṣāliḥ al-Wuḥāẓī > Muʿāwiyah [Chain 2] Muḥammad b. Sahl al-Tamīmī And ʿAbd Allāh b. ʿAbd al-Raḥman al-Dārimī Wa-al-Lafẓ Lahumā > Yaḥyá b. Ḥassān > Muʿāwiyah Wahū Ibn Salāam > Yaḥyá Wahū Ibn Abū Kathīr > ʿUqbah b. ʿAbd al-Ghāfir > Abū Saʿīd > Jāʾ Bilāl Bitamr Barnī

Bilal (Allah be pleased with him) came with fine quality of dates. Messenger of Allah ﷺ said to him: From where (you have brought them)? Bilal said: We had inferior quality of dates and I exchanged two sa's (of inferior quality) with one sa (of fine quality) as food for Allah's Apostle ﷺ, whereupon Messenger of Allah ﷺ said: Woe! it is in fact usury; therefore, don't do that. But when you intend to buy dates (of superior quality), sell (the inferior quality) in a separate bargain and then buy (the superior quality). And in the hadith transmitted by Ibn Sahl there is no mention of" whereupon".  

مسلم:١٥٩٤aحَدَّثَنَا إِسْحَاقُ بْنُ مَنْصُورٍ أَخْبَرَنَا يَحْيَى بْنُ صَالِحٍ الْوُحَاظِيُّ حَدَّثَنَا مُعَاوِيَةُ ح وَحَدَّثَنِي مُحَمَّدُ بْنُ سَهْلٍ التَّمِيمِيُّ وَعَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ الدَّارِمِيُّ وَاللَّفْظُ لَهُمَا جَمِيعًا عَنْ يَحْيَى بْنِ حَسَّانَ حَدَّثَنَا مُعَاوِيَةُ وَهُوَ ابْنُ سَلاَّمٍ أَخْبَرَنِي يَحْيَى وَهُوَ ابْنُ أَبِي كَثِيرٍ قَالَ سَمِعْتُ عُقْبَةَ بْنَ عَبْدِ الْغَافِرِ يَقُولُ

سَمِعْتُ أَبَا سَعِيدٍ يَقُولُ جَاءَ بِلاَلٌ بِتَمْرٍ بَرْنِيٍّ فَقَالَ لَهُ رَسُولُ اللَّهِ ﷺ مِنْ أَيْنَ هَذَا فَقَالَ بِلاَلٌ تَمْرٌ كَانَ عِنْدَنَا رَدِيءٌ فَبِعْتُ مِنْهُ صَاعَيْنِ بِصَاعٍ لِمَطْعَمِ النَّبِيِّ ﷺ فَقَالَ رَسُولُ اللَّهِ عِنْدَ ذَلِكَ أَوَّهْ عَيْنُ الرِّبَا لاَ تَفْعَلْ وَلَكِنْ إِذَا أَرَدْتَ أَنْ تَشْتَرِيَ التَّمْرَ فَبِعْهُ بِبَيْعٍ آخَرَ ثُمَّ اشْتَرِ بِهِ لَمْ يَذْكُرِ ابْنُ سَهْلٍ فِي حَدِيثِهِ عِنْدَ ذَلِكَ