Ubada bin Samit reported,

We were with the Prophet ﷺ in a gathering when he said, "Pledge allegiance to me that you will not associate anything with Allah, that you will not steal, and that you will not commit fornication." He recited the verse to them."Whoever among you fulfills this pledge, his reward is with Allah. Whoever commits any of these offenses and is punished for it, that punishment is an expiation for him. And whoever commits any of these offenses but Allah conceals it for him, his affair rests with Allah. If He wills, He will punish him, and if He wills, He will forgive him."

Tirmidhi 1439

Sahih

حدثنا قتيبة حدثنا سفيان بن عيينة عن الزهري عن أبي إدريس الخولاني

عن عبادة بن الصامت قال

كنا عند النبي ﷺ في مجلس فقال تبايعوني على أن لا تشركوا بالله شيئا ولا تسرقوا ولا تزنوا قرأ عليهم الآية فمن وفى منكم فأجره على الله ومن أصاب من ذلك شيئا فعوقب عليه فهو كفارة له ومن أصاب من ذلك شيئا فستره الله عليه فهو إلى الله إن شاء عذبه وإن شاء غفر له

الترمذي 1439صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Legal punishments
Chapter
Legal punishments being expiation for those who receive them
Numbering
Darussalam 1439
Tirmidhi 1439