“Don't try the paranormal until you know what's normal.” - Granny Weatherwax
No, you have not to pay resources if the action was unsuccessful.
From English rulebook, pages 10 and 11.
Each time you build a Roof, a Palisade or Weapons, discard the required resources and increase the respective level by adjusting the appropriate marker(s) on the main board. Roof, Palisade and Weapons levels are not limited.
When you build Items from Invention cards, discard the required resources and place the Invention card in the Future Resources space (they are not available until all Actions are resolved).
Emphasis (underline) mine.
You pay only if the intended object is built. If the action is unsuccessful because of you rolled the 2 determination tokens on the success die, then your resources aren't spent.