I think Onan's sin was more than just resisting the obligation of fathering a child. I can't remember now who it was, but someone in scripture resisted the same thing and was NOT struck down by God.
I think there are a lot of people that haven't been struck down when another has. God says he will have mercy on whom he will have mercy.