In general a contractual provision that requires a party in breach of contract to pay or foreit a sum of money is unlawful as a penalty unless such provison can be justified as being a payment of liquidated damages being a genuine pre-estimate of the loss which the innnocent party will incur by reson of the breach.
One exception to this general rule is the provision of the payment of a deposit by the purchaser on a contract for the sale of land. Ancient law has established the forfeiture of such a deposit (customarily 10% of the contract price) does not fall within the general rule and can be validly forfeited even though the amount of the deposit bears no reference to the anticipated loss to the vendor flowing from the breach of contract. The special treatment given such deposits derives from the ancient custom of providing an earnest for the perform of a contract in the form of giving either some physical token of earnest (such as a ring) or earnest money. The special treatment given to deposits could be open to abuse if parties could avoid the rule that renders penalties unenforceable by attaching the label “deposit” to any penalty. The courts have held that parties cannot label an extravagant sum as a “deposit” and thereby avoid the sum being a penalty. See: Stockloser v Johnson  1 QB 476 per Denning LJ at 491; see also Workers Trust Bank v Dojap Ltd  1 AC 573. The Workers Trust case contains an interesting discussion about deposits in land sales.