Manage orders with status filter. All/Authorized/Captured/Refunded/Cancelled/Expired.
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
<?php // $Id$
|
||||
|
||||
define('AN_HOST', 'secure.authorize.net');
|
||||
define('AN_HOST_TEST', 'certification.authorize.net');
|
||||
define('AN_PORT', 443);
|
||||
define('AN_PATH', '/gateway/transact.dll');
|
||||
define('AN_APPROVED', '1');
|
||||
define('AN_DECLINED', '2');
|
||||
define('AN_ERROR', '3');
|
||||
define('AN_DELIM', '|');
|
||||
define('AN_ENCAP', '"');
|
||||
|
||||
require_once $CFG->dirroot.'/enrol/authorize/const.php';
|
||||
|
||||
/**
|
||||
@@ -61,7 +56,7 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
global $CFG;
|
||||
static $conststring;
|
||||
|
||||
$an_test = !empty($CFG->an_test);
|
||||
$test = !empty($CFG->an_test);
|
||||
|
||||
if (!isset($conststring)) {
|
||||
$consdata = array(
|
||||
@@ -72,7 +67,7 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
'x_relay_response' => 'FALSE',
|
||||
'x_method' => 'CC',
|
||||
'x_login' => $CFG->an_login,
|
||||
'x_test_request' => $an_test ? 'TRUE' : 'FALSE'
|
||||
'x_test_request' => $test ? 'TRUE' : 'FALSE'
|
||||
);
|
||||
$str = '';
|
||||
foreach($consdata as $ky => $vl) {
|
||||
@@ -205,14 +200,14 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
}
|
||||
|
||||
$response = array();
|
||||
$host = $an_test ? AN_HOST_TEST : AN_HOST;
|
||||
$fp = fsockopen("ssl://" . $host, AN_PORT, $errno, $errstr, 60);
|
||||
$host = $test ? 'certification.authorize.net' : 'secure.authorize.net';
|
||||
$fp = fsockopen("ssl://$host", 443, $errno, $errstr, 60);
|
||||
if (!$fp) {
|
||||
$message = "no connection: $errstr ($errno)";
|
||||
return false;
|
||||
}
|
||||
|
||||
fwrite($fp, "POST " . AN_PATH . " HTTP/1.0\r\n" .
|
||||
fwrite($fp, "POST /gateway/transact.dll HTTP/1.0\r\n" .
|
||||
"Host: $host\r\n" . $referer .
|
||||
"Content-type: application/x-www-form-urlencoded\r\n" .
|
||||
"Connection: close\r\n" .
|
||||
@@ -249,7 +244,7 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
if ($response[0] == AN_APPROVED)
|
||||
{
|
||||
$transid = intval($response[6]);
|
||||
if ($an_test || $transid == 0) {
|
||||
if ($test || $transid == 0) {
|
||||
return true; // don't update original transaction in test mode.
|
||||
}
|
||||
switch ($action) {
|
||||
|
||||
@@ -123,4 +123,4 @@ function CCVal($Num, $Name = "n/a", $Exp = "")
|
||||
// evenly divisible by 10, it's cool!
|
||||
return ($GoodCard && $Total % 10 == 0);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
+37
-32
@@ -121,7 +121,7 @@ class enrolment_plugin extends enrolment_base
|
||||
$this->ccerrors['ccexpire'] = get_string('ccexpired', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$this->ccerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
$this->ccerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class enrolment_plugin extends enrolment_base
|
||||
}
|
||||
|
||||
$SESSION->ccpaid = 1; // security check: don't duplicate payment
|
||||
if (intval($order->transid) == 0) { // TEST MODE
|
||||
if ($order->transid == 0) { // TEST MODE
|
||||
if ($an_review) {
|
||||
redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
|
||||
}
|
||||
@@ -293,16 +293,29 @@ class enrolment_plugin extends enrolment_base
|
||||
if (empty($form->ccfirstname) || empty($form->cclastname)) {
|
||||
$this->ccerrors['ccfirstlast'] = get_string('missingfullname');
|
||||
}
|
||||
if (empty($form->cc)) $this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
|
||||
if (empty($form->cvv)) $this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
|
||||
if (empty($form->cctype)) $this->ccerrors['cctype'] = get_string('missingcctype', 'enrol_authorize');
|
||||
if (empty($form->cc)) {
|
||||
$this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->cvv) || !is_int($form->cvv)) {
|
||||
$this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->cctype)) {
|
||||
$this->ccerrors['cctype'] = get_string('missingcctype', 'enrol_authorize');
|
||||
}
|
||||
if (!empty($CFG->an_avs)) {
|
||||
if (empty($form->ccaddress)) $this->ccerrors['ccaddress'] = get_string('missingaddress', 'enrol_authorize');
|
||||
if (empty($form->cccity)) $this->ccerrors['cccity'] = get_string('missingcity');
|
||||
if (empty($form->cccountry)) $this->ccerrors['cccountry'] = get_string('missingcountry');
|
||||
if (empty($form->cczip)) $this->ccerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
|
||||
if (empty($form->ccaddress)) {
|
||||
$this->ccerrors['ccaddress'] = get_string('missingaddress', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->cccity)) {
|
||||
$this->ccerrors['cccity'] = get_string('missingcity');
|
||||
}
|
||||
if (empty($form->cccountry)) {
|
||||
$this->ccerrors['cccountry'] = get_string('missingcountry');
|
||||
}
|
||||
}
|
||||
if (empty($form->cczip) || !is_int($form->cczip)) {
|
||||
$this->ccerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
|
||||
}
|
||||
|
||||
if (!empty($this->ccerrors)) {
|
||||
$this->ccerrors['header'] = get_string('someerrorswerefound');
|
||||
$return = false;
|
||||
@@ -327,8 +340,8 @@ class enrolment_plugin extends enrolment_base
|
||||
/**
|
||||
* get_course_cost
|
||||
*
|
||||
* @param unknown_type $course
|
||||
* @return unknown
|
||||
* @param object $course
|
||||
* @return array
|
||||
* @access private
|
||||
*/
|
||||
function get_course_cost($course)
|
||||
@@ -574,32 +587,24 @@ class enrolment_plugin extends enrolment_base
|
||||
delete_records_select('enrol_authorize', $select);
|
||||
}
|
||||
|
||||
if (empty($CFG->an_review) || !empty($CFG->an_test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (intval($CFG->an_capture_day < 1)) {
|
||||
if (empty($CFG->an_emailexpired) || intval($mconfig->an_nextmail) > $timenow) {
|
||||
return;
|
||||
}
|
||||
if (!empty($CFG->an_emailexpired) && intval($mconfig->an_nextmail) < $timenowsettle) {
|
||||
set_config('an_nextmail', $timenowsettle + $oneday + 1, 'enrol/authorize');
|
||||
$timediffem = $timenowsettle - ((30 - intval($CFG->an_emailexpired)) * $oneday);
|
||||
$select = "(status = '" . AN_STATUS_AUTH . "') AND " .
|
||||
"(timecreated < '$timediffem') AND (timecreated > '$timediff30')";
|
||||
if (!$count = count_records_select('enrol_authorize', $select)) {
|
||||
return;
|
||||
if ($count = count_records_select('enrol_authorize', $select)) {
|
||||
$a->pending = $count;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->enrolurl = "$CFG->wwwroot/$CFG->admin/users.php";
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
|
||||
$message = get_string('pendingordersemail', 'enrol_authorize', $a);
|
||||
$adminuser = get_admin();
|
||||
email_to_user($adminuser, $adminuser, "WARNING: PENDING PAYMENTS", $a);
|
||||
}
|
||||
$a->pending = $count;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=" . AN_STATUS_AUTH;
|
||||
$a->enrolurl = "$CFG->wwwroot/$CFG->admin/users.php";
|
||||
$message = get_string('pendingordersemail', 'enrol_authorize', $a);
|
||||
$adminuser = get_admin();
|
||||
email_to_user($adminuser, $adminuser, "WARNING: PENDING PAYMENTS", $a);
|
||||
set_config('an_nextmail', $timenow + $oneday, 'enrol/authorize');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->check_openssl_loaded()) {
|
||||
if (empty($CFG->an_review) || (!empty($CFG->an_test)) ||
|
||||
intval($CFG->an_capture_day < 1) || (!$this->check_openssl_loaded())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+41
-21
@@ -1,9 +1,9 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once("const.php");
|
||||
require_once("enrol.php");
|
||||
require_once("action.php");
|
||||
require_once '../../config.php';
|
||||
require_once $CFG->dirroot.'/enrol/authorize/const.php';
|
||||
require_once $CFG->dirroot.'/enrol/authorize/enrol.php';
|
||||
require_once $CFG->dirroot.'/enrol/authorize/action.php';
|
||||
|
||||
define('ORDER_CAPTURE', 'capture');
|
||||
define('ORDER_DELETE', 'delete');
|
||||
@@ -20,12 +20,11 @@ if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$csv = optional_param('csv', '', PARAM_ALPHA);
|
||||
$orderid = optional_param('order', 0, PARAM_INT);
|
||||
|
||||
$strs = get_strings(array('user','status','action','delete','time','course','confirm','yes','no','none','error'));
|
||||
$authstrs = get_strings(array('paymentmanagement','orderid','void','capture','refund','delete',
|
||||
'authorizedpendingcapture','capturedpendingsettle','capturedsettled',
|
||||
'authcaptured','authorizedpendingcapture','capturedpendingsettle','capturedsettled',
|
||||
'settled','refunded','cancelled','expired','tested',
|
||||
'transid','settlementdate','notsettled','amount',
|
||||
'howmuch','captureyes','unenrolstudent'), 'enrol_authorize');
|
||||
@@ -34,10 +33,7 @@ print_header("$site->shortname: $authstrs->paymentmanagement",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$authstrs->paymentmanagement</a>", "");
|
||||
|
||||
if (!empty($csv)) {
|
||||
authorize_csv();
|
||||
}
|
||||
elseif (!empty($orderid)) {
|
||||
if (!empty($orderid)) {
|
||||
authorize_order_details($orderid);
|
||||
}
|
||||
else {
|
||||
@@ -56,6 +52,18 @@ function authorize_orders()
|
||||
$userid = optional_param('user', 0, PARAM_INT);
|
||||
$courseid = optional_param('course', 0, PARAM_INT);
|
||||
$status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
|
||||
$baseurl = $CFG->wwwroot."/enrol/authorize/index.php?course=$courseid&user=$userid";
|
||||
$statusmenu = array(AN_STATUS_NONE => get_string('all'),
|
||||
AN_STATUS_AUTH => $authstrs->authorizedpendingcapture,
|
||||
AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured,
|
||||
AN_STATUS_CREDIT => $authstrs->refunded,
|
||||
AN_STATUS_VOID => $authstrs->cancelled,
|
||||
AN_STATUS_EXPIRE => $authstrs->expired
|
||||
);
|
||||
|
||||
print_simple_box_start('center');
|
||||
echo $strs->status . ': ' . popup_form($baseurl.'&status=', $statusmenu, 'statusmenu', $status, '', '', '', true);
|
||||
print_simple_box_end();
|
||||
|
||||
$table = new flexible_table('enrol-authorize');
|
||||
$table->set_attribute('width', '100%');
|
||||
@@ -66,19 +74,35 @@ function authorize_orders()
|
||||
|
||||
$table->define_columns(array('id', 'timecreated', 'userid', 'status', ''));
|
||||
$table->define_headers(array($authstrs->orderid, $strs->time, $strs->user, $strs->status, $strs->action));
|
||||
$table->define_baseurl($CFG->wwwroot."/enrol/authorize/index.php?course=$courseid&user=$userid&status=$status");
|
||||
$table->define_baseurl($baseurl."&status=$status");
|
||||
|
||||
$table->sortable(true);
|
||||
$table->pageable(true);
|
||||
$table->setup();
|
||||
|
||||
if ($status > AN_STATUS_NONE) $where = "WHERE (status = '$status') ";
|
||||
else $where = "WHERE (status != '" . AN_STATUS_NONE . "') ";
|
||||
if ($userid > 0) { $where .= "AND (userid = '" . $userid . "') "; }
|
||||
if ($courseid > 0) { $where .= "AND (courseid = '" . $courseid . "') "; }
|
||||
$select = "SELECT E.id, E.transid, E.courseid, E.userid, E.status, E.ccname, E.timecreated, E.settletime";
|
||||
$from = " FROM {$CFG->prefix}enrol_authorize E ";
|
||||
|
||||
if ($status > AN_STATUS_NONE) {
|
||||
if ($status == AN_STATUS_CREDIT) {
|
||||
$from .= "INNER JOIN {$CFG->prefix}enrol_authorize_refunds R ON E.id = R.orderid ";
|
||||
$where = "WHERE (E.status = '" . AN_STATUS_AUTHCAPTURE . "') ";
|
||||
}
|
||||
else {
|
||||
$where = "WHERE (status = '$status') ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$where = "WHERE (status != '" . AN_STATUS_NONE . "') ";
|
||||
}
|
||||
|
||||
if ($userid > 0) {
|
||||
$where .= "AND (userid = '" . $userid . "') ";
|
||||
}
|
||||
if ($courseid > 0) {
|
||||
$where .= "AND (courseid = '" . $courseid . "') ";
|
||||
}
|
||||
|
||||
$select = "SELECT id, transid, courseid, userid, status, ccname, timecreated, settletime ";
|
||||
$from = " FROM {$CFG->prefix}enrol_authorize ";
|
||||
if ($sort = $table->get_sql_sort()) {
|
||||
$sort = ' ORDER BY ' . $sort;
|
||||
}
|
||||
@@ -411,10 +435,6 @@ function authorize_order_details($orderno) {
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
function authorize_csv()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
function get_order_status_desc($order)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_authorize.php - created with Moodle 1.6 development (2005101200)
|
||||
|
||||
$string['avsresult'] = 'AVS Result:';
|
||||
|
||||
$string['adminauthorizeccapture'] = 'Order Review & Auto-Capture Settings';
|
||||
$string['adminauthorizeemail'] = 'Email Sending Settings';
|
||||
$string['adminauthorizesettings'] = 'Authorize.net Settings';
|
||||
@@ -47,6 +47,7 @@ $string['anpassword'] = 'Authorize.net: Password';
|
||||
$string['anreferer'] = 'Define the URL referer if you have set up this in your authorize.net account. This will send a line \"Referer: URL\" embedded in the web request.';
|
||||
$string['antestmode'] = 'Run transactions in test mode only (no money will be drawn)';
|
||||
$string['antrankey'] = 'Authorize.net: Transaction Key';
|
||||
$string['authcaptured'] = 'Authorized / Captured';
|
||||
$string['authorizedpendingcapture'] = 'Authorized / Pending Capture';
|
||||
$string['avsa'] = 'Address (street) matches, postal code does not';
|
||||
$string['avsb'] = 'Address information not provided';
|
||||
@@ -55,6 +56,7 @@ $string['avsg'] = 'Non-U.S. Card Issuing Bank';
|
||||
$string['avsn'] = 'No match on address (street) nor postal code';
|
||||
$string['avsp'] = 'Address Verification System not applicable';
|
||||
$string['avsr'] = 'Retry - System unavailable or timed out';
|
||||
$string['avsresult'] = 'AVS Result:';
|
||||
$string['avss'] = 'Service not supported by issuer';
|
||||
$string['avsu'] = 'Address information is unavailable';
|
||||
$string['avsw'] = '9 digit postal code matches, address (street) does not';
|
||||
|
||||
Reference in New Issue
Block a user