Litle_Payments - Version 8.15.0

Version Notes

This extension implements Litle XML

Additional features include enhanced reporting on orders, transactions, and customers.

Download this release

Release Info

Developer Litle
Extension Litle_Payments
Version 8.15.0
Comparing to
See all releases


Code changes from version 8.14.0 to 8.15.0

Files changed (42) hide show
  1. app/.gitignore +2 -0
  2. app/.htaccess +2 -0
  3. app/code/local/Litle/CreditCard/Helper/Data.php +2 -1
  4. app/code/local/Litle/CreditCard/Model/PaymentLogic.php +77 -28
  5. app/code/local/Litle/CreditCard/Model/Url.php +19 -7
  6. app/code/local/Litle/CreditCard/controllers/Adminhtml/OrderController.php +10 -11
  7. app/code/local/Litle/CreditCard/etc/config.xml +1 -1
  8. app/code/local/Litle/LEcheck/Model/PaymentLogic.php +13 -3
  9. app/code/local/Litle/LEcheck/etc/config.xml +1 -1
  10. app/code/local/Litle/LitleSDK/BatchRequest.php +413 -0
  11. app/code/local/Litle/LitleSDK/Checker.php +2 -2
  12. app/code/local/Litle/LitleSDK/Communication.php +7 -2
  13. app/code/local/Litle/LitleSDK/LitleOnline.php +8 -3
  14. app/code/local/Litle/LitleSDK/LitleOnlineRequest.php +313 -146
  15. app/code/local/Litle/LitleSDK/LitleRequest.php +299 -0
  16. app/code/local/Litle/LitleSDK/LitleResponseProcessor.php +73 -0
  17. app/code/local/Litle/LitleSDK/LitleXmlMapper.php +9 -5
  18. app/code/local/Litle/LitleSDK/Obj2xml.php +126 -7
  19. app/code/local/Litle/LitleSDK/Setup.php +22 -2
  20. app/code/local/Litle/LitleSDK/Transactions.php +353 -0
  21. app/code/local/Litle/LitleSDK/XmlFields.php +81 -26
  22. app/code/local/Litle/LitleSDK/XmlParser.php +5 -0
  23. app/code/local/Litle/Palorus/Helper/Data.php +10 -2
  24. app/code/local/Litle/Palorus/Model/Avscid.php +13 -0
  25. app/code/local/Litle/Palorus/Model/Mysql4/Avscid.php +9 -0
  26. app/code/local/Litle/Palorus/Model/Mysql4/Avscid/Collection.php +11 -0
  27. app/code/local/Litle/Palorus/Model/Vault.php +0 -10
  28. app/code/local/Litle/Palorus/etc/config.xml +4 -1
  29. app/code/local/Litle/Palorus/sql/palorus_setup/mysql4-upgrade-8.14.0-8.15.0.php +21 -0
  30. app/design/.gitignore +1 -0
  31. app/design/adminhtml/default/default/layout/.gitignore +31 -0
  32. app/design/adminhtml/default/default/locale/en_US/.gitignore +1 -0
  33. app/design/adminhtml/default/default/template/.gitignore +59 -0
  34. app/design/adminhtml/default/default/template/litle/form/litlecc.phtml +1 -1
  35. app/design/frontend/.gitignore +1 -0
  36. app/design/frontend/base/default/.gitignore +1 -0
  37. app/design/frontend/base/default/layout/.gitignore +39 -0
  38. app/design/frontend/base/default/template/.gitignore +42 -0
  39. app/design/frontend/base/default/template/litle/form/litlecc.phtml +1 -3
  40. app/etc/.gitignore +4 -0
  41. app/etc/modules/.gitignore +19 -0
  42. package.xml +2 -2
app/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /locale
2
+ /Mage.php
app/.htaccess ADDED
@@ -0,0 +1,2 @@
 
 
1
+ Order deny,allow
2
+ Deny from all
app/code/local/Litle/CreditCard/Helper/Data.php CHANGED
@@ -4,9 +4,10 @@ class Litle_CreditCard_Helper_Data extends Mage_Core_Helper_Abstract
4
  public function isStateOfOrderEqualTo($order, $inOrderState){
5
  $payment = $order->getPayment();
6
  $lastTxnId = $payment->getLastTransId();
 
7
  $lastTxn = $payment->getTransaction($lastTxnId);
8
 
9
- if( $lastTxn->getTxnType() === $inOrderState )
10
  return true;
11
  else
12
  return false;
4
  public function isStateOfOrderEqualTo($order, $inOrderState){
5
  $payment = $order->getPayment();
6
  $lastTxnId = $payment->getLastTransId();
7
+ Mage::log("Last txn id: " . $lastTxnId);
8
  $lastTxn = $payment->getTransaction($lastTxnId);
9
 
10
+ if( $lastTxn != null && $lastTxn->getTxnType() === $inOrderState )
11
  return true;
12
  else
13
  return false;
app/code/local/Litle/CreditCard/Model/PaymentLogic.php CHANGED
@@ -78,7 +78,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
78
  $parentTxnId = $payment->getParentTransactionId();
79
  if ($parentTxnId == 'Litle VT') {
80
  Mage::throwException(
81
- "This order was placed using Litle Virtual Terminal. Please process the $txnType by logging into Litle Virtual Terminal (https://vt.litle.com).");
82
  }
83
  }
84
 
@@ -96,7 +96,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
96
  $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
97
  $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
98
  }
99
-
100
  if ($this->getConfigData('vault_enable')) {
101
  $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
102
  $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
@@ -264,13 +264,21 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
264
  'user' => $this->getConfigData('user'),
265
  'password' => $this->getConfigData('password'),
266
  'merchantId' => $this->getMerchantId($payment),
267
- 'version' => '8.10',
268
- 'merchantSdk' => 'Magento;8.14.0',
269
  'reportGroup' => $this->getMerchantId($payment),
270
  'customerId' => $order->getCustomerEmail(),
271
  'url' => $this->getConfigData('url'),
272
  'proxy' => $this->getConfigData('proxy'),
273
- 'timeout' => $this->getConfigData('timeout')
 
 
 
 
 
 
 
 
 
274
  );
275
  return $hash;
276
  }
@@ -290,13 +298,16 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
290
  $url_temp2 = explode('.', $url);
291
  $count = count($url_temp2);
292
  }
293
- if ($count < 3) {
294
  if (strlen($url_temp2['0'] . '.' . $url_temp2['1']) > 13) {
295
  $url = $url_temp2['0'];
296
  } else {
297
  $url = $url_temp2['0'] . '.' . $url_temp2['1'];
298
  }
299
  }
 
 
 
300
  }
301
  }
302
 
@@ -314,7 +325,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
314
  public function getOrderDate(Varien_Object $payment)
315
  {
316
  $order = $payment->getOrder();
317
- $date = $order->getCreatedAtFormated(short);
318
  $date_temp = explode('/', $date);
319
  $month = $date_temp['0'];
320
  if ((int) $month < 10) {
@@ -383,9 +394,18 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
383
  public function getFraudCheck(Varien_Object $payment)
384
  {
385
  $order = $payment->getOrder();
386
- $hash = array(
387
- 'customerIpAddress' => $order->getRemoteIp()
388
- );
 
 
 
 
 
 
 
 
 
389
  return $hash;
390
  }
391
 
@@ -449,7 +469,9 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
449
  $this->getUpdater($litleResponse, 'tokenResponse', 'litleToken'),
450
  $this->getUpdater($litleResponse, 'tokenResponse', 'bin'));
451
 
452
- $this->getInfoInstance()->setAdditionalInformation('vault_id', $vault->getId());
 
 
453
  }
454
  }
455
 
@@ -500,7 +522,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
500
  }
501
  }
502
 
503
- public function writeFailedTransactionToDatabase($customerId, $orderId, $message, $xmlDocument) {
504
  $orderNumber = 0;
505
  if($orderId === null) {
506
  $orderId = 0;
@@ -537,6 +559,29 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
537
  Mage::log("Insert failed with error message: " . mysql_error(), null, "litle.log");
538
  Mage::log("Query executed: " . $sql, null, "litle.log");
539
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  mysql_close($con);
541
  }
542
  }
@@ -554,54 +599,57 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
554
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID,
555
  Mage_Sales_Model_Order::STATE_CANCELED,
556
  Mage_Payment_Model_Method_Abstract::STATUS_VOID,
557
- "Authorization has expired - no need to reverse. The original Authorization is no longer valid, because it has expired. You can not perform an Authorization Reversal for an expired Authorization.");
 
558
  }
559
  elseif($litleResponseCode === '311') {
560
  $this->setOrderStatusAndCommentsForFailedTransaction( $payment, $litleTxnId,
561
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
562
  Mage_Sales_Model_Order::STATE_COMPLETE,
563
  Mage_Payment_Model_Method_Abstract::STATUS_APPROVED,
564
- "Deposit is already referenced by a chargeback. The deposit is already referenced by a chargeback; therefore, a refund cannot be processed against the original transaction.");
 
565
  }
566
  elseif($litleResponseCode === '316') {
567
  $this->setOrderStatusAndCommentsForFailedTransaction( $payment, $litleTxnId,
568
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
569
  Mage_Sales_Model_Order::STATE_COMPLETE,
570
  Mage_Payment_Model_Method_Abstract::STATUS_APPROVED,
571
- "Automatic refund already issued. This refund transaction is a duplicate for one already processed automatically by the Litle Fraud Chargeback Prevention Service.");
 
572
  }
573
  elseif($litleResponseCode === '335') {
574
  $descriptiveMessage = "This method of payment does not support authorization reversals. You can not perform an Authorization Reversal transaction for this payment type.";
575
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
576
  }
577
  elseif($litleResponseCode === '336') {
578
  $descriptiveMessage = "Reversal amount does not match Authorization amount. For a merchant initiated reversal against an American Express authorization, the reversal amount must match the authorization amount exactly.";
579
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
580
  }
581
  elseif($litleResponseCode === '361') {
582
- $descriptiveMessage = "Authorization no longer available. The authorization for this transaction is no longer available; the authorization has already been consumed by another capture.";
583
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
584
  }
585
  elseif($litleResponseCode === '362') {
586
  $descriptiveMessage = "Transaction Not Voided - Already Settled. This transaction cannot be voided; it has already been delivered to the card networks. You may want to try a refund instead.";
587
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
588
  }
589
  elseif($litleResponseCode === '365') {
590
  $descriptiveMessage = "Total credit amount exceeds capture amouont. The amount of the credit is greater than the capture, or the amount of this credit plus other credits already referencing this capture are greater than the capture amount.";
591
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
592
  }
593
  elseif($litleResponseCode === '370') {
594
  $descriptiveMessage = "Internal System Error - Call Litle. There is a problem with the Litle System. Contact support@litle.com and provide the following transaction id: " . $litleTxnId;
595
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
596
  }
597
  else {
598
  $descriptiveMessage = "Transaction was not approved and Litle's Magento extension can not tell why. Contact Litle at support@litle.com and provide the following transaction id: " . $litleTxnId;
599
- $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId);
600
  }
601
 
602
  }
603
 
604
- public function setOrderStatusAndCommentsForFailedTransaction($payment, $litleTxnId, $transactionType, $orderState, $paymentStatus, $litleMessage) {
605
  $paymentHelp = new Litle_CreditCard_Model_Lpayment();
606
  $paymentHelp->setOrder($payment->getOrder());
607
  $transaction = $paymentHelp->addTransaction(transactionType, null, true, $litleMessage);
@@ -609,12 +657,12 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
609
  ->setCcTransId($litleTxnId)
610
  ->setLastTransId($litleTxnId)
611
  ->setTransactionId($litleTxnId)
612
- ->setIsTransactionClosed(true)
613
  ->setTransactionAdditionalInfo('additional_information', $litleMessage);
614
  }
615
 
