]> git.mjollnir.org Git - moodle.git/commitdiff
Autoconfigure accepted echeck bank account types. CHECKING, BUSINESSCHECKING, SAVINGS
authorethem <ethem>
Mon, 4 Sep 2006 09:44:00 +0000 (09:44 +0000)
committerethem <ethem>
Mon, 4 Sep 2006 09:44:00 +0000 (09:44 +0000)
enrol/authorize/authorizenetlib.php
enrol/authorize/enrol.html
enrol/authorize/enrol.php
enrol/authorize/localfuncs.php

index 646b55637725d3a979cb6b9a11462b19f7d0b8f7..55bebe6c1f0c031d3b953197e5668fef8c4e4f14 100644 (file)
@@ -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;
                 }
             }
index 0dd25c0184d2cca4a96ef3e0b2537c7ab6af4c88..9f3734679df689b25b11710f63690c5f8eac31fc 100755 (executable)
@@ -185,11 +185,11 @@ function print_echeck_form($classreference)
     <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']); }
       ?>
index 94cec73dea7bad992e7323321cd5b35ef3017a17..cb17f24c469e0cdec74176bd093642fc3f66ab32 100755 (executable)
@@ -352,6 +352,7 @@ class enrolment_plugin_authorize
         $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'];
index 9cf1cb3e35e009d3cc11247e4dd378eb8400338c..e469856758cfac305d859b86a62117a3478fbc92 100644 (file)
@@ -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');
     }