mirror of
https://github.com/moodle/moodle.git
synced 2025-03-13 20:26:32 +01:00
Config an_review_day renamed to an_capture_day.
Inform admin will be expired transactions 2 days ago. Help for an_review and an_capture_day to admins.
This commit is contained in:
parent
023af16e19
commit
241fbcf510
@ -12,7 +12,7 @@ if (!isset($frm->an_password)) $frm->an_password = '';
|
||||
if (!isset($frm->an_referer)) $frm->an_referer = 'http://';
|
||||
if (!isset($frm->an_test)) $frm->an_test = '';
|
||||
if (!isset($frm->an_review)) $frm->an_review = '';
|
||||
if (!isset($frm->an_review_day)) $frm->an_review_day = '5';
|
||||
if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
|
||||
if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0';
|
||||
if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
|
||||
@ -85,14 +85,16 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_review:</td>
|
||||
<td><input type="checkbox" value="1" name="an_review" <?php if (!empty($frm->an_review)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><input type="checkbox" value="1" name="an_review" <?php if (!empty($frm->an_review)) echo "checked=\"true\"" ?> />
|
||||
<?php helpbutton('', '', 'enrol_authorize', true, 'review', get_string('adminhelpreview', 'enrol_authorize')); ?></td>
|
||||
<td><?php print_string("adminreview", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_review_day:</td>
|
||||
<td><input type="text" name="an_review_day" size="2" maxlength="2" value="<?php p($frm->an_review_day) ?>" /></td>
|
||||
<td><?php print_string("reviewday", "enrol_authorize", $frm->an_review_day) ?></td>
|
||||
<td align="right">an_capture_day:</td>
|
||||
<td><input type="text" name="an_capture_day" size="2" maxlength="2" value="<?php p($frm->an_capture_day) ?>" />
|
||||
<?php helpbutton('', '', 'enrol_authorize', true, 'capture', get_string('adminhelpcapture', 'enrol_authorize')); ?></td>
|
||||
<td><?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
|
@ -84,6 +84,13 @@ function authorize_upgrade($oldversion=0) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006010200) {
|
||||
if (isset($CFG->an_review_day)) { // rename an_review_day
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,13 @@ function authorize_upgrade($oldversion=0) {
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2006010200) {
|
||||
if (isset($CFG->an_review_day)) { // rename an_review_day
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -9,15 +9,15 @@
|
||||
<form name="form" method="post" action="enrol.php" autocomplete="off">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<table align="center" width="100%" border=0>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><input type="text" name="ccfirstname" size="15" value="<?php p($userfirstname) ?>" />
|
||||
<input type="text" name="cclastname" size="15" value="<?php p($userlastname) ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("ccno", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
|
||||
<input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("ccexpire", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><?php
|
||||
@ -48,7 +48,7 @@
|
||||
<tr>
|
||||
<td align="right"><?php print_string("ccvv", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><input type="text" name="cvv" size="4" maxlength="4" value="<?php p($form->cvv) ?>" />
|
||||
<font size=1><?php print_string("ccvvhelp", "enrol_authorize") ?></font></td>
|
||||
<?php helpbutton('', '', 'enrol_authorize', true, 'cvv', get_string('ccvvhelp', 'enrol_authorize')); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
|
||||
|
@ -24,9 +24,9 @@ define('AN_STATUS_AUTH', 0x01);
|
||||
*/
|
||||
define('AN_STATUS_CAPTURE', 0x02);
|
||||
/**
|
||||
* Auth_Captured.
|
||||
* AN_STATUS_AUTH|AN_STATUS_CAPTURE.
|
||||
*/
|
||||
define('AN_STATUS_AUTHCAPTURE', AN_STATUS_AUTH|AN_STATUS_CAPTURE);
|
||||
define('AN_STATUS_AUTHCAPTURE', 0x03);
|
||||
/**
|
||||
* Refunded.
|
||||
*/
|
||||
@ -245,10 +245,10 @@ class enrolment_plugin extends enrolment_base
|
||||
$a->transid = $order->transid;
|
||||
$a->amount = "$order->currency $order->amount";
|
||||
$a->expireon = getsettletime($timenow + (30 * 3600 * 24));
|
||||
$a->captureon = getsettletime($timenow + (intval($CFG->an_review_day) * 3600 * 24));
|
||||
$a->captureon = getsettletime($timenow + (intval($CFG->an_capture_day) * 3600 * 24));
|
||||
$a->course = $course->fullname;
|
||||
$a->user = fullname($USER);
|
||||
$a->acstatus = ($CFG->an_review_day > 0) ? get_string('yes') : get_string('no');
|
||||
$a->acstatus = ($CFG->an_capture_day > 0) ? get_string('yes') : get_string('no');
|
||||
$emailmessage = get_string('adminneworder', 'enrol_authorize', $a);
|
||||
$a->course = $course->shortname;
|
||||
$a->orderid = $order->id;
|
||||
@ -409,6 +409,23 @@ class enrolment_plugin extends enrolment_base
|
||||
notify('PHP must be compiled with SSL support (--with-openssl)');
|
||||
}
|
||||
|
||||
$ac_enabled = !empty($frm->an_review) && intval($frm->an_capture_day) > 0;
|
||||
if ($ac_enabled) { // Cron must be runnig!!! Check last cron...
|
||||
$mconfig = get_config('enrol/authorize');
|
||||
$lastcron = intval($mconfig->an_lastcron);
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
notify(get_string('admincronsetup', 'enrol_authorize'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) {
|
||||
$a->count = $count;
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=" . AN_STATUS_AUTH;
|
||||
$message = get_string('adminpendingorders', 'enrol_authorize', $a);
|
||||
notify($message);
|
||||
}
|
||||
}
|
||||
|
||||
if (data_submitted()) {
|
||||
// something POSTed, Some required fields
|
||||
if (empty($frm->an_login)) {
|
||||
@ -420,30 +437,6 @@ class enrolment_plugin extends enrolment_base
|
||||
if (empty($CFG->loginhttps)) {
|
||||
notify("\$CFG->loginhttps must be ON");
|
||||
}
|
||||
|
||||
// ******************* AUTOCAPTURE *******************
|
||||
if (!(empty($frm->an_review) || $frm->an_review_day < 1)) {
|
||||
// ++ENABLED++
|
||||
// Cron must be runnig!!! Check last cron...
|
||||
$mconfig = get_config('enrol/authorize');
|
||||
$lastcron = intval($mconfig->an_lastcron);
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
// Cron must be enabled if you want to use autocapture feature.
|
||||
// Setup cron or disable an_review again...
|
||||
// Otherwise, transactions will be cancelled unless you review it within 30 days.
|
||||
notify(get_string('cronwarning', 'admin'));
|
||||
}
|
||||
} else {
|
||||
// --DISABLED--
|
||||
// Cron will NOT run anymore, because autocapture runs with cron.
|
||||
// Transactions with AN_STATUS_AUTH will be cancelled and we can display this warning to admin!
|
||||
// Admin can check (Accept|Deny) new transactions manually.
|
||||
|
||||
if ($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) {
|
||||
notify("CRON DISABLED. TRANSACTIONS WITH A STATUS OF AN_STATUS_AUTH WILL BE CANCELLED UNLESS YOU CHECK IT. TOTAL $count");
|
||||
}
|
||||
}
|
||||
// ***************************************************
|
||||
}
|
||||
|
||||
include($CFG->dirroot.'/enrol/authorize/config.html');
|
||||
@ -491,17 +484,17 @@ class enrolment_plugin extends enrolment_base
|
||||
set_config('an_password', $password_val);
|
||||
set_config('an_tran_key', $tran_val);
|
||||
|
||||
// an_review & an_review_day & cron depencies...
|
||||
// an_review & an_capture_day & cron depencies...
|
||||
$review_val = optional_param('an_review', '');
|
||||
if (empty($review_val)) {
|
||||
// review disabled. cron is not required. AUTH_CAPTURE works.
|
||||
set_config('an_review', $review_val);
|
||||
} else {
|
||||
// review enabled.
|
||||
$review_day_val = optional_param('an_review_day', 5, PARAM_INT);
|
||||
if ($review_day_val < 0) $review_day_val = 0;
|
||||
elseif ($review_day_val > 29) $review_day_val = 29;
|
||||
if ($review_day_val > 0) {
|
||||
$capture_day_val = optional_param('an_capture_day', 5, PARAM_INT);
|
||||
if ($capture_day_val < 0) $capture_day_val = 0;
|
||||
elseif ($capture_day_val > 29) $capture_day_val = 29;
|
||||
if ($capture_day_val > 0) {
|
||||
// Cron must change an_lastcron. :))
|
||||
$mconfig = get_config('enrol/authorize');
|
||||
$lastcron = intval($mconfig->an_lastcron);
|
||||
@ -511,7 +504,7 @@ class enrolment_plugin extends enrolment_base
|
||||
}
|
||||
}
|
||||
set_config('an_review', $review_val);
|
||||
set_config('an_review_day', $review_day_val);
|
||||
set_config('an_capture_day', $capture_day_val);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -607,15 +600,38 @@ class enrolment_plugin extends enrolment_base
|
||||
delete_records_select('enrol_authorize', $select);
|
||||
}
|
||||
|
||||
if (!empty($CFG->an_test)) {
|
||||
return; // AUTOCAPTURE doesn't work in test mode.
|
||||
if (empty($CFG->an_review) || !empty($CFG->an_test)) {
|
||||
return;
|
||||
}
|
||||
if (empty($CFG->an_review) || empty($CFG->an_review_day) || $CFG->an_review_day < 1) {
|
||||
return; // AUTOCAPTURE disabled. admin, teacher review it manually
|
||||
|
||||
if (intval($CFG->an_capture_day < 1)) {
|
||||
// Admin review it manually.
|
||||
// We can send email to admin about be expired transactions.
|
||||
// Last 2 days (30-28=2) is good, I think.
|
||||
// Send daily email.
|
||||
$nextmail = intval($mconfig->an_nextmail);
|
||||
if ($nextmail > $timenow)
|
||||
return; // One day must be passed.
|
||||
|
||||
$timediff28 = $timenowsettle - (28 * 3600 * 24);
|
||||
$select = "(status = '" . AN_STATUS_AUTH . "') AND " .
|
||||
"(timecreated < '$timediff28') AND (timecreated > '$timediff30')";
|
||||
if (!$count = count_records_select('enrol_authorize', $sql)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->pending = $count;
|
||||
$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 + (3600 * 24), 'enrol/authorize');
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTO-CAPTURE: Transaction must be captured within 30 days. Otherwise it will expired.
|
||||
$timediffcnf = $timenowsettle - (intval($CFG->an_review_day) * 3600 * 24);
|
||||
$timediffcnf = $timenowsettle - (intval($CFG->an_capture_day) * 3600 * 24);
|
||||
$sql = "SELECT E.*, C.fullname, C.enrolperiod " .
|
||||
"FROM {$CFG->prefix}enrol_authorize E " .
|
||||
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
|
||||
|
@ -54,6 +54,7 @@ function authorize_orders()
|
||||
$perpage = 10;
|
||||
$userid = optional_param('user', 0, PARAM_INT);
|
||||
$courseid = optional_param('course', 0, PARAM_INT);
|
||||
$status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
|
||||
|
||||
$table = new flexible_table('enrol-authorize');
|
||||
$table->set_attribute('width', '100%');
|
||||
@ -64,13 +65,14 @@ 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");
|
||||
$table->define_baseurl($CFG->wwwroot."/enrol/authorize/index.php?course=$courseid&user=$userid&status=$status");
|
||||
|
||||
$table->sortable(true);
|
||||
$table->pageable(true);
|
||||
$table->setup();
|
||||
|
||||
$where = "WHERE (status != '" . AN_STATUS_NONE . "') ";
|
||||
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 . "') "; }
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$module->version = 2005122800;
|
||||
$module->requires = 2005072200;
|
||||
|
||||
?>
|
||||
<?PHP // $Id$
|
||||
|
||||
$module->version = 2006010200;
|
||||
$module->requires = 2005072200;
|
||||
|
||||
?>
|
||||
|
||||
|
@ -6,6 +6,18 @@ $string['adminauthorizeccapture'] = 'Order Review & Auto-Capture Settings';
|
||||
$string['adminauthorizeemail'] = 'Email Sending Settings';
|
||||
$string['adminauthorizesettings'] = 'Authorize.net Settings';
|
||||
$string['adminauthorizewide'] = 'Site-Wide Settings';
|
||||
$string['admincronsetup'] = 'The cron.php maintenance script has not been run for at least 24 hours. <br />Cron must be enabled if you want to use autocapture feature.<br /><a href=\"../doc/?frame=install.html&sub=cron\">Setup cron</a> or uncheck an_review again.<br />If you disable autocapture, transactions will be cancelled unless you review them within 30 days.<br />Check an_review and enter \'0\' to an_capture_day field<br />if you want to manually accept/deny payments within 30 days.';
|
||||
$string['adminhelpcapture'] = 'Not only I want to manually accept/deny payments. But also, use autocapture to prevent cancelling payment. What will I do?
|
||||
|
||||
- Setup cron.
|
||||
- Check an_review.
|
||||
- Enter a number between 1 and 29 to an_capture_day field. Card will be captured and user will be enrolled to course unless you capture it within an_capture_day.';
|
||||
$string['adminhelpreview'] = 'How will I manually accept/deny payments?
|
||||
- Check an_review.
|
||||
- Enter \'0\' to an_capture_day field.
|
||||
|
||||
How students will be enrolled to courses immediately when they entered their card number?
|
||||
- Uncheck an_review.';
|
||||
$string['adminneworder'] = ' Dear Admin,
|
||||
|
||||
You have received a new pending order:
|
||||
@ -25,6 +37,7 @@ $string['adminneworder'] = ' Dear Admin,
|
||||
Also you can accept/deny the payment to enrol the student immediately following this link:
|
||||
$a->url';
|
||||
$string['adminnewordersubject'] = '$a->course: New Pending Order($a->orderid)';
|
||||
$string['adminpendingorders'] = 'You have disabled auto-capture feature.<br />Total $a->count transactions with a status of AN_STATUS_AUTH will be cancelled unless you check it.<br />To accept/deny payments go to <a href=\'$a->url\'>Payment Management</a> page.';
|
||||
$string['adminreview'] = 'Review order before processing the credit card.';
|
||||
$string['amount'] = 'Amount';
|
||||
$string['anlogin'] = 'Authorize.net: Login name';
|
||||
@ -67,6 +80,17 @@ $string['notsettled'] = 'Not settled';
|
||||
$string['orderid'] = 'Order ID';
|
||||
$string['paymentmanagement'] = 'Payment Management';
|
||||
$string['paymentpending'] = 'Your payment is pending for this course with this order number $a->orderid.';
|
||||
$string['pendingordersemail'] = ' Dear admin,
|
||||
|
||||
$a->pending transactions will be expired unless you accept payment with in 2 days.
|
||||
|
||||
This is a warning message, because you didn\'t enable autocapture. Means you have to accept or deny payments manually.
|
||||
|
||||
To accept/deny pending payments go to:
|
||||
$a->url
|
||||
|
||||
To enable autocapture, means you will not receive any warning emails anymore, go to:
|
||||
$a->enrolurl';
|
||||
$string['refund'] = 'Refund';
|
||||
$string['refunded'] = 'Refunded';
|
||||
$string['returns'] = 'Returns';
|
||||
|
Loading…
x
Reference in New Issue
Block a user