616
- public function showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $messageToShow, $litleTxnId) {
617
- $this->writeFailedTransactionToDatabase($customerId, $orderId, $litleMessage, $litleResponse);
618
  $resource = Mage::getSingleton('core/resource');
619
  $conn = $resource->getConnection('core_read');
620
  $query = 'select failed_transactions_id from litle_failed_transactions where litle_txn_id = ' . $litleTxnId;
@@ -628,6 +676,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
628
  */
629
  public function authorize(Varien_Object $payment, $amount)
630
  {
 
631
  // @TODO This is the wrong way to do this.
632
  if (preg_match('/sales_order_create/i', $_SERVER['REQUEST_URI']) &&
633
  ($this->getConfigData('paypage_enable') == '1')) {
@@ -741,7 +790,7 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
741
  } else {
742
  $litleResponse = $litleRequest->captureRequest($hash_in);
743
  }
744
-
745
  if (! is_null($info->getAdditionalInformation('cc_should_save'))) {
746
  $this->_saveToken($payment, $litleResponse);
747
  }
78
  $parentTxnId = $payment->getParentTransactionId();
79
  if ($parentTxnId == 'Litle VT') {
80
  Mage::throwException(
81
+ "This order was placed using Litle Virtual Terminal. Please process the $txnType by logging into Litle Virtual Terminal (https://reports.litle.com).");
82
  }
83
  }
84
 
96
  $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
97
  $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
98
  }
99
+
100
  if ($this->getConfigData('vault_enable')) {
101
  $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
102
  $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
264
  'user' => $this->getConfigData('user'),
265
  'password' => $this->getConfigData('password'),
266
  'merchantId' => $this->getMerchantId($payment),
267
+ 'merchantSdk' => 'Magento;8.15.0',
 
268
  'reportGroup' => $this->getMerchantId($payment),
269
  'customerId' => $order->getCustomerEmail(),
270
  'url' => $this->getConfigData('url'),
271
  'proxy' => $this->getConfigData('proxy'),
272
+ 'timeout' => $this->getConfigData('timeout'),
273
+ 'batch_requests_path' => 'MAGENTO', //Magento doesn't use batch
274
+ 'sftp_username' => 'MAGENTO', //Magento doesn't use batch
275
+ 'sftp_password' => 'MAGENTO', //Magento doesn't use batch
276
+ 'batch_url' => 'MAGENTO', //Magento doesn't use batch
277
+ 'tcp_port' => 'MAGENTO', //Magento doesn't use batch
278
+ 'tcp_ssl' => 'MAGENTO', //Magento doesn't use batch
279
+ 'tcp_timeout' => 'MAGENTO', //Magento doesn't use batch
280
+ 'litle_requests_path' => 'MAGENTO', //Magento doesn't use batch
281
+ 'print_xml' => 'false' //Magento uses debug_enabled instead
282
  );
283
  return $hash;
284
  }
298
  $url_temp2 = explode('.', $url);
299
  $count = count($url_temp2);
300
  }
301
+ if ($count == 2) {
302
  if (strlen($url_temp2['0'] . '.' . $url_temp2['1']) > 13) {
303
  $url = $url_temp2['0'];
304
  } else {
305
  $url = $url_temp2['0'] . '.' . $url_temp2['1'];
306
  }
307
  }
308
+ if($count == 1) {
309
+ $url = substr($url_temp2['0'], 0, 13);
310
+ }
311
  }
312
  }
313
 
325
  public function getOrderDate(Varien_Object $payment)
326
  {
327
  $order = $payment->getOrder();
328
+ $date = $order->getCreatedAtFormated('short');
329
  $date_temp = explode('/', $date);
330
  $month = $date_temp['0'];
331
  if ((int) $month < 10) {
394
  public function getFraudCheck(Varien_Object $payment)
395
  {
396
  $order = $payment->getOrder();
397
+ $ip = $order->getRemoteIp();
398
+ $ipv4Regex = "/\A(?:\d{1,3}\.){3}\d{1,3}\z/";
399
+ $matches = preg_match($ipv4Regex, $ip);
400
+ if($matches === 1) {
401
+ $hash = array(
402
+ 'customerIpAddress' => $ip
403
+ );
404
+ }
405
+ else {
406
+ Mage::log("Not sending ip address " . $ip . " because it isn't ipv4", null, "litle.log");
407
+ $hash = array();
408
+ }
409
  return $hash;
410
  }
411
 
469
  $this->getUpdater($litleResponse, 'tokenResponse', 'litleToken'),
470
  $this->getUpdater($litleResponse, 'tokenResponse', 'bin'));
471
 
472
+ if ($vault) {
473
+ $this->getInfoInstance()->setAdditionalInformation('vault_id', $vault->getId());
474
+ }
475
  }
476
  }
477
 
522
  }
523
  }
524
 
525
+ public function writeFailedTransactionToDatabase($customerId, $orderId, $message, $xmlDocument, $txnType) {
526
  $orderNumber = 0;
527
  if($orderId === null) {
528
  $orderId = 0;
559
  Mage::log("Insert failed with error message: " . mysql_error(), null, "litle.log");
560
  Mage::log("Query executed: " . $sql, null, "litle.log");
561
  }
562
+ $sql = "select * from sales_payment_transaction where order_id = " . $orderId . " order by created_at asc";
563
+ $result = mysql_query($sql);
564
+ Mage::log("Executed sql: " . $sql, null, "litle.log");
565
+ Mage::log($result, null, "litle.log");
566
+ while($row = mysql_fetch_assoc($result)) {
567
+ Mage::log($row['transaction_id'], null, "litle.log");
568
+ $sql = "insert into sales_payment_transaction (parent_id, order_id, payment_id, txn_id, parent_txn_id, txn_type, is_closed, created_at, additional_information) values (".$row['transaction_id'].", ".$orderId.", ".$orderId.", ".$litleTxnId.", ".$row['txn_id'].", '".$txnType."', 0,now(),'".serialize(array('message'=>message))."')";
569
+ }
570
+ Mage::log("Sql to execute is: " . $sql, null, "litle.log");
571
+ $result = mysql_query($sql);
572
+ if(!$result) {
573
+ Mage::log("Insert failed with error message: " . mysql_error(), null, "litle.log");
574
+ Mage::log("Query executed: " . $sql, null, "litle.log");
575
+ }
576
+
577
+ $sql = "insert into sales_flat_order_status_history (parent_id, is_customer_notified, is_visible_on_front, comment, status, created_at, entity_name) values (".$orderId.", 2, 0,'".$message.". Transaction ID: ".$litleTxnId."','processing',now(),'".$txnType."')";
578
+ Mage::log("Sql to execute is: " . $sql, null, "litle.log");
579
+ $result = mysql_query($sql);
580
+ if(!$result) {
581
+ Mage::log("Insert failed with error message: " . mysql_error(), null, "litle.log");
582
+ Mage::log("Query executed: " . $sql, null, "litle.log");
583
+ }
584
+
585
  mysql_close($con);
586
  }
587
  }
599
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID,
600
  Mage_Sales_Model_Order::STATE_CANCELED,
601
  Mage_Payment_Model_Method_Abstract::STATUS_VOID,
602
+ "Authorization has expired - no need to reverse. The original Authorization is no longer valid, because it has expired. You can not perform an Authorization Reversal for an expired Authorization.",
603
+ true);
604
  }
605
  elseif($litleResponseCode === '311') {
606
  $this->setOrderStatusAndCommentsForFailedTransaction( $payment, $litleTxnId,
607
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
608
  Mage_Sales_Model_Order::STATE_COMPLETE,
609
  Mage_Payment_Model_Method_Abstract::STATUS_APPROVED,
610
+ "Deposit is already referenced by a chargeback. The deposit is already referenced by a chargeback; therefore, a refund cannot be processed against the original transaction.",
611
+ true);
612
  }
613
  elseif($litleResponseCode === '316') {
614
  $this->setOrderStatusAndCommentsForFailedTransaction( $payment, $litleTxnId,
615
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
616
  Mage_Sales_Model_Order::STATE_COMPLETE,
617
  Mage_Payment_Model_Method_Abstract::STATUS_APPROVED,
618
+ "Automatic refund already issued. This refund transaction is a duplicate for one already processed automatically by the Litle Fraud Chargeback Prevention Service.",
619
+ true);
620
  }
621
  elseif($litleResponseCode === '335') {
622
  $descriptiveMessage = "This method of payment does not support authorization reversals. You can not perform an Authorization Reversal transaction for this payment type.";
623
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
624
  }
625
  elseif($litleResponseCode === '336') {
626
  $descriptiveMessage = "Reversal amount does not match Authorization amount. For a merchant initiated reversal against an American Express authorization, the reversal amount must match the authorization amount exactly.";
627
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
628
  }
629
  elseif($litleResponseCode === '361') {
630
+ $descriptiveMessage = "The order #".$order->getIncrementId()." can not be captured. Authorization no longer available. The authorization for this transaction is no longer available; the authorization has already been consumed by another capture.";
631
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
632
  }
633
  elseif($litleResponseCode === '362') {
634
  $descriptiveMessage = "Transaction Not Voided - Already Settled. This transaction cannot be voided; it has already been delivered to the card networks. You may want to try a refund instead.";
635
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
636
  }
637
  elseif($litleResponseCode === '365') {
638
  $descriptiveMessage = "Total credit amount exceeds capture amouont. The amount of the credit is greater than the capture, or the amount of this credit plus other credits already referencing this capture are greater than the capture amount.";
639
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
640
  }
641
  elseif($litleResponseCode === '370') {
642
  $descriptiveMessage = "Internal System Error - Call Litle. There is a problem with the Litle System. Contact support@litle.com and provide the following transaction id: " . $litleTxnId;
643
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnIdMage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
644
  }
645
  else {
646
  $descriptiveMessage = "Transaction was not approved and Litle's Magento extension can not tell why. Contact Litle at support@litle.com and provide the following transaction id: " . $litleTxnId;
647
+ $this->showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $descriptiveMessage, $litleTxnId, Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
648
  }
649
 
650
  }
651
 
652
+ public function setOrderStatusAndCommentsForFailedTransaction($payment, $litleTxnId, $transactionType, $orderState, $paymentStatus, $litleMessage, $closed) {
653
  $paymentHelp = new Litle_CreditCard_Model_Lpayment();
654
  $paymentHelp->setOrder($payment->getOrder());
655
  $transaction = $paymentHelp->addTransaction(transactionType, null, true, $litleMessage);
657
  ->setCcTransId($litleTxnId)
658
  ->setLastTransId($litleTxnId)
659
  ->setTransactionId($litleTxnId)
660
+ ->setIsTransactionClosed($closed)
661
  ->setTransactionAdditionalInfo('additional_information', $litleMessage);
662
  }
663
 
664
+ public function showErrorForFailedTransaction($customerId, $orderId, $litleMessage, $litleResponse, $messageToShow, $litleTxnId, $txnType) {
665
+ $this->writeFailedTransactionToDatabase($customerId, $orderId, $litleMessage, $litleResponse, $txnType);
666
  $resource = Mage::getSingleton('core/resource');
667
  $conn = $resource->getConnection('core_read');
668
  $query = 'select failed_transactions_id from litle_failed_transactions where litle_txn_id = ' . $litleTxnId;
676
  */
677
  public function authorize(Varien_Object $payment, $amount)
678
  {
679
+ // What about this? Mage::app()->getStore()->isAdmin()
680
  // @TODO This is the wrong way to do this.
681
  if (preg_match('/sales_order_create/i', $_SERVER['REQUEST_URI']) &&
682
  ($this->getConfigData('paypage_enable') == '1')) {
790
  } else {
791
  $litleResponse = $litleRequest->captureRequest($hash_in);
792
  }
793
+
794
  if (! is_null($info->getAdditionalInformation('cc_should_save'))) {
795
  $this->_saveToken($payment, $litleResponse);
796
  }
app/code/local/Litle/CreditCard/Model/Url.php CHANGED
@@ -10,17 +10,29 @@ class Litle_CreditCard_Model_URL
10
  'label' => 'Sandbox'
11
  ),
12
  array(
13
- 'value' => "https://cert.litle.com/vap/communicator/online",
14
- 'label' => 'Cert'
15
- ),
16
- array(
17
- 'value' => "https://precert.litle.com/vap/communicator/online",
18
- 'label' => 'PreCert'
19
  ),
 
 
 
 
 
 
 
 
 
 
 
 
20
  array(
21
  'value' => "https://payments.litle.com/vap/communicator/online",
22
  'label' => 'Production'
23
- )
 
 
 
 
24
  );
25
 
26
  }
10
  'label' => 'Sandbox'
11
  ),
