diff --git a/booking.admin.inc b/booking.admin.inc index ed69d69..cc75d84 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -103,8 +103,8 @@ function booking_admin() { '#type' => 'textfield', '#title' => t('Registration limit'), '#description' => t("Total number of attendees permitted."), - '#size' => 3, - '#maxlength' => 3, + '#size' => 5, + '#maxlength' => 5, '#required' => TRUE, '#default_value' => variable_get('booking_regn_limit','500'), ); @@ -133,7 +133,31 @@ function booking_admin() { '#options' => array (0 => t('Off'), t('On')), '#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 ( '#type' => 'fieldset', '#title' => 'Enable/Disable Features', diff --git a/booking.helper.inc b/booking.helper.inc index 5c38ed6..c5171cb 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -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; }