[MediaWiki-commits] [Gerrit] Log completed donations - change (mediawiki...DonationInterface)

2016-07-16 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Log completed donations
..


Log completed donations

This is to debug an active issue where the queue message body is missing, so we
circumvent the possibly buggy getStompTransaction.

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

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README.txt b/README.txt
index 60dd3f4..d00546c 100644
--- a/README.txt
+++ b/README.txt
@@ -128,6 +128,10 @@
 $wgDonationInterfaceDebugLog = false
 
 
+As donations are sent to the "completed" queue, also log the json blob.
+
+$wgDonationInterfaceLogCompleted = false
+
  Currency and amounts 
 
 Configure price ceiling and floor for valid contribution amount.  Values
diff --git a/extension.json b/extension.json
index ba0b7d9..c765731 100644
--- a/extension.json
+++ b/extension.json
@@ -441,6 +441,7 @@
"DonationInterfaceDisplayDebug": false,
"DonationInterfaceUseSyslog": false,
"DonationInterfaceSaveCommStats": false,
+   "DonationInterfaceLogCompleted": false,
"DonationInterfaceTimeout": 5,
"DonationInterfaceFallbackCurrency": false,
"DonationInterfaceFallbackCurrencyByCountry": false,
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index c0cb320..f294885 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();
@@ -1696,6 +1702,7 @@
case FinalStatus::COMPLETE:
// This transaction completed successfully.  
Send to the CRM
// for filing.
+   $this->logCompletedPayment();
$this->pushMessage( 'complete' );
break;
 
@@ -3707,7 +3714,17 @@
 
protected function logPaymentDetails() {
$details = $this->getStompTransaction();
-   $this->logger->info( 'Redirecting for transaction: ' . 
json_encode( $details ) );
+   $this->logger->info( self::REDIRECT_PREFACE . json_encode( 
$details ) );
+   }
+
+   protected function logCompletedPayment() {
+   if ( $this->getGlobal( 'LogCompleted' ) ) {
+   // FIXME: We probably want to dial this down to log the 
same fields
+   // as getStompTransaction, but I'm currently debugging 
that
+   // function, so dump it all:
+   $dump = json_encode( $this->getData_Unstaged_Escaped() 
);
+   $this->logger->info( self::COMPLETED_PREFACE . $dump );
+   }
}
 
protected function runApiCallHooks() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iab065e0d70184040e47260d6d54334daa5db88ca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: deployment
Gerrit-Owner: Awight 
Gerrit-Reviewer: Awight 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] Log completed donations - change (mediawiki...DonationInterface)

2016-07-16 Thread Awight (Code Review)
Awight has uploaded a new change for review.

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

Change subject: Log completed donations
..

Log completed donations

This is to debug an active issue where the queue message body is missing, so we
circumvent the possibly buggy getStompTransaction.

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


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

diff --git a/README.txt b/README.txt
index 60dd3f4..d00546c 100644
--- a/README.txt
+++ b/README.txt
@@ -128,6 +128,10 @@
 $wgDonationInterfaceDebugLog = false
 
 
+As donations are sent to the "completed" queue, also log the json blob.
+
+$wgDonationInterfaceLogCompleted = false
+
  Currency and amounts 
 
 Configure price ceiling and floor for valid contribution amount.  Values
diff --git a/extension.json b/extension.json
index ba0b7d9..c765731 100644
--- a/extension.json
+++ b/extension.json
@@ -441,6 +441,7 @@
"DonationInterfaceDisplayDebug": false,
"DonationInterfaceUseSyslog": false,
"DonationInterfaceSaveCommStats": false,
+   "DonationInterfaceLogCompleted": false,
"DonationInterfaceTimeout": 5,
"DonationInterfaceFallbackCurrency": false,
"DonationInterfaceFallbackCurrencyByCountry": false,
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index c0cb320..f294885 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();
@@ -1696,6 +1702,7 @@
case FinalStatus::COMPLETE:
// This transaction completed successfully.  
Send to the CRM
// for filing.
+   $this->logCompletedPayment();
$this->pushMessage( 'complete' );
break;
 
@@ -3707,7 +3714,17 @@
 
protected function logPaymentDetails() {
$details = $this->getStompTransaction();
-   $this->logger->info( 'Redirecting for transaction: ' . 
json_encode( $details ) );
+   $this->logger->info( self::REDIRECT_PREFACE . json_encode( 
$details ) );
+   }
+
+   protected function logCompletedPayment() {
+   if ( $this->getGlobal( 'LogCompleted' ) ) {
+   // FIXME: We probably want to dial this down to log the 
same fields
+   // as getStompTransaction, but I'm currently debugging 
that
+   // function, so dump it all:
+   $dump = json_encode( $this->getData_Unstaged_Escaped() 
);
+   $this->logger->info( self::COMPLETED_PREFACE . $dump );
+   }
}
 