12
  array(
13
+ 'value' => "https://postlive.litle.com/vap/communicator/online",
14
+ 'label' => 'Postlive'
 
 
 
 
15
  ),
16
+ array(
17
+ 'value' => "https://prelive.litle.com/vap/communicator/online",
18
+ 'label' => 'Prelive'
19
+ ),
20
+ array(
21
+ 'value' => "https://transact-postlive.litle.com/vap/communicator/online",
22
+ 'label' => 'Transact Postlive'
23
+ ),
24
+ array(
25
+ 'value' => "https://transact-prelive.litle.com/vap/communicator/online",
26
+ 'label' => 'Transact Prelive'
27
+ ),
28
  array(
29
  'value' => "https://payments.litle.com/vap/communicator/online",
30
  'label' => 'Production'
31
+ ),
32
+ array(
33
+ 'value' => "https://transact.litle.com/vap/communicator/online",
34
+ 'label' => 'Transact Production'
35
+ )
36
  );
37
 
38
  }
app/code/local/Litle/CreditCard/controllers/Adminhtml/OrderController.php CHANGED
@@ -4,21 +4,18 @@ class Litle_CreditCard_Adminhtml_OrderController extends Mage_Adminhtml_Controll
4
  public function massCaptureAction()
5
  {
6
  $orderIds = $this->getRequest()->getPost('order_ids', array());
7
- $countCaptureOrder = 0;
8
  foreach ($orderIds as $orderId) {
9
  $order = Mage::getModel('sales/order')->load($orderId);
10
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice(array());
11
  if ($order->canInvoice()){
12
  $invoice->register();
13
- $this->captureInvoice($invoice);
14
- $countCaptureOrder++;
 
15
  } else {
16
  $this->_getSession()->addError($this->__('The order #' . $invoice->getOrder()->getIncrementId() . ' cannot be Captured '));
17
  }
18
  }
19
- if ($countCaptureOrder) {
20
- $this->_getSession()->addSuccess($this->__('%s order(s) have been Captured', $countCaptureOrder));
21
- }
22
  $referrer = $_SERVER['HTTP_REFERER'];
23
  $this->_redirectUrl($referrer);
24
  }
@@ -28,20 +25,22 @@ class Litle_CreditCard_Adminhtml_OrderController extends Mage_Adminhtml_Controll
28
  try
29
  {
30
  $invoice->setRequestedCaptureCase('online');
31
- $invoice->sendEmail(true);
32
- $invoice->setEmailSent(true);
33
- $invoice->getOrder()->setCustomerNoteNotify(true);
34
- $invoice->getOrder()->setIsInProcess(true);
35
  $invoice->capture();
36
  $transactionSave = Mage::getModel('core/resource_transaction')
37
  ->addObject($invoice)
38
  ->addObject($invoice->getOrder());
39
  $transactionSave->save();
 
40
  }
41
-
42
  catch (Exception $e)
43
  {
 
44
  Mage::logException($e);
 
45
  }
46
  }
47
  }
4
  public function massCaptureAction()
5
  {
6
  $orderIds = $this->getRequest()->getPost('order_ids', array());
 
7
  foreach ($orderIds as $orderId) {
8
  $order = Mage::getModel('sales/order')->load($orderId);
9
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice(array());
10
  if ($order->canInvoice()){
11
  $invoice->register();
12
+ if($this->captureInvoice($invoice)) {
13
+ $this->_getSession()->addSuccess("The order #".$invoice->getOrder()->getIncrementId()." captured successfully");
14
+ }
15
  } else {
16
  $this->_getSession()->addError($this->__('The order #' . $invoice->getOrder()->getIncrementId() . ' cannot be Captured '));
17
  }
18
  }
 
 
 
19
  $referrer = $_SERVER['HTTP_REFERER'];
20
  $this->_redirectUrl($referrer);
21
  }
25
  try
26
  {
27
  $invoice->setRequestedCaptureCase('online');
28
+ //$invoice->sendEmail(true);
29
+ //$invoice->setEmailSent(true);
30
+ //$invoice->getOrder()->setCustomerNoteNotify(true);
31
+ //$invoice->getOrder()->setIsInProcess(true);
32
  $invoice->capture();
33
  $transactionSave = Mage::getModel('core/resource_transaction')
34
  ->addObject($invoice)
35
  ->addObject($invoice->getOrder());
36
  $transactionSave->save();
37
+ return true;
38
  }
 
39
  catch (Exception $e)
40
  {
41
+ Mage::getSingleton('core/session')->addError($e->getMessage());
42
  Mage::logException($e);
43
+ return false;
44
  }
45
  }
46
  }
app/code/local/Litle/CreditCard/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Litle_CreditCard>
5
- <version>8.13.3</version>
6
  </Litle_CreditCard>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Litle_CreditCard>
5
+ <version>8.15.0</version>
6
  </Litle_CreditCard>
7
  </modules>
8
  <global>
app/code/local/Litle/LEcheck/Model/PaymentLogic.php CHANGED
@@ -89,9 +89,9 @@ class Litle_LEcheck_Model_PaymentLogic extends Mage_Payment_Model_Method_Abstrac
89
  $returnFromThisModel = Mage::getStoreConfig('payment/CreditCard/' . $fieldToLookFor);
90
  }
91
 
92
- if( $returnFromThisModel == NULL )
93
  $returnFromThisModel = parent::getConfigData($fieldToLookFor, $store);
94
-
95
  return $returnFromThisModel;
96
  }
97
 
@@ -170,7 +170,17 @@ class Litle_LEcheck_Model_PaymentLogic extends Mage_Payment_Model_Method_Abstrac
170
  'reportGroup'=>$this->getMerchantId($payment),
171
  'url'=>$this->getConfigData("url"),
172
  'proxy'=>$this->getConfigData("proxy"),
173
- 'timeout'=>$this->getConfigData("timeout")
 
 
 
 
 
 
 
 
 
 
174
  );
175
  return $hash;
176
  }
89
  $returnFromThisModel = Mage::getStoreConfig('payment/CreditCard/' . $fieldToLookFor);
90
  }
91
 
92
+ if( $returnFromThisModel == NULL ) {
93
  $returnFromThisModel = parent::getConfigData($fieldToLookFor, $store);
94
+ }
95
  return $returnFromThisModel;
96
  }
97
 
170
  'reportGroup'=>$this->getMerchantId($payment),
171
  'url'=>$this->getConfigData("url"),
172
  'proxy'=>$this->getConfigData("proxy"),
173
+ 'timeout'=>$this->getConfigData("timeout"),
174
+ 'batch_requests_path' => 'MAGENTO', //Magento doesn't use batch
175
+ 'sftp_username' => 'MAGENTO', //Magento doesn't use batch
176
+ 'sftp_password' => 'MAGENTO', //Magento doesn't use batch
177
+ 'batch_url' => 'MAGENTO', //Magento doesn't use batch
178
+ 'tcp_port' => 'MAGENTO', //Magento doesn't use batch
179
+ 'tcp_ssl' => 'MAGENTO', //Magento doesn't use batch
180
+ 'tcp_timeout' => 'MAGENTO', //Magento doesn't use batch
181
+ 'litle_requests_path' => 'MAGENTO', //Magento doesn't use batch
182
+ 'print_xml' => 'false' //Magento uses debug_enabled instead
183
+
184
  );
185
  return $hash;
186
  }
app/code/local/Litle/LEcheck/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Litle_LEcheck>
5
- <version>8.13.3</version>
6
  </Litle_LEcheck>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Litle_LEcheck>
5
+ <version>8.15.0</version>
6
  </Litle_LEcheck>
7
  </modules>
8
  <global>
