]> git.mjollnir.org Git - moodle.git/commitdiff
Ported AUTHORIZE_ECHECK changes into HEAD. (cvs update -j HEAD -j AUTHORIZE_ECHECK)
authorethem <ethem>
Wed, 30 Aug 2006 10:29:10 +0000 (10:29 +0000)
committerethem <ethem>
Wed, 30 Aug 2006 10:29:10 +0000 (10:29 +0000)
* 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
enrol/authorize/config.html
enrol/authorize/const.php
enrol/authorize/db/mysql.php
enrol/authorize/db/postgres7.php
enrol/authorize/enrol.php
enrol/authorize/index.php
enrol/authorize/locallib.php
enrol/authorize/version.php

index 6b4869766e676db660686a546de116723f7aa0b6..bdf5684001e11349bc85d0d70f1d8f9b53c5177e 100644 (file)
@@ -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 <ethem a.t evlice d.o.t com>
  * @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 .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
index ee5ad3c9b20996250883bb57904b1753fdebbd6b..a6f696ca6f2ffbb8a4c10df340a149524d1d3a5a 100755 (executable)
@@ -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)) {
     <td><?php print_string("antestmode", "enrol_authorize") ?></td>
 </tr>
 
+<tr valign="top">
+    <td align="right">an_acceptmethods:</td>
+    <td><?php
+    $allmethods = array('CC','ECHECK');
+    foreach ($allmethods as $key) {
+        print_checkbox('acceptmethods[]', strtolower($key), stristr($CFG->an_acceptmethods, $key) !== false, $key); echo "<br />\n";
+    }
+    ?></td>
+    <td><?php print_string("adminacceptmethods", "enrol_authorize") ?></td>
+</tr>
+
 <tr valign="top">
     <td align="right">an_acceptccs:</td>
     <td><?php
index 66e9002d7bdf44544586e24a3891c34ae76f3993..74f8591a760ac5e1dc3afd02a3cfb2c1631a8dbb 100644 (file)
@@ -1,5 +1,29 @@
 <?php // $Id$
 
+/**#@+
+ * Authorize.net methods.
+ *
+ * Credit Card (CC)
+ * ECheck (ECHECK)
+ */
+define('AN_METHOD_CC',     1);
+define('AN_METHOD_ECHECK', 2);
+/**#@-*/
+
+/**#@+
+ * E-Check types
+ *
+ * Cash Concentration or Disbursement (CCD)
+ * Prearranged Payment and Deposit Entry (PPD)
+ * Telephone-Initiated Entry (TEL)
+ * Internet-Initiated Entry (WEB)
+ */
+define('AN_ECHECK_CCD', 'CCD');
+define('AN_ECHECK_PPD', 'PPD');
+define('AN_ECHECK_TEL', 'TEL');
+define('AN_ECHECK_WEB', 'WEB');
+/**#@-*/
+
 /**#@+
  * Order status used in enrol_authorize table.
  *
@@ -23,13 +47,13 @@ define('AN_STATUS_TEST',        0x80);
 /**#@-*/
 
 /**#@+
- * Actions used in authorize_action function.
+ * Actions used in authorizenet_action function.
  *
  * NONE: No action. Function always returns false.
  * AUTH_ONLY: Used to authorize only, don't capture.
  * CAPTURE_ONLY: Authorization code received from a bank over the phone and capture now.
- * PRIOR_AUTH_CAPTURE:  Used to capture, it was authorized before.
  * AUTH_CAPTURE: Used to authorize and capture.
+ * PRIOR_AUTH_CAPTURE:  Used to capture, it was authorized before.
  * CREDIT: Used to return funds to a customer's credit card.
  * VOID: Used to cancel an exiting pending transaction.
  *
index de260e330e439e842923a511202dfb9b3b88cc67..afd558de54acb4d875cee468defea97fa4c9fb92 100755 (executable)
@@ -1,4 +1,4 @@
-<?PHP  //$Id$
+<?php //$Id$
 
 // MySQL commands for upgrading this enrolment module
 
index 78aec0c5982e8591f9c84d94ae1228531d61743b..18fae57242ade388bd05c624a0521bc139e510ff 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP  //$Id$
+<?php //$Id$
 
 // PostgreSQL commands for upgrading this enrolment module
 
index eb0228a7a0809743fb90d854b425031feeddd742..273e87abf51938b6ea9906693c0b73f2235b6a62 100755 (executable)
@@ -1,4 +1,4 @@
-<?php  // $Id$
+<?php // $Id$
 
 require_once($CFG->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');
 
index b9fd79da529bf99172596eec81c727cab33c518a..80a31ddcca1134476c6ed0f976f7363232819854 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP // $Id$
+<?php // $Id$
 
 /// Load libraries
     require_once('../../config.php');
index dba4396bec02202a863aba07a9e769e9861a9878..58724d6d30825ab8fa836c5a974e1a5e64e7d1ad 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP // $Id$
+<?php // $Id$
 
 if (!defined('MOODLE_INTERNAL')) {
     die('Direct access to this script is forbidden.');
index b00449357a83338a0f4d4e33813f038fde6a279a..15513fbcfdc02ec05ee672fa7137ee3cd620f9d7 100755 (executable)
@@ -1,4 +1,4 @@
-<?PHP // $Id$
+<?php // $Id$
 
 $plugin->version  = 2006081401;
 $plugin->requires = 2005072200;