Awight has uploaded a new change for review.

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

Change subject: Log completed donations
......................................................................

Log completed donations

This is to debug an active issue, and would ideally generalize how we log
transaction details in recoverable form, but doesn't quite make the cut.

Bug: T140515
Change-Id: Iab065e0d70184040e47260d6d54334daa5db88ca
---
M README.txt
M extension.json
M gateway_common/gateway.adapter.php
3 files changed, 20 insertions(+), 2 deletions(-)


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

diff --git a/README.txt b/README.txt
index 8f33d8f..dbe9278 100644
--- a/README.txt
+++ b/README.txt
@@ -132,6 +132,10 @@
 
 $wgDonationInterfaceCurlVerboseLog = false
 
+As donations are sent to the "completed" queue, also log the json blob.
+
+$wgDonationInterfaceLogCompletion = false
+
 ==== Currency and amounts ====
 
 Configure price ceiling and floor for valid contribution amount.  Values
diff --git a/extension.json b/extension.json
index e150795..5a4b044 100644
--- a/extension.json
+++ b/extension.json
@@ -399,6 +399,7 @@
                "DonationInterfaceUseSyslog": false,
                "DonationInterfaceSaveCommStats": false,
                "DonationInterfaceCurlVerboseLog": false,
+               "DonationInterfaceLogCompletion": false,
                "DonationInterfaceTimeout": 5,
                "DonationInterfaceFallbackCurrency": false,
                "DonationInterfaceFallbackCurrencyByCountry": false,
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 044f530..ebdb0ec 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -31,6 +31,12 @@
 abstract class GatewayAdapter implements GatewayType, LogPrefixProvider {
 
        /**
+        * Don't change these strings without fixing cross-repo usages.
+        */
+       const REDIRECT_PREFACE = 'Redirecting for transaction: ';
+       const COMPLETED_PREFACE = 'Completed donation: ';
+
+       /**
         * config tree
         */
        protected $config = array();
@@ -1708,6 +1714,7 @@
                        case FinalStatus::COMPLETE:
                                // This transaction completed successfully.  
Send to the CRM
                                // for filing.
+                               $this->logCompletion();
                                $this->pushMessage( 'complete' );
                                break;
 
@@ -3716,9 +3723,15 @@
                return json_encode( $logObj );
        }
 
-       protected function logPaymentDetails() {
+       protected function logPaymentDetails( $preface = REDIRECT_PREFACE ) {
                $details = $this->getStompTransaction();
-               $this->logger->info( 'Redirecting for transaction: ' . 
json_encode( $details ) );
+               $this->logger->info( $preface . json_encode( $details ) );
+       }
+
+       protected function logCompletion() {
+               if ( $this->getGlobal( 'LogCompletion' ) ) {
+                       $this->logPaymentDetails( COMPLETED_PREFACE );
+               }
        }
 
        protected function runApiCallHooks() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab065e0d70184040e47260d6d54334daa5db88ca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>

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

Reply via email to