Mage_Exactor_Tax - Version 2013.04.18

Version Notes

Supported Magento 1.5.0.0 - 1.7.x, Magento Enterprise 1.8-1.12.x

Download this release

Release Info

Developer Exactor, Inc.
Extension Mage_Exactor_Tax
Version 2013.04.18
Comparing to
See all releases


Code changes from version 2013.01.15 to 2013.04.18

app/code/local/Exactor/Sales/Model/Observer.php CHANGED
@@ -171,7 +171,7 @@ class Exactor_Sales_Model_Observer {
171
  */
172
  private function processFinishedOrder(Mage_Sales_Model_Order $order){
173
  $merchantSettings = $this->loadMerchantSettings($order);
174
- if ($merchantSettings==null) false;
175
  $exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
176
  ->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
177
  $transactionInfo = $this->sessionCache->popTransactionInfo();
171
  */
172
  private function processFinishedOrder(Mage_Sales_Model_Order $order){
173
  $merchantSettings = $this->loadMerchantSettings($order);
174
+ if ($merchantSettings==null) return false;
175
  $exactorProcessingService = ExactorProcessingServiceFactory::getInstance()
176
  ->buildExactorProcessingService($merchantSettings->getMerchantID(), $merchantSettings->getUserID());
177
  $transactionInfo = $this->sessionCache->popTransactionInfo();
app/code/local/Exactor/Tax/Helper/Mapping.php CHANGED
@@ -283,7 +283,7 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
283
  }
284
  // Check if it is bundle or groped product
285
  $product = $magentoItem->getProduct();
286
- if (empty($product)) {
287
  $product = $magentoItem->getOrderItem()->getProduct();
288
  }
289
  if (empty($product) && $magentoItem->getProductId() != null) {
@@ -416,7 +416,8 @@ class Exactor_Tax_Helper_Mapping extends Mage_Core_Helper_Abstract {
416
  // Trying to find billing address in the quote
417
  $billingAddress = $this->buildExactorAddressForQuoteAddress($quoteAddress->getQuote()->getBillingAddress());
418
 
419
- if ($isEstimation) $shipToAddress->setFullName(self::MSG_ESTIMATION_REQUEST);
 
420
  // If this is just tax estimation for not logged in user
421
  // we just need to use shipping as billing
422
  if ($isEstimation){
283
  }
284
  // Check if it is bundle or groped product
285
  $product = $magentoItem->getProduct();
286
+ if (empty($product) && $magentoItem->getOrderItem() != null) {
287
  $product = $magentoItem->getOrderItem()->getProduct();
288
  }
289
  if (empty($product) && $magentoItem->getProductId() != null) {
416
  // Trying to find billing address in the quote
417
  $billingAddress = $this->buildExactorAddressForQuoteAddress($quoteAddress->getQuote()->getBillingAddress());
418
 
419
+ if ($isEstimation)
420
+ $shipToAddress->setFullName(self::MSG_ESTIMATION_REQUEST);
421
  // If this is just tax estimation for not logged in user
422
  // we just need to use shipping as billing
423
  if ($isEstimation){
lib/ExactorCommons/ExactorDomainObjects.php CHANGED
@@ -25,6 +25,7 @@ class ExactorTransactionInfo{
25
  private $createdDate;
26
  private $lastModifiedDate;
27
  private $signature;
 
28
 
29
  public function setCreatedDate($createdDate)
30
  {
@@ -106,6 +107,16 @@ class ExactorTransactionInfo{
106
  return $this->signature;
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
 
111
  /* ========================= COMMON OBJECTS ========================== */
@@ -206,8 +217,7 @@ class AddressType extends XmlSerializationSupport {
206
  public function hasData(){
207
  return //strlen(trim($this->getStreet1()))
208
  // && strlen(trim($this->getCity()))
209
- strlen(trim($this->getPostalCode()));
210
- //&& strlen(trim($this->getStateOrProvince()));
211
  }
212
  }
213
 
@@ -220,13 +230,14 @@ class LineItemType extends XmlSerializationSupport {
220
  public $BillTo;
221
  public $ShipTo;
222
  public $ShipFrom;
223
- /**
224
- * @var string
225
- * @xmlName id
226
- * @xmlAttribute
227
- */
228
  public $id;
229
 
 
 
 
 
 
 
230
  public function setBillTo(AddressType $BillTo)
231
  {
232
  $this->BillTo = $BillTo;
@@ -334,24 +345,18 @@ class InvoiceRequestType extends XmlSerializationSupport {
334
  public $TaxDirection;
335
  public $TaxClass;
336
  public $ExemptionId;
337
- /**
338
- * @var AddressType
339
- */
340
  public $BillTo;
341
- /**
342
- * @var AddressType
343
- */
344
  public $ShipTo;
345
- /**
346
- * @var AddressType
347
- */
348
  public $ShipFrom;
349
- /**
350
- * @var array LineItemType
351
- * @xmlName LineItem
352
- */
353
  public $LineItems;
354
 
 
 
 
 
 
 
 
355
 
356
  /**
357
  * @param \AddressType $BillTo
@@ -398,7 +403,7 @@ class InvoiceRequestType extends XmlSerializationSupport {
398
  }
399
 
400
  /**
401
- * @return
402
  */
403
  public function getLineItems()
404
  {
@@ -483,7 +488,7 @@ class InvoiceRequestType extends XmlSerializationSupport {
483
 
484
  /**
485
  * @param LineItemType|null $lineItem
486
- * @return
487
  */
488
  public function addLineItem($lineItem){
489
  if ($lineItem==null) return;
@@ -495,12 +500,13 @@ class InvoiceRequestType extends XmlSerializationSupport {
495
  class CommitRequestType extends XmlSerializationSupport {
496
  public $CommitDate;
497
  public $InvoiceNumber;
498
- /**
499
- * @var InvoiceRequestType
500
- */
501
  public $InvoiceRequest;
502
  public $PriorTransactionId;
503
 
 
 
 
 
504
 
505
  /**
506
  * @param DateTime $CommitDate
@@ -599,13 +605,12 @@ class ResponseLineItem extends XmlSerializationSupport{
599
  public $TaxDirection;
600
  public $TotalTaxAmount;
601
  public $TaxInfo;
602
- /**
603
- * @var
604
- * @xmlName id
605
- * @xmlAttribute
606
- */
607
  public $id;
608
 
 
 
 
 
609
 
610
  public function setGrossAmount($GrossAmount)
611
  {
@@ -676,12 +681,13 @@ class InvoiceResponseType extends XmlSerializationSupport{
676
  public $GrossAmount;
677
  public $TotalTaxAmount;
678
  public $TaxObligation;
679
- /**
680
- * @var array ResponseLineItem
681
- * @xmlName LineItem
682
- */
683
  public $LineItems;
684
 
 
 
 
 
 
685
 
686
  public function setCurrencyCode($CurrencyCode)
687
  {
@@ -829,12 +835,14 @@ class CommitResponseType extends XmlSerializationSupport{
829
  public $TransactionDate;
830
  public $CommitDate;
831
  public $InvoiceNumber;
832
- /**
833
- * @var InvoiceResponseType
834
- */
835
  public $InvoiceResponse;
836
  public $PriorTransactionId;
837
 
 
 
 
 
 
838
  public function setCommitDate($CommitDate)
839
  {
840
  $this->CommitDate = $CommitDate;
@@ -1042,16 +1050,12 @@ class ErrorResponseType extends XmlSerializationSupport {
1042
  }
1043
  /* ========================= REQUEST\RESPONSE ======================== */
1044
 
1045
- /**
1046
- * @xmlName TaxRequest
1047
- */
1048
  class TaxRequestType extends XmlSerializationSupport {
1049
  protected function getNamespace()
1050
  {
1051
  return 'http://www.exactor.com/ns';
1052
  }
1053
 
1054
-
1055
  /**
1056
  * @var string
1057
  * @xmlName MerchantId
@@ -1098,13 +1102,21 @@ class TaxRequestType extends XmlSerializationSupport {
1098
  public $DeleteRequests = array();
1099
 
1100
  /* =========== ATTRIBUTES ============== */
1101
- /**
1102
- * @var string
1103
- * @xmlName version
1104
- * @xmlAttribute
1105
- */
1106
  public $pluginVersion='';
1107
 
 
 
 
 
 
 
 
 
 
 
 
 
1108
  /**
1109
  * @var string
1110
  * @xmlName plugin
@@ -1297,52 +1309,25 @@ class TaxRequestType extends XmlSerializationSupport {
1297
  }
1298
 
1299
  class TaxResponseType extends XmlSerializationSupport{
1300
- /**
1301
- * @var string
1302
- * @xmlName MerchantId
1303
- */
1304
  public $MerchantId;
1305
- /**
1306
- * @var string
1307
- * @xml UserId
1308
- */
1309
  public $UserId;
1310
-
1311
- /**
1312
- * @var string
1313
- */
1314
  public $PartnerId;
1315
-
1316
- /**
1317
- * @var array InvoiceResponseType
1318
- * @xmlName InvoiceResponse
1319
- */
1320
  public $InvoiceResponses;
1321
-
1322
- /**
1323
- * @var array CommitResponseType
1324
- * @xmlName CommitResponse
1325
- */
1326
  public $CommitResponses;
1327
-
1328
- /**
1329
- * @var array RefundResponseType
1330
- * @xmlName RefundResponse
1331
- */
1332
  public $RefundResponses;
1333
-
1334
- /**
1335
- * @var array DeleteResponseType
1336
- * @xmlName DeleteResponse
1337
- */
1338
  public $DeleteResponses;
1339
-
1340
- /**
1341
- * @var array ErrorResponseType
1342
- * @xmlName ErrorResponse
1343
- */
1344
  public $ErrorResponses;
1345
 
 
 
 
 
 
 
 
 
 
 
1346
  /* ******** SOME SHORTCUTS *********** */
1347
 
1348
  /**
@@ -1366,7 +1351,7 @@ class TaxResponseType extends XmlSerializationSupport{
1366
  /** Returns first InvoiceResponseType from the list or null if there are no any invoice responses
1367
  * @return InvoiceResponseType|null
1368
  */
1369
- public function getFirstInvoice() {
1370
  if (!count($this->getInvoiceResponses())) return null;
1371
  $invoices = $this->getInvoiceResponses();
1372
  return $invoices[0];
25
  private $createdDate;
26
  private $lastModifiedDate;
27
  private $signature;
28
+ private $invoiceTrn=null;
29
 
30
  public function setCreatedDate($createdDate)
31
  {
107
  return $this->signature;
108
  }
109
 
110
+ public function setInvoiceTrn($invoiceTrn)
111
+ {
112
+ $this->invoiceTrn = $invoiceTrn;
113
+ }
114
+
115
+ public function getInvoiceTrn()
116
+ {
117
+ return $this->invoiceTrn;
118
+ }
119
+
120
  }
121
 
122
  /* ========================= COMMON OBJECTS ========================== */
217
  public function hasData(){
218
  return //strlen(trim($this->getStreet1()))
219
  // && strlen(trim($this->getCity()))
220
+ strlen(trim($this->getPostalCode()));
 
221
  }
222
  }
223
 
230
  public $BillTo;
231
  public $ShipTo;
232
  public $ShipFrom;
 
 
 
 
 
233
  public $id;
234
 
235
+ protected function defineBindingRules()
236
+ {
237
+ $this->setBindingRulesFor('id')->xmlName('id')->toXmlAttribute();
238
+ }
239
+
240
+
241
  public function setBillTo(AddressType $BillTo)
242
  {
243
  $this->BillTo = $BillTo;
345
  public $TaxDirection;
346
  public $TaxClass;
347
  public $ExemptionId;
 
 
 
348
  public $BillTo;
 
 
 
349
  public $ShipTo;
 
 
 
350
  public $ShipFrom;
 
 
 
 
351
  public $LineItems;
352
 
353
+ protected function defineBindingRules()
354
+ {
355
+ $this->setBindingRulesFor('BillTo')->objectType('AddressType');
356
+ $this->setBindingRulesFor('ShipTo')->objectType('AddressType');
357
+ $this->setBindingRulesFor('ShipFrom')->objectType('AddressType');
358
+ $this->setBindingRulesFor('LineItems')->objectType('array LineItemType')->xmlName('LineItem');
359
+ }
360
 
361
  /**
362
  * @param \AddressType $BillTo
403
  }
404
 
405
  /**
406
+ * @return LineItemType[]
407
  */
408
  public function getLineItems()
409
  {
488
 
489
  /**
490
  * @param LineItemType|null $lineItem
491
+ * @return void
492
  */
493
  public function addLineItem($lineItem){
494
  if ($lineItem==null) return;
500
  class CommitRequestType extends XmlSerializationSupport {
501
  public $CommitDate;
502
  public $InvoiceNumber;
 
 
 
503
  public $InvoiceRequest;
504
  public $PriorTransactionId;
505
 
506
+ protected function defineBindingRules()
507
+ {
508
+ $this->setBindingRulesFor('InvoiceRequest')->objectType('InvoiceRequestType');
509
+ }
510
 
511
  /**
512
  * @param DateTime $CommitDate
605
  public $TaxDirection;
606
  public $TotalTaxAmount;
607
  public $TaxInfo;
 
 
 
 
 
608
  public $id;
609
 
610
+ protected function defineBindingRules()
611
+ {
612
+ $this->setBindingRulesFor('id')->xmlName('id')->toXmlAttribute();
613
+ }
614
 
615
  public function setGrossAmount($GrossAmount)
616
  {
681
  public $GrossAmount;
682
  public $TotalTaxAmount;
683
  public $TaxObligation;
 
 
 
 
684
  public $LineItems;
685
 
686
+ protected function defineBindingRules()
687
+ {
688
+ $this->setBindingRulesFor('LineItems')->objectType('array ResponseLineItem')->xmlName('LineItem');
689
+ }
690
+
691
 
692
  public function setCurrencyCode($CurrencyCode)
693
  {
835
  public $TransactionDate;
836
  public $CommitDate;
837
  public $InvoiceNumber;
 
 
 
838
  public $InvoiceResponse;
839
  public $PriorTransactionId;
840
 
841
+ protected function defineBindingRules()
842
+ {
843
+ $this->setBindingRulesFor('InvoiceResponse')->objectType('InvoiceResponseType');
844
+ }
845
+
846
  public function setCommitDate($CommitDate)
847
  {
848
  $this->CommitDate = $CommitDate;
1050
  }
1051
  /* ========================= REQUEST\RESPONSE ======================== */
1052
 
 
 
 
1053
  class TaxRequestType extends XmlSerializationSupport {
1054
  protected function getNamespace()
1055
  {
1056
  return 'http://www.exactor.com/ns';
1057
  }
1058
 
 
1059
  /**
1060
  * @var string
1061
  * @xmlName MerchantId
1102
  public $DeleteRequests = array();
1103
 
1104
  /* =========== ATTRIBUTES ============== */
1105
+
 
 
 
 
1106
  public $pluginVersion='';
1107
 
1108
+ protected function defineBindingRules()
1109
+ {
1110
+ $this->setBindingRulesFor('$this')->xmlName('TaxRequest');
1111
+ $this->setBindingRulesFor('pluginVersion')->xmlName('version')->toXmlAttribute();
1112
+
1113
+ $this->setBindingRulesFor('InvoiceRequests')->objectType('array InvoiceRequestType')->xmlName('InvoiceRequest');
1114
+ $this->setBindingRulesFor('CommitRequests')->objectType('array CommitRequestType')->xmlName('CommitRequest');
1115
+ $this->setBindingRulesFor('RefundRequests')->objectType('array RefundRequestType')->xmlName('RefundRequest');
1116
+ $this->setBindingRulesFor('DeleteRequests')->objectType('array DeleteRequestType')->xmlName('DeleteRequest');
1117
+ $this->setBindingRulesFor('ErrorRequests')->objectType('array ErrorRequestType')->xmlName('ErrorRequest');
1118
+ }
1119
+
1120
  /**
1121
  * @var string
1122
  * @xmlName plugin
1309
  }
1310
 
1311
  class TaxResponseType extends XmlSerializationSupport{
 
 
 
 
1312
  public $MerchantId;
 
 
 
 
1313
  public $UserId;
 
 
 
 
1314
  public $PartnerId;
 
 
 
 
 
1315
  public $InvoiceResponses;
 
 
 
 
 
1316
  public $CommitResponses;
 
 
 
 
 
1317
  public $RefundResponses;
 
 
 
 
 
1318
  public $DeleteResponses;
 
 
 
 
 
1319
  public $ErrorResponses;
1320
 
1321
+ protected function defineBindingRules()
1322
+ {
1323
+ $this->setBindingRulesFor('InvoiceResponses')->objectType('array InvoiceResponseType')->xmlName('InvoiceResponse');
1324
+ $this->setBindingRulesFor('CommitResponses')->objectType('array CommitResponseType')->xmlName('CommitResponse');
1325
+ $this->setBindingRulesFor('RefundResponses')->objectType('array RefundResponseType')->xmlName('RefundResponse');
1326
+ $this->setBindingRulesFor('DeleteResponses')->objectType('array DeleteResponseType')->xmlName('DeleteResponse');
1327
+ $this->setBindingRulesFor('ErrorResponses')->objectType('array ErrorResponseType')->xmlName('ErrorResponse');
1328
+
1329
+ }
1330
+
1331
  /* ******** SOME SHORTCUTS *********** */
1332
 
1333
  /**
1351
  /** Returns first InvoiceResponseType from the list or null if there are no any invoice responses
1352
  * @return InvoiceResponseType|null
1353
  */
1354
+ public function getFirstInvoice(){
1355
  if (!count($this->getInvoiceResponses())) return null;
1356
  $invoices = $this->getInvoiceResponses();
1357
  return $invoices[0];
lib/ExactorCommons/XmlProcessing.php CHANGED
@@ -20,81 +20,170 @@
20
  * Date: 4/18/12
21
  * Time: 5:34 PM
22
  */
23
-
24
- class XmlSerializationSupport {
25
 
26
- const DOC_LINE_XML_NAME = '/@xmlName\s+([\w\d]+)\n/i';
27
- const DOC_LINE_XML_VAR_TYPE = '/@var\s+([\w\d]+\s*[\w\d]*)/i';
28
- const DOC_LINE_XML_ATTRIBUTE = '/@xmlAttribute\s*\n/i';
29
- const DOC_LINE_XML_SKIP = '/@xmlSkip\s*\n/i';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  const SERIALIZE_TO_NOTHING = 0;
31
  const SERIALIZE_TO_NODE = 1;
32
  const SERIALIZE_TO_ATTRIBUTE = 2;
33
 
34
  const TYPE_ARRAY_MODIFIER = 'array';
35
 
 
 
 
36
  protected function getNamespace(){
37
  return null;
38
  }
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**Returns serialization action.
41
  * Node - by default
42
- * Supported doc lines: @xmlAttribute, @xmlSkip
43
  * @param ReflectionProperty $property
44
  * @return bool
45
  */
46
- protected function getSerializationType(ReflectionProperty $property){
47
- $serializationAction = self::SERIALIZE_TO_NODE;
48
- // is attribute?
49
- if (preg_match(self::DOC_LINE_XML_ATTRIBUTE, $property->getDocComment(), $matches)>0){
50
- $serializationAction = self::SERIALIZE_TO_ATTRIBUTE;
51
- }else if(preg_match(self::DOC_LINE_XML_SKIP, $property->getDocComment(), $matches)>0){
52
- $serializationAction = self::SERIALIZE_TO_NOTHING;
53
- }
54
  return $serializationAction;
55
  }
56
 
57
  /**
58
- * By default it will be just property name.
59
- * If there is a DocComment with attribute @xmlName it will be used instead
60
  * @param ReflectionProperty $property
61
  * @return string XML Name for the property
62
  */
63
  protected function getTagNameForProperty(ReflectionProperty $property){
64
- $name = $property->getName();
65
- // Trying to parse DOC line of the property to gat valid name
66
- if (preg_match(self::DOC_LINE_XML_NAME, $property->getDocComment(), $matches)>0){
67
- if (count($matches)>1)
68
- $name=$matches[1];
69
- }
70
- return trim($name);
71
  }
72
 
73
- /** Class name by default.
74
- * If there is a DocComment with attribute @xmlName it will be used instead.
 
75
  * @param ReflectionClass $class
76
  * @return string
77
  * @see getTagNameForProperty
78
  */
79
  protected function getTagNameForClass(ReflectionClass $class){
80
- $name = $class->getName();
81
- // Trying to parse DOC line of the property to gat valid name
82
- if (preg_match(self::DOC_LINE_XML_NAME, $class->getDocComment(), $matches)>0){
83
- if (count($matches)>1)
84
- $name=$matches[1];
85
  }
86
- return trim($name);
87
  }
88
 
89
  protected function getTargetClassNameForProperty($property)
90
  {
91
- $className=null;
92
- if (preg_match(self::DOC_LINE_XML_VAR_TYPE, $property->getDocComment(), $matches)>0){
93
- if (count($matches)>1){
94
- $className=$matches[1];
95
- if ((substr($className, 0, strlen(self::TYPE_ARRAY_MODIFIER)) === self::TYPE_ARRAY_MODIFIER)){
96
- $className = substr($className,strlen(self::TYPE_ARRAY_MODIFIER));
97
- }
98
  }
99
  }
100
  return trim($className);
@@ -102,11 +191,10 @@ class XmlSerializationSupport {
102
 
103
  protected function getIsArrayForProperty($property){
104
  $res = false;
105
- if (preg_match(self::DOC_LINE_XML_VAR_TYPE, $property->getDocComment(), $matches)>0){
106
- if (count($matches)>1){
107
- if ((substr($matches[1], 0, strlen(self::TYPE_ARRAY_MODIFIER)) === self::TYPE_ARRAY_MODIFIER)){
108
- $res = true;
109
- }
110
  }
111
  }
112
  return $res;
@@ -125,13 +213,14 @@ class XmlSerializationSupport {
125
  /**
126
  * Do some preprocessing before serialization, e.g. remove special characters
127
  * @param $value
128
- * @return void
129
  */
130
  protected function preprocessValue($value){
131
  return htmlspecialchars($value);
132
  }
133
 
134
  public function toSimpleXmlObject($simpleXmlObject=null){
 
135
  $reflectionObj = new ReflectionObject($this);
136
  $className = $this->getTagNameForClass($reflectionObj);
137
  if ($simpleXmlObject==null)
@@ -173,10 +262,12 @@ class XmlSerializationSupport {
173
  }
174
 
175
  public function serializeToXML(){
 
176
  return $this->toSimpleXmlObject()->asXML();
177
  }
178
 
179
  public function readFromXmlString($xml){
 
180
  $this->populateWithSimpleXmlObject(simplexml_load_string($xml));
181
  }
182
 
@@ -202,9 +293,11 @@ class XmlSerializationSupport {
202
 
203
  /**
204
  * @param SimpleXMLElement $simpleXmlObject
 
205
  * @return void
206
  */
207
  public function populateWithSimpleXmlObject($simpleXmlObject){
 
208
  $xmlArray = (array)$simpleXmlObject; // Array representation of the SimpleXMLElement
209
  $reflectionObj = new ReflectionObject($this);
210
  $properties = $reflectionObj->getProperties();
@@ -253,4 +346,12 @@ class XmlSerializationSupport {
253
  }
254
  }
255
  }
 
 
 
 
 
 
 
 
256
  }
20
  * Date: 4/18/12
21
  * Time: 5:34 PM
22
  */
 
 
23
 
24
+ /**
25
+ * Class represents binding rules for a class property
26
+ * To assign binding rules to the class use '$this' as property name.
27
+ */
28
+ class BindingRule {
29
+ private $serializationType = XmlSerializationSupport::SERIALIZE_TO_NODE;
30
+ private $xmlName = null;
31
+ private $type = null;
32
+
33
+ function __construct($propertyName)
34
+ {
35
+ // Xml name is a property name by default
36
+ $this->xmlName = $propertyName;
37
+ }
38
+
39
+ /**
40
+ * Property will be serialized to the xml node.
41
+ * Will be ignored on class level.
42
+ * @return BindingRule
43
+ */
44
+ public function toXmlNode() {
45
+ $this->serializationType = XmlSerializationSupport::SERIALIZE_TO_NODE;
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Property will be serialized to the xml attribute
51
+ * Will be ignored on class level.
52
+ * @return BindingRule
53
+ */
54
+ public function toXmlAttribute() {
55
+ $this->serializationType = XmlSerializationSupport::SERIALIZE_TO_ATTRIBUTE;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Property will be excluded from XML processing
61
+ * @return BindingRule
62
+ */
63
+ public function skip() {
64
+ $this->serializationType = XmlSerializationSupport::SERIALIZE_TO_NOTHING;
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Define custom xml name. By default property name will be used.
70
+ * @param $name
71
+ * @return BindingRule
72
+ */
73
+ public function xmlName($name) {
74
+ $this->xmlName = $name;
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Defines class type associated with given property. It should be a class name or array of classes.
80
+ * Example: objectType('LineItem'); objectType('array LineItem')
81
+ * Will be ignored on class level.
82
+ * @param $className
83
+ * @return BindingRule
84
+ */
85
+ public function objectType($className) {
86
+ $this->type = $className;
87
+ return $this;
88
+ }
89
+
90
+ public function getSerializationType()
91
+ {
92
+ return $this->serializationType;
93
+ }
94
+
95
+ public function getXmlName()
96
+ {
97
+ return $this->xmlName;
98
+ }
99
+
100
+ public function getObjectType() {
101
+ return $this->type;
102
+ }
103
+ }
104
+
105
+ class XmlSerializationSupport {
106
  const SERIALIZE_TO_NOTHING = 0;
107
  const SERIALIZE_TO_NODE = 1;
108
  const SERIALIZE_TO_ATTRIBUTE = 2;
109
 
110
  const TYPE_ARRAY_MODIFIER = 'array';
111
 
112
+ private $mappingRules = array();
113
+ private $isBindingInitialized = false;
114
+
115
  protected function getNamespace(){
116
  return null;
117
  }
118
 
119
+ protected final function setBindingRulesFor($propertyName) {
120
+ $rule = new BindingRule($propertyName);
121
+ $this->mappingRules[$propertyName] = $rule;
122
+ return $rule;
123
+ }
124
+
125
+ protected final function getMappingRules($propertyName) {
126
+ if (array_key_exists($propertyName, $this->mappingRules)) {
127
+ return $this->mappingRules[$propertyName];
128
+ }
129
+ $rule = new BindingRule($propertyName);
130
+ return $rule;
131
+ }
132
+
133
+ /**
134
+ * This method should be overridden by children classes to define custom binding rules.
135
+ * Default implementation is empty.
136
+ * Typical usage is:
137
+ * $this->setBindingRulesFor('$this')->xmlName('MyXmlNodeName'); // Sets name for xml node of the class
138
+ * $this->setBindingRulesFor('myProperty1')->xmlName('MyProp'); // Sets name for xml element of the myProperty1
139
+ * $this->setBindingRulesFor('myProperty2')->xmlName('mp') // Property 'myProperty2' will be serialized to the
140
+ * ->toAttribute(); // attribute of the class with name 'mp'
141
+ */
142
+ protected function defineBindingRules() {
143
+
144
+ }
145
+
146
  /**Returns serialization action.
147
  * Node - by default
 
148
  * @param ReflectionProperty $property
149
  * @return bool
150
  */
151
+ protected final function getSerializationType(ReflectionProperty $property){
152
+ $serializationAction = $this->getMappingRules($property->getName())->getSerializationType();
 
 
 
 
 
 
153
  return $serializationAction;
154
  }
155
 
156
  /**
157
+ * By default it will be just property name, unless special binding rule has been specified
 
158
  * @param ReflectionProperty $property
159
  * @return string XML Name for the property
160
  */
161
  protected function getTagNameForProperty(ReflectionProperty $property){
162
+ return $this->getMappingRules($property->getName())->getXmlName();
 
 
 
 
 
 
163
  }
164
 
165
+ /**
166
+ * Class name by default.
167
+ * If there is a binding rule pointed to the '$this' field, XML name from that rule will be used instead
168
  * @param ReflectionClass $class
169
  * @return string
170
  * @see getTagNameForProperty
171
  */
172
  protected function getTagNameForClass(ReflectionClass $class){
173
+ $defaultName = $class->getName();
174
+ $bindingName = $this->getMappingRules('$this')->getXmlName();
175
+ if ($bindingName != '$this') {
176
+ return $bindingName;
 
177
  }
178
+ return $defaultName;
179
  }
180
 
181
  protected function getTargetClassNameForProperty($property)
182
  {
183
+ $className=$this->getMappingRules($property->getName())->getObjectType();
184
+ if ($className!=null){
185
+ if ((substr($className, 0, strlen(self::TYPE_ARRAY_MODIFIER)) === self::TYPE_ARRAY_MODIFIER)){
186
+ $className = substr($className,strlen(self::TYPE_ARRAY_MODIFIER));
 
 
 
187
  }
188
  }
189
  return trim($className);
191
 
192
  protected function getIsArrayForProperty($property){
193
  $res = false;
194
+ $className=$this->getMappingRules($property->getName())->getObjectType();
195
+ if ($className != null) {
196
+ if ((substr($className, 0, strlen(self::TYPE_ARRAY_MODIFIER)) === self::TYPE_ARRAY_MODIFIER)){
197
+ $res = true;
 
198
  }
199
  }
200
  return $res;
213
  /**
214
  * Do some preprocessing before serialization, e.g. remove special characters
215
  * @param $value
216
+ * @return string
217
  */
218
  protected function preprocessValue($value){
219
  return htmlspecialchars($value);
220
  }
221
 
222
  public function toSimpleXmlObject($simpleXmlObject=null){
223
+ $this->initializeBindingsIfNeeded();
224
  $reflectionObj = new ReflectionObject($this);
225
  $className = $this->getTagNameForClass($reflectionObj);
226
  if ($simpleXmlObject==null)
262
  }
263
 
264
  public function serializeToXML(){
265
+ $this->initializeBindingsIfNeeded();
266
  return $this->toSimpleXmlObject()->asXML();
267
  }
268
 
269
  public function readFromXmlString($xml){
270
+ $this->initializeBindingsIfNeeded();
271
  $this->populateWithSimpleXmlObject(simplexml_load_string($xml));
272
  }
273
 
293
 
294
  /**
295
  * @param SimpleXMLElement $simpleXmlObject
296
+ * @throws Exception
297
  * @return void
298
  */
299
  public function populateWithSimpleXmlObject($simpleXmlObject){
300
+ $this->initializeBindingsIfNeeded();
301
  $xmlArray = (array)$simpleXmlObject; // Array representation of the SimpleXMLElement
302
  $reflectionObj = new ReflectionObject($this);
303
  $properties = $reflectionObj->getProperties();
346
  }
347
  }
348
  }
349
+
350
+ private function initializeBindingsIfNeeded()
351
+ {
352
+ if (!$this->isBindingInitialized) {
353
+ $this->defineBindingRules();
354
+ $this->isBindingInitialized = true;
355
+ }
356
+ }
357
  }
lib/ExactorCommons/config.php CHANGED
@@ -13,7 +13,7 @@ define('EXACTOR_CONFIG_FEATURE_TRN_FILTER', 'trn-filter');
13
 
14
  /* Initializing factories */
15
  ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
16
- ExactorConnectionFactory::getInstance()->setup('Magento','v20121227');
17
  ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
18
 
19
  /* Initializing configuration object */
13
 
14
  /* Initializing factories */
15
  ExactorLoggingFactory::getInstance()->setup('MagentoLogger', IExactorLogger::TRACE);
16
+ ExactorConnectionFactory::getInstance()->setup('Magento','v20130418');
17
  ExactorProcessingServiceFactory::getInstance()->setup(new MagentoExactorCallback());
18
 
19
  /* Initializing configuration object */
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Exactor_Tax</name>
4
- <version>2013.01.15</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -12,9 +12,9 @@ Once installed, neither the merchant, nor the customer, need to perform any addi
12
  For additional information, please refer to the Exactor Magento User Guide that is attached to the plug-in, or which you can download directly from the Exactor control panel (navigate to Account Management Integration Points &amp; PlugIns).</description>
13
  <notes>Supported Magento 1.5.0.0 - 1.7.x, Magento Enterprise 1.8-1.12.x</notes>
14
  <authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
15
- <date>2013-01-15</date>
16
- <time>16:48:19</time>
17
- <contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="72692a33574f8ba2f1858e2e93aa4edf"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="71a7c2308f6f0eda102ae84dd90df751"/><dir name="Mysql4"><dir name="ExactorTransaction"><file name="Collection.php" hash="c7b890b4d3ab35e65a3856ae0e2fdf72"/></dir><file name="ExactorTransaction.php" hash="c91aebaae767613acf1c439a8b513c3b"/><dir name="MerchantSettings"><file name="Collection.php" hash="c1593f52e582e601409c4651c37495af"/><file name="Collection.php~" hash="d360e202eb30432ac41dc023ce13ffc0"/></dir><file name="MerchantSettings.php" hash="8f22b76bb64cdc7b1deb6f0e38889905"/></dir><dir name="Type"><file name="Onepage.php" hash="2441fb08bbeb579831cea4d3fbd31104"/></dir></dir><dir name="etc"><file name="config.xml" hash="98ecc82a5f7b74ac0bfc0f7ab512afdb"/></dir></dir><dir name="ExactorSettings"><dir name="Block"><file name="Form.php" hash="5ea1d72197306072fe5fad9b97d109e8"/></dir><dir name="Helper"><file name="Data.php" hash="a23bb9c251f0dbb77c107d01dde39e86"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="c0985258b110e0314e6b6ea091ae8c19"/></dir><file name="AjaxController.php" hash="c07aeeca00e1408e52945fc027569793"/><file name="IndexController.php" hash="f47cbc274dd68c57c30b60bbee69259e"/></dir><dir name="etc"><file name="config.xml" hash="674c326bfc901d0becf7c94ddcdd1452"/></dir><dir name="sql"><dir name="ExactorSettings_setup"><file name="mysql4-install-14.04.2012.php" hash="f35af1e12921b57479cb4b5677937a0c"/><file name="upgrade-2012.06.14-2012.09.25.php" hash="174fda5224bc23cdf147fb059d079478"/></dir></dir></dir><dir name="Sales"><dir name="Model"><file name="Observer.php" hash="2c0ee19990b83aa2a5d774f69771de62"/></dir><dir name="etc"><file name="config.xml" hash="ba31618f5165dda20010c40e7ef8dad1"/></dir></dir><dir name="Tax"><dir name="Helper"><file name="Calculation.php" hash="29c5252bdd48b173c90588f449114024"/><file name="Mapping.php" hash="365849e0333ec60c1c1b88469b89751c"/></dir><dir name="Model"><dir name="Sales"><dir name="Total"><dir name="Quote"><dir name="Nominal"><file name="Tax.php" hash="156eff380df5b16db55449759f193490"/></dir><file name="Tax.php" hash="3c283d0960292d45fd95245c7ff11925"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="dac507a6a0437f511973c29646bd6a8d"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="exactorsettings.xml" hash="3707eac08d2393c8796eebf1cf7a0bd9"/><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir><dir name="template"><dir name="ExactorSettings"><file name="settingsform.phtml" hash="3f6e14533076ab97dbb0c98ba770bf87"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Exactor.xml" hash="e8997e8e36a265141b37790caaef39d6"/></dir></target><target name="mageweb"><dir name="js"><dir name="exactor"><file name="exactor.js" hash="5c23e40f4034e50a6e0df5b1c708b7e1"/></dir></dir></target><target name="magelib"><dir name="ExactorCommons"><file name="ExactorCommons.php" hash="7721531d9aa9f3732997e7c0180477fb"/><file name="ExactorDomainObjects.php" hash="ddfc1d3b00874f545eed99d3d35efdc6"/><file name="Magento.php" hash="76da7333fe0692053a47f8564c7b513a"/><file name="RegionResolver.php" hash="2537638a7895a169cee4b1df786d22fb"/><file name="XmlProcessing.php" hash="383fd21839889d720e2094e83ccc7a2a"/><file name="config.php" hash="1dcf7904007430336e9e82ee9202be71"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Exactor_Tax</name>
4
+ <version>2013.04.18</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
12
  For additional information, please refer to the Exactor Magento User Guide that is attached to the plug-in, or which you can download directly from the Exactor control panel (navigate to Account Management Integration Points &amp; PlugIns).</description>
13
  <notes>Supported Magento 1.5.0.0 - 1.7.x, Magento Enterprise 1.8-1.12.x</notes>
14
  <authors><author><name>Exactor, Inc.</name><user>exactor</user><email>support@exactor.com</email></author></authors>
15
+ <date>2013-04-18</date>
16
+ <time>16:00:22</time>
17
+ <contents><target name="magelocal"><dir name="Exactor"><dir name="Core"><dir name="Helper"><file name="SessionCache.php" hash="72692a33574f8ba2f1858e2e93aa4edf"/></dir><dir name="Model"><file name="ExactorTransaction.php" hash="852aa20f6e3b7aa0001439d4bffe9724"/><file name="MerchantSettings.php" hash="71a7c2308f6f0eda102ae84dd90df751"/><dir name="Mysql4"><dir name="ExactorTransaction"><file name="Collection.php" hash="c7b890b4d3ab35e65a3856ae0e2fdf72"/></dir><file name="ExactorTransaction.php" hash="c91aebaae767613acf1c439a8b513c3b"/><dir name="MerchantSettings"><file name="Collection.php" hash="c1593f52e582e601409c4651c37495af"/><file name="Collection.php~" hash="d360e202eb30432ac41dc023ce13ffc0"/></dir><file name="MerchantSettings.php" hash="8f22b76bb64cdc7b1deb6f0e38889905"/></dir><dir name="Type"><file name="Onepage.php" hash="2441fb08bbeb579831cea4d3fbd31104"/></dir></dir><dir name="etc"><file name="config.xml" hash="98ecc82a5f7b74ac0bfc0f7ab512afdb"/></dir></dir><dir name="ExactorSettings"><dir name="Block"><file name="Form.php" hash="5ea1d72197306072fe5fad9b97d109e8"/></dir><dir name="Helper"><file name="Data.php" hash="a23bb9c251f0dbb77c107d01dde39e86"/><file name="VersionResolver.php" hash="14dce068dfe2a7d3364c4bd29e6f8431"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FormController.php" hash="c0985258b110e0314e6b6ea091ae8c19"/></dir><file name="AjaxController.php" hash="c07aeeca00e1408e52945fc027569793"/><file name="IndexController.php" hash="f47cbc274dd68c57c30b60bbee69259e"/></dir><dir name="etc"><file name="config.xml" hash="674c326bfc901d0becf7c94ddcdd1452"/></dir><dir name="sql"><dir name="ExactorSettings_setup"><file name="mysql4-install-14.04.2012.php" hash="f35af1e12921b57479cb4b5677937a0c"/><file name="upgrade-2012.06.14-2012.09.25.php" hash="174fda5224bc23cdf147fb059d079478"/></dir></dir></dir><dir name="Sales"><dir name="Model"><file name="Observer.php" hash="42de4489c7f93e2c1c9b6ea6e7309584"/></dir><dir name="etc"><file name="config.xml" hash="ba31618f5165dda20010c40e7ef8dad1"/></dir></dir><dir name="Tax"><dir name="Helper"><file name="Calculation.php" hash="29c5252bdd48b173c90588f449114024"/><file name="Mapping.php" hash="7c9af929b1ac28eb858e26d6876b950f"/></dir><dir name="Model"><dir name="Sales"><dir name="Total"><dir name="Quote"><dir name="Nominal"><file name="Tax.php" hash="156eff380df5b16db55449759f193490"/></dir><file name="Tax.php" hash="3c283d0960292d45fd95245c7ff11925"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="dac507a6a0437f511973c29646bd6a8d"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="exactorsettings.xml" hash="3707eac08d2393c8796eebf1cf7a0bd9"/><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir><dir name="template"><dir name="ExactorSettings"><file name="settingsform.phtml" hash="3f6e14533076ab97dbb0c98ba770bf87"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="exactoronestepcheckout.xml" hash="9fdfa1db5e4e60b4eec8f348c10aab07"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Exactor.xml" hash="e8997e8e36a265141b37790caaef39d6"/></dir></target><target name="mageweb"><dir name="js"><dir name="exactor"><file name="exactor.js" hash="5c23e40f4034e50a6e0df5b1c708b7e1"/></dir></dir></target><target name="magelib"><dir name="ExactorCommons"><file name="ExactorCommons.php" hash="7721531d9aa9f3732997e7c0180477fb"/><file name="ExactorDomainObjects.php" hash="642c46eb5e1c3daa624cce0f9329348a"/><file name="Magento.php" hash="76da7333fe0692053a47f8564c7b513a"/><file name="RegionResolver.php" hash="2537638a7895a169cee4b1df786d22fb"/><file name="XmlProcessing.php" hash="5d6393a68f86cf9a7d0f3b26b5b8f1e0"/><file name="config.php" hash="d71e1ef2d745f7499dfa0e3fc6739229"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>