If one says ‘ I swear by Allah I will not do this haram act or I must pay X amount" is the oath valid or not?

Yes that would be valid if you mentioned Allah’s name when taking the oath.