Ejegg has uploaded a new change for review.

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

Change subject: Don't fraud-fail on STATUSID 25
......................................................................

Don't fraud-fail on STATUSID 25

Since splitting up staging and unstaging, an empty string added
to a data key is no longer translated to a null in the unstaged
data.  This patch ensures that an XML response with no CVVRESULT
node at all sets the cvv_result key to null rather than the empty
string.

Change-Id: I67a84165ea7c310ab21950a096c8036fd0bd9e8e
---
M globalcollect_gateway/globalcollect.adapter.php
M tests/Adapter/GlobalCollect/GlobalCollectTest.php
A tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse
3 files changed, 58 insertions(+), 2 deletions(-)


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

diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index 5b13476..e235e68 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -1198,8 +1198,8 @@
                        $gotCVV = false;
                        $status_result = $this->do_transaction( 
'GET_ORDERSTATUS' );
                        $xmlResults = array(
-                               'cvv_result' => '',
-                               'avs_result' => ''
+                               'cvv_result' => null,
+                               'avs_result' => null
                        );
                        if ( array_key_exists('data', $status_result) ) {
                                foreach ( $pull_vars as $theirkey => $ourkey) {
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTest.php 
b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
index faf8a88..219c599 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
@@ -161,6 +161,24 @@
        }
 
        /**
+        * Don't fraud-fail someone for bad CVV if GET_ORDERSTATUS
+        * comes back with STATUSID 25 and no CVVRESULT
+        */
+       function testConfirmCreditCardStatus25() {
+               $init = $this->getDonorTestData();
+               $init['payment_method'] = 'cc';
+               $init['payment_submethod'] = 'visa';
+               $init['email'] = '[email protected]';
+
+               $gateway = $this->getFreshGatewayObject( $init );
+               $gateway->setDummyGatewayResponseCode( '25' );
+
+               $gateway->do_transaction( 'Confirm_CreditCard' );
+               $action = $gateway->getValidationAction();
+               $this->assertEquals( 'process', $action, 'Gateway should not 
fraud fail on STATUSID 25' );
+       }
+
+       /**
         * We should skip the API call if we're already suspicious
         */
        function testGetOrderStatusSkipsIfFail() {
diff --git 
a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse 
b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse
new file mode 100644
index 0000000..2a37c20
--- /dev/null
+++ b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse
@@ -0,0 +1,38 @@
+<?xml version = "1.0"?>
+<XML>
+       <REQUEST>
+               <ACTION>GET_ORDERSTATUS</ACTION>
+               <META>
+                       <MERCHANTID>1234</MERCHANTID>
+                       <IPADDRESS>127.0.0.1</IPADDRESS>
+                       <VERSION>2.0</VERSION>
+                       <REQUESTIPADDRESS>11.22.33.44</REQUESTIPADDRESS>
+               </META>
+               <PARAMS>
+                       <ORDER>
+                               <ORDERID>987654321</ORDERID>
+                       </ORDER>
+               </PARAMS>
+               <RESPONSE>
+                       <RESULT>OK</RESULT>
+                       <META>
+                               <REQUESTID>1341324</REQUESTID>
+                               
<RESPONSEDATETIME>20150310075018</RESPONSEDATETIME>
+                       </META>
+                       <STATUS>
+                               <STATUSDATE>20150310072845</STATUSDATE>
+                               <PAYMENTMETHODID>1</PAYMENTMETHODID>
+                               
<MERCHANTREFERENCE>5551212.23560</MERCHANTREFERENCE>
+                               <ATTEMPTID>1</ATTEMPTID>
+                               <PAYMENTREFERENCE>0</PAYMENTREFERENCE>
+                               <AMOUNT>3000</AMOUNT>
+                               <MERCHANTID>1234</MERCHANTID>
+                               <ORDERID>987654321</ORDERID>
+                               <STATUSID>25</STATUSID>
+                               <EFFORTID>1</EFFORTID>
+                               <CURRENCYCODE>SEK</CURRENCYCODE>
+                               <PAYMENTPRODUCTID>1</PAYMENTPRODUCTID>
+                       </STATUS>
+               </RESPONSE>
+       </REQUEST>
+</XML>

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

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