Made paypal fees customisable

This commit is contained in:
2015-03-19 13:39:03 +11:00
parent 0c907cc710
commit 1f7e73ae87
2 changed files with 41 additions and 9 deletions

View File

@@ -811,15 +811,23 @@ function _booking_datepaid_ts($nid)
function _booking_add_paypal_fees($amount, $country)
{
//add the 30 cent fixed cost
$result = $amount + 0.3;
//and the 2.6 percent transaction fee
if ($country === "Australia") {
$result = $result / (1 - 0.026);
$result = '0.00';
$result = (float) ($amount + (float) variable_get('booking_paypal_transaction_fee_fixedcost', '0.3'));
//and the 2.6 percent transaction fee for australian transaction with no currency conversion
if ($country == variable_get('booking_default_country', 'Australia')) {
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage', '2.6');
} else {
watchdog('booking', "This is an international registration.");
$result = $result / (1 - 0.036);
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage_intl', '3.6');
watchdog('booking', "Calculating paypal fees for a currency conversion transaction which adds $percentage percent.");
}
//apply the percentage
$percentage = (float) $percentage / 100;
//watchdog('booking', "Paypal percentage transaction fee works out to $percentage.");
$result = $result / (1 - $percentage);
//return result
return $result;
}