Legal basis:
People's Republic of China (PRC) Civil Code
Article 586 The parties may agree that one party shall pay a deposit to the other party as security for the creditor's rights. The deposit contract is established when the deposit is actually paid. The amount of the deposit shall be agreed by the parties; However, it shall not exceed 20% of the subject matter of the main contract, and the excess shall not have the effect of deposit. If the actual amount of deposit paid is more than or less than the agreed amount, it shall be deemed as a change of the agreed amount of deposit.
Article 587 Where the debtor performs the debt, the deposit shall be set off as the price or recovered. If the party paying the deposit fails to perform the debt or the performance of the debt is not in conformity with the agreement, thus the purpose of the contract cannot be achieved, it has no right to request the return of the deposit; If the party receiving the deposit fails to perform the debt or the performance of the debt does not conform to the agreement, so that the purpose of the contract cannot be achieved, the deposit shall be returned twice.