Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/208295

Change subject: getResponseXX -> parseResponseXX
......................................................................

getResponseXX -> parseResponseXX

Rename parsing functions that looked like getters, add base implementations.

Change-Id: Idcead9c3a0f5453587d74bf151a65da789e23fd1
---
M adyen_gateway/adyen.adapter.php
M amazon_gateway/amazon.adapter.php
M astropay_gateway/astropay.adapter.php
M gateway_common/gateway.adapter.php
M globalcollect_gateway/globalcollect.adapter.php
M globalcollect_gateway/scripts/orphans.php
M paypal_gateway/paypal.adapter.php
M tests/includes/test_gateway/TestingGenericAdapter.php
M worldpay_gateway/worldpay.adapter.php
9 files changed, 43 insertions(+), 55 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/95/208295/1

diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index 5fbaf5e..20e811c 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -236,15 +236,6 @@
                return $this->getTransactionAllResults();
        }
 
-       function getResponseStatus( $response ) {
-       }
-
-       function getResponseErrors( $response ) {
-       }
-
-       function getResponseData( $response ) {
-       }
-
        static function getCurrencies() {
                // See 
http://www.adyen.com/platform/all-countries-all-currencies/
                // This should be the list of all global "acceptance 
currencies".  Not
diff --git a/amazon_gateway/amazon.adapter.php 
b/amazon_gateway/amazon.adapter.php
index 6c60e14..52746e4 100644
--- a/amazon_gateway/amazon.adapter.php
+++ b/amazon_gateway/amazon.adapter.php
@@ -475,7 +475,8 @@
                return $opts;
        }
 
