tidy up some code locations
This commit is contained in:
@@ -249,7 +249,7 @@ function booking_admin() {
|
||||
$form['stripe']['booking_stripe_logo'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Logo URL for Stripe Checkout Form'),
|
||||
'#description' => 'Enter the full URL to a logo png file that will be used on the stripe checkout form.',
|
||||
'#description' => 'Enter the full URL to a logo file that will be used on the stripe checkout form.<br />The recommended minimum size is 128x128px. The supported image types are: .gif, .jpeg, and .png.',
|
||||
'#default_value' => variable_get('booking_stripe_logo', 'https://stripe.com/img/documentation/checkout/marketplace.png'),
|
||||
);
|
||||
|
||||
|
@@ -813,60 +813,10 @@ function _booking_datepaid_ts($nid) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate paypal fees
|
||||
*/
|
||||
function _booking_add_paypal_fees($amount, $country)
|
||||
{
|
||||
//add the 30 cent fixed cost
|
||||
$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 {
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate stripe transaction fees
|
||||
*/
|
||||
function _booking_add_stripe_fees($amount, $country) {
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_stripe_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_stripe_transaction_fee_percentage', '1.75');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage_intl', '2.9');
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to return the amount for a booking deposit, if there is one
|
||||
*/
|
||||
function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
{
|
||||
function _booking_deposit_amount($person, $include_fees = TRUE) {
|
||||
global $event;
|
||||
|
||||
$deposit = db_query("SELECT price.booking_price, price.booking_price_descrip " .
|
||||
|
@@ -1,5 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to calculate paypal fees
|
||||
*/
|
||||
function _booking_add_paypal_fees($amount, $country)
|
||||
{
|
||||
//add the 30 cent fixed cost
|
||||
$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 {
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate string to post to paypal to verify a successful IPN
|
||||
*/
|
||||
function _booking_paypal_post($data = array()) {
|
||||
$post = '';
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -10,7 +39,10 @@ function _booking_paypal_post($data = array()) {
|
||||
return $post;
|
||||
}
|
||||
|
||||
//see https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php for more details
|
||||
/**
|
||||
* Helper function to verify a successful IPN from Paypal
|
||||
* @see https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php
|
||||
*/
|
||||
function _booking_paypal_ipn_verify($vars = array()) {
|
||||
|
||||
if (variable_get('booking_paypal_sandbox', 0)) {
|
||||
|
@@ -31,6 +31,29 @@ function _booking_get_stripe_private_key() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate stripe transaction fees
|
||||
*/
|
||||
function _booking_add_stripe_fees($amount, $country) {
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_stripe_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_stripe_transaction_fee_percentage', '1.75');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage_intl', '2.9');
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate paypal form for payments
|
||||
*/
|
||||
|
@@ -627,33 +627,45 @@ function booking_define_personspecific_tokens($node)
|
||||
if ($payment_processor_type == 0) {
|
||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
|
||||
$tokens['stripe-deposit-amount'] = "";
|
||||
$tokens['stripe-total-amount'] = "";
|
||||
$tokens['stripe-total-intl'] = "";
|
||||
}
|
||||
//if stripe is enabled
|
||||
elseif ($payment_processor_type == 1) {
|
||||
//@todo remove the paypal tokens from here
|
||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
|
||||
$tokens['paypal-deposit-amount'] = "";
|
||||
$tokens['paypal-total-amount'] = "";
|
||||
$tokens['stripe-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['stripe-total-amount'] = _booking_amount_owing($node, $amount_paid, TRUE, FALSE);
|
||||
$tokens['stripe-total-intl'] = _booking_amount_owing($node, $amount_paid, TRUE, TRUE);
|
||||
}
|
||||
|
||||
//if travelform is enabled
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$tokens['travel-link'] = url('travel/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$tokens['travel-link'] = "";
|
||||
$tokens['travel-summary'] = "";
|
||||
}
|
||||
//if studygroups are enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
$tokens['studygroup-summary'] = _booking_studygroup_email_summary($node);
|
||||
$tokens['leaderhelper-pair'] = _booking_leader_helper_email_summary($node);
|
||||
}
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
else {
|
||||
$tokens['studygroup-summary'] = "";
|
||||
$tokens['leaderhelper-pair'] = "";
|
||||
}
|
||||
//if room allocations are enabled
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$tokens['room-allocation'] = _booking_room_email_summary($node);
|
||||
$tokens['bed-type'] = _booking_room_bedtype_lookup(empty($node->booking_room_bedtype) ? '0' : $node->booking_room_bedtype);
|
||||
}
|
||||
else {
|
||||
$tokens['room-allocation'] = "";
|
||||
$tokens['bed-type'] = "";
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Person specific tokens:\n@info</pre>", array('@info' => print_r( $tokens, true)));
|
||||
return $tokens;
|
||||
}
|
||||
|
Reference in New Issue
Block a user