jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/403745 )

Change subject: Add catch statement to processDonorReturn, use timeout status
......................................................................


Add catch statement to processDonorReturn, use timeout status

Bug: T184284
Change-Id: If2e801b4ed876564faf20060c975912657cbf8df
---
M paypal_gateway/express_checkout/paypal_express.adapter.php
M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
A 
tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Timeout.testresponse
3 files changed, 33 insertions(+), 0 deletions(-)

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



diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php 
b/paypal_gateway/express_checkout/paypal_express.adapter.php
index 5e79a63..87d1272 100644
--- a/paypal_gateway/express_checkout/paypal_express.adapter.php
+++ b/paypal_gateway/express_checkout/paypal_express.adapter.php
@@ -504,6 +504,12 @@
                                                );
                                                $fatal = false;
                                                break;
+                                       case '10411':
+                                               if ( $this->isBatchProcessor() 
) {
+                                                       
$this->finalizeInternalStatus( FinalStatus::TIMEOUT );
+                                                       $fatal = false;
+                                                       break;
+                                               }
                                        default:
                                                
$this->transaction_response->addError( $error );
                                }
@@ -556,6 +562,10 @@
                }
                $this->addRequestData( $requestData );
                $resultData = $this->do_transaction( 
'GetExpressCheckoutDetails' );
+               // FixMe: What to do outside of batch processing?
+               if ( $this->isBatchProcessor() && $this->getFinalStatus() == 
FinalStatus::TIMEOUT ) {
+                       return PaymentResult::newEmpty();
+               }
                if ( !$resultData->getCommunicationStatus() ) {
                        throw new ResponseProcessingException( 'Failed to get 
customer details',
                                ResponseCodes::UNKNOWN );
diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php 
b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
index c07050f..14d6443 100644
--- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
+++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
@@ -431,6 +431,28 @@
                $this->assertNull( $message, 'Should not queue a message' );
        }
 
+       /*
+        * Check that it does not call doPayment when the token has timed out
+        */
+       public function testProcessDonorReturnTokenTimeout() {
+               $init = $this->getDonorTestData( 'US' );
+               $init['contribution_tracking_id'] = '45931210';
+               $options = array( 'batch_mode' => true );
+               $this->setUpRequest( $init, array( 'Donor' => $init ) );
+
+               $gateway = $this->getFreshGatewayObject( $init, $options );
+               $gateway::setDummyGatewayResponseCode( 'Timeout' );
+               $gateway->processDonorReturn( array(
+                       'token' => 'EC%2d4V987654XA123456V',
+                       'PayerID' => 'ASDASD',
+               ) );
+
+               $this->assertEquals( FinalStatus::TIMEOUT, 
$gateway->getFinalStatus(), 'Should have Final Status Timeout' );
+               $this->assertEquals( 1, count( $gateway->curled ), 'Should only 
call curl once' );
+               $message = QueueWrapper::getQueue( 'donations' )->pop();
+               $this->assertNull( $message, 'Should not queue a message' );
+       }
+
        /**
         * The result switcher should redirect the donor to the thank you page 
and mark the token as
         * processed.
diff --git 
a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Timeout.testresponse
 
b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Timeout.testresponse
new file mode 100644
index 0000000..d1fed79
--- /dev/null
+++ 
b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Timeout.testresponse
@@ -0,0 +1 @@
+TOKEN=EC%2d50M26113274765456&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2018%2d01%2d12T21%3a22%3a19Z&CORRELATIONID=97825e40f3857&ACK=Failure&VERSION=204&BUILD=40680762&L_ERRORCODE0=10411&L_SHORTMESSAGE0=This%20Express%20Checkout%20session%20has%20expired%2e&L_LONGMESSAGE0=This%20Express%20Checkout%20session%20has%20expired%2e%20%20Token%20value%20is%20no%20longer%20valid%2e&L_SEVERITYCODE0=Error&CURRENCYCODE=JPY&AMT=1000&ITEMAMT=1000&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&CUSTOM=56383531&DESC=Donation%20to%20the%20Wikimedia%20Foundation&INVNUM=56383531%2e1&INSURANCEAMT=0&SHIPDISCAMT=0&L_QTY0=1&L_TAXAMT0=0&L_AMT0=1000&L_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&L_ITEMWEIGHTVALUE0=%20%20%200%2e00000&L_ITEMLENGTHVALUE0=%20%20%200%2e00000&L_ITEMWIDTHVALUE0=%20%20%200%2e00000&L_ITEMHEIGHTVALUE0=%20%20%200%2e00000&PAYMENTREQUEST_0_CURRENCYCODE=JPY&PAYMENTREQUEST_0_AMT=1000&PAYMENTREQUEST_0_ITEMAMT=1000&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_CUSTOM=56383531&PAYMENTREQUEST_0_DESC=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_INVNUM=56383531%2e1&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSNORMALIZATIONSTATUS=None&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_TAXAMT0=0&L_PAYMENTREQUEST_0_AMT0=1000&L_PAYMENTREQUEST_0_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0=%20%20%200%2e00000&L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0=%20%20%200%2e00000&L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0=%20%20%200%2e00000&L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0=%20%20%200%2e00000&PAYMENTREQUESTINFO_0_ERRORCODE=0

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If2e801b4ed876564faf20060c975912657cbf8df
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Mepps <me...@wikimedia.org>
Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com>
Gerrit-Reviewer: Ejegg <ej...@ejegg.com>
Gerrit-Reviewer: Mepps <me...@wikimedia.org>
Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to