It's recoverable, and there are two sensible routes.
First, contact the publisher's support team. Explain what happened and have your receipt ready as proof of purchase — support staff deal with damaged codes regularly and can often reissue one.
Second, if that fails, buying a replacement copy is the reliable fallback. It stings, but it's cheaper than the time you'll spend on workarounds that don't work.
One habit worth forming: the moment you open a new game, write the key down somewhere safe or photograph both sides of the case.