Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/364531 )

Change subject: Some notes on pushing gateway classes down to SmashPig
......................................................................

Some notes on pushing gateway classes down to SmashPig

Change-Id: I7d8f263b96741c3d6e85bf129276a75ee18762e3
---
M gateway_common/GatewayType.php
M gateway_common/gateway.adapter.php
M gateway_forms/Mustache.php
M globalcollect_gateway/globalcollect.adapter.php
4 files changed, 19 insertions(+), 6 deletions(-)


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

diff --git a/gateway_common/GatewayType.php b/gateway_common/GatewayType.php
index b5226f9..b6bb970 100644
--- a/gateway_common/GatewayType.php
+++ b/gateway_common/GatewayType.php
@@ -23,7 +23,7 @@
         * Get a tag to use to identify this adapter in logs, e.g. 
amazon_gateway
         * @return string
         */
-       public static function getLogIdentifier();
+       public static function getLogIdentifier(); // Redundant, lose this on 
the way to smashpig
 
        /**
         * This function is important.
@@ -45,6 +45,7 @@
         * @return mixed The configured value for that gateway if it exists. If 
not,
         * the configured value for Donation Interface if it exists or not.
         */
+       // Kiss this goodbye too, config nodes take care of it
        public static function getGlobal( $varname );
 
        /**
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 5da2a72..eae8c78 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -403,6 +403,7 @@
        }
 
        /**
+        * // All UI stuff, should happen in GatewayPage (and should use real 
MW functions at this point)
         * Checks the edit tokens in the user's session against the one gathered
         * from populated form data.
         * Adds a string to the debugarray, to make it a little easier to tell 
what
@@ -473,6 +474,11 @@
                $this->stageData();
        }
 
+       // How to do this statelessly?
+       // UI layer should pass in raw values from the request (and session), 
and the
+       // gateway should stage those on the way in. Anything coming back from a
+       // processor API call should be fed to processResponse, which should 
return
+       // the data 'unstaged' (what's a better word for that?)
        /**
         * Add data from the processor to staged_data and run any unstaging 
functions.
         *
diff --git a/gateway_forms/Mustache.php b/gateway_forms/Mustache.php
index 0c99d62..389da9f 100644
--- a/gateway_forms/Mustache.php
+++ b/gateway_forms/Mustache.php
@@ -27,6 +27,7 @@
 
        /**
         * Return the rendered HTML form, using template parameters from the 
gateway object
+        * FIXME: can this get all the parameters as arguments to this function?
         *
         * @return string
         * @throw RuntimeException
diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index c3b94d8..1d706f9 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -25,19 +25,19 @@
 class GlobalCollectAdapter extends GatewayAdapter {
        const GATEWAY_NAME = 'Global Collect';
        const IDENTIFIER = 'globalcollect';
-       const GLOBAL_PREFIX = 'wgGlobalCollectGateway';
+       const GLOBAL_PREFIX = 'wgGlobalCollectGateway'; // obsoleted by sp 
configuration
 
        public function getCommunicationType() {
-               return 'xml';
+               return 'xml'; // When not using SDKs, we need a set of helper 
classes to build requests in different formats
        }
 
+       // This is too complicated - could have each transaction be a data 
structure with reuse of common keys
        /**
         * Add a key to the transaction INSERT_ORDERWITHPAYMENT.
         *
         * 
$this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS'][$section][]
 = $value
         */
        protected function addKeyToTransaction( $value, $section = 'PAYMENT' ) {
-
                if ( !in_array( $value, 
$this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS'][$section]
 ) ) {
                        
$this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS'][$section][]
 = $value;
                }
@@ -71,7 +71,7 @@
                }
 
                $defaults = array (
-                       'returnto' => $returnTo,
+                       'returnto' => $returnTo, // UI layer responsibility.
                        'attempt_id' => '1',
                        'effort_id' => '1',
                );
@@ -112,6 +112,7 @@
                $this->defineGoToThankYouOn();
        }
 
+       // Order ID generation should be a helper class
        /**
         * Sets up the $order_id_meta array.
         * Should contain the following keys/values:
@@ -145,7 +146,6 @@
         *
         */
        public function defineGoToThankYouOn() {
-
                $this->goToThankYouOn = array(
                        FinalStatus::COMPLETE,
                        FinalStatus::PENDING,
@@ -172,6 +172,7 @@
        public function defineTransactions() {
                $this->transactions = array( );
 
+               // Each of these should be a data structure (again, if not 
using SDK)
                $this->transactions['DO_BANKVALIDATION'] = array(
                        'request' => array(
                                'REQUEST' => array(
@@ -531,6 +532,9 @@
                return __DIR__;
        }
 
+       // Separate implementations for each method
+       // Maybe there's a GatewayFactory that gets the appropriate class 
implementing doPayment based on
+       // parameters like payment method and gateway
        public function doPayment() {
                $payment_method = $this->getPaymentMethod();
 
@@ -561,6 +565,7 @@
 
                                if ( in_array( $this->getFinalStatus(), 
$this->getGoToThankYouOn() ) ) {
                                        return PaymentResult::newForm( 'end-' . 
$payment_method );
+                                       // Form results should include a set of 
form data.
                                }
                                break;
                                

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d8f263b96741c3d6e85bf129276a75ee18762e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <ej...@ejegg.com>

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

Reply via email to