A middle school teacher in Texas paid a former student nearly $28,000 to keep their sexual relationship secret — and was arrested after the teen’s mother found out about their romps, court documents show.

Thao “Sandy” Doan, a teacher at Raul Quintanilla Sr. Middle School in Dallas, was arrested last week and faces a sexual assault charge in connection to the alleged relationship with the 14-year-old boy, the Dallas Morning News reported, citing Doan’s arrest warrant affidavit filed by the Dallas ISD Police Department.

The boy’s mother told investigators earlier this month that he was receiving “large amounts of money” that he was using for “illegal purposes,” which created problems at home, according to the affidavit.

The boy’s mother told administrators the payments needed to stop and provided investigators with screenshots of messages showing that her son asked for money.

“… watch ima start getting the pics and everything ready … to show the cops right I anit [sic] playing,” one message read.

Dallas ISD Police Department spokeswoman Robyn Harris said Doan, 27, was placed on administrative leave on Jan. 10. She had been employed with the district since 2014, Harris told The Post in a brief telephone interview Wednesday. She declined to elaborate on whether Doan had any previous disciplinary issues or infractions, citing privacy concerns.

Doan, according to the school’s website, worked as a coach for the cross-country and soccer teams. Attempts to reach her were unsuccessful and it wasn’t clear if she had hired an attorney.

Doan admitted to the police, according to the arrest affidavit, that she communicated with the boy via text messages, Instagram and Kik before they had sex at a park in the summer of 2015. They also had sex later that year between November and December — and again in December 2016, she told police.

Doan, who was arrested Friday, was released from jail after posting bail, the Dallas Morning News reported.

The boy’s mother told KDFW that she saw her son’s behavior change dramatically around the time he allegedly started the fling with his teacher.

“At times, he started getting into drugs, drinking, leaving the house. And he would probably get money and just leave the whole weekend,” the boy’s mother said. “I wouldn’t hear from him. I’d be out looking for him.”

Doan confirmed to authorities in a search warrant affidavit that the boy received an image of her exposing her breasts. The two also engaged in explicit texting, KDFW reports.

“She did very bad. She did bad,” she said. “And I’m not condoning what he did because I know he was wrong at what he also did because blackmailing is not acceptable.”

The most recent payment to the boy, now 15, was $1,500, according to his mother, which was sent one day before she reported the messages to school officials.

“I mean this is very hurtful because he’s a victim here, and he was the child,” she continued. “He is the child. He’s still a child. But it hurts me because I’ve been through a lot with him.”

She told KDFW that her son had been previously arrested on unrelated burglary and robbery charges.