The Messenger of Allah ﷺ said, "Allah says, 'When My servant intends to commit a bad deed, do not record it against him until he actually does it. If he does it, record it as one bad deed. If he abandons it for My sake, record it for him as a good deed. If he intends to do a good deed but does not do it, record it for him as one good deed. If he does it, record it for him as ten good deeds, up to seven hundred.'"
أن رسول الله ﷺ قال: يقول الله: إذا أراد عبدي أن يعمل سيئة فلا تكتبوها عليه حتى يعملها، فإن عملها فاكتبوها بمثلها، وإن تركها من أجلي فاكتبوها له حسنة، وإن أراد أن يعمل حسنة فلم يعملها، فاكتبوها له حسنة، فإن عملها فاكتبوها له بعشر أمثالها إلى سبعمائة.
Bukhari narrated it in the Book of Tawheed (7501), and Muslim in the Book of Iman (128:203), both of them via Abu Zinad, from Aaraj, from Abu Hurairah, who related it. The wording given is Bukhari's, and Muslim's wording is similar.