Reference: Fataawa al-‘Aqeedah – Question 177, Page 200
Question: I donated [money] for a charitable project out of fear and shame of my immediate manager at work; If he had left the matter to me I would not have donated, not even half a penny! So am I rewarded in full for this action of mine, just as I would [have been rewarded] if I had donated for this [charitable] project with good intention and personal choice?
Response: If the matter was as you have mentioned, then you are not rewarded for this donation; Because you had not intended [the donation] for the Sake of Allaah, rather, you had offered it to please your colleague out of fear of him.
And it has been authenticated on the authority of the Messenger of Allaah ﷺ that he said:
«Actions are based on intentions and for everyone is what he intended», the hadeeth.
And with Allaah lies all success and may Allaah send prayers and salutations upon our Prophet Muhammad ﷺ and his family and his companions.