app/code/local/Litle/LitleSDK/BatchRequest.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BatchRequest {
4
+
5
+ private $counts_and_amounts;
6
+
7
+ public $total_txns = 0;
8
+
9
+ public $closed = false;
10
+
11
+ # file name which holds the transaction markups during the batch process
12
+ public $transaction_file;
13
+
14
+ public $batch_file;
15
+
16
+
17
+ public function isFull(){
18
+ return $this->total_txns >= MAX_TXNS_PER_BATCH;
19
+ }
20
+
21
+ public function __construct($request_dir=NULL){
22
+ // initialize the counts and amounts
23
+
24
+ $this->counts_and_amounts = array(
25
+ 'auth' => array(
26
+ 'count' => 0,
27
+ 'amount' => 0,
28
+ ),
29
+ 'sale' => array(
30
+ 'count' => 0,
31
+ 'amount' => 0,
32
+ ),
33
+ 'credit' => array(
34
+ 'count' => 0,
35
+ 'amount' => 0,
36
+ ),
37
+ 'tokenRegistration' => array(
38
+ 'count' => 0,
39
+ ),
40
+ 'captureGivenAuth' => array(
41
+ 'count' => 0,
42
+ 'amount' => 0,
43
+ ),
44
+ 'forceCapture' => array(
45
+ 'count' => 0,
46
+ 'amount' => 0,
47
+ ),
48
+ 'authReversal' => array(
49
+ 'count' => 0,
50
+ 'amount' => 0,
51
+ ),
52
+ 'capture' => array(
53
+ 'count' => 0,
54
+ 'amount' => 0,
55
+ ),
56
+ 'echeckVerification' => array(
57
+ 'count' => 0,
58
+ 'amount' => 0,
59
+ ),
60
+ 'echeckCredit' => array(
61
+ 'count' => 0,
62
+ 'amount' => 0,
63
+ ),
64
+ 'echeckRedeposit' => array(
65
+ 'count' => 0,
66
+ ),
67
+ 'echeckSale' => array(
68
+ 'count' => 0,
69
+ 'amount' => 0,
70
+ ),
71
+ 'updateCardValidationNumOnToken' => array(
72
+ 'count' => 0,
73
+ ),
74
+ 'updateSubscription' => array(
75
+ 'count' => 0,
76
+ ),
77
+ 'cancelSubscription' => array(
78
+ 'count' => 0,
79
+ ),
80
+ 'createPlan' => array(
81
+ 'count' => 0,
82
+ ),
83
+ 'updatePlan' => array(
84
+ 'count' => 0,
85
+ ),
86
+ 'activate' => array(
87
+ 'count' => 0,
88
+ 'amount' => 0,
89
+ ),
90
+ 'deactivate' => array(
91
+ 'count' => 0,
92
+ 'amount' => 0,
93
+ ),
94
+ 'load' => array(
95
+ 'count' => 0,
96
+ 'amount' => 0,
97
+ ),
98
+ 'unload' => array(
99
+ 'count' => 0,
100
+ 'amount' => 0,
101
+ ),
102
+ 'balanceInquiry' => array(
103
+ 'count' => 0,
104
+ 'amount' => 0,
105
+ ),
106
+ 'accountUpdate' => array(
107
+ 'count' => 0,
108
+ ));
109
+
110
+ // if a dir to place the request file is not explicitly provided, grab it from the config file
111
+ if(!$request_dir){
112
+ $conf = Obj2xml::getConfig(array());
113
+ $request_dir = $conf['batch_requests_path'];
114
+ }
115
+
116
+ if(substr($request_dir, -1, 1) != DIRECTORY_SEPARATOR){
117
+ $request_dir = $request_dir . DIRECTORY_SEPARATOR;
118
+ }
119
+
120
+ $ts = str_replace(" ", "", substr(microtime(), 2));
121
+ $filename = $request_dir . "batch_" . $ts . "_txns";
122
+ $batch_filename = $request_dir . "batch_" . $ts;
123
+
124
+ // if either file already exists, let's try again!
125
+ if(file_exists($filename) || file_exists($batch_filename)){
126
+ $this->__construct();
127
+ }
128
+
129
+ // if we were unable to write the file
130
+ if(file_put_contents($filename, "") === FALSE){
131
+ throw new RuntimeException("A batch file could not be written at $filename. Please check your privilege.");
132
+ }
133
+ $this->transaction_file = $filename;
134
+
135
+ // if we were unable to write the file
136
+ if(file_put_contents($batch_filename, "") === FALSE){
137
+ throw new RuntimeException("A batch file could not be written at $batch_filename. Please check your privilege.");
138
+ }
139
+ $this->batch_file = $batch_filename;
140
+
141
+ }
142
+
143
+ /*
144
+ * Extracts the appropriate values from the hash in and passes them along to the addTransaction function
145
+ */
146
+ public function addSale($hash_in){
147
+ $hash_out = Transactions::createSaleHash($hash_in);
148
+
149
+ $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
150
+ $choice2_hash= array($hash_out['fraudCheck'],$hash_out['cardholderAuthentication']);
151
+
152
+ $this->addTransaction($hash_out, $hash_in, 'sale', $choice_hash, $choice2_hash);
153
+ $this->counts_and_amounts['sale']['count'] += 1;
154
+ $this->counts_and_amounts['sale']['amount'] += $hash_out['amount'];
155
+ }
156
+
157
+ public function addAuth($hash_in){
158
+ $hash_out = Transactions::createAuthHash($hash_in);
159
+
160
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'paypal'),XmlFields::returnArrayValue($hash_out,'token'),XmlFields::returnArrayValue($hash_out,'paypage'));
161
+
162
+ $this->addTransaction($hash_out, $hash_in, 'authorization', $choice_hash);
163
+ $this->counts_and_amounts['auth']['count'] += 1;
164
+ $this->counts_and_amounts['auth']['amount'] += $hash_out['amount'];
165
+ }
166
+
167
+ public function addAuthReversal($hash_in){
168
+ $hash_out = Transactions::createAuthReversalHash($hash_in);
169
+
170
+ $this->addTransaction($hash_out,$hash_in,'authReversal');
171
+ $this->counts_and_amounts['authReversal']['count'] += 1;
172
+ $this->counts_and_amounts['authReversal']['amount'] += $hash_out['amount'];
173
+ }
174
+
175
+ public function addCredit($hash_in){
176
+ $hash_out = Transactions::createCreditHash($hash_in);
177
+
178
+ $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
179
+
180
+ $this->addTransaction($hash_out,$hash_in,'credit',$choice_hash);
181
+ $this->counts_and_amounts['credit']['count'] += 1;
182
+ $this->counts_and_amounts['credit']['amount'] += $hash_out['amount'];
183
+ }
184
+
185
+ public function addRegisterToken($hash_in){
186
+ $hash_out = Transactions::createRegisterTokenHash($hash_in);
187
+
188
+ $choice_hash = array($hash_out['accountNumber'],$hash_out['echeckForToken'],$hash_out['paypageRegistrationId']);
189
+
190
+ $this->addTransaction($hash_out,$hash_in,'registerTokenRequest',$choice_hash);
191
+ $this->counts_and_amounts['tokenRegistration']['count'] += 1;
192
+ }
193
+
194
+ public function addForceCapture($hash_in){
195
+ $hash_out = Transactions::createForceCaptureHash($hash_in);
196
+
197
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'paypal'),XmlFields::returnArrayValue($hash_out,'token'),XmlFields::returnArrayValue($hash_out,'paypage'));
198
+
199
+ $this->addTransaction($hash_out,$hash_in,'forceCapture',$choice_hash);
200
+ $this->counts_and_amounts['forceCapture']['count'] += 1;
201
+ $this->counts_and_amounts['forceCapture']['amount'] += $hash_out['amount'];
202
+
203
+ }
204
+
205
+ public function addCapture($hash_in){
206
+ $hash_out = Transactions::createCaptureHash($hash_in);
207
+
208
+ $this->addTransaction($hash_out,$hash_in,'capture');
209
+ $this->counts_and_amounts['capture']['count'] += 1;
210
+ $this->counts_and_amounts['capture']['amount'] += $hash_out['amount'];
211
+
212
+ }
213
+
214
+ public function addCaptureGivenAuth($hash_in){
215
+ $hash_out = Transactions::createCaptureGivenAuthHash($hash_in);
216
+
217
+ $choice_hash = array($hash_out['card'],$hash_out['token'],$hash_out['paypage']);
218
+
219
+ $this->addTransaction($hash_out,$hash_in,'captureGivenAuth',$choice_hash);
220
+ $this->counts_and_amounts['captureGivenAuth']['count'] += 1;
221
+ $this->counts_and_amounts['captureGivenAuth']['amount'] += $hash_out['amount'];
222
+
223
+ }
224
+
225
+ public function addEcheckRedeposit($hash_in){
226
+ $hash_out = Transactions::createEcheckRedepositHash($hash_in);
227
+
228
+ $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
229
+
230
+ $this->addTransaction($hash_out,$hash_in,'echeckRedeposit',$choice_hash);
231
+ $this->counts_and_amounts['echeckRedeposit']['count'] += 1;
232
+ }
233
+
234
+ public function addEcheckSale($hash_in){
235
+ $hash_out = Transactions::createEcheckSaleHash($hash_in);
236
+
237
+ $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
238
+
239
+ $this->addTransaction($hash_out,$hash_in,'echeckSale',$choice_hash);
240
+ $this->counts_and_amounts['echeckSale']['count'] += 1;
241
+ $this->counts_and_amounts['echeckSale']['amount'] += $hash_out['amount'];
242
+
243
+ }
244
+
245
+ public function addEcheckCredit($hash_in){
246
+ $hash_out = Transactions::createEcheckCreditHash($hash_in);
247
+
248
+ $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
249
+
250
+ $this->addTransaction($hash_out,$hash_in,'echeckCredit',$choice_hash);
251
+ $this->counts_and_amounts['echeckCredit']['count'] += 1;
252
+ $this->counts_and_amounts['echeckCredit']['amount'] += $hash_out['amount'];
253
+
254
+ }
255
+
256
+ public function addEcheckVerification($hash_in){
257
+ $hash_out = Transactions::createEcheckVerificationHash($hash_in);
258
+
259
+ $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
260
+
261
+ $this->addTransaction($hash_out,$hash_in,'echeckVerification',$choice_hash);
262
+ $this->counts_and_amounts['echeckVerification']['count'] += 1;
263
+ $this->counts_and_amounts['echeckVerification']['amount'] += $hash_out['amount'];
264
+
265
+ }
266
+
267
+ public function addUpdateCardValidationNumOnToken($hash_in){
268
+ $hash_out = Transactions::createUpdateCardValidationNumOnTokenHash($hash_in);
269
+
270
+ $this->addTransaction($hash_out,$hash_in,"updateCardValidationNumOnToken");
271
+ $this->counts_and_amounts['updateCardValidationNumOnToken']['count'] += 1;
272
+ }
273
+
274
+ public function addUpdateSubscription($hash_in){
275
+ $hash_out = Transactions::createUpdateSubscriptionHash($hash_in);
276
+
277
+ $this->addTransaction($hash_out,$hash_in,"updateSubscription");
278
+ $this->counts_and_amounts['updateSubscription']['count'] += 1;
279
+ }
280
+
281
+ public function addCancelSubscription($hash_in){
282
+ $hash_out = Transactions::createCancelSubscriptionHash($hash_in);
283
+
284
+ $this->addTransaction($hash_out,$hash_in,"cancelSubscription");
285
+ $this->counts_and_amounts['cancelSubscription']['count'] += 1;
286
+ }
287
+
288
+ public function addCreatePlan($hash_in){
289
+ $hash_out = Transactions::createCreatePlanHash($hash_in);
290
+
291
+ $this->addTransaction($hash_out,$hash_in,"createPlan");
292
+ $this->counts_and_amounts['createPlan']['count'] += 1;
293
+ }
294
+
295
+ public function addUpdatePlan($hash_in){
296
+ $hash_out = Transactions::createUpdatePlanHash($hash_in);
297
+
298
+ $this->addTransaction($hash_out,$hash_in,"updatePlan");
299
+ $this->counts_and_amounts['updatePlan']['count'] += 1;
300
+ }
301
+
302
+ public function addActivate($hash_in){
303
+ $hash_out = Transactions::createActivateHash($hash_in);
304
+
305
+ $this->addTransaction($hash_out,$hash_in,"activate");
306
+ $this->counts_and_amounts['activate']['count'] += 1;
307
+ $this->counts_and_amounts['activate']['amount'] += $hash_out['amount'];
308
+ }
309
+ public function addDeactivate($hash_in){
310
+ $hash_out = Transactions::createDeactivateHash($hash_in);
311
+
312
+ $this->addTransaction($hash_out,$hash_in,"deactivate");
313
+ $this->counts_and_amounts['deactivate']['count'] += 1;
314
+ }
315
+ public function addLoad($hash_in){
316
+ $hash_out = Transactions::createLoadHash($hash_in);
317
+
318
+ $this->addTransaction($hash_out,$hash_in,"load");
319
+ $this->counts_and_amounts['load']['count'] += 1;
320
+ $this->counts_and_amounts['load']['amount'] += $hash_out['amount'];
321
+ }
322
+ public function addUnload($hash_in){
323
+ $hash_out = Transactions::createUnloadHash($hash_in);
324
+
325
+ $this->addTransaction($hash_out,$hash_in,"unload");
326
+ $this->counts_and_amounts['unload']['count'] += 1;
327
+ $this->counts_and_amounts['unload']['amount'] += $hash_out['amount'];
328
+ }
329
+ public function addBalanceInquiry($hash_in){
330
+ $hash_out = Transactions::createBalanceInquiryHash($hash_in);
331
+
332
+ $this->addTransaction($hash_out,$hash_in,"balanceInquiry");
333
+ $this->counts_and_amounts['balanceInquiry']['count'] += 1;
334
+ }
335
+
336
+ public function addAccountUpdate($hash_in){
337
+ $hash_out = Transactions::createAccountUpdate($hash_in);
338
+
339
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'token'));
340
+
341
+ $this->addTransaction($hash_out,$hash_in,'accountUpdate',$choice_hash);
342
+ $this->counts_and_amounts['accountUpdate']['count'] += 1;
343
+ }
344
+
345
+ /*
346
+ * Adds the XML for the transaction given the appropriate data to the transactions file
347
+ */
348
+ private function addTransaction($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null){
349
+
350
+ if($this->closed){
351
+ throw new RuntimeException("Could not add the transaction. This batchRequest is closed.");
352
+ }
353
+ if($this->isFull()){
354
+ throw new RuntimeException('The transaction could not be added to the batch. It is full.');
355
+ }
356
+ if($type == 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] != $this->total_txns){
357
+ throw new RuntimeException("The transaction could not be added to the batch. The transaction type $type cannot be mixed with non-Account Updates.");
358
+ }
359
+ else if($type != 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] == $this->total_txns && $this->total_txns > 0){
360
+ throw new RuntimeException("The transaction could not be added to the batch. The transaction type $type cannot be mixed with AccountUpdates.");
361
+ }
362
+
363
+ if(isset($hash_in['reportGroup'])){
364
+ $report_group = $hash_in['reportGroup'];
365
+ }
366
+ else{
367
+ $conf = Obj2xml::getConfig(array());
368
+ $report_group = $conf['reportGroup'];
369
+ }
370
+
371
+
372
+ Checker::choice($choice1);
373
+ Checker::choice($choice2);
374
+
375
+ $request = Obj2xml::transactionToXml($hash_out, $type, $report_group);
376
+
377
+ if(file_put_contents($this->transaction_file, $request, FILE_APPEND) === FALSE){
378
+ throw new RuntimeException("A transaction could not be written to the batch file at $transaction_file. Please check your privilege.");
379
+ }
380
+
381
+ $this->total_txns += 1;
382
+ }
383
+
384
+ /*
385
+ * When no more transactions are to be added, the transactions file can be amended with the XML tags for the counts
386
+ * and amounts of the batch request. Returns the filename of the complete batchrequest file
387
+ */
388
+ public function closeRequest(){
389
+ $handle = @fopen($this->transaction_file,"r");
390
+ if($handle){
391
+ file_put_contents($this->batch_file, Obj2xml::generateBatchHeader($this->counts_and_amounts), FILE_APPEND);
392
+ while(($buffer = fgets($handle, 4096)) !== false){
393
+ file_put_contents($this->batch_file, $buffer, FILE_APPEND);
394
+ }
395
+ if(!feof($handle)){
396
+ throw new RuntimeException("Error when reading transactions file at $this->transaction_file. Please check your privilege.");
397
+ }
398
+ fclose($handle);
399
+ file_put_contents($this->batch_file, "</batchRequest>", FILE_APPEND);
400
+
401
+ unlink($this->transaction_file);
402
+ unset($this->transaction_file);
403
+ $this->closed = true;
404
+ }
405
+ else{
406
+ throw new RuntimeException("Could not open transactions file at $this->transaction_file. Please check your privilege.");
407
+ }
408
+ }
409
+
410
+ public function getCountsAndAmounts(){
411
+ return $this->counts_and_amounts;
412
+ }
413
+ }
app/code/local/Litle/LitleSDK/Checker.php CHANGED
@@ -24,7 +24,7 @@
24
  */
