Of quasi contracts.
A quasi contract is the act of a person permitted by the law which obliges him in favour of another, without any agreement intervening between them.
A treatise on the law of obligations or contracts, M. Pothier, vol.1, 1806.
Per Lord Mansfield in Moses v Macferlain (1760) 2 Burr. 1005 at p.1008:
If the defendant be under an obligation, from the ties of natural justice, to refund, the law implies a debt, and gives this action, founded in the equity of the plaintiff’s case, as it were upon a contract (‘quasi ex contractu,’ as the Roman law expresses it) …. This kind of equitable action, to recover back money, which ought not in justice to be kept, is very beneficial, and therefore much encouraged. It lies only for money which, ex aquo et bono, the defendant ought to refund: it does not lie for money paid by the plaintiff, which is claimed of him as payable in point of honor and honesty, although it could not have been recovered from him by any course of law,— as in payment of a debt barred by the statute of limitations, or contracted during his infancy, or to the extent of principal and legal interest upon a usurious contract, or, for money fairly lost at play; because in all these cases the defendant may retain it with a safe conscience, though by positive law he was barred from recovering. But it lies for money paid by mistake; or upon a consideration which happens to fail; or for money got through imposition, (express or implied); or extortion; or oppression; or an undue advantage taken of the plaintiff’s situation, contrary to laws made for the protection of persons under those circumstances. In one word, the gist of this kind of action is, that the defendant, upon the circumstances of the case, is obliged by the ties of natural justice and equity to refund the money.