The factors are: the amount of difference in the value of the appraisal and the agreement.
The amount that the buyer truly wants to own the property.
The uniqueness of the property.
The ability of the seller and or buyer to absorb the difference.
If the fixes needed are cosmetic, dangerous, optional, mandatory, etc.
(Please note: when you choose an answer as a Best Answer, or at least give a thumbs up, it helps those who answer questions here.)
Of course, it would help if there was terminology in your P&S that specifically protects you in the case of appraisal coming in under purchase price.