Katie Horn has submitted this change and it was merged.

Change subject: Refund Actions!
......................................................................


Refund Actions!

This will failmail for us so that at least we know we got one :)

Change-Id: Id7bca5543b65ccf7ceb45834db780669f2dd29bc
---
A SmashPig/PaymentProviders/Adyen/Actions/RefundInitiatedAction.php
M SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RefundWithData.php
2 files changed, 50 insertions(+), 0 deletions(-)

Approvals:
  Katie Horn: Verified; Looks good to me, approved



diff --git a/SmashPig/PaymentProviders/Adyen/Actions/RefundInitiatedAction.php 
b/SmashPig/PaymentProviders/Adyen/Actions/RefundInitiatedAction.php
new file mode 100644
index 0000000..706508c
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/Actions/RefundInitiatedAction.php
@@ -0,0 +1,28 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\Actions;
+
+use SmashPig\Core\Messages\ListenerMessage;
+use SmashPig\Core\Actions\IListenerMessageAction;
+use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\RefundWithData;
+use SmashPig\Core\Logging\Logger;
+
+/**
+ * Action for a refund! whoo!
+ */
+class RefundInitiatedAction implements IListenerMessageAction {
+       public function execute( ListenerMessage $msg ) {
+               Logger::enterContext( 'RefundInitiatedAction' );
+
+               if ( $msg instanceof RefundWithData ) {
+                       // I've never even seen one of these messages so we'll 
just have to wait
+                       // and see
+                       Logger::error(
+                               "Oh hai! We got a refund on pspReference 
'{$msg->pspReference}' with correlation id '" .
+                                       "{$msg->correlationId}'! What do we do 
now?",
+                               $msg
+                       );
+               }
+
+               Logger::leaveContext();
+               return true;
+       }
+}
diff --git 
a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RefundWithData.php 
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RefundWithData.php
index bf572b4..db9f3ff 100644
--- a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RefundWithData.php
+++ b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RefundWithData.php
@@ -1,4 +1,26 @@
 <?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
 
+use SmashPig\PaymentProviders\Adyen\Actions\RefundInitiatedAction;
+
 class RefundWithData extends AdyenMessage {
+
+       /**
+        * 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 RefundInitiatedAction();
+               $result = $action->execute( $this );
+
+               if ( $result === true ) {
+                       return parent::runActionChain();
+               } else {
+                       return false;
+               }
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id7bca5543b65ccf7ceb45834db780669f2dd29bc
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/PaymentsListeners
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>

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

Reply via email to