Sellers are not allowed to charge more than what is stated in the listing. But if you have paid $40, that sounds like Priority, or maybe a courier. It also sounds like you are having to pay more money to get your hands on the item now that it has arrived in your town.
Items with a declared value over $20 are subject to duties and taxes. These have nothing to do with any seller, - it is our dear government that wants a share of every cent we spend. Well, every $20 we spend. 🙂 It's the same as buying down the street at Zellers, so you need to keep that in mind when online shopping outside Canada.
To process the paperwork Canada Post charges $8.50. Couriers charge a lot more, and UPS can be particularly high. That's not actually a 'shipping' charge, it's a 'pencil pushing' fee to send collected tax/duty onward. The seller knows nothing about this and cannot be expected to, given the number of countries in the world.
How much the charges are depend on what the item is and where it is made. Items made in a NAFTA country should be duty-free, but they are taxable. Taxes you pay according to your province. You don't say what you bought or where it is coming from.
So the formula is simple. Start with the item price, add tax on that. Possible duty, tax on that. $8.50 CanPost fee, tax on that. Add it all up and that could be what you are expected to pay.
Not all items are assessed, and many just show up at your door. If, however, you are asked to pay these charges, - as the importer it is your duty and obligation to do so. Pay the charges graciously and then enjoy your lovely new item. 🙂