California has a law, California Civil Code section 1748.1, that prohibits retailers from adding a surcharge when a consumer chooses to use a credit card instead of paying by cash. In March 2015, a federal court found the statute unconstitutional and prohibited the Attorney General from enforcing it. The Office of the Attorney General believes that this decision is incorrect and has appealed that order. However, as of now, the Attorney General cannot enforce the statute.
Although the Attorney General is enjoined from enforcing this specific statute, California law does prohibit a merchant from engaging in activity that is unfair or deceptive. So, for example, if a merchant charges a credit or debit card surcharge or offers a cash discount, but does not fully disclose this to customers prior to their committing themselves to the goods or services, or if the merchant does not clearly explain its policies regarding debit and credit cards, the merchant may be violating California law.
Helpful article link: Accepting credit card payments: The Basics