jenkins-bot has submitted this change and it was merged.

Change subject: Deal with stray 's' on the end of 'chargebacks'
......................................................................


Deal with stray 's' on the end of 'chargebacks'

Either 'Chargeback' or 'Chargebacks' type in file should map to
a refund of type 'chargeback'.

Bug: T112779
Change-Id: I5020525baa5d25ffd0a88d43bce3b4a104f8dc3e
---
M PaymentProviders/AstroPay/Audit/AstroPayAudit.php
A PaymentProviders/AstroPay/Tests/Data/chargebacks.csv
M PaymentProviders/AstroPay/Tests/phpunit/AuditTest.php
3 files changed, 29 insertions(+), 0 deletions(-)

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



diff --git a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php 
b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
index 8b13b0c..fcf46fc 100644
--- a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
+++ b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
@@ -84,6 +84,7 @@
                                break;
                        case 'Refund':
                        case 'Chargeback':
+                       case 'Chargebacks': // started seeing these with the 's'
                                $this->parseRefund( $row, $msg );
                                break;
                        default:
@@ -100,6 +101,10 @@
                $msg['gross_currency'] = $row['currency'];
                $msg['log_id'] = $row['Transaction Invoice'];
                $msg['type'] = strtolower( $row['Type'] );
+               if ( $msg['type'] === 'chargebacks' ) {
+                       // deal with stray plural form, but don't break if they 
fix it
+                       $msg['type'] = 'chargeback';
+               }
        }
 
        protected function parseDonation( array $row, array &$msg ) {
diff --git a/PaymentProviders/AstroPay/Tests/Data/chargebacks.csv 
b/PaymentProviders/AstroPay/Tests/Data/chargebacks.csv
new file mode 100644
index 0000000..97889e0
--- /dev/null
+++ b/PaymentProviders/AstroPay/Tests/Data/chargebacks.csv
@@ -0,0 +1,2 @@
+Type;"Creation date";"Settlement date";Reference;Invoice;Country;"Payment 
Method";"Payment Method Type";"Net Amount (local)";"Amount 
(USD)";currency;Status;"User Mail";"Transaction Reference";"Transaction 
Invoice";Fee;IOF
+Chargebacks;"2015-06-19 
21:05:09";;12345;;BR;;;5.00;;BRL;Settled;[email protected];7654321;314159265.0;;
diff --git a/PaymentProviders/AstroPay/Tests/phpunit/AuditTest.php 
b/PaymentProviders/AstroPay/Tests/phpunit/AuditTest.php
index 709857e..9eeed82 100644
--- a/PaymentProviders/AstroPay/Tests/phpunit/AuditTest.php
+++ b/PaymentProviders/AstroPay/Tests/phpunit/AuditTest.php
@@ -55,4 +55,26 @@
                );
                $this->assertEquals( $expected, $actual, 'Did not parse refund 
correctly' );
        }
+
+       /**
+        * And a chargeback
+        */
+       public function testProcessChargeback() {
+               $processor = new AstroPayAudit();
+               $output = $processor->parseFile( __DIR__ . 
'/../Data/chargebacks.csv' );
+               $this->assertEquals( 1, count( $output ), 'Should have found 
one chargeback' );
+               $actual = $output[0];
+               $expected = array(
+                       'gateway' => 'astropay',
+                       'contribution_tracking_id' => '314159265',
+                       'date' => 1434747909,
+                       'gross' => '5.00',
+                       'gateway_parent_id' => '7654321',
+                       'gateway_refund_id' => 'RFD 12345',
+                       'gross_currency' => 'BRL',
+                       'log_id' => '314159265.0',
+                       'type' => 'chargeback',
+               );
+               $this->assertEquals( $expected, $actual, 'Did not parse 
chargeback correctly' );
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5020525baa5d25ffd0a88d43bce3b4a104f8dc3e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to