The terms for the deposit will be made before it is left for the vehicle; it may or may not be refundable depending on what the dealership and consumer agreed upon. In most cases, a deposit is made to be refundable if the consumer fails to purchase the car.
There is no law that protects buyers from their purchases. Every purchase is made between the dealership and the consumer. If there dealership allows the consumer to receive a refund it will be printed on their policy.
However, there are several instances where a dealership is mandated to return the deposit, such as when they fail to honor the contract or when it is part of their policy. If the dealership claims to prepare the exact vehicle the consumer wants, but fails to do so, it must return the deposit back to the buyer. If the policy clearly states a refund, then the dealership must honor the contract and issue the refund.
Even if the dealership does not offer a refund as part of their policy, a consumer can still attempt to recover it. Generally, asking for a refund and explaining the situation will grant the buyer their deposit back. Most dealerships prefer to have future consumers and attempt to quickly satisfy anyone who fits that criteria. Consumers can also attempt to recover their deposits through small claims court.