It would be handled in the country where the item is imported. That means the item has already been moved to your country by air, ship, train etc. It doesn't happen before your flight, it happens after your flight. So if you buy a refrigerator in Dubai and fly to Belgium, the Belgian customs will ask you to pay. Customs in Dubai doesn't care.
You should first lookup the duty and tax for the country where you are importing. For example, when importing to the UK, duty will be quite low and tax will be 20% of the value in the UK, but depending on circumstances you can import up to some value without paying anything.
If you don't want to pay customs and tax (for example, customs estimates that an item is worth £2,000 with £400 tax, and you think it is only worth £100), customs will likely keep it until you pay. In most places I expect you could then say "I don't want it", and they keep it, without you getting money back or having to pay tax.
For small items, people will often try to smuggle them into the country. Like buying a new laptop and hiding it in your luggage (obviously not with a refrigerator). You'd have to say which country you are importing to and people might tell you how risky it is and what the extra cost if you get caught. Never, ever do that for someone else.