Ejegg has uploaded a new change for review.

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

Change subject: WP: Put stripped email in MerchantReference2
......................................................................

WP: Put stripped email in MerchantReference2

Change-Id: Icd88d7f909ceeee15b668a749786a8996ca04d6f
---
M tests/Adapter/WorldPay/WorldPayTestCase.php
M tests/includes/test_gateway/test.adapter.php
M worldpay_gateway/worldpay.adapter.php
3 files changed, 31 insertions(+), 1 deletion(-)


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

diff --git a/tests/Adapter/WorldPay/WorldPayTestCase.php 
b/tests/Adapter/WorldPay/WorldPayTestCase.php
index a889661..0f4074e 100644
--- a/tests/Adapter/WorldPay/WorldPayTestCase.php
+++ b/tests/Adapter/WorldPay/WorldPayTestCase.php
@@ -252,4 +252,15 @@
                $this->assertFalse( $gateway->getCVVResult(), 'getCVVResult not 
failing somebody with garbage.' );
        }
 
+       /**
+        * Ensure we're staging a punctuation-stripped version of the email 
address in merchant_reference_2
+        */
+       function testMerchantReference2() {
+               $options = $this->getDonorTestData();
+               $options['email'] = '[email protected]';
+               $gateway = $this->getFreshGatewayObject( $options );
+               $gateway->_stageData();
+               $staged = $gateway->_getData_Staged( 'merchant_reference_2' );
+               $this->assertEquals( 'little teapot short stout com', $staged );
+       }
 }
diff --git a/tests/includes/test_gateway/test.adapter.php 
b/tests/includes/test_gateway/test.adapter.php
index 16a290b..be7930e 100644
--- a/tests/includes/test_gateway/test.adapter.php
+++ b/tests/includes/test_gateway/test.adapter.php
@@ -573,6 +573,13 @@
                );
        }
 
+       public function _stageData() {
+               $this->stageData();
+       }
+
+       public function _getData_Staged() {
+               return call_user_func_array( array ( $this, 'getData_Staged' ), 
func_get_args() );
+       }
 }
 
 /**
diff --git a/worldpay_gateway/worldpay.adapter.php 
b/worldpay_gateway/worldpay.adapter.php
index 5094f4f..623c8cb 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -190,6 +190,7 @@
                        'payment_submethod',
                        'zip',
                        'street',
+                       'merchant_reference_2',
                );
        }
 
@@ -257,6 +258,9 @@
 
                        // ZipCode
                        'zip' => array( 'type' => 'alphanumeric', 'length' => 
30 ),
+
+                       // MerchantReference2
+                       'merchant_reference_2' => array( 'type' => 
'alphanumeric', 'length' => 60 ),
                );
        }
 
@@ -438,6 +442,7 @@
                                'ZipCode',
                                'CountryCode',
                                'Email',
+                               'MerchantReference2',
                        ),
                        'values' => array(
                                'VersionUsed' => 6,
@@ -699,7 +704,8 @@
                        'PTTID'             => 'wp_pttid',
                        'UserName'          => 'username',
                        'UserPassword'      => 'user_password',
-                       'MerchantId'        => 'wp_merchant_id'
+                       'MerchantId'        => 'wp_merchant_id',
+                       'MerchantReference2'=> 'merchant_reference_2'
                );
        }
 
@@ -870,6 +876,12 @@
                }
        }
 
+       protected function stage_merchant_reference_2( $type = 'request' ) {
+               $email = $this->getData_Unstaged_Escaped( 'email' );
+               $alphanumeric = preg_replace('/[^0-9a-zA-Z]/', ' ', $email);
+               $this->staged_data['merchant_reference_2'] = $alphanumeric;
+       }
+
        protected function loadRoutingInfo( $transaction ) {
                switch ( $transaction ) {
                        case 'QueryAuthorizeDeposit':

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd88d7f909ceeee15b668a749786a8996ca04d6f
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

Reply via email to