A homeless veteran who admitted to helping a New Jersey couple concoct a GoFundMe scam that raked in more than $400,000 was sentenced Friday to five years of probation.

Johnny Bobbitt Jr., 36, pleaded guilty last month in New Jersey state court to conspiracy to commit theft by deception for his role in the scam that prosecutors on Friday said "worked brilliantly."As a part of his plea deal, Bobbitt agreed to enter a drug treatment program.

The Philadelphia man will be taken to an inpatient rehabilitation center before he can be released. If he violates his probation, a state judge told Bobbitt he will go straight to state prison for five years. Bobbitt also agreed to testify against his co-defendants.

"Mr. Bobbitt was an instrumental part of the fraudulent campaign; indeed he was the face of it," Burlington County Prosecutor Scott Coffina said in a statement. "He admittedly promoted and perpetuated the false narrative that he had given his last $20 to his co-conspirator Kate McClure when she had run out of gas on the side of the highway, with the intent to manipulate the goodwill of others to obtain money for himself."

In addition to the state plea, Bobbitt pleaded guilty last month in federal court to one count of conspiracy to commit money laundering. A sentencing date in the federal case has not yet been set.

In November 2017, McClure and her boyfriend, Mark D'Amico, created the GoFundMe account they said would help Bobbitt.

Prosecutors, however, said McClure and D'Amico came up with the tale and then got Bobbitt in on the ruse. Coffina has said "the entire campaign was predicated on a lie," and that McClure did not run out of gas on the Philadelphia highway, and that Bobbitt did not spend his last $20 to help her, and that all three conspired to fabricate the fake feel-good story.

Johnny Bobbitt Jr., Kate McClure, and McClure's boyfriend Mark D'Amico at a Citgo station in Philadelphia on Nov. 17, 2017. Elizabeth Robertson / Philadelphia Inquirer via AP file

Within weeks of the GoFundMe campaign going up online, 14,000 people had donated almost $403,000 to help Bobbitt, who was homeless at the time.

The story went viral, but it soon fell apart when Bobbitt filed a lawsuit last August against McClure and D'Amico claiming that they were withholding funds from the campaign. The lawsuit accused the couple of using the account "as their personal piggy bank to fund a lifestyle that they could not otherwise afford."

D'Amico and McClure fired back, saying in an interview with NBC that Bobbitt had spent a large chunk of the money on family, drugs, a truck and a trailer.

The trio's public feud led to authorities investigating the case, and according to prosecutors McClure and D'Amico were having financial problems when they concocted the false gas story. The couple allegedly spent the funds on a luxury car, gambling and vacations, among other things, prosecutors said.

Johnny Bobbitt is led away following his sentencing hearing at Burlington County Superior Court in Mount Holly, New Jersey on April 12, 2019. Tim Tai / The Philadelphia Inquirer via AP Pool

In March, McClure pleaded guilty in federal court to one count of conspiring to commit wire fraud. She faces up to 20 years in prison. She was also charged in state court with theft and conspiracy but has not yet been indicted, according to NBC Philadelphia.

D'Amico was also charged in state court with theft and conspiracy but does not face federal charges. He has denied any wrongdoing, the outlet reports.

GoFundMe has since refunded the donations.

Coffina said in Friday’s statement that "there is no denying that Johnny Bobbitt has struggled with addiction, and that his addiction was a factor in his criminal conduct," and that the sentence of probation and treatment — with the certainty of jail time if he doesn't comply — is appropriate.

"This sentence affords him the chance to turn his life around. We wish him well in the program," he said.