Why not? Could you give an example as to why this would not be legal in some country of your choice?
In the case of an actual dispute (non-shipment, etc) you do have an actual contract. However, this smells like extortion(?). You didn’t deliver on your end of the contract (deliver goods) but are penalizing the other side for your failure to deliver. It won’t go over well when you get the class-action suit, and all the little ones in-between.
Especially online, the law says: Customer gets back ALL of his money, every cent.
You will be sued by customer protections in a minute if you act like that. Do you seriously run a business???