Abu Hurairah (May Allah be pleased with him) said:
The Messenger of Allah (ﷺ) said, "There are three (types of) people with whom Allah will neither speak on the Day of Resurrection nor purify them (from sins) and there will be a painful chastisement for them: A person who has spare water in a desert and he refuses to give it to the traveller; a person who sells a commodity to another person after the afternoon prayer and swears by Allah that he has bought it at such and such price, and the buyer pays him accordingly though in reality it was not true; and a person who pledges allegiance to an Imam (leader) just for some worldly benefit, and then if the Imam bestows on him (something out of that) he fulfills his allegiance, and if does not give him, he does not fulfill it."[Al-Bukhari and Muslim].
App reference: Book 19, Hadith 28
Arabic/English book reference: Book 19, Hadith 1835