I said to Umar bin Khattab, "'There is no blame on you if you shorten the prayer when you fear that those who disbelieve may attack you' [Nisa 4:101], yet the people are now safe."Umar replied, "I wondered about the same thing you are wondering about, so I asked the Messenger of Allah ﷺ about it, and he said, 'It is a charity that Allah has bestowed upon you, so accept His charity.'"
أخبرنا إسحق بن إبراهيم قال أنبأنا عبد الله بن إدريس قال أنبأنا ابن جريج عن ابن أبي عمار عن عبد الله بن بابيه
قلت لعمر بن الخطاب {ليس عليكم جناح أن تقصروا من الصلاة إن خفتم أن يفتنكم الذين كفروا} فقد أمن الناس فقال عمر رضي الله عنه عجبت مما عجبت منه فسألت رسول الله ﷺ عن ذلك فقال صدقة تصدق الله بها عليكم فاقبلوا صدقته
Muslim reported it in the Book of the Prayer of Travelers, chapter on the prayer of travelers and its shortening, hadith no. 686, from Ishaq bin Ibrahim, with the same wording. It is also in Sunan al-Kubra, hadith no. 1891.