Big A.D. said:
The mint buys "dore" from miners (usually 80%-90% pure metal), refines it (for a fee) and figures out exactly how much gold or silver is there and then buys it from the miner at whatever their buy price is at the time the transaction is agreed on.
They also buy random scrap, coins and bars according to their current buy-sell prices. They have a price list on their website and the rates are partly calculated based on how much work they have to do in refining and re-manufacturing the metal.
The Perth Mint also trades on the London Bullion Market so if there is a big demand for, say, silver bars they'll buy huge 1000oz bars at the wholesale market spot price, ship them over to Perth and melt them down into smaller bars.