Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved libraries to index.php

  • Loading branch information...
commit 3abe79ff52b570c26bf97ea06d0467bbc4573a91 1 parent 7614a54
ethem authored
View
10 enrol/authorize/authorizenetlib.php
@@ -204,13 +204,8 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
$message = "Order must be credited within 120 days!";
return AN_RETURNZERO;
}
- if (empty($extra)) {
- $message = "Need extra fields to REFUND!";
- return AN_RETURNZERO;
- }
- $total = floatval($extra->sum) + floatval($extra->amount);
- if (($extra->amount == 0) || ($total > $order->amount)) {
- $message = "Can be credited up to original amount.";
+ if (empty($extra->amount)) {
+ $message = "No valid amount!";
return AN_RETURNZERO;
}
$poststring .= '&x_type=CREDIT&x_trans_id=' . urlencode($order->transid);
@@ -336,7 +331,6 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
$extra->status = AN_STATUS_CREDIT;
$extra->transid = $transid;
$extra->settletime = authorize_getsettletime(time());
- unset($extra->sum); // this is not used in refunds table.
if (! $extra->id = insert_record('enrol_authorize_refunds', $extra)) {
unset($extra->id);
email_to_admin("Error while trying to insert data " .
View
3  enrol/authorize/index.php
@@ -2,7 +2,10 @@
/// Load libraries
require_once('../../config.php');
+ require_once('const.php');
require_once('locallib.php');
+ require_once('localfuncs.php');
+ require_once('authorizenetlib.php');
/// Parameters
$orderid = optional_param('order', 0, PARAM_INT);
View
16 enrol/authorize/locallib.php
@@ -4,9 +4,6 @@
die('Direct access to this script is forbidden.');
}
-require_once('const.php');
-require_once('authorizenetlib.php');
-
define('ORDER_CAPTURE', 'capture');
define('ORDER_DELETE', 'delete');
define('ORDER_REFUND', 'refund');
@@ -304,17 +301,14 @@ function authorize_print_order_details($orderno)
error(get_string('youcantdo', 'enrol_authorize', $a));
}
- $extra = new stdClass;
- $extra->sum = 0.0;
- $extra->orderid = $orderno;
-
+ $refunded = 0.0;
$sql = "SELECT SUM(amount) AS refunded FROM {$CFG->prefix}enrol_authorize_refunds " .
"WHERE (orderid = '" . $orderno . "') AND (status = '" . AN_STATUS_CREDIT . "')";
- if (($refund = get_record_sql($sql))) {
- $extra->sum = floatval($refund->refunded);
+ if (($refundval = get_field_sql($sql))) {
+ $refunded = floatval($refundval);
}
- $upto = format_float($order->amount - $extra->sum, 2);
+ $upto = format_float($order->amount - $refunded, 2);
if ($upto <= 0) {
error("Refunded to original amount.");
}
@@ -333,6 +327,8 @@ function authorize_print_order_details($orderno)
$strcanbecredit<br /><input type='submit' name='".ORDER_REFUND."' value='$authstrs->refund'>");
}
else {
+ $extra = new stdClass;
+ $extra->orderid = $orderno;
$extra->amount = $amount;
$message = '';
$success = authorize_action($order, $message, $extra, AN_ACTION_CREDIT);
Please sign in to comment.
Something went wrong with that request. Please try again.