In the US you have to put down an "earnest money deposit", which is sort of the same thing. You can get it back, but there are usually very specific rules about what conditions warrant getting it back, and "I didn't like the house" isn't one of them.
In all offers I submitted and both houses I bought, that was the case.
That also allows the buyer to get out for any reason within the financing contingency window (by just not complying with all the ridiculous paperwork demands from the lender, "oops, sorry, mortgage didn't end up coming through")
That would be a "Mortgage Contingency," which is common in California. Yes, you get back your earnest money if there is a mortgage contingency in the contract but you can't get a loan.