Therefore, Allah devises against those who devise against Him, and this is nothing but a proportionate retribution of their own act. This devising has different degrees that one should never feel secure from, the reason being that the self is very deceitful.
For example, when performing certain religious acts, one might become proud of himself and see himself as better and higher than others, and wants to use these acts to attract others and hunt them. By this, he thinks he has deceived Allah, while Allah lets him do what he wants and doesn’t get in the way using different causes and doesn’t wake him from his sleep of ignorance. In reality, what has happened is that Allah has retaliated for this individual’s devising with His (God’s) own devising. This makes Allah’s devising a good one, because it is the retribution for devising, while man’s devising is the opposite and is rooted in his wretchedness.
So, it is actually one’s own devising that is hitting him, and this is what is meant by the devising of Allah.
Some sages, have drawn an analogy between Allah’s acts in response to man and the sun; the sun shines on everyone the same, but if an object obstructs the sunlight, a shadow will be made. Now if this object is straight or crooked, the resulting shadow will be the same. One’s ego is like a dark object that stands in the way of the light of Allah and causes darkness (such as chastisement, etc.). But if there is no egoism, it means that there will be no object in the way of the light and Allah’s light and mercy will encompass the individual. This is how Allah is with His pure servants and Satan has nothing to do with them. The more complex and complicated the hypocrite and deceitful person acts in his devising, the more Allah’s devising will be complicated (the same way it goes for the shadow; the more crooked the object, the more crooked the shadow), and as was said, it is the person who is the cause and no other, the same way the cause for the shadow was the object and not the sun, and of course, this is if there is a sun; if there was no sun, there would be no light and no darkness at all.