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:70

O Prophet, say to whoever is in your hands of the captives, "If Allah knows ˹any˺ good in your hearts, He will give you ˹something˺ better than what was taken from you, and He will forgive you; and Allah is Forgiving and Merciful."  

O Prophet, say to those captives who are in your hands: (asrā, may also be read as asārā) ‘If God knows of any good, any faith or sincere devotion, in your hearts He will give you better than that which has been taken from you, by way of ransom, by His multiplying it for you in this world and rewarding you in the Hereafter, and will forgive you, your sins. Truly God is Forgiving, Merciful’.
القرآن:٨:٧٠

يَا أَيُّهَا النَّبِيُّ قُلْ لِمَنْ فِي أَيْدِيكُمْ مِنَ الْأَسْرَىٰ إِنْ يَعْلَمِ اللَّهُ فِي قُلُوبِكُمْ خَيْرًا يُؤْتِكُمْ خَيْرًا مِمَّا أُخِذَ مِنْكُمْ وَيَغْفِرْ لَكُمْ ۗ وَاللَّهُ غَفُورٌ رَحِيمٌ  

يا أيها النبي قل لمن في أيديكم من الأسارى} وفي قراءة الأسرى {إن يعلم الله في قلوبكم خيرا} إيمانا وإخلاصا {يؤتكم خيرا مما أخذ منكم} من الفداء بأن يضعِّفه لكم في الدنيا ويثيبكم في الآخرة {ويغفر لكم} ذنوبكم {والله غفور رحيم}.