Cost should be calculated by your other script based on TLD that is passed in. If you are passing in price in some manner from the whois script, your logic is flawed somewhere.
The best thing you can do in your other script (you external / third party / own script) is to base cost on TLD that is passed in such as domain=whatever&ext=TLD. Then you can use a php switch statement or similar to determine cost (the switch statement would be in your third party script):
PHP Code:
// convert to lowercase just in case
$tld = strtolower($_REQUEST['ext']);
// actual switch statement
switch($tld)
{
// .com domains
case "com" : $cost = 25.00;
break;
// .net domains
case "net" : $cost = 20.00;
break;
// .info & .us domains, both same price
case "info" :
case "us" : $cost = 16.00;
break;
// unknown (default case)
default : $cost = "";
}
// error if cost is empty (indicating unknown / invalid extension)
if (empty($cost))
die("Invalid domain extension!");
You should ALWAYS calculate cost based on the TLD and NEVER on any possible cost that can be tampered with by the user (as you noted as well).
In fact, if you are using a PayPal script (you didn't specify), you may want to go so far as to generate multiple encrypted order links from within PayPal website to prevent tampering, one for each of your possible costs. Then you can use a switch statement, similar to the above, to determine which link to display and in that manner display the correct order form with the correct price that is encrypted. This is a real fundamental and basic approach, but it would provide the functionality and security that you require.