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.
quran:8:68

If not for a decree from Allah that preceded, you would have been touched for what you took by a great punishment.  

Had it not been for an ordinance from God which had preceded, making spoils and the taking of captives lawful for you, an awful chastisement would have afflicted you for what you took, as ransom.
القرآن:٨:٦٨

لَوْلَا كِتَابٌ مِنَ اللَّهِ سَبَقَ لَمَسَّكُمْ فِيمَا أَخَذْتُمْ عَذَابٌ عَظِيمٌ  

{لولا كتاب من الله سبق} بإحلال الغنائم والأسرى لكم {لمسَّكم فيما أخذتم} من الفداء {عذاب عظيم}.