Address Verification System (AVS).
This commit is contained in:
@@ -90,6 +90,16 @@
|
||||
</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>
|
||||
|
||||
@@ -56,6 +56,21 @@
|
||||
<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>
|
||||
</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>
|
||||
|
||||
+47
-28
@@ -13,21 +13,21 @@ define('AN_ENCAP', '"');
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php");
|
||||
|
||||
class enrolment_plugin extends enrolment_base {
|
||||
|
||||
|
||||
var $ccerrormsg;
|
||||
|
||||
/// Override: print_entry()
|
||||
function print_entry($course) {
|
||||
global $CFG, $USER, $form;
|
||||
|
||||
|
||||
if ($this->zero_cost($course) || isguest()) {
|
||||
parent::print_entry($course);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// check paid?
|
||||
$this->check_paid();
|
||||
|
||||
|
||||
// I want to paid on SSL.
|
||||
if (empty($_SERVER['HTTPS'])) {
|
||||
if (empty($CFG->loginhttps)) {
|
||||
@@ -40,23 +40,27 @@ 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 = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$teacher = get_teacher($course->id);
|
||||
$cost = $this->get_course_cost($course);
|
||||
$strloginto = get_string("loginto", "", $course->shortname);
|
||||
$strcourses = get_string("courses");
|
||||
$userfirstname = empty($form->ccfirstname) ? $USER->firstname : $form->ccfirstname;
|
||||
$userlastname = empty($form->cclastname) ? $USER->lastname : $form->cclastname;
|
||||
$cost = $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%");
|
||||
|
||||
|
||||
if ($course->password) {
|
||||
print_simple_box(get_string('choosemethod', 'enrol_authorize'), 'center');
|
||||
$password = '';
|
||||
@@ -66,7 +70,7 @@ class enrolment_plugin extends enrolment_base {
|
||||
print_simple_box_start("center");
|
||||
include($CFG->dirroot . '/enrol/authorize/enrol.html');
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
print_footer();
|
||||
}
|
||||
|
||||
@@ -91,14 +95,24 @@ class enrolment_plugin extends enrolment_base {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($CFG->an_avs)) {
|
||||
if (empty($form->ccaddress) || empty($form->cccity) ||
|
||||
empty($form->cccountry) || empty($form->cczip)) {
|
||||
$this->ccerrormsg = get_string("allfieldsrequired");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$exp_date = (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy);
|
||||
if (! CCVal($form->cc, $form->cctype, $exp_date)) {
|
||||
$this->ccerrormsg = get_string( (($valid_cc===0) ? 'ccexpired' : 'ccinvalid'), 'enrol_authorize' );
|
||||
$valid_cc = CCVal($form->cc, $form->cctype, $exp_date);
|
||||
if (!$valid_cc) {
|
||||
$this->ccerrormsg = get_string((($valid_cc===0) ? 'ccexpired' : 'ccinvalid'), 'enrol_authorize');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->check_paid();
|
||||
$order_number = 0; // can be get from db
|
||||
$cost = $this->get_course_cost($course);
|
||||
$formdata = array (
|
||||
'x_version' => '3.1',
|
||||
'x_delim_data' => 'True',
|
||||
@@ -111,15 +125,15 @@ class enrolment_plugin extends enrolment_base {
|
||||
'x_method' => 'CC',
|
||||
'x_first_name' => $form->ccfirstname,
|
||||
'x_last_name' => $form->cclastname,
|
||||
'x_address' => $USER->address,
|
||||
'x_city' => $USER->city,
|
||||
'x_address' => $form->ccaddress,
|
||||
'x_city' => $form->cccity,
|
||||
'x_zip' => $form->cczip,
|
||||
'x_country' => $USER->country,
|
||||
'x_state' => '',
|
||||
'x_country' => $form->cccountry,
|
||||
'x_state' => $form->ccstate,
|
||||
'x_card_num' => $form->cc,
|
||||
'x_card_code' => $form->cvv,
|
||||
'x_currency_code' => $CFG->enrol_currency,
|
||||
'x_amount' => $this->get_course_cost($course),
|
||||
'x_amount' => $cost,
|
||||
'x_exp_date' => $exp_date,
|
||||
'x_email' => $USER->email,
|
||||
'x_email_customer' => 'False',
|
||||
@@ -137,7 +151,7 @@ class enrolment_plugin extends enrolment_base {
|
||||
$poststring .= $k . "=" . urlencode($v) . "&";
|
||||
}
|
||||
$poststring .= (!empty($CFG->an_tran_key)) ?
|
||||
"x_tran_key" . "=" . urlencode($CFG->an_tran_key):
|
||||
"x_tran_key" . "=" . urlencode($CFG->an_tran_key):
|
||||
"x_password" . "=" . urlencode($CFG->an_password);
|
||||
|
||||
// referer
|
||||
@@ -292,11 +306,11 @@ class enrolment_plugin extends enrolment_base {
|
||||
}
|
||||
|
||||
switch ($CFG->enrol_currency) {
|
||||
case 'EUR': $currency = '€'; break;
|
||||
case 'CAD': $currency = '$'; break;
|
||||
case 'GBP': $currency = '£'; break;
|
||||
case 'JPY': $currency = '¥'; break;
|
||||
default: $currency = '$'; break;
|
||||
case 'EUR': $currency = '€'; break;
|
||||
case 'CAD': $currency = '$'; break;
|
||||
case 'GBP': $currency = '£'; break;
|
||||
case 'JPY': $currency = '¥'; break;
|
||||
default: $currency = '$'; break;
|
||||
}
|
||||
|
||||
$str .= "<p class=\"coursecost\"><font size=-1>$strcost: " .
|
||||
@@ -310,7 +324,7 @@ class enrolment_plugin extends enrolment_base {
|
||||
function config_form($frm) {
|
||||
global $CFG;
|
||||
|
||||
$vars = array('an_login', 'an_tran_key', 'an_password', 'an_referer', 'an_test',
|
||||
$vars = array('an_login', 'an_tran_key', 'an_password', 'an_referer', 'an_avs', 'an_test',
|
||||
'enrol_cost', 'enrol_currency', 'enrol_mailstudents', 'enrol_mailteachers', 'enrol_mailadmins');
|
||||
|
||||
foreach ($vars as $var) {
|
||||
@@ -322,7 +336,7 @@ class enrolment_plugin extends enrolment_base {
|
||||
if (!$this->check_openssl_loaded()) {
|
||||
notify('PHP must be compiled with SSL support (--with-openssl)');
|
||||
}
|
||||
|
||||
|
||||
if (data_submitted()) {
|
||||
// Some required fields
|
||||
if (empty($frm->an_login)) {
|
||||
@@ -350,7 +364,7 @@ class enrolment_plugin extends enrolment_base {
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$return = true;
|
||||
|
||||
if (!isset($config->an_login)) {
|
||||
@@ -381,6 +395,11 @@ class enrolment_plugin extends enrolment_base {
|
||||
}
|
||||
set_config('an_referer', $config->an_referer);
|
||||
|
||||
if (!isset($config->an_avs)) {
|
||||
$config->an_avs = '';
|
||||
}
|
||||
set_config('an_avs', $config->an_avs);
|
||||
|
||||
if (!isset($config->an_test)) {
|
||||
$config->an_test = '';
|
||||
}
|
||||
@@ -419,11 +438,11 @@ class enrolment_plugin extends enrolment_base {
|
||||
$admin = get_admin();
|
||||
$site = get_site();
|
||||
$message = "$site->fullname: Transaction failed.\n\n$subject\n\n";
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$message .= "$key => $value\n";
|
||||
}
|
||||
|
||||
|
||||
email_to_user($admin, $admin, "CC ERROR: ".$subject, $message);
|
||||
}
|
||||
|
||||
@@ -436,6 +455,6 @@ class enrolment_plugin extends enrolment_base {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end of class definition
|
||||
?>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_authorize.php - created with Moodle 1.5.1 (2005060210)
|
||||
// enrol_authorize.php - created with Moodle 1.5.3+ (2005060230)
|
||||
|
||||
|
||||
$string['adminavs'] = 'Check this if you have activated Address Verification System (AVS) in your authorize.net account. This demands address fields like street, state, country and zip when user fills out payment form.';
|
||||
$string['anlogin'] = 'Authorize.net: Login name';
|
||||
$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.';
|
||||
|
||||
Reference in New Issue
Block a user