Made paypal fees customisable
This commit is contained in:
@@ -103,8 +103,8 @@ function booking_admin() {
|
|||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => t('Registration limit'),
|
'#title' => t('Registration limit'),
|
||||||
'#description' => t("Total number of attendees permitted."),
|
'#description' => t("Total number of attendees permitted."),
|
||||||
'#size' => 3,
|
'#size' => 5,
|
||||||
'#maxlength' => 3,
|
'#maxlength' => 5,
|
||||||
'#required' => TRUE,
|
'#required' => TRUE,
|
||||||
'#default_value' => variable_get('booking_regn_limit','500'),
|
'#default_value' => variable_get('booking_regn_limit','500'),
|
||||||
);
|
);
|
||||||
@@ -133,7 +133,31 @@ function booking_admin() {
|
|||||||
'#options' => array (0 => t('Off'), t('On')),
|
'#options' => array (0 => t('Off'), t('On')),
|
||||||
'#default_value' => variable_get('booking_paypal_sandbox', 0),
|
'#default_value' => variable_get('booking_paypal_sandbox', 0),
|
||||||
);
|
);
|
||||||
|
$form['paypal']['booking_paypal_transaction_fee_fixedcost'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Paypal fixed cost transaction fee'),
|
||||||
|
'#default_value' => variable_get('booking_paypal_transaction_fee_fixedcost', '0.3'),
|
||||||
|
'#field_prefix' => '$',
|
||||||
|
'#size' => 5,
|
||||||
|
'#description' => 'Transaction fee is currently $0.3 AUD and is added before the percentage fee is applied.',
|
||||||
|
);
|
||||||
|
$form['paypal']['booking_paypal_transaction_fee_percentage'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Paypal Percentage Transaction Fee'),
|
||||||
|
'#default_value' => variable_get('booking_paypal_transaction_fee_percentage', '2.6'),
|
||||||
|
'#field_prefix' => '%',
|
||||||
|
'#size' => 5,
|
||||||
|
'#description' => 'Percentage of transaction charged as paypal fee, currently 2.6% in Australia',
|
||||||
|
);
|
||||||
|
$form['paypal']['booking_paypal_transaction_fee_percentage_intl'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Paypal Percentage Transaction Fee (International)'),
|
||||||
|
'#default_value' => variable_get('booking_paypal_transaction_fee_percentage_intl', '3.6'),
|
||||||
|
'#field_prefix' => '%',
|
||||||
|
'#size' => 5,
|
||||||
|
'#description' => 'Percentage of transaction charged as paypal fee for transactions that include currency conversion, currently 3.6% in Australia',
|
||||||
|
);
|
||||||
|
|
||||||
$form['features'] = array (
|
$form['features'] = array (
|
||||||
'#type' => 'fieldset',
|
'#type' => 'fieldset',
|
||||||
'#title' => 'Enable/Disable Features',
|
'#title' => 'Enable/Disable Features',
|
||||||
|
@@ -811,15 +811,23 @@ function _booking_datepaid_ts($nid)
|
|||||||
function _booking_add_paypal_fees($amount, $country)
|
function _booking_add_paypal_fees($amount, $country)
|
||||||
{
|
{
|
||||||
//add the 30 cent fixed cost
|
//add the 30 cent fixed cost
|
||||||
$result = $amount + 0.3;
|
$result = '0.00';
|
||||||
//and the 2.6 percent transaction fee
|
$result = (float) ($amount + (float) variable_get('booking_paypal_transaction_fee_fixedcost', '0.3'));
|
||||||
if ($country === "Australia") {
|
|
||||||
$result = $result / (1 - 0.026);
|
//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 {
|
} else {
|
||||||
watchdog('booking', "This is an international registration.");
|
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage_intl', '3.6');
|
||||||
$result = $result / (1 - 0.036);
|
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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user