25
  class Checker
26
  {
27
- function requiredField($value)
28
  {
29
  if ($value != null)
30
  {
@@ -36,7 +36,7 @@ class Checker
36
  }
37
  }
38
 
39
- function choice($choiceArray)
40
  {
41
  $i= 0;
42
  for($y=0;$y<count($choiceArray);$y++){
24
  */
25
  class Checker
26
  {
27
+ static function requiredField($value)
28
  {
29
  if ($value != null)
30
  {
36
  }
37
  }
38
 
39
+ static function choice($choiceArray)
40
  {
41
  $i= 0;
42
  for($y=0;$y<count($choiceArray);$y++){
app/code/local/Litle/LitleSDK/Communication.php CHANGED
@@ -23,8 +23,13 @@
23
  * OTHER DEALINGS IN THE SOFTWARE.
24
  */
25
  class Communication{
26
- function httpRequest($req,$hash_config=NULL){
 
27
  $config = Obj2xml::getConfig($hash_config);
 
 
 
 
28
  $ch = curl_init();
29
  curl_setopt($ch, CURLOPT_PROXY, $config['proxy']);
30
  curl_setopt($ch, CURLOPT_POST, true);
@@ -36,6 +41,7 @@ class Communication{
36
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
37
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2);
38
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
39
  if(Mage::getStoreConfig('payment/CreditCard/debug_enable')) {
40
  $xmlToPrint = Communication::cleanseAccountNumber($req);
41
  $xmlToPrint = Communication::cleanseCardValidationNum($xmlToPrint);
@@ -69,5 +75,4 @@ class Communication{
69
  static public function cleansePassword($xml) {
70
  return preg_replace("|<password>.*?</password>|", "<password>NEUTERED</password>",$xml);
71
  }
72
-
73
  }
23
  * OTHER DEALINGS IN THE SOFTWARE.
24
  */
25
  class Communication{
26
+ static function httpRequest($req,$hash_config=NULL){
27
+
28
  $config = Obj2xml::getConfig($hash_config);
29
+
30
+ if((int)$config['print_xml']){
31
+ echo $req;
32
+ }
33
  $ch = curl_init();
34
  curl_setopt($ch, CURLOPT_PROXY, $config['proxy']);
35
  curl_setopt($ch, CURLOPT_POST, true);
41
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
42
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2);
43
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
44
+ curl_setopt($ch, CURLOPT_SSLVERSION, 3);
45
  if(Mage::getStoreConfig('payment/CreditCard/debug_enable')) {
46
  $xmlToPrint = Communication::cleanseAccountNumber($req);
47
  $xmlToPrint = Communication::cleanseCardValidationNum($xmlToPrint);
75
  static public function cleansePassword($xml) {
76
  return preg_replace("|<password>.*?</password>|", "<password>NEUTERED</password>",$xml);
77
  }
 
78
  }
app/code/local/Litle/LitleSDK/LitleOnline.php CHANGED
@@ -23,9 +23,10 @@
23
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
  * OTHER DEALINGS IN THE SOFTWARE.
25
  */
26
- define('CURRENT_XML_VERSION', '8.13');
27
- error_reporting(E_ALL ^ E_NOTICE);
28
- //ini_set('display_errors', '1');
 
29
  require_once realpath(dirname(__FILE__)) . '/LitleXmlMapper.php';
30
  require_once realpath(dirname(__FILE__)) . '/XmlFields.php';
31
  require_once realpath(dirname(__FILE__)) . '/Communication.php';
@@ -34,3 +35,7 @@ require_once realpath(dirname(__FILE__)) . '/Obj2xml.php';
34
  require_once realpath(dirname(__FILE__)) . '/Checker.php';
35
  require_once realpath(dirname(__FILE__)) . '/LitleOnlineRequest.php';
36
  require_once realpath(dirname(__FILE__)) . '/UrlMapper.php';
 
 
 
 
23
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
  * OTHER DEALINGS IN THE SOFTWARE.
25
  */
26
+ define('CURRENT_XML_VERSION', '8.23');
27
+ define('CURRENT_SDK_VERSION', 'PHP;8.23.0');
28
+ define('MAX_TXNS_PER_BATCH', 100000);
29
+ define('MAX_TXNS_PER_REQUEST', 500000);
30
  require_once realpath(dirname(__FILE__)) . '/LitleXmlMapper.php';
31
  require_once realpath(dirname(__FILE__)) . '/XmlFields.php';
32
  require_once realpath(dirname(__FILE__)) . '/Communication.php';
35
  require_once realpath(dirname(__FILE__)) . '/Checker.php';
36
  require_once realpath(dirname(__FILE__)) . '/LitleOnlineRequest.php';
37
  require_once realpath(dirname(__FILE__)) . '/UrlMapper.php';
38
+ require_once realpath(dirname(__FILE__)) . '/BatchRequest.php';
39
+ require_once realpath(dirname(__FILE__)) . '/LitleRequest.php';
40
+ require_once realpath(dirname(__FILE__)) . '/Transactions.php';
41
+ require_once realpath(dirname(__FILE__)) . '/LitleResponseProcessor.php';
app/code/local/Litle/LitleSDK/LitleOnlineRequest.php CHANGED
@@ -25,45 +25,53 @@
25
 
26
  class LitleOnlineRequest
27
  {
28
- public function __construct()
 
 
29
  {
 
30
  $this->newXML = new LitleXmlMapper();
31
  }
32
 
33
  public function authorizationRequest($hash_in)
34
  {
35
  if (isset($hash_in['litleTxnId'])){
36
- $hash_out = array('litleTxnId'=> ($hash_in['litleTxnId']));
37
  }
38
  else {
39
  $hash_out = array(
40
- 'orderId'=> Checker::requiredField($hash_in['orderId']),
41
- 'amount'=>Checker::requiredField($hash_in['amount']),
42
- 'orderSource'=>Checker::requiredField($hash_in['orderSource']),
43
- 'customerInfo'=>(XmlFields::customerInfo($hash_in['customerInfo'])),
44
- 'billToAddress'=>(XmlFields::contact($hash_in['billToAddress'])),
45
- 'shipToAddress'=>(XmlFields::contact($hash_in['shipToAddress'])),
46
- 'card'=> (XmlFields::cardType($hash_in['card'])),
47
- 'paypal'=>(XmlFields::payPal($hash_in['paypal'])),
48
- 'token'=>(XmlFields::cardTokenType($hash_in['token'])),
49
- 'paypage'=>(XmlFields::cardPaypageType($hash_in['paypage'])),
50
- 'billMeLaterRequest'=>(XmlFields::billMeLaterRequest($hash_in['billMeLaterRequest'])),
51
- 'cardholderAuthentication'=>(XmlFields::fraudCheckType($hash_in['cardholderAuthentication'])),
52
- 'processingInstructions'=>(XmlFields::processingInstructions($hash_in['processingInstructions'])),
53
- 'pos'=>(XmlFields::pos($hash_in['pos'])),
54
- 'customBilling'=>(XmlFields::customBilling($hash_in['customBilling'])),
55
- 'taxBilling'=>(XmlFields::taxBilling($hash_in['taxBilling'])),
56
- 'enhancedData'=>(XmlFields::enhancedData($hash_in['enhancedData'])),
57
- 'amexAggregatorData'=>(XmlFields::amexAggregatorData($hash_in['amexAggregatorData'])),
58
- 'allowPartialAuth'=>$hash_in['allowPartialAuth'],
59
- 'healthcareIIAS'=>(XmlFields::healthcareIIAS($hash_in['healthcareIIAS'])),
60
- 'filtering'=>(XmlFields::filteringType($hash_in['filtering'])),
61
- 'merchantData'=>(XmlFields::merchantData($hash_in['merchantData'])),
62
- 'recyclingRequest'=>(XmlFields::recyclingRequestType($hash_in['recyclingRequest'])),
63
- 'fraudFilterOverride'=> $hash_in['fraudFilterOverride']);
 
 
 
 
 
64
  }
65
 
66
- $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
67
  $authorizationResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'authorization',$choice_hash);
68
  return $authorizationResponse;
69
  }
@@ -71,48 +79,55 @@ class LitleOnlineRequest
71
  public function saleRequest($hash_in)
72
  {
73
  $hash_out = array(
74
- 'litleTxnId' => $hash_in['litleTxnId'],
75
- 'orderId' =>Checker::requiredField($hash_in['orderId']),
76
- 'amount' =>Checker::requiredField($hash_in['amount']),
77
- 'orderSource'=>Checker::requiredField($hash_in['orderSource']),
78
- 'customerInfo'=>XmlFields::customerInfo($hash_in['customerInfo']),
79
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
80
- 'shipToAddress'=>XmlFields::contact($hash_in['shipToAddress']),
81
- 'card'=> XmlFields::cardType($hash_in['card']),
82
- 'paypal'=>XmlFields::payPal($hash_in['paypal']),
83
- 'token'=>XmlFields::cardTokenType($hash_in['token']),
84
- 'paypage'=>XmlFields::cardPaypageType($hash_in['paypage']),
85
- 'billMeLaterRequest'=>XmlFields::billMeLaterRequest($hash_in['billMeLaterRequest']),
86
- 'fraudCheck'=>XmlFields::fraudCheckType($hash_in['fraudCheck']),
87
- 'cardholderAuthentication'=>XmlFields::fraudCheckType($hash_in['cardholderAuthentication']),
88
- 'customBilling'=>XmlFields::customBilling($hash_in['customBilling']),
89
- 'taxBilling'=>XmlFields::taxBilling($hash_in['taxBilling']),
90
- 'enhancedData'=>XmlFields::enhancedData($hash_in['enhancedData']),
91
- 'processingInstructions'=>XmlFields::processingInstructions($hash_in['processingInstructions']),
92
- 'pos'=>XmlFields::pos($hash_in['pos']),
93
- 'payPalOrderComplete'=> $hash_in['paypalOrderComplete'],
94
- 'payPalNotes'=> $hash_in['paypalNotesType'],
95
- 'amexAggregatorData'=>XmlFields::amexAggregatorData($hash_in['amexAggregatorData']),
96
- 'allowPartialAuth'=>$hash_in['allowPartialAuth'],
97
- 'healthcareIIAS'=>XmlFields::healthcareIIAS($hash_in['healthcareIIAS']),
98
- 'filtering'=>XmlFields::filteringType($hash_in['filtering']),
99
- 'merchantData'=>XmlFields::merchantData($hash_in['merchantData']),
100
- 'recyclingRequest'=>XmlFields::recyclingRequestType($hash_in['recyclingRequest']),
101
- 'fraudFilterOverride'=> $hash_in['fraudFilterOverride']);
 
 
 
 
 
 
102
 
103
  $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
104
  $choice2_hash= array($hash_out['fraudCheck'],$hash_out['cardholderAuthentication']);
105
- $saleResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'sale',$choice_hash,$choice_hash2);
106
  return $saleResponse;
107
  }
108
 
109
  public function authReversalRequest($hash_in)
110
  {
111
  $hash_out = array(
112
- 'litleTxnId' => Checker::requiredField($hash_in['litleTxnId']),
113
- 'amount' =>$hash_in['amount'],
114
- 'payPalNotes'=>$hash_in['payPalNotes'],
115
- 'actionReason'=>$hash_in['actionReason']);
 
116
  $authReversalResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'authReversal');
117
  return $authReversalResponse;
118
  }
@@ -123,6 +138,7 @@ class LitleOnlineRequest
123
  'litleTxnId' => XmlFields::returnArrayValue($hash_in, 'litleTxnId'),
124
  'orderId' =>XmlFields::returnArrayValue($hash_in, 'orderId'),
125
  'amount' =>XmlFields::returnArrayValue($hash_in, 'amount'),
 
126
  'orderSource'=>XmlFields::returnArrayValue($hash_in, 'orderSource'),
127
  'billToAddress'=>XmlFields::contact(XMLFields::returnArrayValue($hash_in, 'billToAddress')),
128
  'card'=>XmlFields::cardType(XMLFields::returnArrayValue($hash_in, 'card')),
@@ -148,10 +164,12 @@ class LitleOnlineRequest
148
  public function registerTokenRequest($hash_in)
149
  {
150
  $hash_out = array(
151
- 'orderId'=>$hash_in['orderId'],
152
- 'accountNumber'=>$hash_in['accountNumber'],
153
- 'echeckForToken'=>XmlFields::echeckForTokenType($hash_in['echeckForToken']),
154
- 'paypageRegistrationId'=>$hash_in['paypageRegistrationId']);
 
 
155
 
156
  $choice_hash = array($hash_out['accountNumber'],$hash_out['echeckForToken'],$hash_out['paypageRegistrationId']);
157
  $registerTokenResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'registerTokenRequest',$choice_hash);
@@ -161,21 +179,25 @@ class LitleOnlineRequest
161
  public function forceCaptureRequest($hash_in)
162
  {
163
  $hash_out = array(
164
- 'orderId' =>Checker::requiredField($hash_in['orderId']),
165
- 'amount' =>$hash_in['amount'],
166
- 'orderSource'=>Checker::requiredField($hash_in['orderSource']),
167
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
168
- 'card'=> XmlFields::cardType($hash_in['card']),
169
- 'token'=>XmlFields::cardTokenType($hash_in['token']),
170
- 'paypage'=>XmlFields::cardPaypageType($hash_in['paypage']),
171
- 'customBilling'=>XmlFields::customBilling($hash_in['customBilling']),
172
- 'taxBilling'=>XmlFields::taxBilling($hash_in['taxBilling']),
173
- 'enhancedData'=>XmlFields::enhancedData($hash_in['enhancedData']),
174
- 'processingInstructions'=>XmlFields::processingInstructions($hash_in['processingInstructions']),
175
- 'pos'=>XmlFields::pos($hash_in['pos']),
176
- 'amexAggregatorData'=>XmlFields::amexAggregatorData($hash_in['amexAggregatorData']));
 
 
 
 
177
 
178
- $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
179
  $forceCaptureResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'forceCapture',$choice_hash);
180
  return $forceCaptureResponse;
181
  }
@@ -183,13 +205,14 @@ class LitleOnlineRequest
183
  public function captureRequest($hash_in)
184
  {
185
  $hash_out = array(
186
- 'partial'=>$hash_in['partial'],
187
- 'litleTxnId' => Checker::requiredField($hash_in['litleTxnId']),
188
- 'amount' =>($hash_in['amount']),
189
- 'enhancedData'=>XmlFields::enhancedData($hash_in['enhancedData']),
190
- 'processingInstructions'=>XmlFields::processingInstructions($hash_in['processingInstructions']),
191
- 'payPalOrderComplete'=>$hash_in['payPalOrderComplete'],
192
- 'payPalNotes' =>$hash_in['payPalNotes']);
 
193
  $captureResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'capture');
194
  return $captureResponse;
195
  }
@@ -197,22 +220,26 @@ class LitleOnlineRequest
197
  public function captureGivenAuthRequest($hash_in)
198
  {
199
  $hash_out = array(
200
- 'orderId'=>Checker::requiredField($hash_in['orderId']),
201
- 'authInformation'=>XmlFields::authInformation($hash_in['authInformation']),
202
- 'amount' =>Checker::requiredField($hash_in['amount']),
203
- 'orderSource'=>Checker::requiredField($hash_in['orderSource']),
204
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
205
- 'shipToAddress'=>XmlFields::contact($hash_in['shipToAddress']),
206
- 'card'=> XmlFields::cardType($hash_in['card']),
207
- 'token'=>XmlFields::cardTokenType($hash_in['token']),
208
- 'paypage'=>XmlFields::cardPaypageType($hash_in['paypage']),
209
- 'customBilling'=>XmlFields::customBilling($hash_in['customBilling']),
210
- 'taxBilling'=>XmlFields::taxBilling($hash_in['taxBilling']),
211
- 'billMeLaterRequest'=>XmlFields::billMeLaterRequest($hash_in['billMeLaterRequest']),
212
- 'enhancedData'=>XmlFields::enhancedData($hash_in['enhancedData']),
213
- 'processingInstructions'=>XmlFields::processingInstructions($hash_in['processingInstructions']),
214
- 'pos'=>XmlFields::pos($hash_in['pos']),
215
- 'amexAggregatorData'=>XmlFields::amexAggregatorData($hash_in['amexAggregatorData']));
 
 
 
 
216
 
217
  $choice_hash = array($hash_out['card'],$hash_out['token'],$hash_out['paypage']);
218
  $captureGivenAuthResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'captureGivenAuth',$choice_hash);
@@ -222,9 +249,11 @@ class LitleOnlineRequest
222
  public function echeckRedepositRequest($hash_in)
223
  {
224
  $hash_out = array(
225
- 'litleTxnId' => Checker::requiredField($hash_in['litleTxnId']),
226
- 'echeck'=>XmlFields::echeckType($hash_in['echeck']),
227
- 'echeckToken'=>XmlFields::echeckTokenType($hash_in['echeckToken']));
 
 
228
 
229
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
230
  $echeckRedepositResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckRedeposit',$choice_hash);
@@ -234,34 +263,38 @@ class LitleOnlineRequest
234
  public function echeckSaleRequest($hash_in)
235
  {
236
  $hash_out = array(
237
- 'litleTxnId'=>$hash_in['litleTxnId'],
238
- 'orderId'=>$hash_in['orderId'],
239
- 'verify'=>$hash_in['verify'],
240
- 'amount'=>$hash_in['amount'],
241
- 'orderSource'=>$hash_in['orderSource'],
242
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
243
- 'shipToAddress'=>XmlFields::contact($hash_in['shipToAddress']),
244
- 'echeck'=>XmlFields::echeckType($hash_in['echeck']),
245
- 'echeckToken'=>XmlFields::echeckTokenType($hash_in['echeckToken']),
246
- 'customBilling'=>XmlFields::customBilling($hash_in['customBilling']));
247
 
248
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
249
 
250
  $echeckSaleResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckSale',$choice_hash);
251
  return $echeckSaleResponse;
252
  }
 
 
 
 
253
 
254
  public function echeckCreditRequest($hash_in)
255
  {
256
  $hash_out = array(
257
- 'litleTxnId'=>$hash_in['litleTxnId'],
258
- 'orderId'=>$hash_in['orderId'],
259
- 'amount'=>$hash_in['amount'],
260
- 'orderSource'=>$hash_in['orderSource'],
261
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
262
- 'echeck'=>XmlFields::echeckType($hash_in['echeck']),
263
- 'echeckToken'=>XmlFields::echeckTokenType($hash_in['echeckToken']),
264
- 'customBilling'=>XmlFields::customBilling($hash_in['customBilling']));
265
 
266
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
267
  $echeckCreditResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckCredit',$choice_hash);
@@ -272,13 +305,15 @@ class LitleOnlineRequest
272
  {
273
 
274
  $hash_out = array(
275
- 'litleTxnId'=>$hash_in['litleTxnId'],
276
- 'orderId'=>Checker::requiredField($hash_in['orderId']),
277
- 'amount'=>Checker::requiredField($hash_in['amount']),
278
- 'orderSource'=>Checker::requiredField($hash_in['orderSource']),
279
- 'billToAddress'=>XmlFields::contact($hash_in['billToAddress']),
280
- 'echeck'=>XmlFields::echeckType($hash_in['echeck']),
281
- 'echeckToken'=>XmlFields::echeckTokenType($hash_in['echeckToken']));
 
 
282
 
283
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
284
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
@@ -289,8 +324,8 @@ class LitleOnlineRequest
289
  public function voidRequest($hash_in)
290
  {
291
  $hash_out = array(
292
- 'litleTxnId' => Checker::requiredField($hash_in['litleTxnId']),
293
- 'processingInstructions'=>XmlFields::processingInstructions($hash_in['processingInstructions']));
294
 
295
  $voidResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'void');
296
  return $voidResponse;
@@ -299,39 +334,171 @@ class LitleOnlineRequest
299
  public function echeckVoidRequest($hash_in)
300
  {
301
  $hash_out = array(
302
- 'litleTxnId' => Checker::requiredField($hash_in['litleTxnId']),
303
  );
304
  $echeckVoidResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"echeckVoid");
305
  return $echeckVoidResponse;
306
  }
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  private function overideConfig($hash_in)
309
  {
310
  $hash_out = array(
311
- 'user'=>$hash_in['user'],
312
- 'password'=>$hash_in['password'],
313
- 'merchantId'=>$hash_in['merchantId'],
314
- 'reportGroup'=>$hash_in['reportGroup'],
315
- 'version'=>$hash_in['version'],
316
- 'url'=>$hash_in['url'],
317
- 'timeout'=>$hash_in['timeout'],
318
- 'proxy'=>$hash_in['proxy']);
 
 
 
 
 
 
 
 
 
319
  return $hash_out;
320
  }
321
 
322
  private function getOptionalAttributes($hash_in,$hash_out)
323
  {
324
  if(isset($hash_in['merchantSdk'])) {
325
- $hash_out['merchantSdk'] = $hash_in['merchantSdk'];
326
  }
327
  else {
328
- $hash_out['merchantSdk'] = 'PHP;8.14.0';
329
  }
330
  if(isset($hash_in['id'])) {
331
- $hash_out['id'] = $hash_in['id'];
332
  }
333
  if(isset($hash_in['customerId'])) {
334
- $hash_out['customerId'] = $hash_in['customerId'];
 
 
 
335
  }
336
  return $hash_out;
337
  }
@@ -340,13 +507,13 @@ class LitleOnlineRequest
340
  {
341
 
342
  $hash_config = LitleOnlineRequest::overideconfig($hash_in);
 
343
 
344
  $hash = LitleOnlineRequest::getOptionalAttributes($hash_in,$hash_out);
345
  Checker::choice($choice1);
346
  Checker::choice($choice2);
347
  $request = Obj2xml::toXml($hash,$hash_config, $type);
348
-
349
- $litleOnlineResponse = $this->newXML->request($request,$hash_config);
350
  return $litleOnlineResponse;
351
  }
352
 
25
 
26
  class LitleOnlineRequest
27
  {
28
+ private $useSimpleXml = false;
29
+
30
+ public function __construct($treeResponse=false)
31
  {
32
+ $this->useSimpleXml = $treeResponse;
33
  $this->newXML = new LitleXmlMapper();
34
  }
35
 
36
  public function authorizationRequest($hash_in)
37
  {
38
  if (isset($hash_in['litleTxnId'])){
39
+ $hash_out = array('litleTxnId'=> (XmlFields::returnArrayValue($hash_in,'litleTxnId')));
40
  }
41
  else {
42
  $hash_out = array(
43
+ 'orderId'=> Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderId')),
44
+ 'amount'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'amount')),
45
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
46
+ 'orderSource'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderSource')),
47
+ 'customerInfo'=>(XmlFields::customerInfo(XmlFields::returnArrayValue($hash_in,'customerInfo'))),
48
+ 'billToAddress'=>(XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress'))),
49
+ 'shipToAddress'=>(XmlFields::contact(XmlFields::returnArrayValue($hash_in,'shipToAddress'))),
50
+ 'card'=> (XmlFields::cardType(XmlFields::returnArrayValue($hash_in,'card'))),
51
+ 'paypal'=>(XmlFields::payPal(XmlFields::returnArrayValue($hash_in,'paypal'))),
52
+ 'token'=>(XmlFields::cardTokenType(XmlFields::returnArrayValue($hash_in,'token'))),
53
+ 'paypage'=>(XmlFields::cardPaypageType(XmlFields::returnArrayValue($hash_in,'paypage'))),
54
+ 'billMeLaterRequest'=>(XmlFields::billMeLaterRequest(XmlFields::returnArrayValue($hash_in,'billMeLaterRequest'))),
55
+ 'cardholderAuthentication'=>(XmlFields::fraudCheckType(XmlFields::returnArrayValue($hash_in,'cardholderAuthentication'))),
56
+ 'processingInstructions'=>(XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions'))),
57
+ 'pos'=>(XmlFields::pos(XmlFields::returnArrayValue($hash_in,'pos'))),
58
+ 'customBilling'=>(XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling'))),
59
+ 'taxBilling'=>(XmlFields::taxBilling(XmlFields::returnArrayValue($hash_in,'taxBilling'))),
60
+ 'enhancedData'=>(XmlFields::enhancedData(XmlFields::returnArrayValue($hash_in,'enhancedData'))),
61
+ 'amexAggregatorData'=>(XmlFields::amexAggregatorData(XmlFields::returnArrayValue($hash_in,'amexAggregatorData'))),
62
+ 'allowPartialAuth'=>XmlFields::returnArrayValue($hash_in,'allowPartialAuth'),
63
+ 'healthcareIIAS'=>(XmlFields::healthcareIIAS(XmlFields::returnArrayValue($hash_in,'healthcareIIAS'))),
64
+ 'filtering'=>(XmlFields::filteringType(XmlFields::returnArrayValue($hash_in,'filtering'))),
65
+ 'merchantData'=>(XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData'))),
66
+ 'recyclingRequest'=>(XmlFields::recyclingRequestType(XmlFields::returnArrayValue($hash_in,'recyclingRequest'))),
67
+ 'fraudFilterOverride'=> XmlFields::returnArrayValue($hash_in,'fraudFilterOverride'),
68
+ 'recurringRequest'=>XmlFields::recurringRequestType(XmlFields::returnArrayValue($hash_in,'recurringRequest')),
69
+ 'debtRepayment'=>XmlFields::returnArrayValue($hash_in,'debtRepayment'),
70
+ 'advancedFraudChecks'=>XmlFields::advancedFraudChecksType(XmlFields::returnArrayValue($hash_in,'advancedFraudChecks')),
71
+ );
72
  }
73
 
74
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'paypal'),XmlFields::returnArrayValue($hash_out,'token'),XmlFields::returnArrayValue($hash_out,'paypage'));
75
  $authorizationResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'authorization',$choice_hash);
76
  return $authorizationResponse;
77
  }
79
  public function saleRequest($hash_in)
80
  {
81
  $hash_out = array(
82
+ 'litleTxnId' => XmlFields::returnArrayValue($hash_in,'litleTxnId'),
83
+ 'orderId' =>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderId')),
84
+ 'amount' =>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'amount')),
85
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
86
+ 'orderSource'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderSource')),
87
+ 'customerInfo'=>XmlFields::customerInfo(XmlFields::returnArrayValue($hash_in,'customerInfo')),
88
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
89
+ 'shipToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'shipToAddress')),
90
+ 'card'=> XmlFields::cardType(XmlFields::returnArrayValue($hash_in,'card')),
91
+ 'paypal'=>XmlFields::payPal(XmlFields::returnArrayValue($hash_in,'paypal')),
92
+ 'token'=>XmlFields::cardTokenType(XmlFields::returnArrayValue($hash_in,'token')),
93
+ 'paypage'=>XmlFields::cardPaypageType(XmlFields::returnArrayValue($hash_in,'paypage')),
94
+ 'billMeLaterRequest'=>XmlFields::billMeLaterRequest(XmlFields::returnArrayValue($hash_in,'billMeLaterRequest')),
95
+ 'fraudCheck'=>XmlFields::fraudCheckType(XmlFields::returnArrayValue($hash_in,'fraudCheck')),
96
+ 'cardholderAuthentication'=>XmlFields::fraudCheckType(XmlFields::returnArrayValue($hash_in,'cardholderAuthentication')),
97
+ 'customBilling'=>XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling')),
98
+ 'taxBilling'=>XmlFields::taxBilling(XmlFields::returnArrayValue($hash_in,'taxBilling')),
99
+ 'enhancedData'=>XmlFields::enhancedData(XmlFields::returnArrayValue($hash_in,'enhancedData')),
100
+ 'processingInstructions'=>XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions')),
101
+ 'pos'=>XmlFields::pos(XmlFields::returnArrayValue($hash_in,'pos')),
102
+ 'payPalOrderComplete'=> XmlFields::returnArrayValue($hash_in,'paypalOrderComplete'),
103
+ 'payPalNotes'=> XmlFields::returnArrayValue($hash_in,'paypalNotesType'),
104
+ 'amexAggregatorData'=>XmlFields::amexAggregatorData(XmlFields::returnArrayValue($hash_in,'amexAggregatorData')),
105
+ 'allowPartialAuth'=>XmlFields::returnArrayValue($hash_in,'allowPartialAuth'),
106
+ 'healthcareIIAS'=>XmlFields::healthcareIIAS(XmlFields::returnArrayValue($hash_in,'healthcareIIAS')),
107
+ 'filtering'=>XmlFields::filteringType(XmlFields::returnArrayValue($hash_in,'filtering')),
108
+ 'merchantData'=>XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData')),
109
+ 'recyclingRequest'=>XmlFields::recyclingRequestType(XmlFields::returnArrayValue($hash_in,'recyclingRequest')),
110
+ 'fraudFilterOverride'=> XmlFields::returnArrayValue($hash_in,'fraudFilterOverride'),
111
+ 'recurringRequest'=>XmlFields::recurringRequestType(XmlFields::returnArrayValue($hash_in,'recurringRequest')),
112
+ 'litleInternalRecurringRequest'=>XmlFields::litleInternalRecurringRequestType(XmlFields::returnArrayValue($hash_in,'litleInternalRecurringRequest')),
113
+ 'debtRepayment'=>XmlFields::returnArrayValue($hash_in,'debtRepayment'),
114
+ 'advancedFraudChecks'=>XmlFields::advancedFraudChecksType(XmlFields::returnArrayValue($hash_in,'advancedFraudChecks')),
115
+ );
116
 
117
  $choice_hash = array($hash_out['card'],$hash_out['paypal'],$hash_out['token'],$hash_out['paypage']);
118
  $choice2_hash= array($hash_out['fraudCheck'],$hash_out['cardholderAuthentication']);
119
+ $saleResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'sale',$choice_hash,$choice2_hash);
120
  return $saleResponse;
121
  }
122
 
123
  public function authReversalRequest($hash_in)
124
  {
125
  $hash_out = array(
126
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
127
+ 'amount' =>XmlFields::returnArrayValue($hash_in,'amount'),
128
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
129
+ 'payPalNotes'=>XmlFields::returnArrayValue($hash_in,'payPalNotes'),
130
+ 'actionReason'=>XmlFields::returnArrayValue($hash_in,'actionReason'));
131
  $authReversalResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'authReversal');
132
  return $authReversalResponse;
133
  }
138
  'litleTxnId' => XmlFields::returnArrayValue($hash_in, 'litleTxnId'),
139
  'orderId' =>XmlFields::returnArrayValue($hash_in, 'orderId'),
140
  'amount' =>XmlFields::returnArrayValue($hash_in, 'amount'),
141
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
142
  'orderSource'=>XmlFields::returnArrayValue($hash_in, 'orderSource'),
143
  'billToAddress'=>XmlFields::contact(XMLFields::returnArrayValue($hash_in, 'billToAddress')),
144
  'card'=>XmlFields::cardType(XMLFields::returnArrayValue($hash_in, 'card')),
164
  public function registerTokenRequest($hash_in)
165
  {
166
  $hash_out = array(
167
+ 'orderId'=>XmlFields::returnArrayValue($hash_in,'orderId'),
168
+ 'accountNumber'=>XmlFields::returnArrayValue($hash_in,'accountNumber'),
169
+ 'echeckForToken'=>XmlFields::echeckForTokenType(XmlFields::returnArrayValue($hash_in,'echeckForToken')),
170
+ 'paypageRegistrationId'=>XmlFields::returnArrayValue($hash_in,'paypageRegistrationId'),
171
+ 'cardValidationNum'=>XmlFields::returnArrayValue($hash_in,'cardValidationNum'),
172
+ );
173
 
174
  $choice_hash = array($hash_out['accountNumber'],$hash_out['echeckForToken'],$hash_out['paypageRegistrationId']);
175
  $registerTokenResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'registerTokenRequest',$choice_hash);
179
  public function forceCaptureRequest($hash_in)
180
  {
181
  $hash_out = array(
182
+ 'orderId' =>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderId')),
183
+ 'amount' =>XmlFields::returnArrayValue($hash_in,'amount'),
184
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
185
+ 'orderSource'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderSource')),
186
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
187
+ 'card'=> XmlFields::cardType(XmlFields::returnArrayValue($hash_in,'card')),
188
+ 'token'=>XmlFields::cardTokenType(XmlFields::returnArrayValue($hash_in,'token')),
189
+ 'paypage'=>XmlFields::cardPaypageType(XmlFields::returnArrayValue($hash_in,'paypage')),
190
+ 'customBilling'=>XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling')),
191
+ 'taxBilling'=>XmlFields::taxBilling(XmlFields::returnArrayValue($hash_in,'taxBilling')),
192
+ 'enhancedData'=>XmlFields::enhancedData(XmlFields::returnArrayValue($hash_in,'enhancedData')),
193
+ 'processingInstructions'=>XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions')),
194
+ 'pos'=>XmlFields::pos(XmlFields::returnArrayValue($hash_in,'pos')),
195
+ 'amexAggregatorData'=>XmlFields::amexAggregatorData(XmlFields::returnArrayValue($hash_in,'amexAggregatorData')),
196
+ 'merchantData'=>(XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData'))),
197
+ 'debtRepayment'=>XmlFields::returnArrayValue($hash_in,'debtRepayment'),
198
+ );
199
 
200
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'paypal'),XmlFields::returnArrayValue($hash_out,'token'),XmlFields::returnArrayValue($hash_out,'paypage'));
201
  $forceCaptureResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'forceCapture',$choice_hash);
202
  return $forceCaptureResponse;
203
  }
205
  public function captureRequest($hash_in)
206
  {
207
  $hash_out = array(
208
+ 'partial'=>XmlFields::returnArrayValue($hash_in,'partial'),
209
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
210
+ 'amount' =>(XmlFields::returnArrayValue($hash_in,'amount')),
211
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
212
+ 'enhancedData'=>XmlFields::enhancedData(XmlFields::returnArrayValue($hash_in,'enhancedData')),
213
+ 'processingInstructions'=>XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions')),
214
+ 'payPalOrderComplete'=>XmlFields::returnArrayValue($hash_in,'payPalOrderComplete'),
215
+ 'payPalNotes' =>XmlFields::returnArrayValue($hash_in,'payPalNotes'));
216
  $captureResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'capture');
217
  return $captureResponse;
218
  }
220
  public function captureGivenAuthRequest($hash_in)
221
  {
222
  $hash_out = array(
223
+ 'orderId'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderId')),
224
+ 'authInformation'=>XmlFields::authInformation(XmlFields::returnArrayValue($hash_in,'authInformation')),
225
+ 'amount' =>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'amount')),
226
+ 'surchargeAmount' =>XmlFields::returnArrayValue($hash_in,'surchargeAmount'),
227
+ 'orderSource'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderSource')),
228
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
229
+ 'shipToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'shipToAddress')),
230
+ 'card'=> XmlFields::cardType(XmlFields::returnArrayValue($hash_in,'card')),
231
+ 'token'=>XmlFields::cardTokenType(XmlFields::returnArrayValue($hash_in,'token')),
232
+ 'paypage'=>XmlFields::cardPaypageType(XmlFields::returnArrayValue($hash_in,'paypage')),
233
+ 'customBilling'=>XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling')),
234
+ 'taxBilling'=>XmlFields::taxBilling(XmlFields::returnArrayValue($hash_in,'taxBilling')),
235
+ 'billMeLaterRequest'=>XmlFields::billMeLaterRequest(XmlFields::returnArrayValue($hash_in,'billMeLaterRequest')),
236
+ 'enhancedData'=>XmlFields::enhancedData(XmlFields::returnArrayValue($hash_in,'enhancedData')),
237
+ 'processingInstructions'=>XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions')),
238
+ 'pos'=>XmlFields::pos(XmlFields::returnArrayValue($hash_in,'pos')),
239
+ 'amexAggregatorData'=>XmlFields::amexAggregatorData(XmlFields::returnArrayValue($hash_in,'amexAggregatorData')),
240
+ 'merchantData'=>(XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData'))),
241
+ 'debtRepayment'=>XmlFields::returnArrayValue($hash_in,'debtRepayment')
242
+ );
243
 
244
  $choice_hash = array($hash_out['card'],$hash_out['token'],$hash_out['paypage']);
245
  $captureGivenAuthResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'captureGivenAuth',$choice_hash);
