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, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Indeed, this man has committed a shameful and hideous evil. However, since he repented to Allaah, then Allaah will accept his repentance (Allaah willing). Verily, Allaah promised those who repent and are true to their repentance that He will forgive them and pardon their misdeeds. In confirmation, Allaah Almighty says (what means): {And it is He Who accepts repentance from his servants and pardons misdeeds, and He knows what you do.} [Quran 42:25]
He has to do a great deal of good deeds because the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, said, “…And let the good deed follow the evil deed so that the former would erase the latter.” Allaah Almighty also says in this respect (what means): {…Indeed, good deeds do away with misdeeds…} [Quran 11:114]
If this act led to ejaculation of semen, then a ransom is due on that man because he committed one of the acts that are prohibited in Ihram (ritual state of consecration).
Allaah Knows best.