Katie Horn has submitted this change and it was merged.

Change subject: Adding Capture Message
......................................................................


Adding Capture Message

Apparently I forgot a key message -- the Capture message is sent once
the payment has been totally completed. We dont do anything here yet
but maybe in the future we will. Mostly this allows us to check that
nothing silly happens.

Change-Id: I7b79253698e623bfd4cead623317a879a6e0cc71
---
A SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
A SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Capture.php
2 files changed, 69 insertions(+), 0 deletions(-)

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



diff --git a/SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php 
b/SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
new file mode 100644
index 0000000..b313b16
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
@@ -0,0 +1,32 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\Actions;
+
+use SmashPig\Core\Messages\ListenerMessage;
+use SmashPig\Core\Actions\IListenerMessageAction;
+use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Capture;
+use SmashPig\Core\Logging\Logger;
+
+class CaptureResponseAction implements IListenerMessageAction {
+       public function execute( ListenerMessage $msg ) {
+               Logger::enterContext( 'CaptureResponseAction' );
+
+               if ( $msg instanceof Capture ) {
+                       if ( !$msg->success ) {
+                               // Crap; we've already recorded that this 
message has succeeded; guess
+                               // we should just send an email saying hey! 
something unexpected happened!
+                               Logger::error(
+                                       "Payment with reference 
{$msg->pspReference} and correlation id {$msg->correlationId} previously " .
+                                               "recorded as a success has 
failed to be successfully captured! Fix your records!",
+                                       $msg
+                               );
+                       }
+                       /* else {
+                               // TODO: This is probably where we should 
record payment, but I don't want to
+                               // add the complexity of a second job at this 
time.
+                       }
+                       */
+               }
+
+               Logger::leaveContext();
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Capture.php 
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Capture.php
new file mode 100644
index 0000000..eb25a7a
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Capture.php
@@ -0,0 +1,37 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
+
+use SmashPig\PaymentProviders\Adyen\Actions\CaptureResponseAction;
+
+/**
+ * An Adyen Capture message is sent from the server to SmashPig after
+ * the request has been made to capture the payment. Receipt of this
+ * message is the final indication of if a payment has been successfully
+ * completed or not. E.g. Status: Success in this message indicates that
+ * money will end up in your bank account.
+ *
+ * @see CaptureResponseAction
+ *
+ * @package SmashPig\PaymentProviders\Adyen\ExpatriatedMessages
+ */
+class Capture 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 CaptureResponseAction();
+               $result = $action->execute( $this );
+
+               if ( $result === true ) {
+                       return parent::runActionChain();
+               } else {
+                       return false;
+               }
+       }
+}
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7b79253698e623bfd4cead623317a879a6e0cc71
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