Updated

Harry Potter author J.K. Rowling on Wednesday accepted a "substantial" donation to charity from the law firm which leaked the fact she had written a crime novel under a pseudonym.

Russells, which specialises in entertainment law, will pay damages to a charity supporting soldiers after admitting exposing her as the author of "The Cuckoo's Calling", published under the name Robert Galbraith.

The multi-millionaire author had brought proceedings at London's High Court against Chris Gossage, a partner at the law firm, and his friend Judith Callegari after a Sunday Times article revealed the secret.

Russells admitted that Gossage had told Callegari about Rowling's authorship, and she in turn had passed the information to a Sunday Times journalist in a Twitter exchange.

Rowling's solicitor, Jenny Afia, told the court that the author "has been left dismayed and distressed by such a fundamental betrayal of trust".

Russells, which had already apologised for the breach of confidence, will also repay Rowling's legal costs.

The firm said its charity payment would be "substantial" but that no further details would be disclosed.

Rowling said Wednesday she would also donate three years' global royalties for "The Cuckoo's Calling" to the Soldiers' Charity, starting from July 14, when her authorship was exposed.

She said the donation was partly to thank soldiers who helped her with research for the novel, whose hero is a war veteran, and partly because writing it made her aware of the need to support service personnel.

"I always intended to give The Soldiers' Charity a donation out of Robert's royalties but I had not anticipated him making the bestseller list a mere three months after publication -- indeed, I had not counted on him ever being there!" Rowling's statement said.

"The Cuckoo's Calling" tells the story of a private detective investigating a model's apparent suicide. Its author was said to be a former military police officer.

It had sold about 1,500 copies in hardback before its true author was disclosed, in contrast with the 450 million copies of the Harry Potter books sold around the world.

But "The Cuckoo's Calling" had met with critical acclaim, and television companies have expressed interest in adapting the book, Rowling has since said.

The author, who turned 48 on Wednesday, said she had used a pseudonym to "work without hype or expectation and to receive totally unvarnished feedback".