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

Change subject: Deal with retry errors in pp recurring
......................................................................


Deal with retry errors in pp recurring

Bug: T165089
Change-Id: If8caec4ca3a5d4918d4ea9e8993b451a153f5015
---
M paypal_gateway/express_checkout/paypal_express.adapter.php
M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
2 files changed, 31 insertions(+), 2 deletions(-)

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



diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php 
b/paypal_gateway/express_checkout/paypal_express.adapter.php
index 67e593c..481d94b 100644
--- a/paypal_gateway/express_checkout/paypal_express.adapter.php
+++ b/paypal_gateway/express_checkout/paypal_express.adapter.php
@@ -527,14 +527,19 @@
                }
 
                // One-time payment, or initial payment in a subscription.
-               // XXX: This shouldn't finalize the transaction.
                $resultData = $this->do_transaction( 'DoExpressCheckoutPayment' 
);
                if ( !$resultData->getCommunicationStatus() ) {
                        $this->finalizeInternalStatus( FinalStatus::FAILED );
                        return PaymentResult::newFailure();
                }
 
-               if ( $this->getData_Unstaged_Escaped( 'recurring' ) ) {
+               // Silly conditional. What we really want to know is if the
+               // DoExpressCheckoutPayment txn was successful.
+               if (
+                       !$resultData->getRedirect() &&
+                       !$resultData->getErrors() &&
+                       $this->getData_Unstaged_Escaped( 'recurring' )
+               ) {
                        // Set up recurring billing agreement.
                        $this->addRequestData( array(
                                // Start in a month; we're making today's 
payment as an one-time charge.
diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php 
b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
index c062a14..ac4dba3 100644
--- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
+++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
@@ -161,4 +161,28 @@
                );
        }
 
+       public function testProcessDonorReturnRecurringRetry() {
+               $init = $this->getDonorTestData( 'US' );
+               $init['contribution_tracking_id'] = '45931210';
+               $init['recurring'] = '1';
+               $this->setUpRequest( $init, array( 'Donor' => $init ) );
+               $gateway = $this->getFreshGatewayObject( $init );
+               $gateway->setDummyGatewayResponseCode( '10486' );
+               $result = $gateway->processDonorReturn( array(
+                       'token' => 'EC%2d2D123456D9876543U',
+                       'PayerID' => 'ASDASD'
+               ) );
+
+               $this->assertNull(
+                       DonationQueue::instance()->pop( 'complete' ),
+                       'Sending a spurious message to the complete queue!'
+               );
+               $this->assertFalse( $result->isFailed() );
+               $redirect = $result->getRedirect();
+               $this->assertEquals(
+                       
'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2D123456D9876543U',
+                       $redirect
+               );
+       }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If8caec4ca3a5d4918d4ea9e8993b451a153f5015
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to