[MediaWiki-commits] [Gerrit] mediawiki...DonationInterface[master]: Standardize pending queue message and logging in API

2017-07-19 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/366159 )

Change subject: Standardize pending queue message and logging in API
..


Standardize pending queue message and logging in API

Needed for the new PayPal EC redirect flow, as the last change
removed pending messages and logging.

This patch makes the donate API call the same logPending method that
the GatewayPage class calls when the payment result is a redirect.

This patch also adds Adyen API tests.

Bug: T167923
Change-Id: I4ac8eb79fa8ab697eed272ef14a5fd6bf412dc55
---
M adyen_gateway/adyen.adapter.php
M gateway_common/donation.api.php
M globalcollect_gateway/globalcollect.adapter.php
A tests/phpunit/Adapter/Adyen/AdyenApiTest.php
M tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php
M tests/phpunit/Adapter/PayPal/PayPalApiTest.php
M tests/phpunit/DonationInterfaceApiTestCase.php
7 files changed, 250 insertions(+), 25 deletions(-)

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



diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index 47896f2..4542a24 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -165,7 +165,7 @@
if ( !$this->validatedOK() ){
//If the data didn't validate okay, prevent all data 
transmissions.
$response = $this->getFailedValidationResponse();
-   $this->logger->info( "Failed Validation. Aborting 
$transaction " . print_r( $this->errors, true ) );
+   $this->logger->info( "Failed Validation. Aborting 
$transaction " . print_r( $this->errorState, true ) );
return $response;
}
$this->transaction_response = new PaymentTransactionResponse();
@@ -196,10 +196,9 @@
'FORMACTION' => $formaction,
'gateway_params' => 
$requestParams,
) );
-   $this->logger->info( "launching 
external iframe request: " . print_r( $requestParams, true )
+   $this->logger->info(
+   "launching external iframe 
request: " . print_r( $requestParams, true )
);
-   $this->logPaymentDetails();
-   $this->sendPendingMessage();
break;
}
}
diff --git a/gateway_common/donation.api.php b/gateway_common/donation.api.php
index 7ad1075..107f62c 100644
--- a/gateway_common/donation.api.php
+++ b/gateway_common/donation.api.php
@@ -62,6 +62,7 @@
$outputResult['status'] = 
$result->getCommunicationStatus();
}
 
+   $errors = $result->getErrors();
$data = $result->getData();
if ( !empty( $data ) ) {
if ( array_key_exists( 'PAYMENT', $data )
@@ -71,6 +72,9 @@
}
if ( array_key_exists( 'FORMACTION', $data ) ) {
$outputResult['formaction'] = 
$data['FORMACTION'];
+   if ( empty( $errors ) ) {
+   $gatewayObj->logPending();
+   }
}
if ( array_key_exists( 'gateway_params', $data ) ) {
$outputResult['gateway_params'] = 
$data['gateway_params'];
@@ -82,7 +86,6 @@
$outputResult['orderid'] = $data['ORDERID'];
}
}
-   $errors = $result->getErrors();
if ( !empty( $errors ) ) {
$outputResult['errors'] = $this->serializeErrors( 
$errors, $gatewayObj );
$this->getResult()->setIndexedTagName( 
$outputResult['errors'], 'error' );
diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index c3b94d8..f509250 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -1691,24 +1691,6 @@
}
}
 
-   /**
-* post-process function for INSERT_ORDERWITHPAYMENT.
-* This gets called by executeIfFunctionExists, in do_transaction.
-*/
-   protected function post_process_insert_orderwithpayment(){
-   //yeah, we absolutely want to do this for every one of these.
-   if ( $this->getTransactionStatus() === true ) {
-   $data = $this->getTransactionData();
-   $action = $this->findC

[MediaWiki-commits] [Gerrit] mediawiki...DonationInterface[master]: Standardize pending queue message and logging in API

2017-07-18 Thread Ejegg (Code Review)
Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/366159 )

Change subject: Standardize pending queue message and logging in API
..

Standardize pending queue message and logging in API

Needed for the new PayPal EC redirect flow, as the last change
removed pending messages and logging.

This patch makes the donate API call the same logPending method that
the GatewayPage class calls when the payment result is a redirect.

This patch also adds Adyen API tests

TODO: test invalid submissions, look at logged messages.

Bug: T167923
Change-Id: I4ac8eb79fa8ab697eed272ef14a5fd6bf412dc55
---
M adyen_gateway/adyen.adapter.php
M gateway_common/donation.api.php
M globalcollect_gateway/globalcollect.adapter.php
A tests/phpunit/Adapter/Adyen/AdyenApiTest.php
M tests/phpunit/Adapter/GlobalCollect/GlobalCollectApiTest.php
M tests/phpunit/Adapter/PayPal/PayPalApiTest.php
M tests/phpunit/DonationInterfaceApiTestCase.php
7 files changed, 155 insertions(+), 24 deletions(-)


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

diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index 47896f2..4542a24 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -165,7 +165,7 @@
if ( !$this->validatedOK() ){
//If the data didn't validate okay, prevent all data 
transmissions.
$response = $this->getFailedValidationResponse();
-   $this->logger->info( "Failed Validation. Aborting 
$transaction " . print_r( $this->errors, true ) );
+   $this->logger->info( "Failed Validation. Aborting 
$transaction " . print_r( $this->errorState, true ) );
return $response;
}
$this->transaction_response = new PaymentTransactionResponse();
@@ -196,10 +196,9 @@
'FORMACTION' => $formaction,
'gateway_params' => 
$requestParams,
) );
-   $this->logger->info( "launching 
external iframe request: " . print_r( $requestParams, true )
+   $this->logger->info(
+   "launching external iframe 
request: " . print_r( $requestParams, true )
);
-   $this->logPaymentDetails();
-   $this->sendPendingMessage();
break;
}
}
diff --git a/gateway_common/donation.api.php b/gateway_common/donation.api.php
index 7ad1075..107f62c 100644
--- a/gateway_common/donation.api.php
+++ b/gateway_common/donation.api.php
@@ -62,6 +62,7 @@
$outputResult['status'] = 
$result->getCommunicationStatus();
}
 
+   $errors = $result->getErrors();
$data = $result->getData();
if ( !empty( $data ) ) {
if ( array_key_exists( 'PAYMENT', $data )
@@ -71,6 +72,9 @@
}
if ( array_key_exists( 'FORMACTION', $data ) ) {
$outputResult['formaction'] = 
$data['FORMACTION'];
+   if ( empty( $errors ) ) {
+   $gatewayObj->logPending();
+   }
}
if ( array_key_exists( 'gateway_params', $data ) ) {
$outputResult['gateway_params'] = 
$data['gateway_params'];
@@ -82,7 +86,6 @@
$outputResult['orderid'] = $data['ORDERID'];
}
}
-   $errors = $result->getErrors();
if ( !empty( $errors ) ) {
$outputResult['errors'] = $this->serializeErrors( 
$errors, $gatewayObj );
$this->getResult()->setIndexedTagName( 
$outputResult['errors'], 'error' );
diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index c3b94d8..f509250 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -1691,24 +1691,6 @@
}
}
 
-   /**
-* post-process function for INSERT_ORDERWITHPAYMENT.
-* This gets called by executeIfFunctionExists, in do_transaction.
-*/
-   protected function post_process_insert_orderwithpayment(){
-   //yeah, we absolutely want to do this for every one of these.
-   if ( $this->getTransactionStatus() === true ) {
-   $d