Permalink
Browse files

Autoconfigure accepted echeck bank account types. CHECKING, BUSINESSC…

…HECKING, SAVINGS
  • Loading branch information...
1 parent cc398c7 commit 460635599a730da7c9f796160c5cf619bb65f3ea ethem committed Sep 4, 2006
Showing with 39 additions and 7 deletions.
  1. +20 −1 enrol/authorize/authorizenetlib.php
  2. +5 −5 enrol/authorize/enrol.html
  3. +1 −0 enrol/authorize/enrol.php
  4. +13 −1 enrol/authorize/localfuncs.php
@@ -417,7 +417,26 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
case AN_REASON_NOACHTYPE:
case AN_REASON_NOACHTYPE2:
{
- // Not implemented yet.
+ if (!empty($extra->x_echeck_type)) {
+ switch ($extra->x_echeck_type) {
+ // CCD=BUSINESSCHECKING
+ case 'CCD':
+ {
+ set_config('an_acceptechecktypes', 'CHECKING,SAVINGS');
+ email_to_admin("$message " .
+ "This is new config(an_acceptechecktypes):", array('CHECKING','SAVINGS'));
+ }
+ break;
+ // WEB=CHECKING or SAVINGS
+ case 'WEB':
+ {
+ set_config('an_acceptechecktypes', 'BUSINESSCHECKING');
+ email_to_admin("$message " .
+ "This is new config(an_acceptechecktypes):", array('BUSINESSCHECKING'));
+ }
+ break;
+ }
+ }
break;
}
}
View
@@ -185,11 +185,11 @@
<tr>
<td align="right"><?php print_string("echeckacctype", "enrol_authorize") ?>: </td>
<td align="left"><?php
- $acctypes = array(
- 'CHECKING' => get_string("echeckchecking", "enrol_authorize"),
- 'BUSINESSCHECKING' => get_string("echeckbusinesschecking", "enrol_authorize"),
- 'SAVINGS' => get_string("echecksavings", "enrol_authorize")
- );
+ $acctypes = array();
+ $acctypesenabled = get_list_of_bank_account_types();
+ foreach ($acctypesenabled as $key) {
+ $acctypes[$key] = get_string("echeck".strtolower($key), "enrol_authorize");
+ }
choose_from_menu($acctypes, 'acctype', $form->acctype);
if (!empty($classreference->authorizeerrors['acctype'])) { formerr($classreference->authorizeerrors['acctype']); }
?>
@@ -352,6 +352,7 @@ function echeck_submit($form, $course)
$extra->x_bank_aba_code = $form->abacode;
$extra->x_bank_acct_num = $form->accnum;
$extra->x_bank_acct_type = $form->acctype;
+ $extra->x_echeck_type = ($form->acctype == 'BUSINESSCHECKING') ? 'CCD' : 'WEB';
$extra->x_bank_name = $form->bankname;
$extra->x_currency_code = $curcost['currency'];
$extra->x_amount = $curcost['cost'];
@@ -87,6 +87,18 @@ function get_list_of_payment_methods($getall = false)
}
}
+function get_list_of_bank_account_types($getall = false)
+{
+ global $CFG;
+
+ if ($getall || empty($CFG->an_acceptechecktypes)) {
+ return array('CHECKING', 'BUSINESSCHECKING', 'SAVINGS');
+ }
+ else {
+ return explode(',', $CFG->an_acceptechecktypes);
+ }
+}
+
function ABAVal($aba)
{
if (ereg("^[0-9]{9}$", $aba)) {
@@ -263,7 +275,7 @@ function validate_echeck_form($form, &$err)
$err['accnum'] = get_string('invalidaccnum', 'enrol_authorize');
}
- if (empty($form->acctype) || !in_array($form->acctype, array('CHECKING', 'BUSINESSCHECKING', 'SAVINGS'))) {
+ if (empty($form->acctype) || !in_array($form->acctype, get_list_of_bank_account_types())) {
$err['acctype'] = get_string('invalidacctype', 'enrol_authorize');
}

0 comments on commit 4606355

Please sign in to comment.