function test_fiat_commission($fiat, $already_paid = '0') { $commission = commission_on_fiat(numstr_to_internal($fiat), numstr_to_internal($already_paid)); echo "<li>commission selling BTC for <b>{$fiat}</b> " . CURRENCY . " is <b>", internal_to_numstr($commission), "</b> " . CURRENCY; if ($already_paid) { echo " if {$already_paid} was already paid"; } echo "<br/>\n"; }
function commission_on_type($amount, $curr_type, $already_paid) { if ($curr_type == CURRENCY) { return commission_on_fiat($amount, $already_paid); } if ($curr_type == 'BTC') { return commission_on_btc($amount, $already_paid); } throw new Error('Unknown currency type', "Type {$curr_type} isn't " . CURRENCY . " or BTC"); }