Thomas Cash, of Daneshill Caravan Site, was sentenced to five years in prison at Sheffield Crown Court after pleading guilty to attempted robbery.
A 16-year-old boy, also from Retford, who cannot be named for legal reasons, pleaded guilty to assisting an offender and was given a 12-month referral order.
South Yorkshire Police began an investigation after a man saw a red VW Golf advertised for sale online.
He spoke to the seller, who simply called himself “Terry”, on the phone and arranged to meet him in Darfield near Barnsley, on Saturday, 29th June.
He was driven there by his cousin, and while the pair were waiting to meet “Terry” their car was rammed from behind by a maroon Vauxhall Omega.
Their car window was smashed and men wearing face coverings, armed with a machete and a handgun, demanded money.
The victim and his cousin got out of vehicle and managed to escape, while the offenders got back in to the Vauxhall and drove off at speed.
The Vauxhall was later found in Carcroft in Doncaster and Cash and the 16-year-old boy were later arrested and charged.
Detective Sergeant Antony Coy said: “A dangerous offender has been put behind bars thanks to the South Yorkshire Police officers, who caught up with Thomas Cash and were able to secure enough evidence against him to lead to this conviction.”
“This was an extremely violent robbery attempt, carried out in broad daylight when several members of the public witnessed it and would have been justifiably frightened by what they saw.”
“This must also have been terrifying for the victim in this case, who had innocently attempted to buy a car after seeing an advert on the Internet.”
“What we have here is a total lack of respect for the law.”
“This case sends out a strong message to would-be offenders that such criminality will not be tolerated by the police, or by the courts.”