Texas stands to gain hundreds of millions of dollars in tax revenue after the U.S. Supreme Court on Thursday ruled that states may force online retailers to collect sales tax even when they have no physical presence in the state.

Every year, Texas loses $1.1 billion in uncollected sales tax, according to the Texas comptroller’s office — well over the $800 million the state will spend securing its southern border this year and next. That’s the result of the high court’s 1992 decision, now reversed, that retailers are responsible for collecting sales tax only in states where they had “nexus.” That decision — which predated the astronomical rise of the internet and the subsequent boom in online shopping — was outdated, argued lawyers for the state of South Dakota, who won the case this week.

That lost tax revenue is particularly meaningful in Texas, one of just a handful of states without a personal income tax. This May, for example, the state’s sales tax revenue totaled $2.76 billion.

“The Internet’s prevalence and power have changed the dynamics of the national economy,” Justice Anthony Kennedy wrote in the opinion. “The expansion of e-commerce has also increased the revenue shortfall faced by States seeking to collect their sales and use taxes.”

Customers themselves owe sales tax on their purchases, but it’s sellers who are required to collect that money and send it to the government. States have little mechanism — and little incentive — to chase down sales tax on small-ticket purchases from average consumers when the retailers don’t do it themselves. Some of Texas’ largest online retailers — Amazon, for example — already remit sales tax to the state. Amazon has almost a dozen distribution centers in the state.

Texas is highly unlikely to gain back all of the $1.1 billion it’s currently losing, experts said, and any money the state gets back won’t come overnight. While the Texas comptroller has a great deal of taxing authority, some changes to the state’s tax structure might have to be carried out by the Legislature when it reconvenes in 2019, said Dale Craymer, the president of the Texas Taxpayers and Research Association. The Comptroller's office is looking into that, a spokesman said.

"We welcome the court’s ruling in this case and are currently assessing any potential revenue impacts," said Kevin Lyons, a spokesman for the agency.

Online retailers now likely face the logistical nightmare of building the infrastructure to collect sales tax from customers all across the country.

In most of Texas, the sales tax rate is 8.25 percent, with the bulk of that money going to the state. But that number is slightly different in different jurisdictions, and the figures vary widely across the country. Different states also have different standards on what products may be taxed in what way — meaning it will be logistically difficult for online sellers to determine which rates to charge which customers on which products.

U.S. Sen. Ted Cruz, R-Texas, along with two other lawmakers, had advised the court to let its 1992 decision, called Quill, stand, leaving the online sales tax issue for Congress to decide. But the state of Texas signed on to a brief from 35 states asking the court to reverse the decades-old “physical-presence” standard.

“The loss of tax revenue caused by Quill’s rule has forced [states] to forgo the traditional collection method of requiring the retailer to collect the tax directly from the customer at the point of sale—the procedure that applies to the millions of in-person sales made daily at local stores—and cast about for some kind of workable alternative,” the states, led by Colorado, argued in the brief. “But the alternatives tested to date have proved ineffective.”