أَنْفِقُوا طَوْعًا أَوْ كَرْهًا لَنْ يُتَقَبَّلَ مِنْكُمْ
Spend willingly or unwillingly; it will not be accepted from you. (Al-Tawbah 9:53)
Here “أَنْفِقُوا” is formally imperative, but it is not encouragement to spend. The point is that either manner of spending has the same outcome regarding acceptance.
This is taswiyah (equivalence). The alternatives and the following negative result provide the essential contextual clue.