From 460635599a730da7c9f796160c5cf619bb65f3ea Mon Sep 17 00:00:00 2001 From: ethem Date: Mon, 4 Sep 2006 09:44:00 +0000 Subject: [PATCH] Autoconfigure accepted echeck bank account types. CHECKING, BUSINESSCHECKING, SAVINGS --- enrol/authorize/authorizenetlib.php | 21 ++++++++++++++++++++- enrol/authorize/enrol.html | 10 +++++----- enrol/authorize/enrol.php | 1 + enrol/authorize/localfuncs.php | 14 +++++++++++++- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/enrol/authorize/authorizenetlib.php b/enrol/authorize/authorizenetlib.php index 646b556377..55bebe6c1f 100644 --- a/enrol/authorize/authorizenetlib.php +++ b/enrol/authorize/authorizenetlib.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; } } diff --git a/enrol/authorize/enrol.html b/enrol/authorize/enrol.html index 0dd25c0184..9f3734679d 100755 --- a/enrol/authorize/enrol.html +++ b/enrol/authorize/enrol.html @@ -185,11 +185,11 @@ function print_echeck_form($classreference) : 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']); } ?> diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 94cec73dea..cb17f24c46 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -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']; diff --git a/enrol/authorize/localfuncs.php b/enrol/authorize/localfuncs.php index 9cf1cb3e35..e469856758 100644 --- a/enrol/authorize/localfuncs.php +++ b/enrol/authorize/localfuncs.php @@ -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'); } -- 2.39.5