Not a lawyer, but I have a friend who is a family court lawyer, who helped us navigate the family court when we were getting custody of our nephew.
First thing's first, family law is a specific specialization in law. So unless your character is a FAMILY LAW attorney, he wouldn't be handling a case like this.
Most U.S. states have specific laws that would prevent this type of problem (Uniform Parentage Act).
However, a lot depends on how well-written the contract is.
https://www.cnn.com/2014/01/23/justice/kansas-sperm-donation/index.htmlIn the above case, the issue was that the donation was made outside the required legal channels. In the case, the couple performed the fertilization at home (now THERE is a story for you) instead of through a licensed physician.
In most states, anything involving children is going to be handled in FAMILY court, not civil court or criminal court. And family court is a different animal from anything else. For starters, there is no jury. The judge has 100% say in all rulings. And honestly, there probably won't be a lot of "courtroom action."
When going through all of the issues with our nephew, we spent most of our time waiting in the hallway instead of in the courtroom. The judge gets all the documentation ahead of time for review. There is no "prosecutor versus defendant" or opening and closing statements. You get called in. The judge asks his questions in relation to the documents he already reviewed, and he makes a decision.