What is considered a perfect repentance? When one is faced with the same opportunity to repeat the original transgression, but now he does not do it because he has repented... however, when one does not repeat the original transgression, [and refrains from sinning] because now he fears people will find out... his repentance is still accepted, but it is not considered a perfect repentance
Maimonides gives the example of a man who was involved in an adulterous relationship and later on repents. The ultimate test of his repentance would take place if that man is eventually faced with a similar opportunity but now he refrains from repeating the transgression because of his new understanding and resolve.
However, if that man is not faced again with the same circumstances which led to his earlier sin, or if he faces a similar scenario but now he refrains from sinning because he suspects somebody will find out about his affair, his Teshuba is still accepted, but it is not considered a perfect Teshuba. Why? Because this man might have changed not because of his conscience, but because of pressure, embarrassment, interest, etc.
A modern example: Very often we read in the news about a public figure who was caught doing immoral things. Many times they would come in front of the cameras and publicly express their regret and apologize for what they have done. That act is definitely an act of repentance. However, because of its timing it is questionable in terms of its credibility and genuineness. Why? Because the whole process of repentance, regret and apologies happened as a consequence of being caught...
Following Maimonides words, the perfect act of repentance in this case would have taken place if, while still involved in an illicit relationship or other immoral act and without being caught, and with no external impediment to continue with it, one would decide out of his own conscience, to stop, repent and change.
That would be a perfect and credible act of Teshuba.
Rosh Hashanah: The Tipping Point
by Aryeh Sobel and Aish