From 6b1d27020dd7cc47998ca874390a58fa9cc83d47 Mon Sep 17 00:00:00 2001 From: ethem Date: Wed, 30 Aug 2006 10:29:10 +0000 Subject: [PATCH] Ported AUTHORIZE_ECHECK changes into HEAD. (cvs update -j HEAD -j AUTHORIZE_ECHECK) * New Feature (Authorize.net eCheck) Authorize.Net provides an exclusive, fully integrated electronic check payment method, eCheck.Net. Using eCheck.Net, merchants can accept and process payments from consumer and corporate bank accounts directly from their Web site or through the Authorize.Net Virtual Terminal. By accepting electronic checks, you expand the payment options available to new and existing customers, enhancing customer loyalty and potentially increasing sales. + Lower Fees - Lower rates than credit cards or PayPal. + More Efficient - eCheck.Net does everything online, eliminating the cost and inconvenience of manually processing paper checks and waiting for checks in the mail. + Fully Integrated Solution - No third-party integration required implementing eCheck.Net is easy for merchants already using the Authorize.Net Payment Gateway. + Integrated Reporting - Provides a combined view of all eCheck.Net and credit card payment transactions. Reconcile payment and billing activity using online reports and statements. + Ship Product Sooner - Improved up-front transaction validation that returns the status of transactions faster. + Security - Authorize.Net uses the latest 128-bit Secure Socket Layer (SSL) technology for secure Internet Protocol (IP) transactions. == TO DO == - Generate Echeck forms. - Show users a echeck option if admin enabled echeck method. - Allow admins/teachers to enrol a student using echeck method (FIX: role consept) ========== --- enrol/authorize/authorizenetlib.php | 38 +++++++++++++++++++++-------- enrol/authorize/config.html | 21 ++++++++++++++++ enrol/authorize/const.php | 28 +++++++++++++++++++-- enrol/authorize/db/mysql.php | 2 +- enrol/authorize/db/postgres7.php | 2 +- enrol/authorize/enrol.php | 6 +++-- enrol/authorize/index.php | 2 +- enrol/authorize/locallib.php | 2 +- enrol/authorize/version.php | 2 +- 9 files changed, 84 insertions(+), 19 deletions(-) diff --git a/enrol/authorize/authorizenetlib.php b/enrol/authorize/authorizenetlib.php index 6b4869766e..bdf5684001 100644 --- a/enrol/authorize/authorizenetlib.php +++ b/enrol/authorize/authorizenetlib.php @@ -82,11 +82,12 @@ function authorize_expired(&$order) * @param string &$message Information about error message if this function returns false. * @param object &$extra Extra data that used for refunding and credit card information. * @param int $action Which action will be performed. See AN_ACTION_* + * @param int $method Transaction method. AN_METHOD_CC or AN_METHOD_ECHECK * @return bool true Transaction was successful, false otherwise. Use $message for reason. * @author Ethem Evlice * @uses $CFG */ -function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE) +function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $method=AN_METHOD_CC) { global $CFG; static $conststring; @@ -94,18 +95,16 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE) $test = !empty($CFG->an_test); if (!isset($conststring)) { - $consdata = array( + $constdata = array( 'x_version' => '3.1', 'x_delim_data' => 'True', 'x_delim_char' => AN_DELIM, 'x_encap_char' => AN_ENCAP, 'x_relay_response' => 'FALSE', - 'x_method' => 'CC', - 'x_login' => $CFG->an_login, - 'x_test_request' => $test ? 'TRUE' : 'FALSE' + 'x_login' => $CFG->an_login ); $str = ''; - foreach($consdata as $ky => $vl) { + foreach($constdata as $ky => $vl) { $str .= $ky . '=' . urlencode($vl) . '&'; } $str .= (!empty($CFG->an_tran_key)) ? @@ -113,20 +112,39 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE) 'x_password=' . urlencode($CFG->an_password); $conststring = $str; + $str = ''; } - $action = intval($action); - if (empty($order) or empty($order->id)) { $message = "Check order->id!"; return false; } - elseif ($action <= AN_ACTION_NONE or $action > AN_ACTION_VOID) { + + if (empty($method)) { + $method = AN_METHOD_CC; + } + elseif ($method != AN_METHOD_CC && $method != AN_METHOD_ECHECK) { + $message = "Missing method: $method"; + return false; + } + + if ($method == AN_METHOD_ECHECK) { + if ($action != AN_ACTION_AUTH_CAPTURE && $action != AN_ACTION_CREDIT) { + $message = "Please perform AUTH_CAPTURE or CREDIT for echecks"; + return false; + } + } + + $action = intval($action); + if ($action <= AN_ACTION_NONE or $action > AN_ACTION_VOID) { $message = "Invalid action!"; return false; } $poststring = $conststring; + $poststring .= '&x_method=' . ($method==AN_METHOD_CC ? 'CC' : 'ECHECK'); + $poststring .= '&x_test_request=' . ($test ? 'TRUE' : 'FALSE'); + $timenowsettle = getsettletime(time()); switch ($action) { case AN_ACTION_AUTH_ONLY: @@ -344,7 +362,7 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE) if ($message == '[[' . $reason . ']]') { $message = isset($response[3]) ? $response[3] : 'unknown error'; } - if (!empty($CFG->an_avs)) { + if (!empty($CFG->an_avs) and $method == AN_METHOD_CC) { $avs = "avs" . strtolower($response[5]); $stravs = get_string($avs, "enrol_authorize"); $message .= "
" . get_string("avsresult", "enrol_authorize", $stravs); diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index ee5ad3c9b2..a6f696ca6f 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -30,6 +30,16 @@ if (!isset($frm->an_cutoff_hour)) { $frm->an_cutoff_min = (intval(round($timezone)) != intval($timezone)) ? 35 : 5; } +if (!isset($frm->acceptmethods)) { + if (empty($CFG->an_acceptmethods)) { + $frm->acceptmethods = array('cc'); + $CFG->an_acceptmethods = implode(',', $frm->acceptmethods); + } + else { + $frm->acceptmethods = explode(',', $CFG->an_acceptmethods); + } +} + if (!isset($frm->acceptccs)) { $frm->acceptccs = array_keys(enrolment_plugin_authorize::get_list_of_creditcards()); $CFG->an_acceptccs = implode(',', $frm->acceptccs); @@ -124,6 +134,17 @@ if (!isset($frm->acceptccs)) { + + an_acceptmethods: + an_acceptmethods, $key) !== false, $key); echo "
\n"; + } + ?> + + + an_acceptccs: dirroot.'/enrol/enrol.class.php'); require_once($CFG->dirroot.'/enrol/authorize/const.php'); @@ -481,6 +481,9 @@ class enrolment_plugin_authorize set_config('an_test', optional_param('an_test', 0, PARAM_BOOL)); set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL)); + $acceptmethods = optional_param('acceptmethods', array('cc'), PARAM_ALPHA); + set_config('an_acceptmethods', implode(',', $acceptmethods)); + $acceptccs = optional_param('acceptccs', array_keys(enrolment_plugin_authorize::get_list_of_creditcards()), PARAM_ALPHA); @@ -695,7 +698,6 @@ class enrolment_plugin_authorize $timenow = time(); $settlementtime = authorize_getsettletime($timenow); $timediff30 = $settlementtime - (30 * $oneday); - $mconfig = get_config('enrol/authorize'); set_config('an_lastcron', $timenow, 'enrol/authorize'); diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php index b9fd79da52..80a31ddcca 100644 --- a/enrol/authorize/index.php +++ b/enrol/authorize/index.php @@ -1,4 +1,4 @@ -version = 2006081401; $plugin->requires = 2005072200; -- 2.39.5