Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/232911

Change subject: WIP Convert queue message back into DI format
......................................................................

WIP Convert queue message back into DI format

Queue messages use slightly different keys than in the rest of 
DonationInterface.
Normalize them so we can run do_transaction on the data.

This reverts a regression I introduced in 696861e5.

TODO
* Unit and smoke tests

Bug: T109527
Change-Id: I23e44114a5c8ae1d5ad9eeab4fe285de4b55bbc9
---
M gateway_common/DonationQueue.php
M globalcollect_gateway/scripts/orphans.php
2 files changed, 35 insertions(+), 1 deletion(-)


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

diff --git a/gateway_common/DonationQueue.php b/gateway_common/DonationQueue.php
index 9428917..a57ea1b 100644
--- a/gateway_common/DonationQueue.php
+++ b/gateway_common/DonationQueue.php
@@ -240,4 +240,37 @@
 
                return $message;
        }
+
+       /**
+        * Called by the orphan rectifier to change a queue message back into a 
gateway
+        * transaction array, basically undoing the mappings from 
createQueueMessage
+        *
+        * TODO: This shouldn't be necessary, see 
https://phabricator.wikimedia.org/T109819
+        *
+        * @param array $transaction Queue message
+        *
+        * @return array message with queue keys remapped to gateway keys
+        */
+       public static function queueMessageToNormalized( $transaction ) {
+               // For now, this function assumes that we have a complete queue 
message.
+
+               $rekey = array(
+                       'first_name' => 'fname',
+                       'last_name' => 'lname',
+                       'street_address' => 'street',
+                       'state_province' => 'state',
+                       'postal_code' => 'zip',
+                       'currency' => 'currency_code',
+                       'gross' => 'amount',
+               );
+
+               foreach ( $rekey as $wire => $normal ){
+                       if ( isset( $transaction[$wire] ) ){
+                               $transaction[$normal] = $transaction[$wire];
+                               unset($transaction[$wire]);
+                       };
+               }
+
+               return $transaction;
+       }
 }
diff --git a/globalcollect_gateway/scripts/orphans.php 
b/globalcollect_gateway/scripts/orphans.php
index 292dcf3..451df9b 100644
--- a/globalcollect_gateway/scripts/orphans.php
+++ b/globalcollect_gateway/scripts/orphans.php
@@ -179,7 +179,8 @@
                $this->info( "Rectifying orphan: {$data['order_id']}" );
                $rectified = false;
 
-               $this->adapter->loadDataAndReInit( $data, 
$query_contribution_tracking );
+               $normalized = DonationQueue::queueMessageToNormalized( $data );
+               $this->adapter->loadDataAndReInit( $normalized, 
$query_contribution_tracking );
                $results = $this->adapter->do_transaction( 'Confirm_CreditCard' 
);
                $message = $results->getMessage();
                if ( $results->getCommunicationStatus() ){

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23e44114a5c8ae1d5ad9eeab4fe285de4b55bbc9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

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

Reply via email to