mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Admin can setup which credit card types will be accepted.
Merged from MOODLE_16_STABLE.
This commit is contained in:
parent
0045d58c69
commit
4a1e506a35
@ -21,8 +21,13 @@ if (isset($CFG->an_cutoff)) {
|
|||||||
$frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60;
|
$frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60;
|
||||||
$frm->an_cutoff_min = intval($CFG->an_cutoff) % 60;
|
$frm->an_cutoff_min = intval($CFG->an_cutoff) % 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0';
|
if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0';
|
||||||
if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||||
|
if (!isset($frm->acceptccs)) {
|
||||||
|
$frm->acceptccs = array_keys(get_list_of_creditcards());
|
||||||
|
$CFG->an_acceptccs = implode(',', $frm->acceptccs);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -95,6 +100,20 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
|||||||
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
|
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td align="right">an_acceptccs:</td>
|
||||||
|
<td><?php
|
||||||
|
foreach (get_list_of_creditcards(true) as $key => $val) {
|
||||||
|
echo '<input type="checkbox" name="acceptccs[]" value="'.$key.'"';
|
||||||
|
if (stristr($CFG->an_acceptccs, $key) !== false) {
|
||||||
|
echo ' checked="checked"';
|
||||||
|
}
|
||||||
|
echo " /> $val<br />\n";
|
||||||
|
}
|
||||||
|
?></td>
|
||||||
|
<td><?php print_string("adminacceptccs", "enrol_authorize") ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?></h4></td></tr>
|
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?></h4></td></tr>
|
||||||
|
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
|
@ -59,12 +59,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
|||||||
<tr>
|
<tr>
|
||||||
<td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
|
<td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
|
||||||
<td align="left"><?php
|
<td align="left"><?php
|
||||||
$CCTYPES = array(
|
choose_from_menu(get_list_of_creditcards(), 'cctype', $form->cctype);
|
||||||
'mcd' => 'Master Card', 'vis' => 'Visa', 'amx' => 'American Express',
|
|
||||||
'dsc' => 'Discover', 'dnc' => 'Diners Club', 'jcb' => 'JCB',
|
|
||||||
'swi' => 'Switch', 'dlt' => 'Delta', 'enr' => 'EnRoute'
|
|
||||||
);
|
|
||||||
choose_from_menu($CCTYPES, 'cctype', $form->cctype);
|
|
||||||
if (!empty($this->ccerrors['cctype'])) { formerr($this->ccerrors['cctype']); }
|
if (!empty($this->ccerrors['cctype'])) { formerr($this->ccerrors['cctype']); }
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
|
@ -3,6 +3,46 @@
|
|||||||
require_once $CFG->dirroot.'/enrol/enrol.class.php';
|
require_once $CFG->dirroot.'/enrol/enrol.class.php';
|
||||||
require_once $CFG->dirroot.'/enrol/authorize/const.php';
|
require_once $CFG->dirroot.'/enrol/authorize/const.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_list_of_creditcards
|
||||||
|
*
|
||||||
|
* @param bool $getall
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_list_of_creditcards($getall = false)
|
||||||
|
{
|
||||||
|
global $CFG;
|
||||||
|
static $alltypes = array();
|
||||||
|
|
||||||
|
if (empty($alltypes)) {
|
||||||
|
$alltypes = array(
|
||||||
|
'mcd' => 'Master Card',
|
||||||
|
'vis' => 'Visa',
|
||||||
|
'amx' => 'American Express',
|
||||||
|
'dsc' => 'Discover',
|
||||||
|
'dnc' => 'Diners Club',
|
||||||
|
'jcb' => 'JCB',
|
||||||
|
'swi' => 'Switch',
|
||||||
|
'dlt' => 'Delta',
|
||||||
|
'enr' => 'EnRoute'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($getall || empty($CFG->an_acceptccs)) {
|
||||||
|
return $alltypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
$ccs = explode(',', $CFG->an_acceptccs);
|
||||||
|
$intersects = array_intersect(array_keys($alltypes), $ccs);
|
||||||
|
|
||||||
|
foreach ($intersects as $key) {
|
||||||
|
$ret[$key] = $alltypes[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enrolment_plugin_authorize
|
* enrolment_plugin_authorize
|
||||||
*
|
*
|
||||||
@ -464,6 +504,9 @@ class enrolment_plugin_authorize
|
|||||||
set_config('enrol_mailteachers', optional_param('enrol_mailteachers', ''));
|
set_config('enrol_mailteachers', optional_param('enrol_mailteachers', ''));
|
||||||
set_config('enrol_mailadmins', optional_param('enrol_mailadmins', ''));
|
set_config('enrol_mailadmins', optional_param('enrol_mailadmins', ''));
|
||||||
|
|
||||||
|
$acceptccs = optional_param('acceptccs', array_keys(get_list_of_creditcards()));
|
||||||
|
set_config('an_acceptccs', implode(',', $acceptccs));
|
||||||
|
|
||||||
// optional authorize.net settings
|
// optional authorize.net settings
|
||||||
set_config('an_avs', optional_param('an_avs', ''));
|
set_config('an_avs', optional_param('an_avs', ''));
|
||||||
set_config('an_test', optional_param('an_test', ''));
|
set_config('an_test', optional_param('an_test', ''));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user