249
  public function echeckRedepositRequest($hash_in)
250
  {
251
  $hash_out = array(
252
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
253
+ 'echeck'=>XmlFields::echeckType(XmlFields::returnArrayValue($hash_in,'echeck')),
254
+ 'echeckToken'=>XmlFields::echeckTokenType(XmlFields::returnArrayValue($hash_in,'echeckToken')),
255
+ 'merchantData'=>(XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData')))
256
+ );
257
 
258
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
259
  $echeckRedepositResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckRedeposit',$choice_hash);
263
  public function echeckSaleRequest($hash_in)
264
  {
265
  $hash_out = array(
266
+ 'litleTxnId'=>XmlFields::returnArrayValue($hash_in,'litleTxnId'),
267
+ 'orderId'=>XmlFields::returnArrayValue($hash_in,'orderId'),
268
+ 'verify'=>XmlFields::returnArrayValue($hash_in,'verify'),
269
+ 'amount'=>XmlFields::returnArrayValue($hash_in,'amount'),
270
+ 'orderSource'=>XmlFields::returnArrayValue($hash_in,'orderSource'),
271
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
272
+ 'shipToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'shipToAddress')),
273
+ 'echeck'=>XmlFields::echeckType(XmlFields::returnArrayValue($hash_in,'echeck')),
274
+ 'echeckToken'=>XmlFields::echeckTokenType(XmlFields::returnArrayValue($hash_in,'echeckToken')),
275
+ 'customBilling'=>XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling')));
276
 
277
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
278
 
279
  $echeckSaleResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckSale',$choice_hash);
280
  return $echeckSaleResponse;
281
  }
282
+
283
+ //public function echeckSaleRequestObject(EcheckSale $echeckSale) {
284
+ //TODO Can I overload? What are php's rules?
285
+ //}
286
 
287
  public function echeckCreditRequest($hash_in)
288
  {
289
  $hash_out = array(
290
+ 'litleTxnId'=>XmlFields::returnArrayValue($hash_in,'litleTxnId'),
291
+ 'orderId'=>XmlFields::returnArrayValue($hash_in,'orderId'),
292
+ 'amount'=>XmlFields::returnArrayValue($hash_in,'amount'),
293
+ 'orderSource'=>XmlFields::returnArrayValue($hash_in,'orderSource'),
294
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
295
+ 'echeck'=>XmlFields::echeckType(XmlFields::returnArrayValue($hash_in,'echeck')),
296
+ 'echeckToken'=>XmlFields::echeckTokenType(XmlFields::returnArrayValue($hash_in,'echeckToken')),
297
+ 'customBilling'=>XmlFields::customBilling(XmlFields::returnArrayValue($hash_in,'customBilling')));
298
 
299
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
300
  $echeckCreditResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'echeckCredit',$choice_hash);
305
  {
306
 
307
  $hash_out = array(
308
+ 'litleTxnId'=>XmlFields::returnArrayValue($hash_in,'litleTxnId'),
309
+ 'orderId'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderId')),
310
+ 'amount'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'amount')),
311
+ 'orderSource'=>Checker::requiredField(XmlFields::returnArrayValue($hash_in,'orderSource')),
312
+ 'billToAddress'=>XmlFields::contact(XmlFields::returnArrayValue($hash_in,'billToAddress')),
313
+ 'echeck'=>XmlFields::echeckType(XmlFields::returnArrayValue($hash_in,'echeck')),
314
+ 'echeckToken'=>XmlFields::echeckTokenType(XmlFields::returnArrayValue($hash_in,'echeckToken')),
315
+ 'merchantData'=>(XmlFields::merchantData(XmlFields::returnArrayValue($hash_in,'merchantData'))),
316
+ );
317
 
318
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
319
  $choice_hash = array($hash_out['echeck'],$hash_out['echeckToken']);
324
  public function voidRequest($hash_in)
325
  {
326
  $hash_out = array(
327
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
328
+ 'processingInstructions'=>XmlFields::processingInstructions(XmlFields::returnArrayValue($hash_in,'processingInstructions')));
329
 
330
  $voidResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,'void');
331
  return $voidResponse;
334
  public function echeckVoidRequest($hash_in)
335
  {
336
  $hash_out = array(
337
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
338
  );
339
  $echeckVoidResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"echeckVoid");
340
  return $echeckVoidResponse;
341
  }
342
 
343
+ public function depositReversalRequest($hash_in)
344
+ {
345
+ $hash_out = array(
346
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
347
+ );
348
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"depositReversal");
349
+ return $response;
350
+ }
351
+ public function refundReversalRequest($hash_in)
352
+ {
353
+ $hash_out = array(
354
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
355
+ );
356
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"refundReversal");
357
+ return $response;
358
+ }
359
+ public function activateReversalRequest($hash_in)
360
+ {
361
+ $hash_out = array(
362
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
363
+ );
364
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"activateReversal");
365
+ return $response;
366
+ }
367
+ public function deactivateReversalRequest($hash_in)
368
+ {
369
+ $hash_out = array(
370
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
371
+ );
372
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"deactivateReversal");
373
+ return $response;
374
+ }
375
+ public function loadReversalRequest($hash_in)
376
+ {
377
+ $hash_out = array(
378
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
379
+ );
380
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"loadReversal");
381
+ return $response;
382
+ }
383
+ public function unloadReversalRequest($hash_in)
384
+ {
385
+ $hash_out = array(
386
+ 'litleTxnId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleTxnId')),
387
+ );
388
+ $response = LitleOnlineRequest::processRequest($hash_out,$hash_in,"unloadReversal");
389
+ return $response;
390
+ }
391
+
392
+ public function updateCardValidationNumOnToken($hash_in)
393
+ {
394
+ $hash_out = array(
395
+ 'orderId'=>XmlFields::returnArrayValue($hash_in,'orderId'),
396
+ 'litleToken' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'litleToken')),
397
+ 'cardValidationNum' => Checker::requiredField(XmlFields::returnArrayValue($hash_in,'cardValidationNum')),
398
+ );
399
+ $updateCardValidationNumOnTokenResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"updateCardValidationNumOnToken");
400
+ return $updateCardValidationNumOnTokenResponse;
401
+ }
402
+
403
+ public function updateSubscription($hash_in)
404
+ {
405
+ $hash_out = Transactions::createUpdateSubscriptionHash($hash_in);
406
+ $choice_hash = array(XmlFields::returnArrayValue($hash_out,'card'),XmlFields::returnArrayValue($hash_out,'token'),XmlFields::returnArrayValue($hash_out,'paypage'));
407
+ $updateSubscriptionResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"updateSubscription");
408
+ return $updateSubscriptionResponse;
409
+ }
410
+
411
+ public function cancelSubscription($hash_in)
412
+ {
413
+ $hash_out = Transactions::createCancelSubscriptionHash($hash_in);
414
+ $cancelSubscriptionResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"cancelSubscription");
415
+ return $cancelSubscriptionResponse;
416
+ }
417
+
418
+ public function updatePlan($hash_in)
419
+ {
420
+ $hash_out = Transactions::createUpdatePlanHash($hash_in);
421
+ $updatePlanResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"updatePlan");
422
+ return $updatePlanResponse;
423
+ }
424
+
425
+ public function createPlan($hash_in)
426
+ {
427
+ $hash_out = Transactions::createCreatePlanHash($hash_in);
428
+ $createPlanResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"createPlan");
429
+ return $createPlanResponse;
430
+ }
431
+
432
+ public function activate($hash_in)
433
+ {
434
+ $hash_out = Transactions::createActivateHash($hash_in);
435
+ $txnResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"activate");
436
+ return $txnResponse;
437
+ }
438
+ public function deactivate($hash_in)
439
+ {
440
+ $hash_out = Transactions::createDeactivateHash($hash_in);
441
+ $txnResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"deactivate");
442
+ return $txnResponse;
443
+ }
444
+ public function load($hash_in)
445
+ {
446
+ $hash_out = Transactions::createLoadHash($hash_in);
447
+ $txnResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"load");
448
+ return $txnResponse;
449
+ }
450
+ public function unload($hash_in)
451
+ {
452
+ $hash_out = Transactions::createUnloadHash($hash_in);
453
+ $txnResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"unload");
454
+ return $txnResponse;
455
+ }
456
+ public function balanceInquiry($hash_in)
457
+ {
458
+ $hash_out = Transactions::createBalanceInquiryHash($hash_in);
459
+ $txnResponse = LitleOnlineRequest::processRequest($hash_out,$hash_in,"balanceInquiry");
460
+ return $txnResponse;
461
+ }
462
+
463
  private function overideConfig($hash_in)
