Skip to content
Browse files

Send warning email to admins X days ago

how many status of 'authorized/pending capture' transaction is there,
 before transactions have expired.
  • Loading branch information...
1 parent ebc763c commit e74d4dc1b448bf2cb41a5ccc4396898c69c2a6a9 ethem committed
Showing with 29 additions and 16 deletions.
  1. +10 −3 enrol/authorize/config.html
  2. +18 −13 enrol/authorize/enrol.php
  3. +1 −0 lang/en/enrol_authorize.php
View
13 enrol/authorize/config.html
@@ -13,6 +13,7 @@
if (!isset($frm->an_test)) $frm->an_test = '';
if (!isset($frm->an_review)) $frm->an_review = '';
if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
+if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0';
if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
@@ -84,6 +85,12 @@
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?></h4></td></tr>
<tr valign="top">
+ <td align="right">an_cutoff:</td>
+ <td><?php print_time_selector("an_cutoff_hour","an_cutoff_min",make_timestamp(2000,1,1,$frm->an_cutoff_hour,$frm->an_cutoff_min),5); ?></td>
+ <td><?php print_string("cutofftime", "enrol_authorize") ?></td>
+</tr>
+
+<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\"" ?> />
<?php helpbutton('', '', 'enrol_authorize', true, 'review', get_string('adminhelpreview', 'enrol_authorize')); ?></td>
@@ -98,9 +105,9 @@
</tr>
<tr valign="top">
- <td align="right">an_cutoff:</td>
- <td><?php print_time_selector("an_cutoff_hour","an_cutoff_min",make_timestamp(2000,1,1,$frm->an_cutoff_hour,$frm->an_cutoff_min),5); ?></td>
- <td><?php print_string("cutofftime", "enrol_authorize") ?></td>
+ <td align="right">an_emailexpired:</td>
+ <td><input type="text" name="an_emailexpired" size="1" maxlength="1" value="<?php p($frm->an_emailexpired) ?>" /></td>
+ <td><?php print_string("adminemailexpired", "enrol_authorize", $frm->an_emailexpired) ?></td>
</tr>
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeemail", "enrol_authorize") ?></h4></td></tr>
View
31 enrol/authorize/enrol.php
@@ -490,7 +490,13 @@ function process_config($config)
// review disabled. cron is not required. AUTH_CAPTURE works.
set_config('an_review', $review_val);
} else {
- // review enabled.
+ // REVIEW ENABLED.
+ // an_emailexpired: default=2, min=0, max=5.
+ $an_emailexpired_val = optional_param('an_emailexpired', 2, PARAM_INT);
+ if ($an_emailexpired_val < 0) $an_emailexpired_val = 0;
+ elseif ($an_emailexpired_val > 5) $an_emailexpired_val = 5;
+ set_config('an_emailexpired', $an_emailexpired_val);
+
$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;
@@ -601,21 +607,20 @@ function cron()
}
if (empty($CFG->an_review) || !empty($CFG->an_test)) {
- return;
+ return; // review disabled, auth_capture works.
}
+ //CAPTURE-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);
+ if (empty($CFG->an_emailexpired)) {
+ return; // no information email.
+ }
+ if (intval($mconfig->an_nextmail) > $timenow) {
+ return; // One day must passed.
+ }
+ $timediffem = $timenowsettle - ((30 - intval($CFG->an_emailexpired)) * 3600 * 24);
$select = "(status = '" . AN_STATUS_AUTH . "') AND " .
- "(timecreated < '$timediff28') AND (timecreated > '$timediff30')";
+ "(timecreated < '$timediffem') AND (timecreated > '$timediff30')";
if (!$count = count_records_select('enrol_authorize', $select)) {
return;
}
@@ -630,7 +635,7 @@ function cron()
return;
}
- // AUTO-CAPTURE: Transaction must be captured within 30 days. Otherwise it will expired.
+ // CAPTURE-AUTO: Transaction must be captured within 30 days.
$timediffcnf = $timenowsettle - (intval($CFG->an_capture_day) * 3600 * 24);
$sql = "SELECT E.*, C.fullname, C.enrolperiod " .
"FROM {$CFG->prefix}enrol_authorize E " .
View
1 lang/en/enrol_authorize.php
@@ -7,6 +7,7 @@
$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['adminemailexpired'] = 'Send warning email to admins <b>$a</b> days ago how many status of \'authorized/pending capture\' transaction is there, before transactions have expired. (0=disable sending email, default=2, max=5)<br />This is useful if you enabled capturing manually (an_review=checked, an_capture_day=0).';
$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.

0 comments on commit e74d4dc

Please sign in to comment.
Something went wrong with that request. Please try again.