jenkins-bot has submitted this change and it was merged.

Change subject: reuse code to check for valid WMF transaction status
......................................................................


reuse code to check for valid WMF transaction status

Change-Id: I30666898c88f4aa92959426f0d102fedc8fa9496
---
M gateway_common/gateway.adapter.php
1 file changed, 19 insertions(+), 22 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index cd51827..308b1ef 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -280,6 +280,14 @@
        public $redirect = FALSE;
        public $log_outbound = FALSE; //This should be set to true for gateways 
that don't return the request in the response. @see buildLogXML()
 
+       protected $valid_statuses = array(
+               'complete', 
+               'pending', 
+               'pending-poke', 
+               'failed', 
+               'revised',
+       );
+
        /**
         * Get @see GlobalCollectAdapter::$goToThankYouOn
         *
@@ -1727,18 +1735,8 @@
         * @return void
         */
        protected function addCodeRange( $transaction, $key, $action, $lower, 
$upper = null ) {
-               //our choices here are: 
-               //TODO: Move this somewhere both this function and 
-               //finalizeInternalStatus can get to it. 
-               $statuses = array(
-                       'complete', 
-                       'pending', 
-                       'pending-poke', 
-                       'failed', 
-                       'revised'
-               );
-               if ( !in_array( $action, $statuses ) ) {
-                       throw new MWException( "Internal Final Status $action 
is invalid." );
+               if ( !$this->validTransactionWMFStatus( $action ) ) {
+                       throw new MWException( "Transaction WMF Status $action 
is invalid." );
                }
                if ( $upper === null ) {
                        $this->return_value_map[$transaction][$key][$lower] = 
$action;
@@ -2204,6 +2202,13 @@
                }
        }
 
+       public function validTransactionWMFStatus( $status = null ) {
+               if ( $status == null ) {
+                       $status = $this->getTransactionWMFStatus();
+               }
+               return in_array( $status, $this->valid_statuses );
+       }
+
        /**
         * Sets the final payment status. This is the one we care about for
         * switching on behavior.
@@ -2217,16 +2222,8 @@
         * @throws MWException
         */
        public function finalizeInternalStatus( $status ) {
-               //our choices here are: 
-               $statuses = array(
-                       'complete', 
-                       'pending', 
-                       'pending-poke', 
-                       'failed', 
-                       'revised'
-               );
-               if ( !in_array( $status, $statuses ) ) {
-                       throw new MWException( "Transaction Final Status 
$status is invalid." );
+               if ( !$this->validTransactionWMFStatus( $status ) ) {
+                       throw new MWException( "Transaction WMF Status $status 
is invalid." );
                }
 
                /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I30666898c88f4aa92959426f0d102fedc8fa9496
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deploy-payments_1.22
Gerrit-Owner: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: Mwalker <mwal...@wikimedia.org>
Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to