All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
If what happened was a kind of cheating and helping in answering the questions of exams that students are assigned to answer by themselves, then this is forbidden and it is not permissible to take a payment or gift in return. Indeed, it is confirmed that the Prophet said, “Whoever cheats us is not one of us.” [Muslim]
Therefore, you are obliged – in that case – to repent to Allaah and get rid of that gift by giving it to the poor and needy or spend it in acts of righteousness and general welfare of the Muslims because it is a recompense in return for a forbidden benefit. This gift should not be given back to those who made use of the benefit so that they would not acquire both the unlawful benefit and the compensation that they had paid for it, and it is not permissible for you to take it for yourself because it is not permissible for someone who gained forbidden money to benefit from it.
Nonetheless, if what happened was not a matter of cheating in exams and the like, then there is nothing wrong in what you did and in accepting the gift.
Allaah knows best.