The scholars derive from the Book and Sunnah that sincere repentance (tawbah nasuha) rests on several conditions: that it be done sincerely for Allah alone, that you feel genuine remorse for the sin, that you immediately give it up, and that you firmly resolve never to return to it. A fifth condition applies when the sin involved wronging another person — you must also restore their right or seek their pardon. All of this must occur while the door of tawbah is still open, i.e. before death overtakes you and before the sun rises from the west.
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.