Receive the latest entertainment-news updates in your inbox

Author J.K. Rowling accepted an apology and a charitable donation Wednesday from a law firm which revealed she wrote a crime novel under a pseudonym.

The "Harry Potter" author was exposed by a newspaper on July 14 as the author of "The Cuckoo's Calling," a thriller ostensibly written by former soldier and first-time novelist Robert Galbraith.

"Real Housewives" Star Smacks Photog Outside Court

Two stars of the "Real Housewives of New Jersey" arrived for a court appearance on federal fraud charges Tuesday. Giuseppe "Joe" Giudice smacked a photographer's camera out of his face as he and wife Teresa walked in. (Published Tuesday, Jul 30, 2013)

The book was published in April to good reviews but modest sales, and there was speculation that Rowling or her publisher had leaked the news to raise the book's profile.

But the law firm Russells, which has done work for Rowling, acknowledged that one of its partners had let the information slip to his wife's best friend, who tweetd it to a Sunday Times cloumnist.

Cate Blanchett Talks Woody Allen's "Blue Jasmine"

Cate Blanchett hits the red carpet for the premiere of her new film, "Blue Jasmine," in Beverly Hills. She talks about the Oscar buzz surrounding the movie and why Woody Allen is a great director. (Published Tuesday, Mar 4, 2014)

Rowling sued the lawyer and the friend. Her attorney, Jenny Afia, told Britain's High Court on Wednesday that Rowling had been left "angry and distressed that her confidences had been betrayed."

"As a reflection of their regret for breach of the claimant's confidence, including frustrating the claimant's ability to continue to write anonymously under the name Robert Galbraith, the defendants are here today to apologize publicly to the claimant," Afia said.

Russells agreed to reimburse Rowling's legal costs and to make a "substantial" donation to The Soldiers' Charity, which helps former military personnel and their families.

Rowling also said she was donating all royalties from the book for the next three years to the charity.

The hero of her novel, Cormoran Strike, is a veteran who lost a leg in Afghanistan, and Rowling has said she drew on conversations with serving soldiers and veterans to create the character.

"This donation is being made to The Soldiers' Charity partly as a thank you to the army people who helped me with research, but also because writing a hero who is a veteran has given me an even greater appreciation and understanding of exactly how much this charity does for ex-servicemen and their families, and how much that support is needed," Rowling said in a statement.

The writer said she had always intended to give part of Galbraith's royalties to the organization, "but I had not anticipated him making the best-seller list a mere three months after publication — indeed, I had not counted on him ever being there!"

Since Rowling was outed as the author, "The Cuckoo's Calling" has topped best-seller lists in Britain and the United States.