Move paypal fee calculations to new function
This commit is contained in:
@@ -805,10 +805,28 @@ function _booking_datepaid_ts($nid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate paypal fees
|
||||
*/
|
||||
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);
|
||||
} else {
|
||||
watchdog('booking', "This is an international registration.");
|
||||
$result = $result / (1 - 0.036);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to return the amount for a booking deposit, if there is one
|
||||
*/
|
||||
function _booking_deposit_amount($include_fees = TRUE)
|
||||
function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
{
|
||||
global $event;
|
||||
|
||||
@@ -822,10 +840,13 @@ function _booking_deposit_amount($include_fees = TRUE)
|
||||
//if we're using paypal, add the transaction fee
|
||||
if (variable_get('booking_use_paypal', 0) == 1 && $include_fees == TRUE)
|
||||
{
|
||||
$amount_owing = _booking_add_paypal_fees($deposit->booking_price, $person->booking_country);
|
||||
/*
|
||||
//add the 30 cent fixed cost
|
||||
$amount_owing = $deposit->booking_price + 0.3;
|
||||
//and the 2.4 percent transaction fee
|
||||
$amount_owing = $amount_owing / (1 - 0.026);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1026,6 +1047,8 @@ function _booking_amount_owing($person, $amount_paid = 0, $include_paypal_fees =
|
||||
//if we're using paypal, add the transaction fee
|
||||
if (variable_get('booking_use_paypal', 0) == 1 && $include_paypal_fees == TRUE)
|
||||
{
|
||||
$amount_owing = _booking_add_paypal_fees($total_due - $amount_paid, $person->booking_country);
|
||||
/*
|
||||
//add the 30 cent fixed cost
|
||||
$amount_owing = $total_due - $amount_paid + 0.3;
|
||||
//and the 2.4 percent transaction fee
|
||||
@@ -1038,6 +1061,7 @@ function _booking_amount_owing($person, $amount_paid = 0, $include_paypal_fees =
|
||||
$amount_owing = $amount_owing / (1 - 0.036);
|
||||
//watchdog('booking', "This is an international registration.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
$amount_owing = $total_due - $amount_paid;
|
||||
@@ -1061,12 +1085,12 @@ function _booking_process_refund($person)
|
||||
{
|
||||
//calculate the refund due
|
||||
//don't include paypal fees in the deposit amount
|
||||
$refund = $paid - _booking_deposit_amount(FALSE);
|
||||
$refund = $paid - _booking_deposit_amount($person, FALSE);
|
||||
|
||||
//if there is a spouse, subtract their deposit too
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $person->booking_partner_id > 0)
|
||||
{
|
||||
$refund = $refund - _booking_deposit_amount(FALSE);
|
||||
$refund = $refund - _booking_deposit_amount($person, FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user