148 lines
5.0 KiB
PHP
148 lines
5.0 KiB
PHP
<?php
|
|
if (!isset($PAYMENT_FORM_INCLUDED)) $PAYMENT_FORM_INCLUDED = true;
|
|
else if ($PAYMENT_FORM_INCLUDED) return;
|
|
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-CREDIT-CARD-PAYMENT');
|
|
|
|
|
|
if (!isset($user_num)) $user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
|
|
unset($selected_amount);
|
|
if (isset($naction) && $naction == 'deposit' && array_key_exists('selected_amount',$_POST)) $selected_amount = $_POST['selected_amount'];
|
|
|
|
?>
|
|
<table width='500' cellpadding='5' cellspacing='2' border='0'>
|
|
<tr>
|
|
<td align='center'>
|
|
<?php
|
|
|
|
// Get processing timestamp
|
|
$now = time();
|
|
|
|
// Get current balance
|
|
$balance = db_getVal("select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
|
|
if (!$balance) $balance = 0.00;
|
|
|
|
$onlineMessage = db_getVal("SELECT text_data FROM text_data WHERE school_num = $school_num AND text_id = 'Online Payment Message'");
|
|
if (strlen($onlineMessage)) $onlineMessage .= "<br><br>\n";
|
|
|
|
switch ($school_num) {
|
|
case 251:
|
|
case 19438:
|
|
$onlineMessage .= "-- Please note that Interac Debit cards are not accepted --";
|
|
break;
|
|
|
|
default:
|
|
$onlineMessage .= "-- Please note that MasterCard Debit and Interac Debit cards are not accepted --";
|
|
break;
|
|
}
|
|
$onlineMessageDisplayed = false;
|
|
|
|
|
|
//
|
|
// Bambora Form
|
|
//
|
|
if ($school_record['bambora_enabled'] == 'Y' && strlen($school_record['bambora_merchant_id']) > 0) {
|
|
// Get current balance
|
|
$balance = db_getVal("select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
|
|
if (!$balance) $balance = 0.00;
|
|
if (isset($selected_amount) && $selected_amount > 0) $balance = $selected_amount;
|
|
|
|
if ($balance >= $school_record['bambora_minimum_amount']) {
|
|
$trx_time = date("Y-m-d H:i:s",$now);
|
|
|
|
// Calculate the transaction fee
|
|
$trx_time = date("Y-m-d H:i:s",$now);
|
|
$trx_fee = intval($balance * $school_record['bambora_percentage']) / 100 + $school_record['bambora_fee'];
|
|
$owing = $balance + $trx_fee;
|
|
|
|
if (!$onlineMessageDisplayed && strlen($onlineMessage)) {
|
|
displayStatusMessage($onlineMessage,"warningframedspan");
|
|
$onlineMessageDisplayed = true;
|
|
}
|
|
|
|
// Calculate any payment discounts
|
|
|
|
// Check for an entry to the online payments table
|
|
$query = "select * from user_online_payments " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $user_num " .
|
|
"and status = 'Pending'";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) > 0) {
|
|
$row = db_fetch_array($results);
|
|
$trxnum = $row['record_num'];
|
|
$query = "update user_online_payments " .
|
|
"set user_account_balance = $balance, " .
|
|
"transaction_fee = $trx_fee, " .
|
|
"balance_owing = $owing, " .
|
|
"transaction_datetime = '$trx_time', " .
|
|
"transaction_time = $now " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $user_num " .
|
|
"and status = 'Pending'";
|
|
db_query($query);
|
|
}
|
|
else {
|
|
$query = "insert into user_online_payments (school_num,user_num,transaction_datetime,transaction_time,user_account_balance,transaction_fee,balance_owing,status) " .
|
|
"values ($school_num,$user_num,'$trx_time',$now,$balance,$trx_fee,$owing,'Pending')";
|
|
db_query($query);
|
|
$trxnum = db_insert_id();
|
|
}
|
|
|
|
// If there is a transaction fee
|
|
if ($trx_fee != 0 || strlen(trim($school_record['bambora_fee_message'])) > 0) {
|
|
$trx_title = getLanguageText('TEXT-TRX-FEE');
|
|
if (strlen($school_record['bambora_fee_title'])) $trx_title = $school_record['bambora_fee_title'];
|
|
?>
|
|
<table width='100%' class='content-table'>
|
|
<tr>
|
|
<td align='center' class='warning'>
|
|
<br>
|
|
<?php if (strlen(trim($school_record['bambora_fee_message']))) { ?>
|
|
<b><?php echo(nl2br(trim($school_record['bambora_fee_message']))); ?></b><br>
|
|
<br>
|
|
<?php } ?>
|
|
<?php if ($trx_fee != 0) { ?>
|
|
<?php if (isset($selected_amount) && $selected_amount > 0) { ?>
|
|
<b><nobr><?php echo(getLanguageText('TEXT-DEPOSIT-AMOUNT') . ": " . $currencySymbol . number_format($owing,2)) ?></nobr></b><br>
|
|
<?php } else { ?>
|
|
<b><nobr><?php echo(getLanguageText('TEXT-ACCOUNT-BALANCE') . ": " . $currencySymbol . number_format($owing,2)) ?></nobr></b><br>
|
|
<?php } ?>
|
|
<b><nobr><?php echo($trx_title . ": " . $currencySymbol . number_format($trx_fee,2)) ?></nobr></b>
|
|
<br>
|
|
<br>
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
|
|
include "bambora_form.php";
|
|
echo("<br>\n");
|
|
echo("<br>\n");
|
|
echo("<br>\n");
|
|
echo("<br>\n");
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php endTemplate(); ?>
|