Permalink
Browse files

Address Verification System (AVS).

  • Loading branch information...
ethem
ethem committed Jan 5, 2006
1 parent e1e35bb commit 4bfda899b666ee275108567f71e1a4358343d838
Showing with 49 additions and 9 deletions.
  1. +8 −1 enrol/authorize/config.html
  2. +15 −0 enrol/authorize/enrol.html
  3. +26 −8 enrol/authorize/enrol.php
@@ -10,6 +10,7 @@
if (!isset($frm->an_tran_key)) $frm->an_tran_key = '';
if (!isset($frm->an_password)) $frm->an_password = '';
if (!isset($frm->an_referer)) $frm->an_referer = 'http://';
+if (!isset($frm->an_avs)) $frm->an_avs = '';
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';
@@ -38,7 +39,7 @@
<tr valign="top">
<td align="right">loginhttps:</td>
- <td><?php echo (empty($CFG->loginhttps) ? "<font color=\"red\">off</font>" : "<font color=\"green\">on</font>") ?></td>
+ <td><?php echo (empty($CFG->loginhttps) ? "<font color=\"red\"><b>off</b></font>" : "<font color=\"green\">on</font>") ?></td>
<td><?php
$a->url = "$CFG->wwwroot/$CFG->admin/config.php#configsectionsecurity";
print_string("logindesc", "enrol_authorize", $a)
@@ -76,6 +77,12 @@
<td><?php print_string("anreferer", "enrol_authorize") ?></td>
</tr>
+<tr valign="top">
+ <td align="right">an_avs:</td>
+ <td><input type="checkbox" value="1" name="an_avs" <?php if (!empty($frm->an_avs)) echo "checked=\"true\"" ?> /></td>
+ <td><?php print_string("adminavs", "enrol_authorize") ?></td>
+</tr>
+
<tr valign="top">
<td align="right">an_test:</td>
<td><input type="checkbox" value="1" name="an_test" <?php if (!empty($frm->an_test)) echo "checked=\"true\"" ?> /></td>
View
@@ -50,6 +50,21 @@
<td align="left"><input type="text" name="cvv" size="4" maxlength="4" value="<?php p($form->cvv) ?>" />
<?php helpbutton('', '', 'enrol_authorize', true, 'cvv', get_string('ccvvhelp', 'enrol_authorize')); ?></td>
</tr>
+<?php if (!empty($CFG->an_avs)) { /* Address Verification System */ ?>
+<tr>
+ <td align="right"><?php print_string("address") ?>: </td>
+ <td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" /></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("city") ?> / <?php print_string("state") ?>: </td>
+ <td align="left"><input type="text" name="cccity" size="16" value="<?php p($usercity) ?>" /> /
+ <input type="text" name="ccstate" size="2" maxlength="2" value="<?php p($form->ccstate) ?>" /></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("country") ?>: </td>
+ <td align="left"><?php choose_from_menu(get_list_of_countries(), "cccountry", $usercountry, get_string("selectacountry")."..."); ?></td>
+</tr>
+<?php } ?>
<tr>
<td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
<td align="left"><input type="text" name="cczip" size="5" value="<?php p($form->cczip) ?>" /></td>
View
@@ -95,7 +95,8 @@ function print_entry($course)
}
}
- $formvars = array('password','ccfirstname','cclastname','cc','ccexpiremm','ccexpireyyyy','cctype','cvv','cczip');
+ $formvars = array('password', 'ccfirstname', 'cclastname', 'cc', 'ccexpiremm', 'ccexpireyyyy', 'cctype', 'cvv',
+ 'ccaddress', 'cccity', 'ccstate', 'cccountry', 'cczip');
foreach ($formvars as $var) {
if (!isset($form->$var)) {
$form->$var = '';
@@ -105,9 +106,13 @@ function print_entry($course)
$teacher = get_teacher($course->id);
$strloginto = get_string("loginto", "", $course->shortname);
$strcourses = get_string("courses");
+ $curcost = $this->get_course_cost($course);
+
$userfirstname = empty($form->ccfirstname) ? $USER->firstname : $form->ccfirstname;
$userlastname = empty($form->cclastname) ? $USER->lastname : $form->cclastname;
- $curcost = $this->get_course_cost($course);
+ $useraddress = empty($form->ccaddress) ? $USER->address : $form->ccaddress;
+ $usercity = empty($form->cccity) ? $USER->city : $form->cccity;
+ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto");
print_course($course, "80%");
@@ -163,9 +168,11 @@ function cc_submit($form, $course)
return;
}
- if (!empty($CFG->an_test)) {
- error("Credit card module cannot be present because of test mode");
- return;
+ if (!empty($CFG->an_avs)) {
+ if (empty($form->ccaddress) || empty($form->cccity) || empty($form->cccountry)) {
+ $this->ccerrormsg = get_string("allfieldsrequired");
+ return;
+ }
}
$this->prevent_double_paid($course);
@@ -190,6 +197,7 @@ function cc_submit($form, $course)
$order->userid = $USER->id;
$order->status = AN_STATUS_NONE; // it will be changed...
$order->settletime = 0; // cron changes this.
+ $order->transid = 0; // Transaction Id
$order->timecreated = $timenow;
$order->amount = $curcost['cost'];
$order->currency = $curcost['currency'];
@@ -232,8 +240,16 @@ function cc_submit($form, $course)
return;
}
- if (intval($order->transid) == 0) { // I know it is test mode. :)
- error("Credit card module cannot be present because of test mode");
+ if (intval($order->transid) == 0) { // TEST MODE
+ if ($an_review) {
+ redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
+ }
+ else {
+ $timestart = $timenow;
+ $timeend = $timestart + (3600 * 24); // just enrol for 1 days :)
+ enrol_student($USER->id, $course->id, $timestart, $timeend, 'authorize');
+ redirect("$CFG->wwwroot/course/view.php?id=$course->id");
+ }
return;
}
@@ -464,6 +480,7 @@ function process_config($config)
// AUTHORIZE.NET config
// not required!
+ set_config('an_avs', optional_param('an_avs', '') );
set_config('an_test', optional_param('an_test', '') );
set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL) );
set_config('an_cutoff_hour', optional_param('an_cutoff_hour', '0') );
@@ -613,7 +630,7 @@ function cron()
//CAPTURE-MANUALLY
if (intval($CFG->an_capture_day < 1)) {
if (empty($CFG->an_emailexpired)) {
- return; // no information email.
+ return; // no information email.
}
if (intval($mconfig->an_nextmail) > $timenow) {
return; // One day must passed.
@@ -626,6 +643,7 @@ function cron()
}
$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);

0 comments on commit 4bfda89

Please sign in to comment.