The simplest solution has already been stated. You just take out a regular repayment mortgage and if your wife's folks really want to help they can just gift the 40k to her and let her pay it off the mortgage. Risk to everyone is low.
The sbove solution leaves your wife's parents completely at the mercy of a court should you stop paying them back and seeing as it'll be a family home and the loan cannot be secured on it like a bank secures their mortgages against the property, there's not much (no) chance of your wife's folks getting possession back if you decide not to repay them.
The main benefit of have my wifes parent involved isn't only for the 40k thats coming regardless, its for the interest, its a fraction of what the bank would charge.