Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/239505
Change subject: Amazon: Set txn id on $this->transaction_response
......................................................................
Amazon: Set txn id on $this->transaction_response
This fixes the missing gateway_txn_id value in queue messages.
FIXME: deprecate this whole ambient state thing.
Bug: T113089
Change-Id: Id3c7b60bcc36dfaee2b37699274ed2ba2bbaf593
---
M amazon_gateway/amazon.adapter.php
M tests/Adapter/Amazon/AmazonTest.php
M tests/includes/test_gateway/TestingAmazonAdapter.php
3 files changed, 18 insertions(+), 3 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/05/239505/1
diff --git a/amazon_gateway/amazon.adapter.php
b/amazon_gateway/amazon.adapter.php
index d64075d..3fcb11d 100644
--- a/amazon_gateway/amazon.adapter.php
+++ b/amazon_gateway/amazon.adapter.php
@@ -155,7 +155,7 @@
public function doPayment() {
$this->client = $this->getPwaClient();
- $resultData = new PaymentTransactionResponse();
+ $this->transaction_response = new PaymentTransactionResponse();
if ( $this->session_getData( 'sequence' ) ) {
$this->regenerateOrderID();
}
@@ -164,13 +164,13 @@
$this->confirmOrderReference();
$this->authorizeAndCapturePayment();
} catch ( ResponseProcessingException $ex ) {
- $this->handleErrors( $ex, $resultData );
+ $this->handleErrors( $ex, $this->transaction_response );
}
$this->incrementSequenceNumber();
return PaymentResult::fromResults(
- $resultData,
+ $this->transaction_response,
$this->getFinalStatus()
);
}
@@ -206,8 +206,10 @@
} catch( Exception $ex ) {
$this->logger->error( 'SDK client call failed: ' .
$ex->getMessage() );
$donorMessage = WmfFramework::formatMessage(
'donate_interface-processing-error' );
+ $this->transaction_response->setCommunicationStatus(
false );
throw new ResponseProcessingException( $donorMessage,
ResponseCodes::NO_RESPONSE );
}
+ $this->transaction_response->setCommunicationStatus( true );
$this->checkErrors( $result );
return $result;
}
@@ -317,6 +319,8 @@
$captureId = $authDetails['IdList']['member'];
// Use capture ID as gateway_txn_id, since we need that for
refunds
$this->addResponseData( array( 'gateway_txn_id' => $captureId )
);
+ // And add it to the ambient transaction_response for
doStompTransaction
+ $this->transaction_response->setGatewayTransactionId(
$captureId );
$this->logger->info( "Getting details of capture $captureId" );
$captureResponse = $this->callPwaClient( 'getCaptureDetails',
array(
@@ -326,6 +330,7 @@
$this->logger->info( 'Capture details: ' . print_r(
$captureResponse, true ) );
$captureDetails =
$captureResponse['GetCaptureDetailsResult']['CaptureDetails'];
$captureState = $captureDetails['CaptureStatus']['State'];
+ $this->transaction_response->setTxnMessage( $captureState );
// TODO: verify that this does not prevent us from refunding.
$this->closeOrderReference();
diff --git a/tests/Adapter/Amazon/AmazonTest.php
b/tests/Adapter/Amazon/AmazonTest.php
index 29d07cb..1e47950 100644
--- a/tests/Adapter/Amazon/AmazonTest.php
+++ b/tests/Adapter/Amazon/AmazonTest.php
@@ -160,6 +160,10 @@
$this->assertEquals( $oid,
$setOrderReferenceDetailsArgs['seller_order_reference_id'], 'Did not set order
id on order reference' );
$this->assertEquals( $init['amount'],
$setOrderReferenceDetailsArgs['amount'], 'Did not set amount on order
reference' );
$this->assertEquals( $init['currency_code'],
$setOrderReferenceDetailsArgs['currency_code'], 'Did not set currency code on
order reference' );
+ $queued = $gateway->queue_messages;
+ $this->assertNotEmpty( $queued['complete'], 'Not sending a
message to the complete queue' );
+ $message = $queued['complete'][0];
+ $this->assertEquals( 'S01-0391295-0674065-C095112',
$message['gateway_txn_id'], 'Queue message has wrong txn ID' );
}
/**
diff --git a/tests/includes/test_gateway/TestingAmazonAdapter.php
b/tests/includes/test_gateway/TestingAmazonAdapter.php
index a1bf0f6..45407ea 100644
--- a/tests/includes/test_gateway/TestingAmazonAdapter.php
+++ b/tests/includes/test_gateway/TestingAmazonAdapter.php
@@ -8,6 +8,8 @@
public static $fakeGlobals = array();
public static $mockClient;
+ public $queue_messages = array();
+
public static function getGlobal( $name ) {
if ( array_key_exists( $name,
TestingAmazonAdapter::$fakeGlobals ) ) {
return TestingAmazonAdapter::$fakeGlobals[$name];
@@ -18,4 +20,8 @@
protected function getPwaClient() {
return self::$mockClient;
}
+
+ protected function pushMessage( $queue ) {
+ $this->queue_messages[$queue][] = $this->getStompTransaction();
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/239505
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3c7b60bcc36dfaee2b37699274ed2ba2bbaf593
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits