Skip to content
Browse files

Admin can setup which credit card types will be accepted.

  • Loading branch information...
1 parent 474c8d3 commit 8d101bc52241bae3ffa50341085ba34fe991e4a5 ethem committed May 5, 2006
Showing with 63 additions and 6 deletions.
  1. +19 −0 enrol/authorize/config.html
  2. +1 −6 enrol/authorize/enrol.html
  3. +43 −0 enrol/authorize/enrol.php
View
19 enrol/authorize/config.html
@@ -21,8 +21,13 @@
$frm->an_cutoff_hour = 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_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 @@
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
</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">
View
7 enrol/authorize/enrol.html
@@ -59,12 +59,7 @@
<tr>
<td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
<td align="left"><?php
- $CCTYPES = array(
- '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);
+ choose_from_menu(get_list_of_creditcards(), 'cctype', $form->cctype);
if (!empty($this->ccerrors['cctype'])) { formerr($this->ccerrors['cctype']); }
?>
</td>
View
43 enrol/authorize/enrol.php
@@ -4,6 +4,46 @@
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
*
*/
@@ -464,6 +504,9 @@ function process_config($config)
set_config('enrol_mailteachers', optional_param('enrol_mailteachers', ''));
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
set_config('an_avs', optional_param('an_avs', ''));
set_config('an_test', optional_param('an_test', ''));

0 comments on commit 8d101bc

Please sign in to comment.
Something went wrong with that request. Please try again.