[MediaWiki-commits] [Gerrit] mediawiki...DonationInterface[master]: Amazon: show TY page on TransactionTimedOut
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/399832 ) Change subject: Amazon: show TY page on TransactionTimedOut .. Amazon: show TY page on TransactionTimedOut Show the TY page when donor services might push a payment through. Bug: T183429 Change-Id: I7aa643f9014bdc9fd6b394e44c1ff130a998422e --- M amazon_gateway/amazon.adapter.php M tests/phpunit/Adapter/Amazon/AmazonTest.php 2 files changed, 24 insertions(+), 5 deletions(-) Approvals: Mepps: Looks good to me, approved jenkins-bot: Verified diff --git a/amazon_gateway/amazon.adapter.php b/amazon_gateway/amazon.adapter.php index 274fbd6..27c8920 100644 --- a/amazon_gateway/amazon.adapter.php +++ b/amazon_gateway/amazon.adapter.php @@ -49,12 +49,16 @@ // When an authorization or capture is declined, some reason codes indicate // a situation where the donor can retry later or try a different card - protected $retry_errors = array( + protected $retry_reasons = array( 'InternalServerError', 'RequestThrottled', 'ServiceUnavailable', 'ProcessingFailure', 'InvalidPaymentMethod', + ); + + protected $pending_reasons = array( + 'TransactionTimedOut', ); function __construct( $options = array() ) { @@ -411,12 +415,22 @@ */ public function handleErrors( $exception, $resultData ) { $errorCode = $exception->getErrorCode(); + if ( array_search( $errorCode, $this->pending_reasons ) !== false ) { + // These reason codes mean the donation is in limbo. We can't + // do anything more about it right now, but donor services might + // push it through manually later. + $this->logger->info( + "Setting final status to pending on decline reason $errorCode" + ); + $this->finalizeInternalStatus( FinalStatus::PENDING ); + return; + } $resultData->addError( new PaymentError( $errorCode, $exception->getMessage(), LogLevel::ERROR ) ); - if ( array_search( $errorCode, $this->retry_errors ) === false ) { + if ( array_search( $errorCode, $this->retry_reasons ) === false ) { // Fail on anything we don't recognize as retry-able. For example: // These two may show up if we start doing asynchronous authorization // 'AmazonClosed', diff --git a/tests/phpunit/Adapter/Amazon/AmazonTest.php b/tests/phpunit/Adapter/Amazon/AmazonTest.php index a949780..dc4fa6a 100644 --- a/tests/phpunit/Adapter/Amazon/AmazonTest.php +++ b/tests/phpunit/Adapter/Amazon/AmazonTest.php @@ -219,8 +219,8 @@ } /** -* When the transaction times out, just gotta fail it till we work out an -* asynchronous authorization flow +* When the transaction times out, show the thank you page and call the +* payment 'pending'. */ function testTransactionTimedOut() { $init = $this->getDonorTestData( 'US' ); @@ -237,7 +237,12 @@ $gateway = $this->getFreshGatewayObject( $init ); $result = $gateway->doPayment(); - $this->assertTrue( $result->isFailed(), 'Result should be failed' ); + $this->assertEquals( FinalStatus::PENDING, $gateway->getFinalStatus() ); + $this->assertFalse( $result->isFailed() ); + $donationMessage = QueueWrapper::getQueue( 'donations' )->pop(); + $this->assertNull( $donationMessage ); + $paymentInitMessages = QueueWrapper::getQueue( 'payments-init' )->pop(); + $this->assertEquals( FinalStatus::PENDING, $paymentInitMessages['payments_final_status'] ); } /** -- To view, visit https://gerrit.wikimedia.org/r/399832 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7aa643f9014bdc9fd6b394e44c1ff130a998422e Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg Gerrit-Reviewer: AndyRussG Gerrit-Reviewer: Mepps Gerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...DonationInterface[master]: Amazon: show TY page on TransactionTimedOut
Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/399832 ) Change subject: Amazon: show TY page on TransactionTimedOut .. Amazon: show TY page on TransactionTimedOut Show the TY page when donor services might push a payment through. Bug: T183429 Change-Id: I7aa643f9014bdc9fd6b394e44c1ff130a998422e --- M amazon_gateway/amazon.adapter.php M tests/phpunit/Adapter/Amazon/AmazonTest.php 2 files changed, 24 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/32/399832/1 diff --git a/amazon_gateway/amazon.adapter.php b/amazon_gateway/amazon.adapter.php index 274fbd6..27c8920 100644 --- a/amazon_gateway/amazon.adapter.php +++ b/amazon_gateway/amazon.adapter.php @@ -49,12 +49,16 @@ // When an authorization or capture is declined, some reason codes indicate // a situation where the donor can retry later or try a different card - protected $retry_errors = array( + protected $retry_reasons = array( 'InternalServerError', 'RequestThrottled', 'ServiceUnavailable', 'ProcessingFailure', 'InvalidPaymentMethod', + ); + + protected $pending_reasons = array( + 'TransactionTimedOut', ); function __construct( $options = array() ) { @@ -411,12 +415,22 @@ */ public function handleErrors( $exception, $resultData ) { $errorCode = $exception->getErrorCode(); + if ( array_search( $errorCode, $this->pending_reasons ) !== false ) { + // These reason codes mean the donation is in limbo. We can't + // do anything more about it right now, but donor services might + // push it through manually later. + $this->logger->info( + "Setting final status to pending on decline reason $errorCode" + ); + $this->finalizeInternalStatus( FinalStatus::PENDING ); + return; + } $resultData->addError( new PaymentError( $errorCode, $exception->getMessage(), LogLevel::ERROR ) ); - if ( array_search( $errorCode, $this->retry_errors ) === false ) { + if ( array_search( $errorCode, $this->retry_reasons ) === false ) { // Fail on anything we don't recognize as retry-able. For example: // These two may show up if we start doing asynchronous authorization // 'AmazonClosed', diff --git a/tests/phpunit/Adapter/Amazon/AmazonTest.php b/tests/phpunit/Adapter/Amazon/AmazonTest.php index a949780..dc4fa6a 100644 --- a/tests/phpunit/Adapter/Amazon/AmazonTest.php +++ b/tests/phpunit/Adapter/Amazon/AmazonTest.php @@ -219,8 +219,8 @@ } /** -* When the transaction times out, just gotta fail it till we work out an -* asynchronous authorization flow +* When the transaction times out, show the thank you page and call the +* payment 'pending'. */ function testTransactionTimedOut() { $init = $this->getDonorTestData( 'US' ); @@ -237,7 +237,12 @@ $gateway = $this->getFreshGatewayObject( $init ); $result = $gateway->doPayment(); - $this->assertTrue( $result->isFailed(), 'Result should be failed' ); + $this->assertEquals( FinalStatus::PENDING, $gateway->getFinalStatus() ); + $this->assertFalse( $result->isFailed() ); + $donationMessage = QueueWrapper::getQueue( 'donations' )->pop(); + $this->assertNull( $donationMessage ); + $paymentInitMessages = QueueWrapper::getQueue( 'payments-init' )->pop(); + $this->assertEquals( FinalStatus::PENDING, $paymentInitMessages['payments_final_status'] ); } /** -- To view, visit https://gerrit.wikimedia.org/r/399832 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7aa643f9014bdc9fd6b394e44c1ff130a998422e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits