]> git.mjollnir.org Git - moodle.git/commitdiff
Authorize.net Trans IDs are changing in October-Will it break moodle? YES
authorethem <ethem>
Fri, 26 Sep 2008 23:42:53 +0000 (23:42 +0000)
committerethem <ethem>
Fri, 26 Sep 2008 23:42:53 +0000 (23:42 +0000)
http://moodle.org/mod/forum/discuss.php?d=106626

enrol/authorize/authorizenet.class.php
enrol/authorize/db/install.xml
enrol/authorize/db/upgrade.php
enrol/authorize/locallib.php
enrol/authorize/version.php

index b8288efee8ebc87b367d11c91cfa30f6063ae4ad..60c21a34caccb69b34d2d6095c8da78cc7a30e8c 100644 (file)
@@ -273,7 +273,7 @@ class AuthorizeNet
         $responsecode = intval($response[0]);
         if ($responsecode == AN_APPROVED || $responsecode == AN_REVIEW)
         {
-            $transid = intval($response[6]);
+            $transid = floatval($response[6]);
             if ($test || $transid == 0) {
                 return $responsecode; // don't update original transaction in test mode.
             }
index 2ebc3e847dcf1a603b5a52e9d1b5db61ac845821..f559023bb1784100c6282b12db6b0f23775aa06e 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="enrol/authorize/db" VERSION="20061117" COMMENT="XMLDB file for Moodle enrol/authorize"
+<XMLDB PATH="enrol/authorize/db" VERSION="20080927" COMMENT="XMLDB file for Moodle enrol/authorize"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -12,7 +12,7 @@
         <FIELD NAME="ccname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="refundinfo" NEXT="courseid"/>
         <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ccname" NEXT="userid"/>
         <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="transid"/>
-        <FIELD NAME="transid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="status"/>
+        <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="status"/>
         <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="transid" NEXT="timecreated"/>
         <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="status" NEXT="settletime"/>
         <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="amount"/>
@@ -20,7 +20,7 @@
         <FIELD NAME="currency" TYPE="char" LENGTH="3" NOTNULL="true" DEFAULT="USD" SEQUENCE="false" ENUM="false" PREVIOUS="amount"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="userid"/>
@@ -35,7 +35,7 @@
         <FIELD NAME="orderid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="status"/>
         <FIELD NAME="status" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="orderid" NEXT="amount"/>
         <FIELD NAME="amount" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="status" NEXT="transid"/>
-        <FIELD NAME="transid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="amount" NEXT="settletime"/>
+        <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="amount" NEXT="settletime"/>
         <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="transid"/>
       </FIELDS>
       <KEYS>
index 7bbf8cc9aa7147ade125a4e32e196c9d6c6d1770..64a75bbb09d1a72d67d69a80003bee3b647ea802 100644 (file)
@@ -26,7 +26,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
     $dbman = $DB->get_manager();
     $result = true;
 
-//===== 1.9.0 upgrade line ======//
+    //===== 1.9.0 upgrade line ======//
 
     if ($result && $oldversion < 2008020500 && is_enabled_enrol('authorize')) {
         require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
@@ -36,6 +36,44 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
         }
     }
 
+    if ($result && $oldversion < 2008092700) {
+        /// enrol_authorize.transid
+        /// Define index transid (not unique) to be dropped form enrol_authorize
+        $table = new xmldb_table('enrol_authorize');
+        $index = new xmldb_index('transid', XMLDB_INDEX_NOTUNIQUE, array('transid'));
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+
+        /// Changing precision of field transid on table enrol_authorize to (20)
+        $table = new xmldb_table('enrol_authorize');
+        $field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'userid');
+        $dbman->change_field_precision($table, $field);
+
+        /// Launch add index transid again
+        $table = new xmldb_table('enrol_authorize');
+        $index = new xmldb_index('transid', XMLDB_INDEX_NOTUNIQUE, array('transid'));
+        $dbman->add_index($table, $index);
+
+        /// enrol_authorize_refunds.transid
+        /// Define index transid (not unique) to be dropped form enrol_authorize_refunds
+        $table = new xmldb_table('enrol_authorize_refunds');
+        $index = new xmldb_index('transid', XMLDB_INDEX_NOTUNIQUE, array('transid'));
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+
+        /// Changing precision of field transid on table enrol_authorize_refunds to (20)
+        $table = new xmldb_table('enrol_authorize_refunds');
+        $field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, null, '0', 'amount');
+        $dbman->change_field_precision($table, $field);
+
+        /// Launch add index transid again
+        $table = new xmldb_table('enrol_authorize_refunds');
+        $index = new xmldb_index('transid', XMLDB_INDEX_NOTUNIQUE, array('transid'));
+        $dbman->add_index($table, $index);
+    }
+
     return $result;
 }
 
index 904ec27b08dd1ce1cab24d0fad760ff07a193cb7..4cc0b9160c4e0c8708c202a6816c785bd45498d0 100644 (file)
@@ -529,7 +529,7 @@ function authorize_get_status_action($order)
 
     $canmanage = has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $order->courseid));
 
-    if (intval($order->transid) == 0) { // test transaction or new order
+    if (floatval($order->transid) == 0) { // test transaction or new order
         if ($order->timecreated < $newordertime) {
             if ($canmanage) {
                 $ret->actions = array(ORDER_DELETE);
index baba6a152a2145131d30cdc71af3fd2639652ea0..13afaaaa2190990025135901dfaf6fda8e72e83f 100755 (executable)
@@ -1,6 +1,6 @@
 <?php // $Id$
 
-$plugin->version  = 2008020501;
+$plugin->version  = 2008092700;
 $plugin->requires = 2007101507;
 
 ?>