protected function runApiCallHooks() {

-- 
To view, visit https://gerrit.wikimedia.org/r/299290
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: deployment
Gerrit-Owner: Awight 

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


[MediaWiki-commits] [Gerrit] Log completed donations - change (mediawiki...DonationInterface)

2016-07-16 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Log completed donations
..


Log completed donations

This is to debug an active issue where the queue message body is missing, so we
circumvent the possibly buggy getStompTransaction.

Bug: T140515
Change-Id: Iab065e0d70184040e47260d6d54334daa5db88ca
---
M README.txt
M extension.json
M gateway_common/gateway.adapter.php
A tests/LoggingTest.php
A tests/includes/Responses/globalcollect/DO_FINISHPAYMENT_200.testresponse
M tests/includes/Responses/globalcollect/GET_ORDERSTATUS.testresponse
A tests/includes/Responses/globalcollect/GET_ORDERSTATUS_200.testresponse
A tests/includes/Responses/globalcollect/SET_PAYMENT.testresponse
A tests/includes/Responses/globalcollect/SET_PAYMENT_200.testresponse
9 files changed, 263 insertions(+), 2 deletions(-)

Approvals:
  Cdentinger: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README.txt b/README.txt
index 8f33d8f..9ff6972 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.
+
+$wgDonationInterfaceLogCompleted = false
+
  Currency and amounts 
 
 Configure price ceiling and floor for valid contribution amount.  Values
diff --git a/extension.json b/extension.json
index e150795..3ea22ba 100644
--- a/extension.json
+++ b/extension.json
@@ -399,6 +399,7 @@
"DonationInterfaceUseSyslog": false,
"DonationInterfaceSaveCommStats": false,
"DonationInterfaceCurlVerboseLog": false,
+   "DonationInterfaceLogCompleted": false,
"DonationInterfaceTimeout": 5,
"DonationInterfaceFallbackCurrency": false,
"DonationInterfaceFallbackCurrencyByCountry": false,
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 044f530..dd991e5 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->logCompletedPayment();
$this->pushMessage( 'complete' );
break;
 
@@ -3718,7 +3725,17 @@
 
protected function logPaymentDetails() {
$details = $this->getStompTransaction();
-   $this->logger->info( 'Redirecting for transaction: ' . 
json_encode( $details ) );
+   $this->logger->info( self::REDIRECT_PREFACE . json_encode( 
$details ) );
+   }
+
+   protected function logCompletedPayment() {
+   if ( $this->getGlobal( 'LogCompleted' ) ) {
+   // FIXME: We probably want to dial this down to log the 
same fields
+   // as getStompTransaction, but I'm currently debugging 
that
+   // function, so dump it all:
+   $dump = json_encode( $this->getData_Unstaged_Escaped() 
);
+   $this->logger->info( self::COMPLETED_PREFACE . $dump );
+   }
}
 
protected function runApiCallHooks() {
diff --git a/tests/LoggingTest.php b/tests/LoggingTest.php
new file mode 100644
index 000..2ff51be
--- /dev/null
+++ b/tests/LoggingTest.php
@@ -0,0 +1,106 @@
+setMwGlobals( array(
+   'wgDonationInterfaceLogCompleted' => true,
+   ) );
+   }
+
+   /**
+* @param $name string The name of the test case
+* @param $data array Any parameters read from a dataProvider
+* @param $dataName string|int The name or index of the data set
+*/
+   function __construct( $name = null, array $data = array(), $dataName = 
'' ) {
+   parent::__construct( $name, $data, $dataName );
+   $this->testAdapterClass = 'TestingGlobalCollectAdapter';
+   }
+
+   /**
+* Check that we can log completed transactions
+*/
+   public function testLogCompleted() {
+   $init = $this->getDonorTestData();
+   $init['payment_method'] = 'cc';
+   $init['payment_submethod'] = 'visa';
+   $init['email'] = 'innoc...@manichean.com';
+   $init['ffname'] = 'cc-vmad';
+   $init['unusual_key'] = mt_rand();
+   

[MediaWiki-commits] [Gerrit] Log completed donations - change (mediawiki...DonationInterface)

2016-07-16 Thread Awight (Code Review)
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 

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