mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Some UI changes.
This commit is contained in:
parent
6b1d27020d
commit
75bb06e0aa
@ -82,7 +82,7 @@ function authorize_expired(&$order)
|
||||
* @param string &$message Information about error message if this function returns false.
|
||||
* @param object &$extra Extra data that used for refunding and credit card information.
|
||||
* @param int $action Which action will be performed. See AN_ACTION_*
|
||||
* @param int $method Transaction method. AN_METHOD_CC or AN_METHOD_ECHECK
|
||||
* @param string $method Transaction method. AN_METHOD_CC or AN_METHOD_ECHECK
|
||||
* @return bool true Transaction was successful, false otherwise. Use $message for reason.
|
||||
* @author Ethem Evlice <ethem a.t evlice d.o.t com>
|
||||
* @uses $CFG
|
||||
@ -92,8 +92,6 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
global $CFG;
|
||||
static $conststring;
|
||||
|
||||
$test = !empty($CFG->an_test);
|
||||
|
||||
if (!isset($conststring)) {
|
||||
$constdata = array(
|
||||
'x_version' => '3.1',
|
||||
@ -124,10 +122,11 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
$method = AN_METHOD_CC;
|
||||
}
|
||||
elseif ($method != AN_METHOD_CC && $method != AN_METHOD_ECHECK) {
|
||||
$message = "Missing method: $method";
|
||||
$message = "Invalid method: $method";
|
||||
return false;
|
||||
}
|
||||
|
||||
$action = intval($action);
|
||||
if ($method == AN_METHOD_ECHECK) {
|
||||
if ($action != AN_ACTION_AUTH_CAPTURE && $action != AN_ACTION_CREDIT) {
|
||||
$message = "Please perform AUTH_CAPTURE or CREDIT for echecks";
|
||||
@ -135,16 +134,16 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
}
|
||||
}
|
||||
|
||||
$action = intval($action);
|
||||
if ($action <= AN_ACTION_NONE or $action > AN_ACTION_VOID) {
|
||||
$message = "Invalid action!";
|
||||
return false;
|
||||
}
|
||||
|
||||
$poststring = $conststring;
|
||||
$poststring .= '&x_method=' . ($method==AN_METHOD_CC ? 'CC' : 'ECHECK');
|
||||
$poststring .= '&x_method=' . $method;
|
||||
|
||||
$test = !empty($CFG->an_test);
|
||||
$poststring .= '&x_test_request=' . ($test ? 'TRUE' : 'FALSE');
|
||||
$timenowsettle = getsettletime(time());
|
||||
|
||||
switch ($action) {
|
||||
case AN_ACTION_AUTH_ONLY:
|
||||
@ -362,7 +361,7 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
if ($message == '[[' . $reason . ']]') {
|
||||
$message = isset($response[3]) ? $response[3] : 'unknown error';
|
||||
}
|
||||
if (!empty($CFG->an_avs) and $method == AN_METHOD_CC) {
|
||||
if ($method == AN_METHOD_CC and !empty($CFG->an_avs)) {
|
||||
$avs = "avs" . strtolower($response[5]);
|
||||
$stravs = get_string($avs, "enrol_authorize");
|
||||
$message .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
|
||||
|
@ -31,13 +31,8 @@ if (!isset($frm->an_cutoff_hour)) {
|
||||
}
|
||||
|
||||
if (!isset($frm->acceptmethods)) {
|
||||
if (empty($CFG->an_acceptmethods)) {
|
||||
$frm->acceptmethods = array('cc');
|
||||
$CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
|
||||
}
|
||||
else {
|
||||
$frm->acceptmethods = explode(',', $CFG->an_acceptmethods);
|
||||
}
|
||||
$frm->acceptmethods = enrolment_plugin_authorize::get_list_of_payment_methods();
|
||||
$CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
|
||||
}
|
||||
|
||||
if (!isset($frm->acceptccs)) {
|
||||
@ -50,99 +45,100 @@ if (!isset($frm->acceptccs)) {
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
|
||||
<tr valign="top">
|
||||
<td colspan="3" align="right"><a href="../enrol/authorize/index.php"><?php print_string("paymentmanagement", "enrol_authorize") ?></a></td>
|
||||
<td colspan="2" align="right"><a href="../enrol/authorize/index.php"><?php print_string("paymentmanagement", "enrol_authorize") ?></a></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizewide", "enrol_authorize") ?></h4></td></tr>
|
||||
<tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizewide", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_cost:</td>
|
||||
<td><input type="text" size="5" name="enrol_cost" value="<?php p($frm->enrol_cost) ?>" /></td>
|
||||
<td><?php print_string("costdefault") ?>. <?php print_string("costdefaultdesc", "enrol_authorize") ?></td>
|
||||
<td><input type="text" size="5" name="enrol_cost" value="<?php p($frm->enrol_cost) ?>" /><br />
|
||||
<?php print_string("costdefault") ?>. <?php print_string("costdefaultdesc", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_currency:</td>
|
||||
<td><?php choose_from_menu(get_list_of_currencies(), "enrol_currency", $frm->enrol_currency, "","", "") ?></td>
|
||||
<td><?php print_string("currency") ?>
|
||||
<td><?php choose_from_menu(get_list_of_currencies(), "enrol_currency", $frm->enrol_currency, "","", "") ?><br />
|
||||
<?php print_string("currency") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if (substr($CFG->wwwroot, 0, 5) !== 'https') { /* https && loginhttps */ ?>
|
||||
<tr valign="top">
|
||||
<td align="right">loginhttps:</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)
|
||||
?></td>
|
||||
echo (empty($CFG->loginhttps) ? "<font color=\"red\"><b>off</b></font>" : "<font color=\"green\">on</font>");
|
||||
$a->url = "$CFG->wwwroot/$CFG->admin/config.php#configsectionsecurity";
|
||||
echo '<br />'; print_string("logindesc", "enrol_authorize", $a);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } /* end: https && loginhttps */ ?>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizesettings", "enrol_authorize") ?></h4></td></tr>
|
||||
<tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizesettings", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_login:</td>
|
||||
<td><input type="text" name="an_login" value="<?php p($frm->an_login) ?>" /></td>
|
||||
<td><?php print_string("anlogin", "enrol_authorize") ?></td>
|
||||
<td><input type="text" name="an_login" value="<?php p($frm->an_login) ?>" /><br />
|
||||
<?php print_string("anlogin", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"># # </td>
|
||||
<td colspan="2"><?php print_string("chooseone", "enrol_authorize") ?></td>
|
||||
<td><?php print_string("chooseone", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_tran_key:</td>
|
||||
<td><input type="text" name="an_tran_key" value="<?php p($frm->an_tran_key) ?>" /><sup>#1</sup></td>
|
||||
<td><?php print_string("antrankey", "enrol_authorize") ?></td>
|
||||
<td><input type="text" name="an_tran_key" value="<?php p($frm->an_tran_key) ?>" /><sup>#1</sup><br />
|
||||
<?php print_string("antrankey", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_password:</td>
|
||||
<td><input type="text" name="an_password" value="" /><sup>#2</sup></td>
|
||||
<td><?php print_string("anpassword", "enrol_authorize") ?><br />(<?php print_string("leavetokeep") ?>)</td>
|
||||
<td><input type="text" name="an_password" value="" /><sup>#2</sup><br />
|
||||
<?php print_string("anpassword", "enrol_authorize") ?><br />(<?php print_string("leavetokeep") ?>)</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">delete_current:</td>
|
||||
<td><?php print_checkbox('delete_current', '1', !empty($frm->delete_current)) ?></td>
|
||||
<td><?php print_string("deletecheck", "moodle", get_string('oldpassword')) ?><br /><br /></td>
|
||||
<td><?php print_checkbox('delete_current', '1', !empty($frm->delete_current)) ?> <br />
|
||||
<?php print_string("deletecheck", "moodle", get_string('oldpassword')) ?><br /><br /></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_referer:</td>
|
||||
<td><input type="text" name="an_referer" value="<?php p($frm->an_referer) ?>" /></td>
|
||||
<td><?php print_string("anreferer", "enrol_authorize") ?></td>
|
||||
<td><input type="text" name="an_referer" value="<?php p($frm->an_referer) ?>" /><br />
|
||||
<?php print_string("anreferer", "enrol_authorize") ?></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>
|
||||
<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); ?><br />
|
||||
<?php print_string("cutofftime", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_avs:</td>
|
||||
<td><?php print_checkbox('an_avs', '1', !empty($frm->an_avs)) ?></td>
|
||||
<td><?php print_string("adminavs", "enrol_authorize") ?></td>
|
||||
<td><?php print_checkbox('an_avs', '1', !empty($frm->an_avs)) ?><br />
|
||||
<?php print_string("adminavs", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_test:</td>
|
||||
<td><?php print_checkbox('an_test', '1', !empty($frm->an_test)) ?></td>
|
||||
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
|
||||
<td><?php print_checkbox('an_test', '1', !empty($frm->an_test)) ?><br />
|
||||
<?php print_string("antestmode", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_acceptmethods:</td>
|
||||
<td><?php
|
||||
$allmethods = array('CC','ECHECK');
|
||||
foreach ($allmethods as $key) {
|
||||
print_checkbox('acceptmethods[]', strtolower($key), stristr($CFG->an_acceptmethods, $key) !== false, $key); echo "<br />\n";
|
||||
$allpaymentmethods = enrolment_plugin_authorize::get_list_of_payment_methods(true);
|
||||
$paymentmethodsenabled = enrolment_plugin_authorize::get_list_of_payment_methods();
|
||||
foreach ($allpaymentmethods as $key) {
|
||||
print_checkbox('acceptmethods[]', $key, in_array($key, $paymentmethodsenabled), get_string('method'.strtolower($key),'enrol_authorize')); echo "<br />\n";
|
||||
}
|
||||
?></td>
|
||||
<td><?php print_string("adminacceptmethods", "enrol_authorize") ?></td>
|
||||
?><br /><?php print_string("adminacceptmethods", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
@ -152,41 +148,40 @@ if (!isset($frm->acceptccs)) {
|
||||
foreach ($allccs as $key => $val) {
|
||||
print_checkbox('acceptccs[]', $key, stristr($CFG->an_acceptccs, $key) !== false, $val); echo "<br />\n";
|
||||
}
|
||||
?></td>
|
||||
<td><?php print_string("adminacceptccs", "enrol_authorize") ?></td>
|
||||
?><br /><?php print_string("adminacceptccs", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?>
|
||||
<tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?>
|
||||
<?php helpbutton('orderreview', '', 'enrol/authorize'); ?>
|
||||
</h4></td></tr>
|
||||
</h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_review:</td>
|
||||
<td><?php print_checkbox('an_review', '1', !empty($frm->an_review)) ?>
|
||||
<?php helpbutton('review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol/authorize'); ?></td>
|
||||
<td><?php print_string("adminreview", "enrol_authorize") ?></td>
|
||||
<?php helpbutton('review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol/authorize'); ?><br />
|
||||
<?php print_string("adminreview", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<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('captureday', get_string('adminhelpcapturetitle', 'enrol_authorize'), 'enrol/authorize'); ?></td>
|
||||
<td><?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
|
||||
<?php helpbutton('captureday', get_string('adminhelpcapturetitle', 'enrol_authorize'), 'enrol/authorize'); ?><br />
|
||||
<?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeemail", "enrol_authorize") ?></h4></td></tr>
|
||||
<tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizeemail", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<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) ?><br />
|
||||
<td><input type="text" name="an_emailexpired" size="1" maxlength="1" value="<?php p($frm->an_emailexpired) ?>" /><br />
|
||||
<?php print_string("adminemailexpired", "enrol_authorize", $frm->an_emailexpired) ?><br />
|
||||
<?php print_string("adminemailexpsetting", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_emailexpiredteacher:</td>
|
||||
<td><?php print_checkbox('an_emailexpiredteacher', '1', !empty($frm->an_emailexpiredteacher)) ?></td>
|
||||
<td><?php print_string("adminemailexpiredteacher", "enrol_authorize") ?></td>
|
||||
<td><?php print_checkbox('an_emailexpiredteacher', '1', !empty($frm->an_emailexpiredteacher)) ?><br />
|
||||
<?php print_string("adminemailexpiredteacher", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
@ -194,26 +189,26 @@ if (!isset($frm->acceptccs)) {
|
||||
<td><?php
|
||||
$sorts = array('ttl' => get_string('adminemailexpiredsortsum', 'enrol_authorize'),
|
||||
'cnt' => get_string('adminemailexpiredsortcount', 'enrol_authorize'));
|
||||
choose_from_menu($sorts, "an_sorttype", $frm->an_sorttype, "","", "") ?></td>
|
||||
<td><?php print_string("adminemailexpiredsort", "enrol_authorize") ?></td>
|
||||
choose_from_menu($sorts, "an_sorttype", $frm->an_sorttype, "","", "") ?><br />
|
||||
<?php print_string("adminemailexpiredsort", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailstudents:</td>
|
||||
<td><?php print_checkbox('enrol_mailstudents', '1', !empty($frm->enrol_mailstudents)) ?></td>
|
||||
<td><?php print_string("mailstudents") ?></td>
|
||||
<td><?php print_checkbox('enrol_mailstudents', '1', !empty($frm->enrol_mailstudents)) ?><br />
|
||||
<?php print_string("mailstudents") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailteachers:</td>
|
||||
<td><?php print_checkbox('enrol_mailteachers', '1', !empty($frm->enrol_mailteachers)) ?></td>
|
||||
<td><?php print_string("mailteachers") ?></td>
|
||||
<td><?php print_checkbox('enrol_mailteachers', '1', !empty($frm->enrol_mailteachers)) ?><br />
|
||||
<?php print_string("mailteachers") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailadmins:</td>
|
||||
<td><?php print_checkbox('enrol_mailadmins', '1', !empty($frm->enrol_mailadmins)) ?></td>
|
||||
<td><?php print_string("mailadmins") ?></td>
|
||||
<td><?php print_checkbox('enrol_mailadmins', '1', !empty($frm->enrol_mailadmins)) ?><br />
|
||||
<?php print_string("mailadmins") ?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
@ -6,8 +6,8 @@
|
||||
* Credit Card (CC)
|
||||
* ECheck (ECHECK)
|
||||
*/
|
||||
define('AN_METHOD_CC', 1);
|
||||
define('AN_METHOD_ECHECK', 2);
|
||||
define('AN_METHOD_CC', 'CC');
|
||||
define('AN_METHOD_ECHECK', 'ECHECK');
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
@ -47,7 +47,7 @@ define('AN_STATUS_TEST', 0x80);
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Actions used in authorizenet_action function.
|
||||
* Actions used in authorize_action function.
|
||||
*
|
||||
* NONE: No action. Function always returns false.
|
||||
* AUTH_ONLY: Used to authorize only, don't capture.
|
||||
|
@ -19,7 +19,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
|
||||
?>
|
||||
|
||||
<p align="center"><?php if (!empty($this->ccerrors['header'])) { formerr($this->ccerrors['header']); } ?></p>
|
||||
<p align="center"><?php if (!empty($this->authorizeerrors['header'])) { formerr($this->authorizeerrors['header']); } ?></p>
|
||||
|
||||
<div align="center">
|
||||
|
||||
@ -30,16 +30,26 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
<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>
|
||||
<?php if (false) { /* ECHECK: active */ ?>
|
||||
<tr>
|
||||
<td align="right" colspan="2"><?php
|
||||
$a = new stdClass;
|
||||
$a->url = 'enrol.php?id='.$course->id.'&paymentmethod='.AN_METHOD_ECHECK;
|
||||
print_string("usingecheckmethod", "enrol_authorize", $a);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } /* end: ECHECK */ ?>
|
||||
<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) ?>" />
|
||||
<?php if (!empty($this->ccerrors['cc'])) { formerr($this->ccerrors['cc']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['cc'])) { formerr($this->authorizeerrors['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) ?>" />
|
||||
<?php if (!empty($this->ccerrors['ccfirstlast'])) { formerr($this->ccerrors['ccfirstlast']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['ccfirstlast'])) { formerr($this->authorizeerrors['ccfirstlast']); } ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("ccexpire", "enrol_authorize") ?>: </td>
|
||||
@ -54,14 +64,14 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
$years[$i] = $i;
|
||||
}
|
||||
choose_from_menu($years, 'ccexpireyyyy', $form->ccexpireyyyy);
|
||||
if (!empty($this->ccerrors['ccexpire'])) { formerr($this->ccerrors['ccexpire']); }
|
||||
if (!empty($this->authorizeerrors['ccexpire'])) { formerr($this->authorizeerrors['ccexpire']); }
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><?php
|
||||
choose_from_menu(enrolment_plugin_authorize::get_list_of_creditcards(), 'cctype', $form->cctype);
|
||||
if (!empty($this->ccerrors['cctype'])) { formerr($this->ccerrors['cctype']); }
|
||||
if (!empty($this->authorizeerrors['cctype'])) { formerr($this->authorizeerrors['cctype']); }
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@ -69,24 +79,24 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
<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) ?>" />
|
||||
<?php helpbutton('', '', 'enrol_authorize', true, 'cvv', get_string('ccvvhelp', 'enrol_authorize')); ?>
|
||||
<?php if (!empty($this->ccerrors['cvv'])) { formerr($this->ccerrors['cvv']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['cvv'])) { formerr($this->authorizeerrors['cvv']); } ?></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) ?>" />
|
||||
<?php if (!empty($this->ccerrors['ccaddress'])) { formerr($this->ccerrors['ccaddress']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['ccaddress'])) { formerr($this->authorizeerrors['ccaddress']); } ?></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) ?>" />
|
||||
<?php if (!empty($this->ccerrors['cccity'])) { formerr($this->ccerrors['cccity']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['cccity'])) { formerr($this->authorizeerrors['cccity']); } ?></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")."..."); ?>
|
||||
<?php if (!empty($this->ccerrors['cccountry'])) { formerr($this->ccerrors['cccountry']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['cccountry'])) { formerr($this->authorizeerrors['cccountry']); } ?></td>
|
||||
</tr>
|
||||
<?php } else { /* not AVS */ ?>
|
||||
<tr>
|
||||
@ -101,7 +111,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
<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) ?>" />
|
||||
<?php if (!empty($this->ccerrors['cczip'])) { formerr($this->ccerrors['cczip']); } ?></td>
|
||||
<?php if (!empty($this->authorizeerrors['cczip'])) { formerr($this->authorizeerrors['cczip']); } ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" name="ccsubmit" value="<?php print_string("sendpaymentbutton", "enrol_authorize") ?>">
|
||||
|
@ -10,12 +10,12 @@ require_once($CFG->dirroot.'/enrol/authorize/const.php');
|
||||
class enrolment_plugin_authorize
|
||||
{
|
||||
/**
|
||||
* Credit card error messages.
|
||||
* Credit card and Echeck error messages.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $ccerrors = array();
|
||||
var $authorizeerrors = array();
|
||||
|
||||
/**
|
||||
* Cron log.
|
||||
@ -89,7 +89,9 @@ class enrolment_plugin_authorize
|
||||
$strcourses = get_string('courses');
|
||||
$strloginto = get_string('loginto', '', $course->shortname);
|
||||
|
||||
print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto");
|
||||
print_header($strloginto,
|
||||
$course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto");
|
||||
print_course($course, '80%');
|
||||
|
||||
if ($course->password) {
|
||||
@ -126,16 +128,30 @@ class enrolment_plugin_authorize
|
||||
* @param object $course Course info
|
||||
* @access public
|
||||
*/
|
||||
function check_entry($form, $course) {
|
||||
function check_entry($form, $course)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
if (enrolment_plugin_authorize::zero_cost($course) or
|
||||
(!empty($course->password) and !empty($form->password))) {
|
||||
(!empty($course->password) and !empty($form->password))) { // MANUAL ENROLMENT
|
||||
$manual = enrolment_factory::factory('manual');
|
||||
$manual->check_entry($form, $course);
|
||||
if (!empty($manual->errormsg)) {
|
||||
$this->errormsg = $manual->errormsg;
|
||||
}
|
||||
} elseif ((!empty($form->ccsubmit)) and $this->validate_enrol_form($form)) {
|
||||
$this->cc_submit($form, $course);
|
||||
}
|
||||
else { // AUTHORIZE.NET ENROLMENT
|
||||
$paymentmethodsenabled = enrolment_plugin_authorize::get_list_of_payment_methods();
|
||||
if (in_array(AN_METHOD_CC, $paymentmethodsenabled) and
|
||||
!empty($form->ccsubmit) and
|
||||
$this->validate_cc_form($form)) {
|
||||
$this->cc_submit($form, $course);
|
||||
}
|
||||
elseif (in_array(AN_METHOD_ECHECK, $paymentmethodsenabled) and
|
||||
!empty($form->echecksubmit) and
|
||||
$this->validate_echeck_form($form)) {
|
||||
$this->echeck_submit($form, $course);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +191,7 @@ class enrolment_plugin_authorize
|
||||
$order->id = insert_record("enrol_authorize", $order);
|
||||
if (!$order->id) {
|
||||
enrolment_plugin_authorize::email_to_admin("Error while trying to insert new data", $order);
|
||||
$this->ccerrors['header'] = "Insert record error. Admin has been notified!";
|
||||
$this->authorizeerrors['header'] = "Insert record error. Admin has been notified!";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -209,7 +225,7 @@ class enrolment_plugin_authorize
|
||||
$success = authorize_action($order, $message, $extra, $action);
|
||||
if (!$success) {
|
||||
enrolment_plugin_authorize::email_to_admin($message, $order);
|
||||
$this->ccerrors['header'] = $message;
|
||||
$this->authorizeerrors['header'] = $message;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -306,72 +322,88 @@ class enrolment_plugin_authorize
|
||||
redirect($destination);
|
||||
}
|
||||
|
||||
function echeck_submit($form, $course)
|
||||
{
|
||||
global $CFG, $USER, $SESSION;
|
||||
require_once('authorizenetlib.php');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validate_enrol_form
|
||||
* validate_cc_form (static method)
|
||||
*
|
||||
* @param object $form Form parameters
|
||||
* @access private
|
||||
* @param unknown_type $form
|
||||
* @return bool
|
||||
*/
|
||||
function validate_enrol_form($form)
|
||||
function validate_cc_form($form)
|
||||
{
|
||||
global $CFG;
|
||||
require_once('ccval.php');
|
||||
|
||||
if (empty($form->cc)) {
|
||||
$this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
|
||||
$this->authorizeerrors['cc'] = get_string('missingcc', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->ccexpiremm) || empty($form->ccexpireyyyy)) {
|
||||
$this->ccerrors['ccexpire'] = get_string('missingccexpire', 'enrol_authorize');
|
||||
$this->authorizeerrors['ccexpire'] = get_string('missingccexpire', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$expdate = sprintf("%02d", intval($form->ccexpiremm)) . $form->ccexpireyyyy;
|
||||
$validcc = CCVal($form->cc, $form->cctype, $expdate);
|
||||
if (!$validcc) {
|
||||
if ($validcc === 0) {
|
||||
$this->ccerrors['ccexpire'] = get_string('ccexpired', 'enrol_authorize');
|
||||
$this->authorizeerrors['ccexpire'] = get_string('ccexpired', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$this->ccerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
$this->authorizeerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($form->ccfirstname) || empty($form->cclastname)) {
|
||||
$this->ccerrors['ccfirstlast'] = get_string('missingfullname');
|
||||
$this->authorizeerrors['ccfirstlast'] = get_string('missingfullname');
|
||||
}
|
||||
|
||||
if (empty($form->cvv) || !is_numeric($form->cvv)) {
|
||||
$this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
|
||||
$this->authorizeerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
|
||||
}
|
||||
|
||||
if (empty($form->cctype) or
|
||||
!in_array($form->cctype, array_keys(enrolment_plugin_authorize::get_list_of_creditcards()))) {
|
||||
$this->ccerrors['cctype'] = get_string('missingcctype', 'enrol_authorize');
|
||||
$this->authorizeerrors['cctype'] = get_string('missingcctype', 'enrol_authorize');
|
||||
}
|
||||
|
||||
if (!empty($CFG->an_avs)) {
|
||||
if (empty($form->ccaddress)) {
|
||||
$this->ccerrors['ccaddress'] = get_string('missingaddress', 'enrol_authorize');
|
||||
$this->authorizeerrors['ccaddress'] = get_string('missingaddress', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->cccity)) {
|
||||
$this->ccerrors['cccity'] = get_string('missingcity');
|
||||
$this->authorizeerrors['cccity'] = get_string('missingcity');
|
||||
}
|
||||
if (empty($form->cccountry)) {
|
||||
$this->ccerrors['cccountry'] = get_string('missingcountry');
|
||||
$this->authorizeerrors['cccountry'] = get_string('missingcountry');
|
||||
}
|
||||
}
|
||||
if (empty($form->cczip) || !is_numeric($form->cczip)) {
|
||||
$this->ccerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
|
||||
$this->authorizeerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
|
||||
}
|
||||
|
||||
if (!empty($this->ccerrors)) {
|
||||
$this->ccerrors['header'] = get_string('someerrorswerefound');
|
||||
if (!empty($this->authorizeerrors)) {
|
||||
$this->authorizeerrors['header'] = get_string('someerrorswerefound');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function validate_echeck_form($form)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets access icons.
|
||||
@ -481,7 +513,9 @@ class enrolment_plugin_authorize
|
||||
set_config('an_test', optional_param('an_test', 0, PARAM_BOOL));
|
||||
set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
|
||||
|
||||
$acceptmethods = optional_param('acceptmethods', array('cc'), PARAM_ALPHA);
|
||||
$acceptmethods = optional_param('acceptmethods',
|
||||
enrolment_plugin_authorize::get_list_of_payment_methods(),
|
||||
PARAM_ALPHA);
|
||||
set_config('an_acceptmethods', implode(',', $acceptmethods));
|
||||
|
||||
$acceptccs = optional_param('acceptccs',
|
||||
@ -678,6 +712,29 @@ class enrolment_plugin_authorize
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function get_list_of_payment_methods($getall = false)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
$alltypes = array(AN_METHOD_CC, AN_METHOD_ECHECK);
|
||||
|
||||
if ($getall) {
|
||||
return $alltypes;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
if (empty($CFG->an_acceptmethods)) {
|
||||
$ret[] = AN_METHOD_CC; // default
|
||||
}
|
||||
else {
|
||||
$mthds = explode(',', $CFG->an_acceptmethods);
|
||||
foreach ($mthds as $mthd) {
|
||||
$ret[] = $mthd;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is run by admin/cron.php every time if admin has enabled this plugin.
|
||||
|
Loading…
x
Reference in New Issue
Block a user