Katie Horn has submitted this change and it was merged.
Change subject: Adyen Chargeback Handling
......................................................................
Adyen Chargeback Handling
This will at least give us some intelligent failmail when we get
a chargeback :)
Change-Id: I564f64676e01cb6aa52dfd199f49df5428bf7692
---
M SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
A SmashPig/PaymentProviders/Adyen/Actions/ChargebackInitiatedAction.php
A SmashPig/PaymentProviders/Adyen/Actions/ChargebackReversedAction.php
A SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Chargeback.php
M SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/ChargebackReversed.php
A
SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/NotificationOfChargeback.php
A SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RequestForInformation.php
7 files changed, 194 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
index b313b16..2e8bb90 100644
--- a/SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
+++ b/SmashPig/PaymentProviders/Adyen/Actions/CaptureResponseAction.php
@@ -5,6 +5,11 @@
use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Capture;
use SmashPig\Core\Logging\Logger;
+/**
+ * Action that takes place after a Capture modification request has completed.
+ *
+ * @package SmashPig\PaymentProviders\Adyen\Actions
+ */
class CaptureResponseAction implements IListenerMessageAction {
public function execute( ListenerMessage $msg ) {
Logger::enterContext( 'CaptureResponseAction' );
diff --git
a/SmashPig/PaymentProviders/Adyen/Actions/ChargebackInitiatedAction.php
b/SmashPig/PaymentProviders/Adyen/Actions/ChargebackInitiatedAction.php
new file mode 100644
index 0000000..6a0835f
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/Actions/ChargebackInitiatedAction.php
@@ -0,0 +1,34 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\Actions;
+
+use SmashPig\Core\Messages\ListenerMessage;
+use SmashPig\Core\Actions\IListenerMessageAction;
+use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Chargeback;
+use
SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\NotificationOfChargeback;
+use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\RequestForInformation;
+use SmashPig\Core\Logging\Logger;
+
+/**
+ * When any kind of chargeback initiated (or completion) message arrives, this
will
+ * be fired.
+ */
+class ChargebackInitiatedAction implements IListenerMessageAction {
+ public function execute( ListenerMessage $msg ) {
+ Logger::enterContext( 'ChargebackInitiatedAction' );
+
+ if ( $msg instanceof Chargeback ||
+ $msg instanceof NotificationOfChargeback ||
+ $msg instanceof RequestForInformation
+ ) {
+ // 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 chargeback 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/Actions/ChargebackReversedAction.php
b/SmashPig/PaymentProviders/Adyen/Actions/ChargebackReversedAction.php
new file mode 100644
index 0000000..aebcff5
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/Actions/ChargebackReversedAction.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\ChargebackReversed;
+use SmashPig\Core\Logging\Logger;
+
+/**
+ * Action to fire when an iniated chargeback is canceled.
+ */
+class ChargebackReversedAction implements IListenerMessageAction {
+ public function execute( ListenerMessage $msg ) {
+ Logger::enterContext( 'ChargebackInitiatedAction' );
+
+ if ( $msg instanceof ChargebackReversed ) {
+ // 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 chargeback reversal 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/Chargeback.php
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Chargeback.php
new file mode 100644
index 0000000..3e5f2a4
--- /dev/null
+++ b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/Chargeback.php
@@ -0,0 +1,34 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
+
+use SmashPig\PaymentProviders\Adyen\Actions\PaymentCaptureAction;
+
+/**
+ * A CHARGEBACK message is sent as the final stage of the chargeback
+ * process. At this point the money will have been debited from the
+ * account. This is not sent if a REQUEST_FOR_INFORMATION or
+ * NOTIFICATION_OF_CHARGEBACK notification has already been sent.
+ *
+ * @package SmashPig\PaymentProviders\Adyen\ExpatriatedMessages
+ */
+class Chargeback 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 PaymentCaptureAction();
+ $result = $action->execute( $this );
+
+ if ( $result === true ) {
+ return parent::runActionChain();
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git
a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/ChargebackReversed.php
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/ChargebackReversed.php
index ce8e21a..907beba 100644
--- a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/ChargebackReversed.php
+++ b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/ChargebackReversed.php
@@ -1,5 +1,32 @@
<?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
+use SmashPig\PaymentProviders\Adyen\Actions\ChargebackReversedAction;
+
+/**
+ * A CHARGEBACK_REVERSED message is sent when the chargeback has been
+ * canceled somehow.
+ *
+ * @package SmashPig\PaymentProviders\Adyen\ExpatriatedMessages
+ */
class ChargebackReversed 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 ChargebackReversedAction();
+ $result = $action->execute( $this );
+
+ if ( $result === true ) {
+ return parent::runActionChain();
+ } else {
+ return false;
+ }
+ }
}
diff --git
a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/NotificationOfChargeback.php
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/NotificationOfChargeback.php
new file mode 100644
index 0000000..a7267fd
--- /dev/null
+++
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/NotificationOfChargeback.php
@@ -0,0 +1,33 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
+
+use SmashPig\PaymentProviders\Adyen\Actions\PaymentCaptureAction;
+
+/**
+ * A NOTIFICATION_OF_CHARGEBACK message is sent as a preliminary stage
+ * for a chargeback process. The chargeback is pending, but may still
+ * be defended if needed.
+ *
+ * @package SmashPig\PaymentProviders\Adyen\ExpatriatedMessages
+ */
+class NotificationOfChargeback 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 PaymentCaptureAction();
+ $result = $action->execute( $this );
+
+ if ( $result === true ) {
+ return parent::runActionChain();
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git
a/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RequestForInformation.php
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RequestForInformation.php
new file mode 100644
index 0000000..99d900f
--- /dev/null
+++
b/SmashPig/PaymentProviders/Adyen/ExpatriatedMessages/RequestForInformation.php
@@ -0,0 +1,33 @@
+<?php namespace SmashPig\PaymentProviders\Adyen\ExpatriatedMessages;
+
+use SmashPig\PaymentProviders\Adyen\Actions\PaymentCaptureAction;
+
+/**
+ * A REQUEST_FOR_INFORMATION message is sent as a preliminary stage
+ * for a chargeback process. In theory this means that the account
+ * holder needs to defend why the chargeback should not be upheld.
+ *
+ * @package SmashPig\PaymentProviders\Adyen\ExpatriatedMessages
+ */
+class RequestForInformation 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 PaymentCaptureAction();
+ $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/67564
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I564f64676e01cb6aa52dfd199f49df5428bf7692
Gerrit-PatchSet: 3
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