464
  {
465
  $hash_out = array(
466
+ 'user'=>XmlFields::returnArrayValue($hash_in,'user'),
467
+ 'password'=>XmlFields::returnArrayValue($hash_in,'password'),
468
+ 'merchantId'=>XmlFields::returnArrayValue($hash_in,'merchantId'),
469
+ 'reportGroup'=>XmlFields::returnArrayValue($hash_in,'reportGroup'),
470
+ 'version'=>XmlFields::returnArrayValue($hash_in,'version'),
471
+ 'url'=>XmlFields::returnArrayValue($hash_in,'url'),
472
+ 'timeout'=>XmlFields::returnArrayValue($hash_in,'timeout'),
473
+ 'proxy'=>XmlFields::returnArrayValue($hash_in,'proxy'),
474
+ 'litle_requests_path'=>XmlFields::returnArrayValue($hash_in,'litle_requests_path'),
475
+ 'batch_requests_path'=>XmlFields::returnArrayValue($hash_in,'batch_requests_path'),
476
+ 'sftp_username'=>XmlFields::returnArrayValue($hash_in,'sftp_username'),
477
+ 'sftp_password'=>XmlFields::returnArrayValue($hash_in,'sftp_password'),
478
+ 'batch_url'=>XmlFields::returnArrayValue($hash_in,'batch_url'),
479
+ 'tcp_port'=>XmlFields::returnArrayValue($hash_in,'tcp_port'),
480
+ 'tcp_ssl'=>XmlFields::returnArrayValue($hash_in,'tcp_ssl'),
481
+ 'tcp_timeout'=>XmlFields::returnArrayValue($hash_in,'tcp_timeout'),
482
+ 'print_xml'=>XmlFields::returnArrayValue($hash_in,'print_xml'));
483
  return $hash_out;
484
  }
