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

Change subject: Recover Amazon order IDs when txn captured at console
......................................................................


Recover Amazon order IDs when txn captured at console

Bug: T167380
Change-Id: I60408a7029d06945ac9dd69af0ebf0f00695cbdf
---
M PaymentProviders/Amazon/Actions/ReconstructMerchantReference.php
M PaymentProviders/Amazon/AmazonApi.php
M PaymentProviders/Amazon/Audit/SettlementReport.php
3 files changed, 13 insertions(+), 2 deletions(-)

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



diff --git a/PaymentProviders/Amazon/Actions/ReconstructMerchantReference.php 
b/PaymentProviders/Amazon/Actions/ReconstructMerchantReference.php
index 21be498..27ff4df 100644
--- a/PaymentProviders/Amazon/Actions/ReconstructMerchantReference.php
+++ b/PaymentProviders/Amazon/Actions/ReconstructMerchantReference.php
@@ -18,7 +18,7 @@
                        return true;
                }
                $captureReference = $msg->getOrderId();
-               if ( substr( $captureReference, 0, 10 ) !== 'AUTHORIZE_' ) {
+               if ( !AmazonApi::isAmazonGeneratedMerchantReference( 
$captureReference ) ) {
                        // We only have to fix Amazon-generated IDs with that 
prefix
                        return true;
                }
diff --git a/PaymentProviders/Amazon/AmazonApi.php 
b/PaymentProviders/Amazon/AmazonApi.php
index 1a0bf66..9714c80 100644
--- a/PaymentProviders/Amazon/AmazonApi.php
+++ b/PaymentProviders/Amazon/AmazonApi.php
@@ -158,4 +158,8 @@
                        throw new SmashPigException( 
$result['Error']['Message'] );
                }
        }
+
+       public static function isAmazonGeneratedMerchantReference( $reference ) 
{
+               return substr( $reference, 0, 10 ) === 'AUTHORIZE_';
+       }
 }
diff --git a/PaymentProviders/Amazon/Audit/SettlementReport.php 
b/PaymentProviders/Amazon/Audit/SettlementReport.php
index 9b8f524..c96e28a 100644
--- a/PaymentProviders/Amazon/Audit/SettlementReport.php
+++ b/PaymentProviders/Amazon/Audit/SettlementReport.php
@@ -4,6 +4,7 @@
 use SmashPig\Core\DataFiles\DataFileException;
 use SmashPig\Core\Logging\Logger;
 use SmashPig\Core\UtcDate;
+use SmashPig\PaymentProviders\Amazon\AmazonApi;
 
 /**
  * Parses off-Amazon payments settlement reports retrieved from MWS
@@ -35,7 +36,7 @@
 
        /**
         * @param HeadedCsvReader $csv
-        * @throws OutOfBoundsException
+        * @throws \OutOfBoundsException
         */
        protected function parseLine( HeadedCsvReader $csv ) {
                $type = $csv->currentCol( 'TransactionType' );
@@ -47,6 +48,12 @@
 
                $msg = array();
                $orderId = $csv->currentCol( 'SellerReferenceId' );
+               if ( AmazonApi::isAmazonGeneratedMerchantReference( $orderId ) 
) {
+                       // If the capture was pushed through via console and the
+                       // SellerReferenceId is an arbitrary number generated by
+                       // Amazon, our original order ID might be in 
SellerOrderId
+                       $orderId = $csv->currentCol( 'SellerOrderId' );
+               }
                $parts = explode( '-', $orderId );
                $msg['contribution_tracking_id'] = $parts[0];
                $msg['currency'] = $csv->currentCol( 'CurrencyCode' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I60408a7029d06945ac9dd69af0ebf0f00695cbdf
Gerrit-PatchSet: 4
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Mepps <[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