Mwalker has uploaded a new change for review.

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


Change subject: Actions Should be Associated with their Messages
......................................................................

Actions Should be Associated with their Messages

Instead of going through the global action chain this will have
the message be responsible for running it's actions.

Change-Id: Ibc2a408e847aa1d229b9d87777967599198cf512
---
M SmashPig/PaymentProviders/Adyen/Actions/PaymentCaptureAction.php
M SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Authorisation.php
M SmashPig/config_defaults.php
3 files changed, 22 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/PaymentsListeners 
refs/changes/55/67555/1

diff --git a/SmashPig/PaymentProviders/Adyen/Actions/PaymentCaptureAction.php 
b/SmashPig/PaymentProviders/Adyen/Actions/PaymentCaptureAction.php
index b2ace0f..8cdd2b6 100644
--- a/SmashPig/PaymentProviders/Adyen/Actions/PaymentCaptureAction.php
+++ b/SmashPig/PaymentProviders/Adyen/Actions/PaymentCaptureAction.php
@@ -4,7 +4,6 @@
 use SmashPig\Core\Messages\ListenerMessage;
 use SmashPig\Core\Actions\IListenerMessageAction;
 use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Authorisation;
-use SmashPig\Core\DataStores\KeyedOpaqueDataStore;
 use SmashPig\PaymentProviders\Adyen\Jobs\ProcessCaptureRequestJob;
 use SmashPig\Core\Logging\Logger;
 
diff --git 
a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Authorisation.php 
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Authorisation.php
index edeac2b..4f711a8 100644
--- a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Authorisation.php
+++ b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Authorisation.php
@@ -1,6 +1,7 @@
 <?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
 
 use SmashPig\Core\Logging\Logger;
+use SmashPig\PaymentProviders\Adyen\Actions\PaymentCaptureAction;
 use SmashPig\PaymentProviders\Adyen\WSDL\NotificationRequestItem;
 
 class Authorisation extends AdyenMessage {
@@ -39,4 +40,24 @@
                // Recreate the correlation ID because we have more information 
about things
                $this->correlationId = static::createCorrelationId( 
$this->merchantReference );
        }
+
+       /**
+        * Will run all the actions that are loaded (from the 'actions' 
configuration
+        * node) and that are applicable to this message type. Will return true
+        * if all actions returned true. Otherwise will return false. This 
implicitly
+        * means that the message will be re-queued if any action fails. 
Therefore
+        * all actions need to be idempotent.
+        *
+        * @returns bool True if all actions were successful. False otherwise.
+        */
+       public function runActionChain() {
+               $action = new PaymentCaptureAction();
+               $result = $action->execute( $this );
+
+               if ( $result === true ) {
+                       return parent::runActionChain();
+               } else {
+                       return false;
+               }
+       }
 }
diff --git a/SmashPig/config_defaults.php b/SmashPig/config_defaults.php
index 5fa0e36..c8a4ce9 100644
--- a/SmashPig/config_defaults.php
+++ b/SmashPig/config_defaults.php
@@ -108,9 +108,7 @@
             ),
         ),
 
-               'actions' => array(
-                       
'SmashPig\PaymentProviders\Adyen\Actions\PaymentCaptureAction',
-               )
+               'actions' => array( ),
     ),
 
        'paypal' => array(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc2a408e847aa1d229b9d87777967599198cf512
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/PaymentsListeners
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to