485
 
486
  private function getOptionalAttributes($hash_in,$hash_out)
487
  {
488
  if(isset($hash_in['merchantSdk'])) {
489
+ $hash_out['merchantSdk'] = XmlFields::returnArrayValue($hash_in,'merchantSdk');
490
  }
491
  else {
492
+ $hash_out['merchantSdk'] = CURRENT_SDK_VERSION;
493
  }
494
  if(isset($hash_in['id'])) {
495
+ $hash_out['id'] = XmlFields::returnArrayValue($hash_in,'id');
496
  }
497
  if(isset($hash_in['customerId'])) {
498
+ $hash_out['customerId'] = XmlFields::returnArrayValue($hash_in,'customerId');
499
+ }
500
+ if(isset($hash_in['loggedInUser'])) {
501
+ $hash_out['loggedInUser'] = XmlFields::returnArrayValue($hash_in,'loggedInUser');
502
  }
503
  return $hash_out;
504
  }
507
  {
508
 
509
  $hash_config = LitleOnlineRequest::overideconfig($hash_in);
510
+ Mage::log($hash_config);
511
 
512
  $hash = LitleOnlineRequest::getOptionalAttributes($hash_in,$hash_out);
513
  Checker::choice($choice1);
514
  Checker::choice($choice2);
515
  $request = Obj2xml::toXml($hash,$hash_config, $type);
516
+ $litleOnlineResponse = $this->newXML->request($request,$hash_config,$this->useSimpleXml);
 
517
  return $litleOnlineResponse;
518
  }
519
 
app/code/local/Litle/LitleSDK/LitleRequest.php ADDED
@@ -0,0 +1,299 @@