From f5eb7e2fbc166b3e8c83e075e0a2f7dfa457bb03 Mon Sep 17 00:00:00 2001 From: ethem Date: Fri, 26 Sep 2008 23:42:53 +0000 Subject: [PATCH] Authorize.net Trans IDs are changing in October-Will it break moodle? YES http://moodle.org/mod/forum/discuss.php?d=106626 --- enrol/authorize/authorizenet.class.php | 2 +- enrol/authorize/db/install.xml | 8 +++--- enrol/authorize/db/upgrade.php | 40 +++++++++++++++++++++++++- enrol/authorize/locallib.php | 2 +- enrol/authorize/version.php | 2 +- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/enrol/authorize/authorizenet.class.php b/enrol/authorize/authorizenet.class.php index b8288efee8..60c21a34ca 100644 --- a/enrol/authorize/authorizenet.class.php +++ b/enrol/authorize/authorizenet.class.php @@ -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. } diff --git a/enrol/authorize/db/install.xml b/enrol/authorize/db/install.xml index 2ebc3e847d..f559023bb1 100644 --- a/enrol/authorize/db/install.xml +++ b/enrol/authorize/db/install.xml @@ -1,5 +1,5 @@ - @@ -12,7 +12,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/enrol/authorize/db/upgrade.php b/enrol/authorize/db/upgrade.php index 7bbf8cc9aa..64a75bbb09 100644 --- a/enrol/authorize/db/upgrade.php +++ b/enrol/authorize/db/upgrade.php @@ -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; } diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index 904ec27b08..4cc0b9160c 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -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); diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php index baba6a152a..13afaaaa21 100755 --- a/enrol/authorize/version.php +++ b/enrol/authorize/version.php @@ -1,6 +1,6 @@ version = 2008020501; +$plugin->version = 2008092700; $plugin->requires = 2007101507; ?> -- 2.39.5