-       function getResponseData( $response ) {
+       // FIXME: this should return an array, dagnabbit!
+       function parseResponseData( $response ) {
                // The XML string isn't really all that useful, so just return 
TRUE if the signature
                // was verified
                if ( $this->getCurrentTransaction() == 'VerifySignature' ) {
@@ -490,7 +491,7 @@
                return FALSE;
        }
 
-       public function getResponseStatus( $response ) {
+       function parseResponseStatus( $response ) {
                $aok = false;
 
                if ( $this->getCurrentTransaction() == 'VerifySignature' ) {
@@ -505,7 +506,7 @@
        }
 
        // @todo FIXME: This doesn't go anywhere.
-       function getResponseErrors( $response ) {
+       function parseResponseErrors( $response ) {
                $errors = array( );
                foreach ( $response->getElementsByTagName( 'Error' ) as $node ) 
{
                        $code = '';
diff --git a/astropay_gateway/astropay.adapter.php 
b/astropay_gateway/astropay.adapter.php
index d941460..fec76ef 100644
--- a/astropay_gateway/astropay.adapter.php
+++ b/astropay_gateway/astropay.adapter.php
@@ -395,14 +395,14 @@
                $this->staged_data['donor_id'] = substr( $hashed, 0, 20 );
        }
 
-       function getResponseStatus( $response ) {
+       function parseResponseStatus( $response ) {
                if ( $response === NULL || !isset( $response['status'] ) ) {
                        return false;
                }
                return $response['status'] === '0';
        }
 
-       function getResponseErrors( $response ) {
+       function parseResponseErrors( $response ) {
                $logged = false;
                $errors = array();
                $code = 'internal-0000';
@@ -439,7 +439,7 @@
                return $errors;
        }
 
-       function getResponseData( $response ) {
+       function parseResponseData( $response ) {
                $data = array();
 
                switch( $this->getCurrentTransaction() ) {
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index ac512e9..2fade05 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -27,23 +27,6 @@
        //all the particulars of the child classes. Aaaaall.
 
        /**
-        * Parse the response to get the status. Not sure if this should return 
a bool, or something more... telling.
-        */
-       function getResponseStatus( $response );
-
-       /**
-        * Parse the response to get the errors in a format we can log and 
otherwise deal with.
-        * return a key/value array of codes (if they exist) and messages.
-        */
-       function getResponseErrors( $response );
-
-       /**
-        * Harvest the data we need back from the gateway.
-        * return a key/value array
-        */
-       function getResponseData( $response );
-
-       /**
         * Perform any additional processing on the response obtained from the 
server.
         *
         * @param array $response   The internal response object array -> ie: 
data, errors, action...
@@ -1160,15 +1143,15 @@
                        //set the status of the response. This is the 
COMMUNICATION status, and has nothing
                        //to do with the result of the transaction.
                        $formatted = $this->getFormattedResponse( 
$this->transaction_result->getRawResponse() );
-                       $this->setTransactionResult( $this->getResponseStatus( 
$formatted ), 'status' );
+                       $this->setTransactionResult( 
$this->parseResponseStatus( $formatted ), 'status' );
 
                        //set errors
                        //TODO: This "errors" business is becoming a bit of a 
misnomer, as the result code and message
                        //are frequently packaged togther in the same place, 
whether the transaction passed or failed.
-                       $this->setTransactionResult( $this->getResponseErrors( 
$formatted ), 'errors' );
+                       $this->setTransactionResult( 
$this->parseResponseErrors( $formatted ), 'errors' );
 
                        //if we're still okay (hey, even if we're not), get 
relevant data.
-                       $this->setTransactionResult( $this->getResponseData( 
$formatted ), 'data' );
+                       $this->setTransactionResult( $this->parseResponseData( 
$formatted ), 'data' );
 
                        // Process the formatted response data. This will then 
drive the result action
                        $errCode = $this->processResponse( 
$this->getTransactionAllResults(), $retryVars );
@@ -1518,6 +1501,31 @@
        }
 
        /**
+        * Parse the response to get the status.
+        * @return boolean true if response looks sane
+        */
+       protected function parseResponseStatus( $response ) {
+               return true;
+       }
+
+       /**
+        * Parse the response to get the errors in a format we can log and 
otherwise deal with.
+        * @return array a key/value array of codes (if they exist) and 
messages.
+        */
+       protected function parseResponseErrors( $response ) {
+               return array();
+       }
+
+       /**
+        * This is only public for the orphan script.
+        * Harvest the data we need back from the gateway.
+        * @return array a key/value array
+        */
+       public function parseResponseData( $response ) {
+               return array();
+       }
+
+       /**
         * Take the entire response string, and strip everything we don't care
         * about.  For instance: If it's XML, we only want correctly-formatted 
XML.
         * Headers must be killed off.
diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index 8c3cb0e..5f286ad 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -1457,7 +1457,7 @@
         * @param DomDocument   $response       The response XML loaded into a 
DomDocument
         * @return bool
         */
-       public function getResponseStatus( $response ) {
+       public function parseResponseStatus( $response ) {
 
                $aok = true;
 
@@ -1481,7 +1481,7 @@
         * @param array $response       The response array
         * @return array
         */
-       public function getResponseErrors( $response ) {
+       public function parseResponseErrors( $response ) {
                $errors = array( );
                foreach ( $response->getElementsByTagName( 'ERROR' ) as $node ) 
{
                        $code = '';
@@ -1521,7 +1521,7 @@
         * @param DOMDocument   $response       The response object
         * @return array
         */
-       public function getResponseData( $response ) {
+       public function parseResponseData( $response ) {
                $data = array( );
 
                $transaction = $this->getCurrentTransaction();
@@ -1870,7 +1870,7 @@
                                        //look in the message for more clues.
                                        //Yes: That's an 8-digit error code 
that buckets a silly number of validation issues, some of which are 
legitimately ours.
                                        //The only way to tell is to search the 
English message.
-                                       //@TODO: Refactor all 3rd party error 
handling for GC. This whole switch should definitely be in getResponseErrors; 
It is very silly that this is here at all.
+                                       //@TODO: Refactor all 3rd party error 
handling for GC. This whole switch should definitely be in parseResponseErrors; 
It is very silly that this is here at all.
                                        $enhanced = 
$this->transaction_result->getErrors();
                                        // Matching previous behavior, which 
set a random transaction_result
                                        // key to the raw message of the last 
error inspected
diff --git a/globalcollect_gateway/scripts/orphans.php 
b/globalcollect_gateway/scripts/orphans.php
index 85b42af..e649e08 100644
--- a/globalcollect_gateway/scripts/orphans.php
+++ b/globalcollect_gateway/scripts/orphans.php
@@ -312,7 +312,7 @@
                
                foreach ($payments as $key => $payment_data){
                        $xml->loadXML($payment_data['xml']);
-                       $parsed = $this->adapter->getResponseData($xml);
+                       $parsed = $this->adapter->parseResponseData($xml);
                        $payments[$key]['parsed'] = $parsed;
                        $payments[$key]['unstaged'] = 
$this->adapter->unstage_data($parsed);
                        $payments[$key]['unstaged']['contribution_tracking_id'] 
= $payments[$key]['contribution_tracking_id'];
diff --git a/paypal_gateway/paypal.adapter.php 
b/paypal_gateway/paypal.adapter.php
index 2c74b4b..9ea2258 100644
--- a/paypal_gateway/paypal.adapter.php
+++ b/paypal_gateway/paypal.adapter.php
@@ -60,9 +60,6 @@
                $this->accountInfo = array();
        }
        function defineReturnValueMap() {}
-       function getResponseStatus( $response ) {}
-       function getResponseErrors( $response ) {}
-       function getResponseData( $response ) {}
        function processResponse( $response, &$retryVars = null ) {}
        function defineDataConstraints() {}
        function defineOrderIDMeta() {
diff --git a/tests/includes/test_gateway/TestingGenericAdapter.php 
b/tests/includes/test_gateway/TestingGenericAdapter.php
index 812e2d1..4ea734e 100644
--- a/tests/includes/test_gateway/TestingGenericAdapter.php
+++ b/tests/includes/test_gateway/TestingGenericAdapter.php
@@ -85,15 +85,6 @@
        public function defineVarMap() {
        }
 
-       public function getResponseData($response) {
-       }
-
-       public function getResponseErrors($response) {
-       }
-
-       public function getResponseStatus($response) {
-       }
-
        public function processResponse($response, &$retryVars = null) {
        }
 
diff --git a/worldpay_gateway/worldpay.adapter.php 
b/worldpay_gateway/worldpay.adapter.php
index dadd3ed..bd18dae 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -789,7 +789,7 @@
         *
         * @return bool
         */
-       function getResponseStatus( $response ) {
+       function parseResponseStatus( $response ) {
                foreach( $response->getElementsByTagName( 'MessageCode' ) as 
$node) {
                        return true;
                }
@@ -806,7 +806,7 @@
         * @param DOMDocument   $response       The XML response data all 
loaded into a DOMDocument
         * @return array
         */
-       function getResponseErrors( $response ) {
+       function parseResponseErrors( $response ) {
                $code = false;
                $message = false;
                $errors = array( );
@@ -914,7 +914,7 @@
                return $return;
        }
 
-       function getResponseData( $response ) {
+       function parseResponseData( $response ) {
                $data = $this->xmlChildrenToArray( $response, 'TMSTN' );
                return $data;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/208295
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcead9c3a0f5453587d74bf151a65da789e23fd1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to