From 55246ce2e30a6b3eeca0077bf9d1126ab420ea30 Mon Sep 17 00:00:00 2001 From: ethem Date: Sat, 27 Sep 2008 00:40:00 +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 Backported from HEAD. --- enrol/authorize/authorizenetlib.php | 2 +- enrol/authorize/db/install.xml | 8 +++--- enrol/authorize/db/upgrade.php | 41 +++++++++++++++++++++++++++++ enrol/authorize/locallib.php | 2 +- enrol/authorize/version.php | 2 +- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/enrol/authorize/authorizenetlib.php b/enrol/authorize/authorizenetlib.php index f1a2c7ea9da..5c7be9cc778 100644 --- a/enrol/authorize/authorizenetlib.php +++ b/enrol/authorize/authorizenetlib.php @@ -295,7 +295,7 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $ $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 2ebc3e847dc..f559023bb17 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 c28da08f875..edbb7f2d489 100644 --- a/enrol/authorize/db/upgrade.php +++ b/enrol/authorize/db/upgrade.php @@ -59,6 +59,47 @@ function xmldb_enrol_authorize_upgrade($oldversion=0) { } } + + if ($result && $oldversion < 2006112903) { + /// enrol_authorize.transid + /// Define index transid (not unique) to be dropped form enrol_authorize + $table = new XMLDBTable('enrol_authorize'); + $index = new XMLDBIndex('transid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('transid')); + drop_index($table, $index); + + /// Changing precision of field transid on table enrol_authorize to (20) + $table = new XMLDBTable('enrol_authorize'); + $field = new XMLDBField('transid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'userid'); + change_field_precision($table, $field); + + /// Launch add index transid again + $table = new XMLDBTable('enrol_authorize'); + $index = new XMLDBIndex('transid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('transid')); + add_index($table, $index); + + /// enrol_authorize_refunds.transid + /// Define index transid (not unique) to be dropped form enrol_authorize_refunds + $table = new XMLDBTable('enrol_authorize_refunds'); + $index = new XMLDBIndex('transid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('transid')); + drop_index($table, $index); + + /// Changing precision of field transid on table enrol_authorize_refunds to (20) + $table = new XMLDBTable('enrol_authorize_refunds'); + $field = new XMLDBField('transid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, null, '0', 'amount'); + change_field_precision($table, $field); + + /// Launch add index transid again + $table = new XMLDBTable('enrol_authorize_refunds'); + $index = new XMLDBIndex('transid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('transid')); + add_index($table, $index); + } + return $result; } diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index dd65af249ba..2fd71583e1f 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -561,7 +561,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 d353a7b6247..e8301130d76 100755 --- a/enrol/authorize/version.php +++ b/enrol/authorize/version.php @@ -1,6 +1,6 @@ version = 2006112902; +$plugin->version = 2006112903; $plugin->requires = 2007101000; ?>