SAN JOSE — Call it revenge of the shoplifters: Some of the country’s biggest retailers, from Walmart to Bloomingdale’s to Abercrombie & Fitch, are being accused of extorting shoppers caught swiping merchandise.

The bizarre twist is spelled out in a class-action lawsuit filed in federal court in San Jose that begins when a mother shopping for a birthday barbecue with her kids was stopped while leaving the self-checkout at Walmart. The retailer’s loss-prevention officers took her aside and accused her of not paying for hot dog buns and a water bottle.

They gave her a choice: Cop to shoplifting and agree to pay $500 for an online class aimed at setting her on the straight and narrow — or else they’d call the police.

The Utah company that provides the class, Corrective Education Company, called it a win for everyone. The accused shoplifter avoided an arrest, jail and criminal record while learning crime doesn’t pay. The retailer got justice. The cops stay focused on more pressing needs.

But the lawsuit against Corrective Education officials and their retail clients called it an extortion racket that would make Al Capone blush.

“Despite their glittering credentials,” the complaint says, the program’s producers “are all participants in a long-running, highly profitable extortion scheme that has extracted millions of dollars from thousands of poor, desperate people across the country.”

Not quite, said Scott Gant, a lawyer with the Boies Schiller Flexner firm representing the accused CEC officials. He said the complaint alleging violations of the Racketeer Influenced and Corrupt Organizations Act is based on “a novel but incorrect legal theory.”

“This simply isn’t extortion,” Gant said. “The program is voluntary. People don’t have to participate when they sign up. They’re given an opportunity to change their minds. And they get benefits for participating — they get the actual service of the education program.”

The lawsuit claims the company had initially paid some retailers up to $40 per person enrolled in the class. That wasn’t the case with Walmart, whose spokesman Ragan Dickens said the retailer did nothing wrong and has since dropped the program.

“We began evaluating this program last year and ultimately suspended it last December,” Dickens said. “We deny the allegations made against us and plan to defend ourselves.”

Other retailers named in the complaint, filed April 9, declined or did not respond to requests for comment. The court has not set a hearing date.

Corrective Education Company was co-founded in 2010 by Glenn Bingham, Darrell Huntsman and Brian Ashton, all graduates of Brigham Young University and Harvard Business School. All are named in the lawsuit, along with six other company officials.

The company pitch is straightforward: “CEC understands the challenges facing retailers, courts, prosecutors and law enforcement agencies due to retail theft” and offers “a successful, equitable and more efficient alternative to judicial prosecution.” Shoplifting cost retailers more than $17 billion in 2016, according to Loss Prevention Media.

The program is aimed at first-time shoplifters who, after being detained by retail personnel, are shown a video explaining the deal.

The video notes that it is not legal advice, that the “Restorative Justice Option” being offered is entirely voluntary and that they are free to consult a lawyer.

To successfully complete the program, the accused must stay out of trouble, complete the course of up to eight hours to “help you to lead a more constructive life,” and pay for it. Participants could pay either $400 up-front or installments up to $500, the lawsuit claimed, but If they fail to complete the course, they are referred to police.

The lawsuit cites three plaintiffs by pseudonyms, including the Georgia mother referred to as “Jane Doe,” and “Mary Moe” of Florida, who was accused of stealing snack foods and hygiene products at a Walmart in November and paid $400 for the course. “John Roe,” a Texan accused of lifting a ball hitch in January 2017, failed to pay for his course and was referred to a collection agency.

CEC has drawn growing scrutiny and legal trouble. A 2015 Slate article said the company in its first four years had served 20,000 accused shoplifters but also quoted critics including a New York legal aid lawyer who said the operation was “flirting with the crime of coercion.”

The San Francisco City Attorney sued CEC in 2015 and won a Superior Court injunction last year that called the program “textbook extortion under California law.” The company and retailers, the ruling said, were “jointly liable for the extortionate conduct” of “asking for money in exchange for forbearance in calling police.”

The Indiana attorney general concluded in April that the program “potentially violates a number of legal and ethical provisions.”

CEC on its website called the San Francisco ruling “a sad day for Californians,” arguing its program has kept 10,000 people out of the criminal justice system and that fewer than 2 percent of those who complete its program repeat the crime. It called the Indiana opinion a “flawed analysis.”

But the company has a noteworthy ally: G. Robert Blakey, primary drafter of the RICO Act, told the Bay Area News Group the case against the company seemed a “misuse of the statute.”

“If a person was physically restrained from leaving and reasonably afraid of unlawful physical violence, you might make out an extortion,” Blakey said. “But that has not been pled in this complaint.”