Skip to content
Browse files

bumping version to schema 8.12 and fix bug where merchantData can't be

sent on auths and sales
  • Loading branch information...
1 parent b4bf0d4 commit f7082e9b5d9169a93ebb9affba7063b50c7ad55f @GregDake GregDake committed Apr 17, 2012
View
1 lib/.gitignore
@@ -0,0 +1 @@
+/litle_SDK_config.ini
View
2 lib/LitleOnline.php
@@ -23,7 +23,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
-define('CURRENT_XML_VERSION', '8.10');
+define('CURRENT_XML_VERSION', '8.12');
error_reporting(E_ALL ^ E_NOTICE);
//ini_set('display_errors', '1');
require_once realpath(dirname(__FILE__)) . '/LitleXmlMapper.php';
View
13 lib/LitleOnlineRequest.php
@@ -58,7 +58,7 @@ public function authorizationRequest($hash_in)
'allowPartialAuth'=>$hash_in['allowPartialAuth'],
'healthcareIIAS'=>(XmlFields::healthcareIIAS($hash_in['healthcareIIAS'])),
'filtering'=>(XmlFields::filteringType($hash_in['filtering'])),
- 'merchantData'=>(XmlFields::filteringType($hash_in['merchantData'])),
+ 'merchantData'=>(XmlFields::merchantData($hash_in['merchantData'])),
'recyclingRequest'=>(XmlFields::recyclingRequestType($hash_in['recyclingRequest'])));
}
@@ -95,7 +95,7 @@ public function saleRequest($hash_in)
'allowPartialAuth'=>$hash_in['allowPartialAuth'],
'healthcareIIAS'=>XmlFields::healthcareIIAS($hash_in['healthcareIIAS']),
'filtering'=>XmlFields::filteringType($hash_in['filtering']),
- 'merchantData'=>XmlFields::filteringType($hash_in['merchantData']),
+ 'merchantData'=>XmlFields::merchantData($hash_in['merchantData']),
'recyclingRequest'=>XmlFields::recyclingRequestType($hash_in['recyclingRequest']));
$choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
@@ -134,7 +134,8 @@ public function creditRequest($hash_in)
'processingInstructions'=>XmlFields::processingInstructions(XMLFields::returnArrayValue($hash_in, 'processingInstructions')),
'pos'=>XmlFields::pos(XMLFields::returnArrayValue($hash_in, 'pos')),
'amexAggregatorData'=>XmlFields::amexAggregatorData(XMLFields::returnArrayValue($hash_in, 'amexAggregatorData')),
- 'payPalNotes' =>XmlFields::returnArrayValue($hash_in, 'payPalNotes')
+ 'payPalNotes' =>XmlFields::returnArrayValue($hash_in, 'payPalNotes'),
+ 'actionReason'=>XmlFields::returnArrayValue($hash_in, 'actionReason')
);
$choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
@@ -321,6 +322,12 @@ private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $ch
{
$hash_config = LitleOnlineRequest::overideconfig($hash_in);
+ if(isset($hash_in['merchantSdk'])) {
+ $hash_out['merchantSdk'] = $hash_in['merchantSdk'];
+ }
+ else {
+ $hash_out['merchantSdk'] = 'PHP;8.12.0';
+ }
Checker::choice($choice1);
Checker::choice($choice2);
$request = Obj2xml::toXml($hash_out,$hash_config, $type);
View
3 lib/Obj2xml.php
@@ -31,6 +31,8 @@ public static function toXml($data, $hash_config, $type, $rootNodeName = 'litleO
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
$xml-> addAttribute('merchantId',$config["merchantId"]);
$xml-> addAttribute('version',$config["version"]);
+ $xml-> addAttribute('merchantSdk',$data['merchantSdk']);
+ unset($data['merchantSdk']);
$xml-> addAttribute('xmlns:xmlns','http://www.litle.com/schema');// does not show up on browser docs
$authentication = $xml->addChild('authentication');
$authentication->addChild('user',$config["user"]);
@@ -40,7 +42,6 @@ public static function toXml($data, $hash_config, $type, $rootNodeName = 'litleO
($transacType-> addAttribute('partial',$data["partial"]));
};
unset($data['partial']);
- #merchant SDK attribute $transacType-> addAttribute('partial',$data["partial"])
if(isset($config['customerId'])) {
($transacType-> addAttribute('customerId',$config["customerId"]));
};
View
2 lib/Setup.php
@@ -57,7 +57,7 @@ function initialize(){
print "Please input the proxy, if no proxy hit enter key: ";
$line['proxy'] = trim(fgets(STDIN));
writeConfig($line,$handle);
- fwrite($handle, "version = 8.10" . PHP_EOL);
+ fwrite($handle, "version = 8.12" . PHP_EOL);
fwrite($handle, "timeout = 65". PHP_EOL);
fwrite($handle, "reportGroup = Default Report Group". PHP_EOL);
}
View
14 lib/XmlFields.php
@@ -116,6 +116,20 @@ public static function fraudCheckType($hash_in)
}
}
+ public static function merchantData($hash_in)
+ {
+ if (isset($hash_in))
+ {
+ $hash_out = array(
+ "campaign"=>XmlFields::returnArrayValue($hash_in, "campaign"),
+ "affiliate"=>XmlFields::returnArrayValue($hash_in, "affiliate"),
+ "merchantGroupingId"=>XmlFields::returnArrayValue($hash_in, "merchantGroupingId")
+ );
+ return $hash_out;
+ }
+ }
+
+
public static function authInformation($hash_in)
{
if (isset($hash_in))
View
17 test/unit/test_authorization.php
@@ -191,4 +191,21 @@ function test_all_choices_card_and_paypage_and_paypal_and_token()
$retOb = $litleTest->authorizationRequest($hash_in);
}
+ function test_merchant_data()
+ {
+ $hash_in = array(
+ 'orderId'=> '2111',
+ 'orderSource'=>'ecommerce',
+ 'amount'=>'123',
+ 'merchantData'=>array(
+ 'campaign'=>'foo'
+ )
+ );
+ $mappTest = &new MockLitleXmlMapper();
+ $commTest = &new Mockcommunication();
+ $mappTest->expectOnce('request',array(new PatternExpectation('/.*<merchantData>.*?<campaign>foo<\/campaign>.*?<\/merchantData>.*/'),array("user"=>NULL,"password"=>NULL,"merchantId"=>NULL,"reportGroup"=>NULL,"id"=>NULL,"version"=>NULL,"url"=>NULL,"timeout"=>NULL,"proxy"=>NULL)));
+ $litleTest = &new LitleOnlineRequest();
+ $litleTest->newXML = $mappTest;
+ $retOb = $litleTest->authorizationRequest($hash_in);
+ }
}
View
16 test/unit/test_credit.php
@@ -124,6 +124,22 @@ function test_all_choices_card_and_paypage_and_paypal_and_token()
$litleTest = &new LitleOnlineRequest();
$this->expectException(new Exception("Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!"));
$retOb = $litleTest->creditRequest($hash_in);
+ }
+ function test_action_reason_on_orphaned_refund()
+ {
+ $hash_in = array(
+ 'orderId'=> '2111',
+ 'orderSource'=>'ecommerce',
+ 'amount'=>'123',
+ 'actionReason'=>'SUSPECT_FRAUD'
+ );
+ $mappTest = &new MockLitleXmlMapper();
+ $commTest = &new Mockcommunication();
+ $mappTest->expectOnce('request',array(new PatternExpectation('/.*<actionReason>SUSPECT_FRAUD<\/actionReason>.*/'),array("user"=>NULL,"password"=>NULL,"merchantId"=>NULL,"reportGroup"=>NULL,"id"=>NULL,"version"=>NULL,"url"=>NULL,"timeout"=>NULL,"proxy"=>NULL)));
+ $litleTest = &new LitleOnlineRequest();
+ $litleTest->newXML = $mappTest;
+ $retOb = $litleTest->creditRequest($hash_in);
}
+
}
View
63 test/unit/test_litleOnlineRequest.php
@@ -0,0 +1,63 @@
+<?php
+/*
+ * Copyright (c) 2011 Litle & Co.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+require_once("../../simpletest/autorun.php");
+require_once('../../simpletest/unit_tester.php');
+require_once('../../simpletest/mock_objects.php');
+require_once realpath(dirname(__FILE__)) . '/../../lib/LitleOnline.php';
+Mock::generate('communication');
+Mock::generate('LitleXmlMapper');
+
+class LitleOnlineRequest_UnitTest extends UnitTestCase
+{
+ function test_set_merchant_sdk_integration()
+ {
+ $hash_in = array(
+ 'merchantSdk'=>'Magento;8.14.3',
+ 'orderId'=> '2111',
+ 'orderSource'=>'ecommerce',
+ 'amount'=>'123');
+ $mappTest = &new MockLitleXmlMapper();
+ $commTest = &new Mockcommunication();
+ $mappTest->expectOnce('request',array(new PatternExpectation('/.*merchantSdk="Magento;8.14.3".*/'),array("user"=>NULL,"password"=>NULL,"merchantId"=>NULL,"reportGroup"=>NULL,"id"=>NULL,"version"=>NULL,"url"=>NULL,"timeout"=>NULL,"proxy"=>NULL,)));
+ $litleTest = &new LitleOnlineRequest();
+ $litleTest->newXML = $mappTest;
+ $retOb = $litleTest->authorizationRequest($hash_in);
+ }
+
+ function test_set_merchant_sdk_default()
+ {
+ $hash_in = array(
+ 'orderId'=> '2111',
+ 'orderSource'=>'ecommerce',
+ 'amount'=>'123');
+ $mappTest = &new MockLitleXmlMapper();
+ $commTest = &new Mockcommunication();
+ $mappTest->expectOnce('request',array(new PatternExpectation('/.*merchantSdk="PHP;8.12.0".*/'),array("user"=>NULL,"password"=>NULL,"merchantId"=>NULL,"reportGroup"=>NULL,"id"=>NULL,"version"=>NULL,"url"=>NULL,"timeout"=>NULL,"proxy"=>NULL,)));
+ $litleTest = &new LitleOnlineRequest();
+ $litleTest->newXML = $mappTest;
+ $retOb = $litleTest->authorizationRequest($hash_in);
+ }
+
+}
View
20 test/unit/test_sale.php
@@ -195,8 +195,26 @@ function test_all_choices_card_and_paypage_and_paypal_and_token()
);
$litleTest = &new LitleOnlineRequest();
$this->expectException(new Exception("Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!"));
- $retOb = $litleTest->saleRequest($hash_in);
+ $retOb = $litleTest->saleRequest($hash_in);
+ }
+ function test_merchant_data()
+ {
+ $hash_in = array(
+ 'orderId'=> '2111',
+ 'orderSource'=>'ecommerce',
+ 'amount'=>'123',
+ 'merchantData'=>array(
+ 'affiliate'=>'bar'
+ )
+ );
+ $mappTest = &new MockLitleXmlMapper();
+ $commTest = &new Mockcommunication();
+ $mappTest->expectOnce('request',array(new PatternExpectation('/.*<merchantData>.*?<affiliate>bar<\/affiliate>.*?<\/merchantData>.*/'),array("user"=>NULL,"password"=>NULL,"merchantId"=>NULL,"reportGroup"=>NULL,"id"=>NULL,"version"=>NULL,"url"=>NULL,"timeout"=>NULL,"proxy"=>NULL)));
+ $litleTest = &new LitleOnlineRequest();
+ $litleTest->newXML = $mappTest;
+ $retOb = $litleTest->saleRequest($hash_in);
}
+
}
View
1 test/unit/ts_all.php
@@ -40,3 +40,4 @@
require realpath(dirname(__FILE__)) . '/test_echeckSale.php';
require realpath(dirname(__FILE__)) . '/test_echeckCredit.php';
require realpath(dirname(__FILE__)) . '/test_echeckVerification.php';
+require realpath(dirname(__FILE__)) . '/test_litleOnlineRequest.php';

0 comments on commit f7082e9

Please sign in to comment.
Something went wrong with that request. Please try again.