From 4bfda899b666ee275108567f71e1a4358343d838 Mon Sep 17 00:00:00 2001 From: ethem Date: Thu, 5 Jan 2006 14:30:49 +0000 Subject: [PATCH] Address Verification System (AVS). --- enrol/authorize/config.html | 9 ++++++++- enrol/authorize/enrol.html | 15 +++++++++++++++ enrol/authorize/enrol.php | 34 ++++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index 88fe854bc61..9bd06726030 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -10,6 +10,7 @@ if (!isset($frm->an_login)) $frm->an_login = ''; 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 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5'; loginhttps: - loginhttps) ? "off" : "on") ?> + loginhttps) ? "off" : "on") ?> url = "$CFG->wwwroot/$CFG->admin/config.php#configsectionsecurity"; print_string("logindesc", "enrol_authorize", $a) @@ -76,6 +77,12 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5'; + + an_avs: + an_avs)) echo "checked=\"true\"" ?> /> + + + an_test: an_test)) echo "checked=\"true\"" ?> /> diff --git a/enrol/authorize/enrol.html b/enrol/authorize/enrol.html index c6dae9a7537..50602958bb5 100755 --- a/enrol/authorize/enrol.html +++ b/enrol/authorize/enrol.html @@ -50,6 +50,21 @@ +an_avs)) { /* Address Verification System */ ?> + + : + + + + / : + / + + + + : + + + : diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 5254a932566..08c977e9071 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -95,7 +95,8 @@ class enrolment_plugin extends enrolment_base } } - $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 @@ class enrolment_plugin extends enrolment_base $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, "wwwroot/course/\">$strcourses -> $strloginto"); print_course($course, "80%"); @@ -163,9 +168,11 @@ class enrolment_plugin extends enrolment_base 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 @@ class enrolment_plugin extends enrolment_base $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 @@ class enrolment_plugin extends enrolment_base 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 @@ class enrolment_plugin extends enrolment_base // 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 @@ class enrolment_plugin extends enrolment_base //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 @@ class enrolment_plugin extends enrolment_base } $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);