When Californians place an online order with Best Buy, they pay the company and they pay a state sales tax. What the receipt doesn’t say is that Best Buy gets some of the sales tax, too.

California distributes a portion of sales tax revenue to local governments, based on the location of sales. In 2015, Best Buy agreed to keep a distribution warehouse in the small city of Dinuba, and to credit its online sales to that location. In exchange, Dinuba agreed to give Best Buy 45 percent of its share of the resulting sales tax revenue.

Companies including Apple, Macy’s and QVC have struck similar deals with other California municipalities, according to a recent investigation by Bloomberg Tax. A consultant to the League of California Cities estimates that corporations are now receiving more than $1 billion a year in such payouts — more than 20 percent of the total local share of sales tax revenue.

The tax deals are a facet of a much larger problem: the incredibly wasteful competition among state and local governments to lure and keep corporations. Everyone (well, everyone except corporations) would be better off if states prevented local governments from offering such incentives, and if the federal government deterred states from doing so, for example by taxing state and local incentives. So long as such incentives are legal, the result is an endless game of beggar-thy-neighbors-and-thyself.