tidy up some code locations
This commit is contained in:
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user