ClearSale_Total - Version 1.0.1

Version Notes

Fix Sensitive Case bug

Download this release

Release Info

Developer ClearSale Dev Team
Extension ClearSale_Total
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

Files changed (86) hide show
  1. app/code/community/Clearsale/Integration/Block/Adminhtml/Totalbackend.php +5 -0
  2. app/code/community/Clearsale/Integration/Helper/Data.php +5 -0
  3. app/code/community/Clearsale/Integration/Model/Auth/Business/Object.php +33 -0
  4. app/code/community/Clearsale/Integration/Model/Auth/Entity/Credentials.php +9 -0
  5. app/code/community/Clearsale/Integration/Model/Auth/Entity/RequestAuth.php +9 -0
  6. app/code/community/Clearsale/Integration/Model/Auth/Entity/ResponseAuth.php +9 -0
  7. app/code/community/Clearsale/Integration/Model/Auth/Entity/Token.php +7 -0
  8. app/code/community/Clearsale/Integration/Model/Gateway/Authorizenet.php +15 -0
  9. app/code/community/Clearsale/Integration/Model/Log.php +19 -0
  10. app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic.php +8 -0
  11. app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic/Collection.php +12 -0
  12. app/code/community/Clearsale/Integration/Model/Observer.php +603 -0
  13. app/code/community/Clearsale/Integration/Model/Order/Business/Object.php +98 -0
  14. app/code/community/Clearsale/Integration/Model/Order/Entity/Address.php +11 -0
  15. app/code/community/Clearsale/Integration/Model/Order/Entity/CustomField.php +9 -0
  16. app/code/community/Clearsale/Integration/Model/Order/Entity/Diagnostic.php +12 -0
  17. app/code/community/Clearsale/Integration/Model/Order/Entity/Item.php +10 -0
  18. app/code/community/Clearsale/Integration/Model/Order/Entity/Order.php +28 -0
  19. app/code/community/Clearsale/Integration/Model/Order/Entity/Payment.php +15 -0
  20. app/code/community/Clearsale/Integration/Model/Order/Entity/Person.php +23 -0
  21. app/code/community/Clearsale/Integration/Model/Order/Entity/Phone.php +9 -0
  22. app/code/community/Clearsale/Integration/Model/Order/Entity/RequestOrder.php +12 -0
  23. app/code/community/Clearsale/Integration/Model/Order/Entity/ResponseOrder.php +11 -0
  24. app/code/community/Clearsale/Integration/Model/Order/Entity/Status.php +14 -0
  25. app/code/community/Clearsale/Integration/Model/System/Config/Source/Analysislocation/Values.php +18 -0
  26. app/code/community/Clearsale/Integration/Model/System/Config/Source/Cron/Values.php +30 -0
  27. app/code/community/Clearsale/Integration/Model/System/Config/Source/Environment/Values.php +18 -0
  28. app/code/community/Clearsale/Integration/Model/System/Config/Source/OrderStatus/Values.php +24 -0
  29. app/code/community/Clearsale/Integration/Model/System/Config/Source/Paymentmethod/Values.php +20 -0
  30. app/code/community/Clearsale/Integration/Model/Utils/HttpHelper.php +45 -0
  31. app/code/community/Clearsale/Integration/Model/Utils/HttpMessage.php +9 -0
  32. app/code/community/Clearsale/Integration/Model/Utils/Status.php +42 -0
  33. app/code/community/Clearsale/Integration/controllers/Adminhtml/TotalbackendController.php +12 -0
  34. app/code/community/Clearsale/Integration/controllers/IndexController.php +14 -0
  35. app/code/community/Clearsale/Integration/etc/config.xml +189 -0
  36. app/code/community/Clearsale/Integration/etc/system.xml +115 -0
  37. app/code/community/Clearsale/{Total/sql/total_setup/mysql4-install-1.0.0.php → Integration/sql/total_setup/mysql4-install-1.0.1.php} +0 -0
  38. app/code/community/Clearsale/Total/Block/Adminhtml/Totalbackend.php +1 -1
  39. app/code/community/Clearsale/Total/Helper/Data.php +1 -1
  40. app/code/community/Clearsale/Total/Model/Auth/Business/Object.php +10 -10
  41. app/code/community/Clearsale/Total/Model/Auth/Entity/Credentials.php +1 -1
  42. app/code/community/Clearsale/Total/Model/Auth/Entity/RequestAuth.php +2 -2
  43. app/code/community/Clearsale/Total/Model/Auth/Entity/ResponseAuth.php +2 -2
  44. app/code/community/Clearsale/Total/Model/Auth/Entity/Token.php +1 -1
  45. app/code/community/Clearsale/Total/Model/Gateway/Authorizenet.php +15 -0
  46. app/code/community/Clearsale/Total/Model/Log.php +2 -3
  47. app/code/community/Clearsale/Total/Model/Observer.php +603 -335
  48. app/code/community/Clearsale/Total/Model/Order/Business/Object.php +8 -8
  49. app/code/community/Clearsale/Total/Model/Order/Entity/Address.php +1 -1
  50. app/code/community/Clearsale/Total/Model/Order/Entity/CustomField.php +1 -1
  51. app/code/community/Clearsale/Total/Model/Order/Entity/Diagnostic.php +1 -1
  52. app/code/community/Clearsale/Total/Model/Order/Entity/Item.php +1 -1
  53. app/code/community/Clearsale/Total/Model/Order/Entity/Order.php +3 -3
  54. app/code/community/Clearsale/Total/Model/Order/Entity/Payment.php +1 -1
  55. app/code/community/Clearsale/Total/Model/Order/Entity/Person.php +2 -2
  56. app/code/community/Clearsale/Total/Model/Order/Entity/Phone.php +1 -1
  57. app/code/community/Clearsale/Total/Model/Order/Entity/RequestOrder.php +1 -1
  58. app/code/community/Clearsale/Total/Model/Order/Entity/ResponseOrder.php +1 -1
  59. app/code/community/Clearsale/Total/Model/Order/Entity/Status.php +1 -1
  60. app/code/community/Clearsale/Total/Model/System/Config/Source/Analysislocation/Values.php +1 -1
  61. app/code/community/Clearsale/Total/Model/System/Config/Source/Cron/Values.php +1 -1
  62. app/code/community/Clearsale/Total/Model/System/Config/Source/Environment/Values.php +1 -1
  63. app/code/community/Clearsale/Total/Model/System/Config/Source/OrderStatus/Values.php +1 -1
  64. app/code/community/Clearsale/Total/Model/System/Config/Source/Paymentmethod/Values.php +1 -1
  65. app/code/community/Clearsale/Total/Model/Utils/HttpHelper.php +6 -6
  66. app/code/community/Clearsale/Total/Model/Utils/HttpMessage.php +1 -1
  67. app/code/community/Clearsale/Total/Model/Utils/Status.php +41 -24
  68. app/code/community/Clearsale/Total/controllers/Adminhtml/TotalbackendController.php +1 -1
  69. app/code/community/Clearsale/Total/controllers/IndexController.php +1 -1
  70. app/code/community/Clearsale/Total/etc/config.xml +37 -28
  71. app/code/community/Clearsale/Total/etc/system.xml +5 -4
  72. app/code/community/Clearsale/Total/sql/total_setup/mysql4-install-1.0.1.php +39 -0
  73. app/design/adminhtml/default/default/template/total/totalbackend.phtml +210 -0
  74. app/design/frontend/base/default/layout/total.xml +11 -1
  75. app/design/frontend/base/default/template/total/fingerprint.phtml +8 -5
  76. app/design/frontend/base/default/template/total/mapper.phtml +6 -3
  77. app/design/frontend/base/default/template/total/meta_cart.phtml +1 -1
  78. app/design/frontend/base/default/template/total/meta_checkout.phtml +1 -1
  79. app/design/frontend/base/default/template/total/meta_contact.phtml +1 -1
  80. app/design/frontend/base/default/template/total/meta_home.phtml +1 -1
  81. app/design/frontend/base/default/template/total/meta_pass_fail.phtml +1 -1
  82. app/design/frontend/base/default/template/total/meta_password_reset.phtml +1 -1
  83. app/design/frontend/base/default/template/total/meta_product.html +1 -1
  84. app/etc/modules/{ClearSale_Total.xml → Clearsale_Total.xml} +3 -3
  85. js/clearsale/total/Graphs/graph-data.js +29 -34
  86. package.xml +6 -5
app/code/community/Clearsale/Integration/Block/Adminhtml/Totalbackend.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Block_Adminhtml_Totalbackend extends Mage_Adminhtml_Block_Template {
4
+
5
+ }
app/code/community/Clearsale/Integration/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/community/Clearsale/Integration/Model/Auth/Business/Object.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Auth_Business_Object
4
+ {
5
+
6
+ public $Http;
7
+
8
+ function __construct() {
9
+ $this->Http = new Clearsale_Total_Model_Utils_HttpHelper();
10
+ }
11
+
12
+ public function login($enviroment) {
13
+
14
+ $url = $enviroment."api/auth/login/";
15
+ $authRequest = new Clearsale_Total_Model_Auth_Entity_RequestAuth();
16
+ $authRequest->Login->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
17
+ $authRequest->Login->ClientID = Mage::getStoreConfig("clearsale_total/general/clientid");
18
+ $authRequest->Login->ClientSecret =Mage::getStoreConfig("clearsale_total/general/clientsecret");
19
+ $response = $this->Http->postData($authRequest, $url);
20
+ return $response;
21
+ }
22
+
23
+ public function logout($enviroment) {
24
+ $authRequest = new Clearsale_Total_Model_Auth_Entity_RequestAuth();
25
+ $authRequest->Login->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
26
+ $authRequest->Login->ClientID = Mage::getStoreConfig("clearsale_total/general/clientid");
27
+ $authRequest->Login->ClientSecret =Mage::getStoreConfig("clearsale_total/general/clientsecret");
28
+ $url = $enviroment."api/auth/logout/";
29
+ $response = $this->Http->postData($authRequest, $url);
30
+ return $response;
31
+ }
32
+ }
33
+
app/code/community/Clearsale/Integration/Model/Auth/Entity/Credentials.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Auth_Entity_Credentials
4
+ {
5
+ public $ApiKey;
6
+ public $ClientID;
7
+ public $ClientSecret;
8
+
9
+ }
app/code/community/Clearsale/Integration/Model/Auth/Entity/RequestAuth.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Auth_Entity_RequestAuth
4
+ {
5
+ public $Login;
6
+ function __construct() {
7
+ $this->Login = new Clearsale_Total_Model_Auth_Entity_Credentials();
8
+ }
9
+ }
app/code/community/Clearsale/Integration/Model/Auth/Entity/ResponseAuth.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Auth_Entity_ResponseAuth
4
+ {
5
+ public $Token;
6
+ function __construct() {
7
+ $this->Token = new Clearsale_Total_Model_Auth_Entity_Token();
8
+ }
9
+ }
app/code/community/Clearsale/Integration/Model/Auth/Entity/Token.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Auth_Entity_Token
4
+ {
5
+ public $Value;
6
+ public $ExpirationDate;
7
+ }
app/code/community/Clearsale/Integration/Model/Gateway/Authorizenet.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Riskified_Full_Model_Authorizenet extends Mage_Paygate_Model_Authorizenet
4
+ {
5
+
6
+ protected function _registercard(varien_object $return, mage_sales_model_order_payment $payment)
7
+ {
8
+ $card=parent::_registercard($return,$payment);
9
+ $card->setCcAvsResultCode($return->getAvsResultCode());
10
+ $card->setCcResponseCode($return->getCardCodeResponseCode());
11
+ $payment->setCcAvsStatus($return->getAvsResultCode());
12
+ $payment->setCcCidStatus($return->getCardCodeResponseCode());
13
+ return $card;
14
+ }
15
+ }
app/code/community/Clearsale/Integration/Model/Log.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Log {
4
+
5
+ protected $_adapter;
6
+
7
+ function __construct() {
8
+ $this->_adapter = Mage::getModel('core/log_adapter', 'clearsale_total.log');
9
+ }
10
+
11
+ public function getAdapter() {
12
+ return $this->_adapter;
13
+ }
14
+
15
+ public function log($message) {
16
+ $this->getAdapter()->log($message);
17
+ }
18
+
19
+ }
app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Model_Mysql4_Clearsaleorderdiagnostic extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("total/clearsaleorderdiagnostic", "order_id");
7
+ }
8
+ }
app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Model_Mysql4_Clearsaleorderdiagnostic_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("total/clearsaleorderdiagnostic");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/community/Clearsale/Integration/Model/Observer.php ADDED
@@ -0,0 +1,603 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Observer
4
+ {
5
+
6
+ public function sendOrder()
7
+ {
8
+ try {
9
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
10
+
11
+ if ($isActive)
12
+ {
13
+
14
+ $order = new Mage_Sales_Model_Order();
15
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
16
+ $order->loadByIncrementId($incrementId);
17
+ $isReanalysis = false;
18
+ $payment = $order->getPayment();
19
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
20
+ $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
21
+
22
+ if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
23
+ {
24
+ $authBO = Mage::getModel('total/auth_business_object');
25
+ $authResponse = $authBO->login($environment);
26
+ $clearSaleOrder = $this->toClearsaleOrderObject($order,$isReanalysis,$environment);
27
+ $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
28
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
29
+ $requestOrder->LoginToken = $authResponse->Token->Value;
30
+ $requestOrder->AnalysisLocation = "USA";
31
+ $requestOrder->Orders[0] = $clearSaleOrder;
32
+
33
+ $orderBO = Mage::getModel('total/order_business_object');
34
+ $orderResponse = $orderBO->send($requestOrder,$environment);
35
+
36
+ if($orderResponse)
37
+ {
38
+ if($orderResponse->Orders)
39
+ {
40
+ $orderBO->save($orderResponse->Orders[0]);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ catch (Exception $e) {
47
+
48
+ $csLog = Mage::getSingleton('total/log');
49
+ $csLog->log($e->getMessage());
50
+
51
+ }
52
+
53
+
54
+ }
55
+
56
+ public function sendHistoricalOrders()
57
+ {
58
+ try {
59
+
60
+ $orders = Mage::getModel('sales/order')->getCollection();
61
+
62
+ foreach($orders as $order)
63
+ {
64
+ $isReanalysis = false;
65
+ $payment = $order->getPayment();
66
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
67
+ $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
68
+
69
+ if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
70
+ {
71
+ $authBO = Mage::getModel('total/auth_business_object');
72
+ $authResponse = $authBO->login($environment);
73
+ $clearSaleOrder = $this->toClearsaleOrderObject2($order,$isReanalysis,$environment,"History");
74
+ $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
75
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
76
+ $requestOrder->LoginToken = $authResponse->Token->Value;
77
+ $requestOrder->AnalysisLocation = "USA";
78
+ $requestOrder->Orders[0] = $clearSaleOrder;
79
+
80
+ $orderBO = Mage::getModel('total/order_business_object');
81
+ $orderResponse = $orderBO->send($requestOrder,$environment);
82
+ echo "Order n:".$order->getRealOrderId()." sent <br />";
83
+ }
84
+ }
85
+ }
86
+ catch (Exception $e) {
87
+
88
+ $csLog = Mage::getSingleton('total/log');
89
+ $csLog->log($e->getMessage());
90
+
91
+ }
92
+
93
+
94
+ }
95
+
96
+
97
+ public function toClearsaleOrderObject2(Mage_Sales_Model_Order $order,$isReanalysis,$location,$obs){
98
+
99
+ try {
100
+
101
+ $customerModel = Mage::getModel('customer/customer');
102
+ $customer = $customerModel->load($order->getCustomerId());
103
+ $email =$customer->getEmail();
104
+
105
+ if (!$email)
106
+ {
107
+ $email = $order->getBillingAddress()->getEmail();
108
+ }
109
+
110
+ if($location == "BRA")
111
+ {
112
+ $legalDocument = preg_replace('/[^0-9]/', '', $customer->getTaxvat());
113
+ $currency = "BRL";
114
+ }else
115
+ {
116
+ $currency = "USD";
117
+ $legalDocument = "";
118
+ }
119
+
120
+ $date = new DateTime($order->getCreatedAt());
121
+ $date = date('c', strtotime($order->getCreatedAt()));
122
+
123
+ $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
124
+ $clearsaleOrder->ID = $order->getRealOrderId();
125
+ $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
126
+ $clearsaleOrder->Currency = $currency;
127
+ $clearsaleOrder->Date = $date;
128
+ $clearsaleOrder->Reanalysis = $isReanalysis;
129
+ $clearsaleOrder->Email = $email;
130
+ $clearsaleOrder->TotalOrder = number_format(floatval($order->getGrandTotal()), 2, ".", "");
131
+
132
+ $StatusHandle = new Clearsale_Total_Model_Utils_Status();
133
+ $statusCS = $StatusHandle->toClearSaleStatus($order->getStatus());
134
+ $clearsaleOrder->Status = $statusCS;
135
+ echo "Status :".$statusCS."<br />";
136
+
137
+ if($obs != "")
138
+ {
139
+ $clearsaleOrder->Obs = $obs;
140
+ }
141
+
142
+ $items = $order->getAllItems();
143
+ $payment = $order->getPayment();
144
+
145
+ $billingAddress = $order->getBillingAddress();
146
+ $shippingAddress = $order->getShippingAddress();
147
+ $dob = $customer->getDob();
148
+ $dob = $date;
149
+
150
+ if(!$billingAddress)
151
+ {
152
+ $billingAddress = $shippingAddress;
153
+ }
154
+
155
+ if(!$shippingAddress)
156
+ {
157
+ $shippingAddress = $billingAddress;
158
+ }
159
+
160
+ $billingName = $billingAddress->getFirstname() . " " . $billingAddress->getMiddlename() . " " . $billingAddress->getLastname();
161
+ $billingName = trim(str_replace(" ", " ", $billingName));
162
+ $billingCountry = Mage::getModel('directory/country')->loadByCode($billingAddress->getCountry());
163
+ $billingPhone = preg_replace('/[^0-9]/', '', $billingAddress->getTelephone());
164
+
165
+ $shippingName = $shippingAddress->getFirstname() . " " . $shippingAddress->getMiddlename() . " " . $shippingAddress->getLastname();
166
+ $shippingName = trim(str_replace(" ", " ", $shippingName));
167
+ $shippingCountry = Mage::getModel('directory/country')->loadByCode($shippingAddress->getCountry());
168
+ $shippingPhone = preg_replace('/[^0-9]/', '', $shippingAddress->getTelephone());
169
+
170
+ $paymentType = 1;
171
+ $creditcardBrand = 0;
172
+ $paymentIndex = 0;
173
+
174
+ $creditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
175
+
176
+ $clearsaleOrder->Payments[$paymentIndex] = new Clearsale_Total_Model_Order_Entity_Payment();
177
+ $clearsaleOrder->Payments[$paymentIndex]->Amount = number_format(floatval($order->getGrandTotal()), 2, ".", "");
178
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 14;
179
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = 4;
180
+ $clearsaleOrder->Payments[$paymentIndex]->Date = $date;
181
+
182
+ if ($payment->getMethodInstance()->getCode() == "authorizenet")
183
+ {
184
+
185
+ if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods)) {
186
+
187
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 1;
188
+
189
+ $creditcardBrand = 4;
190
+ $paymentData = $payment->getData("additional_data");
191
+
192
+ if (strripos($paymentData, "diners") !== false)
193
+ $creditcardBrand = 1;
194
+
195
+ if (strripos($paymentData, "mastercard") !== false)
196
+ $creditcardBrand = 2;
197
+
198
+ if (strripos($paymentData, "visa") !== false)
199
+ $creditcardBrand = 3;
200
+
201
+ if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
202
+ $creditcardBrand = 5;
203
+
204
+ if (strripos($paymentData, "hipercard") !== false)
205
+ $creditcardBrand = 6;
206
+
207
+ if (strripos($paymentData, "aura") !== false)
208
+ $creditcardBrand = 7;
209
+
210
+ if (strripos($paymentData, "carrefour") !== false)
211
+ $creditcardBrand = 8;
212
+
213
+ $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
214
+ $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getCcOwner();
215
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
216
+ $clearsaleOrder->Payments[$paymentIndex]->CardEndNumber = $payment->getCcLast4();
217
+ $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
218
+
219
+ }
220
+ }
221
+
222
+
223
+ $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
224
+ $clearsaleOrder->BillingData->ID = "1";
225
+ $clearsaleOrder->BillingData->Email = $email;
226
+ $clearsaleOrder->BillingData->BirthDate = $dob;
227
+ $clearsaleOrder->BillingData->Name = $billingName;
228
+ $clearsaleOrder->BillingData->Type = 1;
229
+ $clearsaleOrder->BillingData->Gender = 'M';
230
+ $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
231
+ $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreetFull();
232
+ $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
233
+ $clearsaleOrder->BillingData->Address->Number = $billingAddress->getStreet(2);
234
+ $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
235
+ $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
236
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
237
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
238
+ $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
239
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
240
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
241
+
242
+ $clearsaleOrder->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
243
+ $clearsaleOrder->ShippingData->ID = "1";
244
+ $clearsaleOrder->ShippingData->Email = $email;
245
+ $clearsaleOrder->ShippingData->LegalDocument = $legalDocument;
246
+ $clearsaleOrder->ShippingData->BirthDate = $dob;
247
+ $clearsaleOrder->ShippingData->Name = 'teste';
248
+ $clearsaleOrder->ShippingData->Gender = 'M';
249
+ $clearsaleOrder->ShippingData->Type = 1;
250
+
251
+ $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
252
+ $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreetFull();
253
+ $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
254
+ $clearsaleOrder->ShippingData->Address->Number = $shippingAddress->getStreet(2);
255
+ $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
256
+ $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
257
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
258
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
259
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
260
+ $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
261
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
262
+
263
+ $itemIndex = 0;
264
+ $TotalItems = 0;
265
+
266
+ foreach ($items as $item) {
267
+ $clearsaleOrder->Items[$itemIndex] = new Clearsale_Total_Model_Order_Entity_Item();
268
+ $clearsaleOrder->Items[$itemIndex]->Price = number_format(floatval($item->getPrice()), 2, ".", "");
269
+ $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
270
+ $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
271
+ $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
272
+ //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
273
+ $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
274
+ $itemIndex++;
275
+ }
276
+
277
+ $clearsaleOrder->TotalOrder = $order->getGrandTotal();
278
+ $clearsaleOrder->TotalItems = $TotalItems;
279
+ $clearsaleOrder->TotalShipping = $order->getShippingInclTax();
280
+ $clearsaleOrder->SessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
281
+
282
+
283
+ return $clearsaleOrder;
284
+
285
+ } catch (Exception $e) {
286
+ $csLog = Mage::getSingleton('total/log');
287
+ $csLog->log($e->getMessage());
288
+ }
289
+ }
290
+
291
+
292
+ public function getClearsaleOrderStatus()
293
+ {
294
+ require_once('app/Mage.php');
295
+ Mage::app();
296
+
297
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
298
+
299
+
300
+ if ($isActive)
301
+ {
302
+
303
+ $orders = Mage::getModel('sales/order')->getCollection()
304
+ ->addFieldToFilter('status', 'analysing_clearsale');
305
+
306
+ if($orders)
307
+ {
308
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
309
+ $authBO = Mage::getModel('total/auth_business_object');
310
+ $authResponse = $authBO->login($environment);
311
+ $orderBO = Mage::getModel('total/order_business_object');
312
+
313
+ if($authResponse)
314
+ {
315
+ foreach ($orders as $order) {
316
+
317
+ $orderId = $order->getRealOrderId();
318
+ $requestOrder = Mage::getModel('total/order_entity_requestorder');
319
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
320
+ $requestOrder->LoginToken = $authResponse->Token->Value;;
321
+ $requestOrder->AnalysisLocation = "USA";//Mage::getStoreConfig("clearsale_total/general/analysislocation");
322
+ $requestOrder->Orders = array();
323
+ $requestOrder->Orders[0] = $orderId;
324
+ $ResponseOrder = $orderBO->get($requestOrder,$environment);
325
+ $orderBO->Update($ResponseOrder->Orders[0]);
326
+
327
+ $order = $order->loadByIncrementId($orderId);
328
+ if($order->getStatus() == 'approved_clearsale')
329
+ {
330
+ $createInvoice = Mage::getStoreConfig("clearsale_total/general/create_invoice");
331
+ if($createInvoice)
332
+ {
333
+ echo "Criar Invoice <br />";
334
+ $this->createInvoice($order);
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }
342
+
343
+ public function toClearsaleOrderObject(Mage_Sales_Model_Order $order,$isReanalysis,$location){
344
+
345
+ try {
346
+
347
+ $customerModel = Mage::getModel('customer/customer');
348
+ $customer = $customerModel->load($order->getCustomerId());
349
+ $email =$customer->getEmail();
350
+
351
+ if (!$email)
352
+ {
353
+ $email = $order->getBillingAddress()->getEmail();
354
+ }
355
+
356
+ if($location == "BRA")
357
+ {
358
+ $legalDocument = preg_replace('/[^0-9]/', '', $customer->getTaxvat());
359
+ $currency = "BRL";
360
+ }else
361
+ {
362
+ $currency = "USD";
363
+ $legalDocument = "";
364
+ }
365
+
366
+ $date = new DateTime($order->getCreatedAt());
367
+ $date = date('c', strtotime($order->getCreatedAt()));
368
+
369
+ $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
370
+ $clearsaleOrder->ID = $order->getRealOrderId();
371
+ $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
372
+ $clearsaleOrder->Currency = $currency;
373
+ $clearsaleOrder->Date = $date;
374
+ $clearsaleOrder->Reanalysis = $isReanalysis;
375
+ $clearsaleOrder->Email = $email;
376
+ $clearsaleOrder->TotalOrder = number_format(floatval($order->getGrandTotal()), 2, ".", "");
377
+
378
+ $items = $order->getAllItems();
379
+ $payment = $order->getPayment();
380
+
381
+ $billingAddress = $order->getBillingAddress();
382
+ $shippingAddress = $order->getShippingAddress();
383
+ $dob = $customer->getDob();
384
+ $dob = $date;
385
+
386
+ if(!$billingAddress)
387
+ {
388
+ $billingAddress = $shippingAddress;
389
+ }
390
+
391
+ if(!$shippingAddress)
392
+ {
393
+ $shippingAddress = $billingAddress;
394
+ }
395
+
396
+ $billingName = $billingAddress->getFirstname() . " " . $billingAddress->getMiddlename() . " " . $billingAddress->getLastname();
397
+ $billingName = trim(str_replace(" ", " ", $billingName));
398
+ $billingCountry = Mage::getModel('directory/country')->loadByCode($billingAddress->getCountry());
399
+ $billingPhone = preg_replace('/[^0-9]/', '', $billingAddress->getTelephone());
400
+
401
+ $shippingName = $shippingAddress->getFirstname() . " " . $shippingAddress->getMiddlename() . " " . $shippingAddress->getLastname();
402
+ $shippingName = trim(str_replace(" ", " ", $shippingName));
403
+ $shippingCountry = Mage::getModel('directory/country')->loadByCode($shippingAddress->getCountry());
404
+ $shippingPhone = preg_replace('/[^0-9]/', '', $shippingAddress->getTelephone());
405
+
406
+ $paymentType = 1;
407
+ $creditcardBrand = 0;
408
+ $paymentIndex = 0;
409
+
410
+ $creditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
411
+
412
+ $clearsaleOrder->Payments[$paymentIndex] = new Clearsale_Total_Model_Order_Entity_Payment();
413
+ $clearsaleOrder->Payments[$paymentIndex]->Amount = number_format(floatval($order->getGrandTotal()), 2, ".", "");
414
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 14;
415
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = 4;
416
+ $clearsaleOrder->Payments[$paymentIndex]->Date = $date;
417
+
418
+ //if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods))
419
+ if($payment->getAdditionalInformation('clearsaleCCNumber'))
420
+ {
421
+
422
+ if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods)) {
423
+
424
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 1;
425
+
426
+ $creditcardBrand = 4;
427
+ $paymentData = $payment->getData("additional_data");
428
+
429
+ if (strripos($paymentData, "diners") !== false)
430
+ $creditcardBrand = 1;
431
+
432
+ if (strripos($paymentData, "mastercard") !== false)
433
+ $creditcardBrand = 2;
434
+
435
+ if (strripos($paymentData, "visa") !== false)
436
+ $creditcardBrand = 3;
437
+
438
+ if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
439
+ $creditcardBrand = 5;
440
+
441
+ if (strripos($paymentData, "hipercard") !== false)
442
+ $creditcardBrand = 6;
443
+
444
+ if (strripos($paymentData, "aura") !== false)
445
+ $creditcardBrand = 7;
446
+
447
+ if (strripos($paymentData, "carrefour") !== false)
448
+ $creditcardBrand = 8;
449
+
450
+
451
+ $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
452
+ $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getCcOwner();
453
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
454
+ $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
455
+ }
456
+ }
457
+
458
+
459
+ $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
460
+ $clearsaleOrder->BillingData->ID = "1";
461
+ $clearsaleOrder->BillingData->Email = $email;
462
+ $clearsaleOrder->BillingData->BirthDate = $dob;
463
+ //$clearsaleOrder->BillingData->LegalDocument = '11111111111';
464
+ $clearsaleOrder->BillingData->Name = $billingName;
465
+ $clearsaleOrder->BillingData->Type = 1;
466
+ $clearsaleOrder->BillingData->Gender = 'M';
467
+ $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
468
+ $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreetFull();
469
+ $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
470
+ $clearsaleOrder->BillingData->Address->Number = $billingAddress->getStreet(2);
471
+ $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
472
+ $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
473
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
474
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
475
+ $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
476
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
477
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
478
+
479
+ $clearsaleOrder->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
480
+ $clearsaleOrder->ShippingData->ID = "1";
481
+ $clearsaleOrder->ShippingData->Email = $email;
482
+ $clearsaleOrder->ShippingData->LegalDocument = $legalDocument;
483
+ $clearsaleOrder->ShippingData->BirthDate = $dob;
484
+ $clearsaleOrder->ShippingData->Name = 'teste';
485
+ $clearsaleOrder->ShippingData->Gender = 'M';
486
+ $clearsaleOrder->ShippingData->Type = 1;
487
+
488
+ $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
489
+ $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreetFull();
490
+ $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
491
+ $clearsaleOrder->ShippingData->Address->Number = $shippingAddress->getStreet(2);
492
+ $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
493
+ $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
494
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
495
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
496
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
497
+ $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
498
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
499
+
500
+ $itemIndex = 0;
501
+ $TotalItems = 0;
502
+
503
+ foreach ($items as $item) {
504
+ $clearsaleOrder->Items[$itemIndex] = new Clearsale_Total_Model_Order_Entity_Item();
505
+ $clearsaleOrder->Items[$itemIndex]->Price = number_format(floatval($item->getPrice()), 2, ".", "");
506
+ $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
507
+ $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
508
+ $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
509
+ //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
510
+ $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
511
+ $itemIndex++;
512
+ }
513
+
514
+ $clearsaleOrder->TotalOrder = $order->getGrandTotal();
515
+ $clearsaleOrder->TotalItems = $TotalItems;
516
+ $clearsaleOrder->TotalShipping = $order->getShippingInclTax();
517
+ $clearsaleOrder->SessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
518
+
519
+
520
+ return $clearsaleOrder;
521
+
522
+ } catch (Exception $e) {
523
+ $csLog = Mage::getSingleton('total/log');
524
+ $csLog->log($e->getMessage());
525
+ }
526
+ }
527
+
528
+
529
+ public function getCategoryName($product)
530
+ {
531
+ $categoryIds = $product->getCategoryIds();
532
+ $categoryname = "";
533
+ if(count($categoryIds) ){
534
+ $firstCategoryId = $categoryIds[0];
535
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
536
+
537
+ $categoryname = $_category->getName();
538
+ }
539
+ return $categoryname;
540
+ }
541
+
542
+
543
+ public function getCountryCode($countryName)
544
+ {
545
+ $countryId = '';
546
+ $countryCollection = Mage::getModel('directory/country')->getCollection();
547
+ foreach ($countryCollection as $country) {
548
+ if ($countryName == $country->getName()) {
549
+ $countryId = $country->getCountryId();
550
+ break;
551
+ }
552
+ }
553
+ return $countryId;
554
+ }
555
+
556
+
557
+ public function createInvoice($order)
558
+ {
559
+ $invoice = $order->prepareInvoice()
560
+ ->setTransactionId($order->getId())
561
+ ->addComment("Invoice auto created by Clearsale approvement configuration.")
562
+ ->register()
563
+ ->pay();
564
+
565
+ $transaction_save = Mage::getModel('core/resource_transaction')
566
+ ->addObject($invoice)
567
+ ->addObject($invoice->getOrder());
568
+
569
+ $transaction_save->save();
570
+
571
+ $shipment = $order->prepareShipment();
572
+ if( $shipment ) {
573
+ $shipment->register();
574
+ $order->setIsInProcess(true);
575
+
576
+ $transaction_save = Mage::getModel('core/resource_transaction')
577
+ ->addObject($shipment)
578
+ ->addObject($shipment->getOrder())
579
+ ->save();
580
+ }
581
+ }
582
+
583
+ public function getCCInfo($order) {
584
+
585
+ $payment = $order->getPayment();
586
+ $cc = $payment->getCcNumber();
587
+
588
+ if(isset($cc))
589
+ {
590
+
591
+ $payment = $order->getPayment();
592
+ $last4 = substr($payment->getCcNumber(),(strlen($cc)-4),4);
593
+ $bin = substr($payment->getCcNumber(),0,6);
594
+
595
+ $number = $bin."XX-XXXXX-".$last4;
596
+ $payment->setAdditionalInformation('clearsaleCCBin', $bin);
597
+ $payment->setAdditionalInformation('clearsaleCCLast4', $last4);
598
+ $payment->setAdditionalInformation('clearsaleCCNumber', $number);
599
+ $payment->setAdditionalInformation('clearsaleCcOwner', $payment->getCcOwner());
600
+
601
+ }
602
+ }
603
+ }
app/code/community/Clearsale/Integration/Model/Order/Business/Object.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Business_Object
4
+ {
5
+ public $StatusHandle;
6
+ public $Http;
7
+
8
+ function __construct() {
9
+ $this->StatusHandle = new Clearsale_Total_Model_Utils_Status();
10
+ $this->Http = new Clearsale_Total_Model_Utils_HttpHelper();
11
+ }
12
+
13
+ public function send($requestSend,$enviroment) {
14
+ $url = $enviroment."api/order/send/";
15
+ $response = $this->Http->postData($requestSend, $url);
16
+ return $response;
17
+ }
18
+
19
+ public function get($requestGet,$enviroment)
20
+ {
21
+ $url = $enviroment."api/order/get/";
22
+ $response = $this->Http->postData($requestGet, $url);
23
+ return $response;
24
+ }
25
+
26
+
27
+ public function save($order)
28
+ {
29
+ $this->insertClearsaleOrderDiagnostic($order);
30
+ $magentoStatus = $this->StatusHandle->toMagentoStatus($order->Status);
31
+ $this->setOrderStatus($order->ID,$magentoStatus);
32
+ }
33
+
34
+ public function update($Order)
35
+ {
36
+ $this->updateClearsaleOrderDiagnostic($Order);
37
+ $magentoStatus = $this->StatusHandle->toMagentoStatus($Order->Status);
38
+ $this->setOrderStatus($Order->ID,$magentoStatus);
39
+
40
+ }
41
+
42
+ public function insertClearsaleOrderDiagnostic($Order)
43
+ {
44
+ try{
45
+ $orderArray = $this->objectOrderToArray($Order);
46
+ $orderArray["dt_sent"] = date('Y-m-d H:i:s');
47
+ $connection = Mage::getSingleton('core/resource')->getconnection('core_write');
48
+ $connection->insert('clearsale_order_diagnostic', $orderArray);
49
+ }
50
+ catch (Exception $e)
51
+ {
52
+ $CSLog = Mage::getSingleton('total/log');
53
+ $CSLog->log($e->getMessage());
54
+ }
55
+ }
56
+
57
+
58
+ public function updateClearsaleOrderDiagnostic($Order)
59
+ {
60
+ try {
61
+ $orderArray = $this->objectOrderToArray($Order);
62
+ $orderArray["dt_update"] = date('Y-m-d H:i:s');
63
+
64
+ $connection = Mage::getSingleton('core/resource')->getconnection('core_write');
65
+ $__where = $connection->quoteInto('order_id = ?', $orderArray["order_id"]);
66
+ $connection->update('clearsale_order_diagnostic', $orderArray, $__where);
67
+
68
+ } catch (Exception $e){
69
+ $CSLog = Mage::getSingleton('total/log');
70
+ $CSLog->log($e->getMessage());
71
+ }
72
+
73
+ }
74
+
75
+
76
+ public function setOrderStatus($orderid,$status)
77
+ {
78
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderid);
79
+ if($order->getStatus() != $status)
80
+ {
81
+ $order->setStatus($status);
82
+ $order->addStatusToHistory($status, 'Clearsale Status Update', false);
83
+ $order->save();
84
+ }
85
+ }
86
+
87
+ public function objectOrderToArray($order)
88
+ {
89
+ $array_order["order_id"] = $order->ID;
90
+ $array_order["clearsale_status"] = $order->Status;
91
+ $array_order["score"] = $order->Score;
92
+ return $array_order;
93
+ }
94
+
95
+ }
96
+
97
+
98
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Address.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Address
4
+ {
5
+ public $Street;
6
+ public $City;
7
+ public $State;
8
+ public $ZipCode;
9
+ public $County;
10
+ public $Number;
11
+ }
app/code/community/Clearsale/Integration/Model/Order/Entity/CustomField.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_CustomField
4
+ {
5
+ public $Type;
6
+ public $FieldName;
7
+ public $Value;
8
+
9
+ }
app/code/community/Clearsale/Integration/Model/Order/Entity/Diagnostic.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Diagnostic
4
+ {
5
+ public $order_id;
6
+ public $clearsale_status;
7
+ public $score;
8
+ public $diagnostics;
9
+ public $dt_sent;
10
+ public $dt_update;
11
+ }
12
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Item.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Item
4
+ {
5
+ public $ProductId;
6
+ public $ProductTitle;
7
+ public $Price;
8
+ public $Category;
9
+ public $Quantity;
10
+ }
app/code/community/Clearsale/Integration/Model/Order/Entity/Order.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Model_Order_Entity_Order
3
+ {
4
+ public $ID;
5
+ public $Date;
6
+ public $Email;
7
+ public $TotalItems;
8
+ public $TotalOrder;
9
+ public $TotalShipping;
10
+ public $Currency;
11
+ public $Payments;
12
+ public $BillingData;
13
+ public $ShippingData;
14
+ public $Items;
15
+ public $CustomFields;
16
+ public $SessionID;
17
+ public $IP;
18
+ public $Reanalysis;
19
+
20
+ function __construct() {
21
+ $this->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
22
+ $this->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
23
+ $this->Items = array();
24
+ $this->Reanalysis = false;
25
+ }
26
+ }
27
+
28
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Payment.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Payment
4
+ {
5
+ public $Date;
6
+ public $Type;
7
+ public $Gateway;
8
+ public $CardNumber;
9
+ public $CardHolderName;
10
+ public $Amount;
11
+ public $PaymentTypeID;
12
+ public $CardBin;
13
+ }
14
+
15
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Person.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Person
4
+ {
5
+ public $ID;
6
+ public $Type;
7
+ public $Name;
8
+ public $BirthDate;
9
+ public $Email;
10
+ public $LegalDocument;
11
+ public $Gender;
12
+
13
+ public $Address;
14
+ public $Phones;
15
+
16
+ function __construct() {
17
+ $this->Address = new Clearsale_Total_Model_Order_Entity_Address();
18
+ $this->Phones = array();
19
+
20
+ }
21
+ }
22
+
23
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Phone.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Phone
4
+ {
5
+ public $Type;
6
+ public $CountryCode;
7
+ public $AreaCode;
8
+ public $Number;
9
+ }
app/code/community/Clearsale/Integration/Model/Order/Entity/RequestOrder.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_RequestOrder
4
+ {
5
+ public $ApiKey ;
6
+ public $LoginToken;
7
+ public $Orders;
8
+ public $AnalysisLocation;
9
+ function __construct() {
10
+ $this->Orders = array();
11
+ }
12
+ }
app/code/community/Clearsale/Integration/Model/Order/Entity/ResponseOrder.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Model_Order_Entity_ResponseOrder
3
+ {
4
+ public $Orders;
5
+ public $TransactionID;
6
+ function __construct() {
7
+ $this->Orders = array();
8
+ }
9
+ }
10
+
11
+
app/code/community/Clearsale/Integration/Model/Order/Entity/Status.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Order_Entity_Status
4
+ {
5
+ public $ID;
6
+ public $Status;
7
+ public $Score;
8
+
9
+ function __construct() {
10
+ $this->ID = "";
11
+ }
12
+ }
13
+
14
+
app/code/community/Clearsale/Integration/Model/System/Config/Source/Analysislocation/Values.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_System_Config_Source_Analysislocation_Values
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 'BRA',
10
+ 'label' => 'BRA',
11
+ ),
12
+ array(
13
+ 'value' => 'USA',
14
+ 'label' => 'USA',
15
+ ),
16
+ );
17
+ }
18
+ }
app/code/community/Clearsale/Integration/Model/System/Config/Source/Cron/Values.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_System_Config_Source_Cron_Values
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => '*/5 * * * *',
10
+ 'label' => '05 minutes',
11
+ ),
12
+ array(
13
+ 'value' => '*/10 * * * *',
14
+ 'label' => '10 minutes',
15
+ ),
16
+ array(
17
+ 'value' => '*/15 * * * *',
18
+ 'label' => '15 minutes',
19
+ ),
20
+ array(
21
+ 'value' => '*/30 * * * *',
22
+ 'label' => '30 minutes',
23
+ ),
24
+ array(
25
+ 'value' => '*/60 * * * *',
26
+ 'label' => '60 minutes',
27
+ ),
28
+ );
29
+ }
30
+ }
app/code/community/Clearsale/Integration/Model/System/Config/Source/Environment/Values.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_System_Config_Source_Environment_Values
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 'https://integration.clearsale.com.br/',
10
+ 'label' => ' Production',
11
+ ),
12
+ array(
13
+ 'value' => 'https://sandbox.clearsale.com.br/',
14
+ 'label' => ' SandBox',
15
+ ),
16
+ );
17
+ }
18
+ }
app/code/community/Clearsale/Integration/Model/System/Config/Source/OrderStatus/Values.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_System_Config_Source_OrderStatus_Values
4
+ {
5
+ public function toOptionArray() {
6
+
7
+ $list = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));
8
+ $orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
9
+
10
+ foreach($orderStatusCollection as $orderStatus) {
11
+
12
+ $title = $orderStatus['label'];
13
+ $value = $orderStatus['status'];
14
+
15
+ $list[$value] = array(
16
+ 'label' => $title,
17
+ 'value' => $value,
18
+ );
19
+ }
20
+
21
+ return $list;
22
+ }
23
+ }
24
+
app/code/community/Clearsale/Integration/Model/System/Config/Source/Paymentmethod/Values.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_System_Config_Source_Paymentmethod_Values
4
+ {
5
+ public function toOptionArray() {
6
+
7
+ $payments = Mage::getSingleton('payment/config')->getActiveMethods();
8
+ $methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));
9
+
10
+ foreach ($payments as $paymentCode=>$paymentModel) {
11
+ $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
12
+ $methods[$paymentCode] = array(
13
+ 'label' => $paymentTitle,
14
+ 'value' => $paymentCode,
15
+ );
16
+ }
17
+
18
+ return $methods;
19
+ }
20
+ }
app/code/community/Clearsale/Integration/Model/Utils/HttpHelper.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Utils_HttpHelper
4
+ {
5
+
6
+ public function PostData($data, $url) {
7
+
8
+ $return = new Clearsale_Total_Model_Utils_HttpMessage();
9
+
10
+ $dataString = json_encode($data);
11
+
12
+ $ch = curl_init($url);
13
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
14
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
15
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
16
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
17
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
18
+ 'Content-Type: application/json',
19
+ 'Content-Length: ' . strlen($dataString))
20
+ );
21
+
22
+ $return->Body = curl_exec($ch);
23
+
24
+ if(!$return) {
25
+ die(curl_error($ch));
26
+ }else
27
+ {
28
+ $return->HttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
29
+ }
30
+
31
+ curl_close($ch);
32
+
33
+
34
+ if($return->HttpCode == 200)
35
+ {
36
+ return json_decode($return->Body);
37
+ }else
38
+ {
39
+ $csLog = Mage::getSingleton('total/log');
40
+ $csLog->log($return->Body);
41
+ }
42
+ }
43
+
44
+
45
+ }
app/code/community/Clearsale/Integration/Model/Utils/HttpMessage.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Utils_HttpMessage
4
+ {
5
+ public $HttpCode;
6
+ public $HttpMessage;
7
+ public $Body;
8
+
9
+ }
app/code/community/Clearsale/Integration/Model/Utils/Status.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Utils_Status
4
+ {
5
+ public function toMagentoStatus($clearSaleStatus)
6
+ {
7
+ switch($clearSaleStatus)
8
+ {
9
+ case "NVO" :
10
+ case "AMA" : $status = "analysing_clearsale";break;
11
+ case "RPM" :
12
+ case "SUS" :
13
+ case "FRD" :
14
+ case "RPA" :
15
+ case "RPP" : $status = "reproved_clearsale";break;
16
+ case "APM" :
17
+ case "APA" : $status = "approved_clearsale";break;
18
+ case "CAN" : $status = "canceled_clearsale";break;
19
+ break;
20
+ }
21
+
22
+ return $status;
23
+ }
24
+
25
+ public function toClearSaleStatus($magentoStatus)
26
+ {
27
+ $status = "";
28
+
29
+ switch($magentoStatus)
30
+ {
31
+ case "shipped" :
32
+ case "closed" :
33
+ case "invoiced" :
34
+ case "complete" : $status = "APM";break;
35
+ case "canceled" : $status = "CAN";break;
36
+ case "fraud" : $status = "RPM";break;
37
+ }
38
+
39
+ return $status;
40
+ }
41
+ }
42
+
app/code/community/Clearsale/Integration/controllers/Adminhtml/TotalbackendController.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Clearsale_Total_Adminhtml_TotalbackendController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ $this->loadLayout();
8
+ $this->_setActiveMenu('total/adminhtml_totalbackend');
9
+ $this->_title($this->__("Dashboard"));
10
+ $this->renderLayout();
11
+ }
12
+ }
app/code/community/Clearsale/Integration/controllers/IndexController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ <?php
3
+ class Clearsale_Total_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+ public function somethingAction()
11
+ {
12
+ echo 'test nameMethod';
13
+ }
14
+ }
app/code/community/Clearsale/Integration/etc/config.xml ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Clearsale_Total>
5
+ <version>1.0.1</version>
6
+ </Clearsale_Total>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <total>
11
+ <class>Clearsale_Total_Helper</class>
12
+ </total>
13
+ </helpers>
14
+ <models>
15
+ <total>
16
+ <class>Clearsale_Total_Model</class>
17
+ <resourceModel>total_mysql4</resourceModel>
18
+ </total>
19
+ <total_mysql4>
20
+ <class>Clearsale_Total_Model_Mysql4</class>
21
+ <entities>
22
+ <clearsaleorderdiagnostic>
23
+ <table>clearsale_order_diagnostic</table>
24
+ </clearsaleorderdiagnostic>
25
+ </entities>
26
+ </total_mysql4>
27
+ </models>
28
+ <blocks>
29
+ <total>
30
+ <class>Clearsale_Total_Block</class>
31
+ </total>
32
+ <adminhtml>
33
+ </adminhtml>
34
+ <front>
35
+ </front>
36
+ </blocks>
37
+ <resources>
38
+ <total_setup>
39
+ <setup>
40
+ <module>Clearsale_Total</module>
41
+ </setup>
42
+ <connection>
43
+ <use>core_setup</use>
44
+ </connection>
45
+ </total_setup>
46
+ <total_write>
47
+ <connection>
48
+ <use>core_write</use>
49
+ </connection>
50
+ </total_write>
51
+ <total_read>
52
+ <connection>
53
+ <use>core_read</use>
54
+ </connection>
55
+ </total_read>
56
+ </resources>
57
+ <events>
58
+ <sales_order_payment_place_start>
59
+ <observers>
60
+ <clearsale_total>
61
+ <type>singleton</type>
62
+ <class>Clearsale_Total_Model_Observer</class>
63
+ <method>getCCInfo</method>
64
+ </clearsale_total>
65
+ </observers>
66
+ </sales_order_payment_place_start>
67
+ <checkout_onepage_controller_success_action>
68
+ <observers>
69
+ <clearsale_total>
70
+ <type>singleton</type>
71
+ <class>Clearsale_Total_Model_Observer</class>
72
+ <method>sendOrder</method>
73
+ </clearsale_total>
74
+ </observers>
75
+ </checkout_onepage_controller_success_action>
76
+ </events>
77
+ </global>
78
+ <default>
79
+ <tab1>
80
+ <general>
81
+ <text_field>Default value</text_field>
82
+ <textarea></textarea>
83
+ <dropdown>key2</dropdown>
84
+ <multiple_dropdown>key1,key2</multiple_dropdown>
85
+ <time>11,30,45</time>
86
+ <active>0</active>
87
+ <boolean>1</boolean>
88
+ <dependant_text_field>Default value</dependant_text_field>
89
+ </general>
90
+ </tab1>
91
+ </default>
92
+ <admin>
93
+ <routers>
94
+ <total>
95
+ <use>admin</use>
96
+ <args>
97
+ <module>Clearsale_Total</module>
98
+ <frontName>clearsale</frontName>
99
+ </args>
100
+ </total>
101
+ </routers>
102
+ </admin>
103
+ <frontend>
104
+ <routers>
105
+ <total>
106
+ <use>standard</use>
107
+ <args>
108
+ <module>Clearsale_Total</module>
109
+ <frontName>clearsale</frontName>
110
+ </args>
111
+ </total>
112
+ </routers>
113
+ <layout>
114
+ <updates>
115
+ <total>
116
+ <file>total.xml</file>
117
+ </total>
118
+ </updates>
119
+ </layout>
120
+ </frontend>
121
+ <adminhtml>
122
+ <menu>
123
+ <total module="total">
124
+ <title>Clearsale</title>
125
+ <sort_order>100</sort_order>
126
+ <children>
127
+ <totalbackend module="total">
128
+ <title>Dashboard</title>
129
+ <sort_order>0</sort_order>
130
+ <action>clearsale/adminhtml_totalbackend</action>
131
+ </totalbackend>
132
+ </children>
133
+ </total>
134
+ </menu>
135
+ <acl>
136
+ <resources>
137
+ <all>
138
+ <title>Allow Everything</title>
139
+ </all>
140
+ <admin>
141
+ <children>
142
+ <total translate="title" module="total">
143
+ <title>Clearsale</title>
144
+ <sort_order>1000</sort_order>
145
+ <children>
146
+ <totalbackend translate="title">
147
+ <title>Dashboard</title>
148
+ </totalbackend>
149
+ </children>
150
+ </total>
151
+ </children>
152
+ <children>
153
+ <system>
154
+ <children>
155
+ <config>
156
+ <children>
157
+ <clearsale_total>
158
+ <title>Clearsale</title>
159
+ <!-- Used in resources tree -->
160
+ </clearsale_total>
161
+ </children>
162
+ </config>
163
+ </children>
164
+ </system>
165
+ </children>
166
+ </admin>
167
+ </resources>
168
+ </acl>
169
+ <layout>
170
+ <updates>
171
+ <total>
172
+ <file>total.xml</file>
173
+ </total>
174
+ </updates>
175
+ </layout>
176
+ </adminhtml>
177
+ <crontab>
178
+ <jobs>
179
+ <total>
180
+ <schedule>
181
+ <cron_expr>clearsale/total/cron_settings_clearsalesend</cron_expr>
182
+ </schedule>
183
+ <run>
184
+ <model>total/observer::getClearsaleOrderStatus</model>
185
+ </run>
186
+ </total>
187
+ </jobs>
188
+ </crontab>
189
+ </config>
app/code/community/Clearsale/Integration/etc/system.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <clearsaleconf translate="label">
5
+ <label>ClearSale</label>
6
+ <sort_order>150</sort_order>
7
+ </clearsaleconf>
8
+ </tabs>
9
+ <sections>
10
+ <clearsale_total translate="label" module="total">
11
+ <label>Total</label>
12
+ <tab>clearsaleconf</tab>
13
+ <sort_order>10</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <general translate="label comment">
19
+ <label>General</label>
20
+ <sort_order>50</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <active translate="label">
26
+ <label>Enabled</label>
27
+ <frontend_type>select</frontend_type>
28
+ <source_model>
29
+ adminhtml/system_config_source_yesno</source_model>
30
+ <sort_order>1</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </active>
35
+ <key translate="label">
36
+ <label>API Key</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>2</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </key>
43
+ <clientid>
44
+ <label>Client ID</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>3</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </clientid>
51
+ <clientsecret>
52
+ <label>Client Secret</label>
53
+ <frontend_type>obscure</frontend_type>
54
+ <sort_order>4</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </clientsecret>
59
+ <!-- -->
60
+ <environment translate="label">
61
+ <label>Enviroment</label>
62
+ <frontend_type>select</frontend_type>
63
+ <source_model>
64
+ total/system_config_source_environment_values</source_model>
65
+ <sort_order>5</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </environment>
70
+ <!--
71
+ <analysislocation translate="label">
72
+ <label>Analysis Location</label>
73
+ <frontend_type>label</frontend_type>
74
+ <source_model>
75
+ total/system_config_source_analysislocation_values</source_model>
76
+ <sort_order>5</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </analysislocation>
81
+ -->
82
+ <credicardmethod translate="label">
83
+ <label>Credit Card Methods</label>
84
+ <frontend_type>multiselect</frontend_type>
85
+ <source_model>
86
+ total/system_config_source_paymentmethod_values</source_model>
87
+ <sort_order>6</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </credicardmethod>
92
+ <cron_settings_get>
93
+ <label>Get order status on each </label>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>total/system_config_source_cron_values</source_model>
96
+ <sort_order>7</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ </cron_settings_get>
99
+ <create_invoice translate="label">
100
+ <label>Create invoice on approved</label>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>
103
+ adminhtml/system_config_source_yesno</source_model>
104
+ <sort_order>8</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </create_invoice>
109
+ </fields>
110
+ </general>
111
+ </groups>
112
+ </clearsale_total>
113
+ </sections>
114
+ </config>
115
+
app/code/community/Clearsale/{Total/sql/total_setup/mysql4-install-1.0.0.php → Integration/sql/total_setup/mysql4-install-1.0.1.php} RENAMED
File without changes
app/code/community/Clearsale/Total/Block/Adminhtml/Totalbackend.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
 
3
- class ClearSale_Total_Block_Adminhtml_Totalbackend extends Mage_Adminhtml_Block_Template {
4
 
5
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Block_Adminhtml_Totalbackend extends Mage_Adminhtml_Block_Template {
4
 
5
  }
app/code/community/Clearsale/Total/Helper/Data.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class ClearSale_Total_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
  }
5
 
1
  <?php
2
+ class Clearsale_Total_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
  }
5
 
app/code/community/Clearsale/Total/Model/Auth/Business/Object.php CHANGED
@@ -1,30 +1,30 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Auth_Business_Object
4
  {
5
 
6
  public $Http;
7
 
8
  function __construct() {
9
- $this->Http = new ClearSale_Total_Model_Utils_HttpHelper();
10
  }
11
 
12
  public function login($enviroment) {
13
 
14
  $url = $enviroment."api/auth/login/";
15
- $authRequest = new ClearSale_Total_Model_Auth_Entity_RequestAuth();
16
- $authRequest->Login->ApiKey = Mage::getStoreConfig("tab1/general/key");
17
- $authRequest->Login->ClientID = Mage::getStoreConfig("tab1/general/clientid");
18
- $authRequest->Login->ClientSecret =Mage::getStoreConfig("tab1/general/clientsecret");
19
  $response = $this->Http->postData($authRequest, $url);
20
  return $response;
21
  }
22
 
23
  public function logout($enviroment) {
24
- $authRequest = new ClearSale_Total_Model_Auth_Entity_RequestAuth();
25
- $authRequest->Login->ApiKey = Mage::getStoreConfig("tab1/general/key");
26
- $authRequest->Login->ClientID = Mage::getStoreConfig("tab1/general/clientid");
27
- $authRequest->Login->ClientSecret =Mage::getStoreConfig("tab1/general/clientsecret");
28
  $url = $enviroment."api/auth/logout/";
29
  $response = $this->Http->postData($authRequest, $url);
30
  return $response;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Auth_Business_Object
4
  {
5
 
6
  public $Http;
7
 
8
  function __construct() {
9
+ $this->Http = new Clearsale_Total_Model_Utils_HttpHelper();
10
  }
11
 
12
  public function login($enviroment) {
13
 
14
  $url = $enviroment."api/auth/login/";
15
+ $authRequest = new Clearsale_Total_Model_Auth_Entity_RequestAuth();
16
+ $authRequest->Login->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
17
+ $authRequest->Login->ClientID = Mage::getStoreConfig("clearsale_total/general/clientid");
18
+ $authRequest->Login->ClientSecret =Mage::getStoreConfig("clearsale_total/general/clientsecret");
19
  $response = $this->Http->postData($authRequest, $url);
20
  return $response;
21
  }
22
 
23
  public function logout($enviroment) {
24
+ $authRequest = new Clearsale_Total_Model_Auth_Entity_RequestAuth();
25
+ $authRequest->Login->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
26
+ $authRequest->Login->ClientID = Mage::getStoreConfig("clearsale_total/general/clientid");
27
+ $authRequest->Login->ClientSecret =Mage::getStoreConfig("clearsale_total/general/clientsecret");
28
  $url = $enviroment."api/auth/logout/";
29
  $response = $this->Http->postData($authRequest, $url);
30
  return $response;
app/code/community/Clearsale/Total/Model/Auth/Entity/Credentials.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Auth_Entity_Credentials
4
  {
5
  public $ApiKey;
6
  public $ClientID;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Auth_Entity_Credentials
4
  {
5
  public $ApiKey;
6
  public $ClientID;
app/code/community/Clearsale/Total/Model/Auth/Entity/RequestAuth.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Auth_Entity_RequestAuth
4
  {
5
  public $Login;
6
  function __construct() {
7
- $this->Login = new ClearSale_Total_Model_Auth_Entity_Credentials();
8
  }
9
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Auth_Entity_RequestAuth
4
  {
5
  public $Login;
6
  function __construct() {
7
+ $this->Login = new Clearsale_Total_Model_Auth_Entity_Credentials();
8
  }
9
  }
app/code/community/Clearsale/Total/Model/Auth/Entity/ResponseAuth.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Auth_Entity_ResponseAuth
4
  {
5
  public $Token;
6
  function __construct() {
7
- $this->Token = new ClearSale_Total_Model_Auth_Entity_Token();
8
  }
9
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Auth_Entity_ResponseAuth
4
  {
5
  public $Token;
6
  function __construct() {
7
+ $this->Token = new Clearsale_Total_Model_Auth_Entity_Token();
8
  }
9
  }
app/code/community/Clearsale/Total/Model/Auth/Entity/Token.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Auth_Entity_Token
4
  {
5
  public $Value;
6
  public $ExpirationDate;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Auth_Entity_Token
4
  {
5
  public $Value;
6
  public $ExpirationDate;
app/code/community/Clearsale/Total/Model/Gateway/Authorizenet.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Riskified_Full_Model_Authorizenet extends Mage_Paygate_Model_Authorizenet
4
+ {
5
+
6
+ protected function _registercard(varien_object $return, mage_sales_model_order_payment $payment)
7
+ {
8
+ $card=parent::_registercard($return,$payment);
9
+ $card->setCcAvsResultCode($return->getAvsResultCode());
10
+ $card->setCcResponseCode($return->getCardCodeResponseCode());
11
+ $payment->setCcAvsStatus($return->getAvsResultCode());
12
+ $payment->setCcCidStatus($return->getCardCodeResponseCode());
13
+ return $card;
14
+ }
15
+ }
app/code/community/Clearsale/Total/Model/Log.php CHANGED
@@ -1,14 +1,13 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Log {
4
 
5
  protected $_adapter;
6
 
7
  function __construct() {
8
- $this->_adapter = Mage::getModel('core/log_adapter', 'cs_total.log');
9
  }
10
 
11
- // It's public incase we want to use ->debug(), ->info(), and friends
12
  public function getAdapter() {
13
  return $this->_adapter;
14
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Log {
4
 
5
  protected $_adapter;
6
 
7
  function __construct() {
8
+ $this->_adapter = Mage::getModel('core/log_adapter', 'clearsale_total.log');
9
  }
10
 
 
11
  public function getAdapter() {
12
  return $this->_adapter;
13
  }
app/code/community/Clearsale/Total/Model/Observer.php CHANGED
@@ -1,335 +1,603 @@
1
- <?php
2
-
3
- class ClearSale_Total_Model_Observer
4
- {
5
-
6
- public function sendOrder()
7
- {
8
- try {
9
-
10
- $order = new Mage_Sales_Model_Order();
11
- $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
12
- $order->loadByIncrementId($incrementId);
13
- $isReanalysis = false;
14
- $payment = $order->getPayment();
15
- $environment = Mage::getStoreConfig("tab1/general/environment");
16
- $CreditcardMethods = explode(",", Mage::getStoreConfig("tab1/general/credicardmethod"));
17
-
18
- if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
19
- {
20
- $authBO = Mage::getModel('total/auth_business_object');
21
- $authResponse = $authBO->login($environment);
22
- $clearSaleOrder = $this->toClearSaleOrderObject($order,$isReanalysis,$environment);
23
- $requestOrder = new ClearSale_Total_Model_Order_Entity_RequestOrder();
24
- $requestOrder->ApiKey = Mage::getStoreConfig("tab1/general/key");
25
- $requestOrder->LoginToken = $authResponse->Token->Value;
26
- $requestOrder->AnalysisLocation = Mage::getStoreConfig("tab1/general/analysislocation");
27
- $requestOrder->Orders[0] = $clearSaleOrder;
28
-
29
- $orderBO = Mage::getModel('total/order_business_object');
30
- $orderResponse = $orderBO->send($requestOrder,$environment);
31
-
32
- if($orderResponse)
33
- {
34
- if($orderResponse->Orders)
35
- {
36
- $orderBO->save($orderResponse->Orders[0]);
37
- }
38
- }
39
- }
40
- }
41
- catch (Exception $e) {
42
-
43
- $csLog = Mage::getSingleton('total/log');
44
- $csLog->log($e->getMessage());
45
-
46
- }
47
- }
48
-
49
- public function getClearSaleOrderStatus()
50
- {
51
- require_once('app/Mage.php');
52
- Mage::app();
53
-
54
- $orders = Mage::getModel('sales/order')->getCollection()
55
- ->addFieldToFilter('status', 'analysing_clearsale');
56
-
57
- if($orders)
58
- {
59
- $environment = Mage::getStoreConfig("tab1/general/environment");
60
- $authBO = Mage::getModel('total/auth_business_object');
61
- $authResponse = $authBO->login($environment);
62
- $orderBO = Mage::getModel('total/order_business_object');
63
-
64
- if($authResponse)
65
- {
66
- foreach ($orders as $order) {
67
-
68
- $orderId = $order->getRealOrderId();
69
- $requestOrder = Mage::getModel('total/order_entity_requestorder');
70
- $requestOrder->ApiKey = Mage::getStoreConfig("tab1/general/key");
71
- $requestOrder->LoginToken = $authResponse->Token->Value;;
72
- $requestOrder->AnalysisLocation = Mage::getStoreConfig("tab1/general/analysislocation");
73
- $requestOrder->Orders = array();
74
- $requestOrder->Orders[0] = $orderId;
75
- $ResponseOrder = $orderBO->get($requestOrder,$environment);
76
- $orderBO->Update($ResponseOrder->Orders[0]);
77
-
78
- $order = $order->loadByIncrementId($orderId);
79
- if($order->getStatus() == 'approved_clearsale')
80
- {
81
- $createInvoice = Mage::getStoreConfig("tab1/general/create_invoice");
82
- if($createInvoice)
83
- {
84
- echo "Criar Invoice <br />";
85
- $this->createInvoice($order);
86
- }
87
- }
88
- }
89
- }
90
- }
91
- }
92
-
93
- public function toClearSaleOrderObject(Mage_Sales_Model_Order $order,$isReanalysis,$location){
94
-
95
- try {
96
-
97
- $customerModel = Mage::getModel('customer/customer');
98
- $customer = $customerModel->load($order->getCustomerId());
99
- $email =$customer->getEmail();
100
-
101
- if (!$email)
102
- {
103
- $email = $order->getBillingAddress()->getEmail();
104
- }
105
-
106
- if($location == "BRA")
107
- {
108
- $legalDocument = preg_replace('/[^0-9]/', '', $customer->getTaxvat());
109
- $currency = "BRL";
110
- }else
111
- {
112
- $currency = "USD";
113
- $legalDocument = "";
114
- }
115
-
116
- $date = new DateTime($order->getCreatedAt());
117
- $date = date('c', strtotime($order->getCreatedAt()));
118
-
119
- $clearsaleOrder = new ClearSale_Total_Model_Order_Entity_Order();
120
- $clearsaleOrder->ID = $order->getRealOrderId();
121
- $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
122
- $clearsaleOrder->Currency = $currency;
123
- $clearsaleOrder->Date = $date;
124
- $clearsaleOrder->Reanalysis = $isReanalysis;
125
- $clearsaleOrder->Email = $email;
126
- $clearsaleOrder->TotalOrder = number_format(floatval($order->getGrandTotal()), 2, ".", "");
127
-
128
- $items = $order->getAllItems();
129
- $payment = $order->getPayment();
130
-
131
- $billingAddress = $order->getBillingAddress();
132
- $shippingAddress = $order->getShippingAddress();
133
- $dob = $customer->getDob();
134
- $dob = $date;
135
-
136
- if(!$billingAddress)
137
- {
138
- $billingAddress = $shippingAddress;
139
- }
140
-
141
- if(!$shippingAddress)
142
- {
143
- $shippingAddress = $billingAddress;
144
- }
145
-
146
- $billingName = $billingAddress->getFirstname() . " " . $billingAddress->getMiddlename() . " " . $billingAddress->getLastname();
147
- $billingName = trim(str_replace(" ", " ", $billingName));
148
- $billingCountry = Mage::getModel('directory/country')->loadByCode($billingAddress->getCountry());
149
- $billingPhone = preg_replace('/[^0-9]/', '', $billingAddress->getTelephone());
150
-
151
- $shippingName = $shippingAddress->getFirstname() . " " . $shippingAddress->getMiddlename() . " " . $shippingAddress->getLastname();
152
- $shippingName = trim(str_replace(" ", " ", $shippingName));
153
- $shippingCountry = Mage::getModel('directory/country')->loadByCode($shippingAddress->getCountry());
154
- $shippingPhone = preg_replace('/[^0-9]/', '', $shippingAddress->getTelephone());
155
-
156
- $paymentType = 1;
157
- $creditcardBrand = 0;
158
-
159
- $creditcardMethods = explode(",", Mage::getStoreConfig("tab1/general/credicardmethod"));
160
-
161
- $paymentIndex = 0;
162
-
163
-
164
- if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods))
165
- {
166
-
167
- $paymentType = 1;
168
-
169
- if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods)) {
170
-
171
- $creditcardBrand = 4;
172
- $paymentData = $payment->getData("additional_data");
173
-
174
- if (strripos($paymentData, "diners") !== false)
175
- $creditcardBrand = 1;
176
-
177
- if (strripos($paymentData, "mastercard") !== false)
178
- $creditcardBrand = 2;
179
-
180
- if (strripos($paymentData, "visa") !== false)
181
- $creditcardBrand = 3;
182
-
183
- if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
184
- $creditcardBrand = 5;
185
-
186
- if (strripos($paymentData, "hipercard") !== false)
187
- $creditcardBrand = 6;
188
-
189
- if (strripos($paymentData, "aura") !== false)
190
- $creditcardBrand = 7;
191
-
192
- if (strripos($paymentData, "carrefour") !== false)
193
- $creditcardBrand = 8;
194
- }
195
-
196
- $clearsaleOrder->Payments[$paymentIndex] = new ClearSale_Total_Model_Order_Entity_Payment();
197
- $clearsaleOrder->Payments[$paymentIndex]->Amount = number_format(floatval($order->getGrandTotal()), 2, ".", "");
198
- $clearsaleOrder->Payments[$paymentIndex]->CardNumber = $payment->getCcNumber();
199
- $clearsaleOrder->Payments[$paymentIndex]->CardBin = substr($payment->getCcNumber(),0,4);
200
- $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getCcOwner();
201
- $clearsaleOrder->Payments[$paymentIndex]->Date = $date;
202
- $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
203
- $clearsaleOrder->Payments[$paymentIndex]->Type = $paymentType;
204
- $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = $paymentType;
205
- }
206
-
207
-
208
- $clearsaleOrder->BillingData = new ClearSale_Total_Model_Order_Entity_Person();
209
- $clearsaleOrder->BillingData->ID = "1";
210
- $clearsaleOrder->BillingData->Email = $email;
211
- $clearsaleOrder->BillingData->BirthDate = $dob;
212
- //$clearsaleOrder->BillingData->LegalDocument = '11111111111';
213
- $clearsaleOrder->BillingData->Name = $billingName;
214
- $clearsaleOrder->BillingData->Type = 1;
215
- $clearsaleOrder->BillingData->Gender = 'M';
216
- $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
217
- $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreetFull();
218
- $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
219
- $clearsaleOrder->BillingData->Address->Number = $billingAddress->getStreet(2);
220
- $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
221
- $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
222
- $clearsaleOrder->BillingData->Phones[0] = new ClearSale_Total_Model_Order_Entity_Phone();
223
- $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
224
- $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
225
- $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
226
- $clearsaleOrder->BillingData->Phones[0]->Type = 1;
227
-
228
- $clearsaleOrder->ShippingData = new ClearSale_Total_Model_Order_Entity_Person();
229
- $clearsaleOrder->ShippingData->ID = "1";
230
- $clearsaleOrder->ShippingData->Email = $email;
231
- $clearsaleOrder->ShippingData->LegalDocument = $legalDocument;
232
- $clearsaleOrder->ShippingData->BirthDate = $dob;
233
- $clearsaleOrder->ShippingData->Name = 'teste';
234
- $clearsaleOrder->ShippingData->Gender = 'M';
235
- $clearsaleOrder->ShippingData->Type = 1;
236
-
237
- $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
238
- $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreetFull();
239
- $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
240
- $clearsaleOrder->ShippingData->Address->Number = $shippingAddress->getStreet(2);
241
- $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
242
- $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
243
- $clearsaleOrder->ShippingData->Phones[0] = new ClearSale_Total_Model_Order_Entity_Phone();
244
- $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
245
- $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
246
- $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
247
- $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
248
-
249
- $itemIndex = 0;
250
- $TotalItems = 0;
251
-
252
- foreach ($items as $item) {
253
- $clearsaleOrder->Items[$itemIndex] = new ClearSale_Total_Model_Order_Entity_Item();
254
- $clearsaleOrder->Items[$itemIndex]->Price = number_format(floatval($item->getPrice()), 2, ".", "");
255
- $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
256
- $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
257
- $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
258
- //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
259
- $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
260
- $itemIndex++;
261
- }
262
-
263
- $clearsaleOrder->TotalOrder = $order->getGrandTotal();
264
- $clearsaleOrder->TotalItems = $TotalItems;
265
- $clearsaleOrder->TotalShipping = $order->getShippingInclTax();
266
- $clearsaleOrder->SessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
267
-
268
-
269
- return $clearsaleOrder;
270
-
271
- } catch (Exception $e) {
272
- $csLog = Mage::getSingleton('total/log');
273
- $csLog->log($e->getMessage());
274
- }
275
- }
276
-
277
-
278
- public function getCategoryName($product)
279
- {
280
- $categoryIds = $product->getCategoryIds();
281
- $categoryname = "";
282
- if(count($categoryIds) ){
283
- $firstCategoryId = $categoryIds[0];
284
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
285
-
286
- $categoryname = $_category->getName();
287
- }
288
- return $categoryname;
289
- }
290
-
291
-
292
-
293
- public function getCountryCode($countryName)
294
- {
295
- $countryId = '';
296
- $countryCollection = Mage::getModel('directory/country')->getCollection();
297
- foreach ($countryCollection as $country) {
298
- if ($countryName == $country->getName()) {
299
- $countryId = $country->getCountryId();
300
- break;
301
- }
302
- }
303
- return $countryId;
304
- }
305
-
306
-
307
-
308
- public function createInvoice($order)
309
- {
310
- $invoice = $order->prepareInvoice()
311
- ->setTransactionId($order->getId())
312
- ->addComment("Invoice auto created by ClearSale approvement configuration.")
313
- ->register()
314
- ->pay();
315
-
316
- $transaction_save = Mage::getModel('core/resource_transaction')
317
- ->addObject($invoice)
318
- ->addObject($invoice->getOrder());
319
-
320
- $transaction_save->save();
321
-
322
- $shipment = $order->prepareShipment();
323
- if( $shipment ) {
324
- $shipment->register();
325
- $order->setIsInProcess(true);
326
-
327
- $transaction_save = Mage::getModel('core/resource_transaction')
328
- ->addObject($shipment)
329
- ->addObject($shipment->getOrder())
330
- ->save();
331
- }
332
- }
333
-
334
-
335
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Observer
4
+ {
5
+
6
+ public function sendOrder()
7
+ {
8
+ try {
9
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
10
+
11
+ if ($isActive)
12
+ {
13
+
14
+ $order = new Mage_Sales_Model_Order();
15
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
16
+ $order->loadByIncrementId($incrementId);
17
+ $isReanalysis = false;
18
+ $payment = $order->getPayment();
19
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
20
+ $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
21
+
22
+ if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
23
+ {
24
+ $authBO = Mage::getModel('total/auth_business_object');
25
+ $authResponse = $authBO->login($environment);
26
+ $clearSaleOrder = $this->toClearsaleOrderObject($order,$isReanalysis,$environment);
27
+ $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
28
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
29
+ $requestOrder->LoginToken = $authResponse->Token->Value;
30
+ $requestOrder->AnalysisLocation = "USA";
31
+ $requestOrder->Orders[0] = $clearSaleOrder;
32
+
33
+ $orderBO = Mage::getModel('total/order_business_object');
34
+ $orderResponse = $orderBO->send($requestOrder,$environment);
35
+
36
+ if($orderResponse)
37
+ {
38
+ if($orderResponse->Orders)
39
+ {
40
+ $orderBO->save($orderResponse->Orders[0]);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ catch (Exception $e) {
47
+
48
+ $csLog = Mage::getSingleton('total/log');
49
+ $csLog->log($e->getMessage());
50
+
51
+ }
52
+
53
+
54
+ }
55
+
56
+ public function sendHistoricalOrders()
57
+ {
58
+ try {
59
+
60
+ $orders = Mage::getModel('sales/order')->getCollection();
61
+
62
+ foreach($orders as $order)
63
+ {
64
+ $isReanalysis = false;
65
+ $payment = $order->getPayment();
66
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
67
+ $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
68
+
69
+ if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
70
+ {
71
+ $authBO = Mage::getModel('total/auth_business_object');
72
+ $authResponse = $authBO->login($environment);
73
+ $clearSaleOrder = $this->toClearsaleOrderObject2($order,$isReanalysis,$environment,"History");
74
+ $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
75
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
76
+ $requestOrder->LoginToken = $authResponse->Token->Value;
77
+ $requestOrder->AnalysisLocation = "USA";
78
+ $requestOrder->Orders[0] = $clearSaleOrder;
79
+
80
+ $orderBO = Mage::getModel('total/order_business_object');
81
+ $orderResponse = $orderBO->send($requestOrder,$environment);
82
+ echo "Order n:".$order->getRealOrderId()." sent <br />";
83
+ }
84
+ }
85
+ }
86
+ catch (Exception $e) {
87
+
88
+ $csLog = Mage::getSingleton('total/log');
89
+ $csLog->log($e->getMessage());
90
+
91
+ }
92
+
93
+
94
+ }
95
+
96
+
97
+ public function toClearsaleOrderObject2(Mage_Sales_Model_Order $order,$isReanalysis,$location,$obs){
98
+
99
+ try {
100
+
101
+ $customerModel = Mage::getModel('customer/customer');
102
+ $customer = $customerModel->load($order->getCustomerId());
103
+ $email =$customer->getEmail();
104
+
105
+ if (!$email)
106
+ {
107
+ $email = $order->getBillingAddress()->getEmail();
108
+ }
109
+
110
+ if($location == "BRA")
111
+ {
112
+ $legalDocument = preg_replace('/[^0-9]/', '', $customer->getTaxvat());
113
+ $currency = "BRL";
114
+ }else
115
+ {
116
+ $currency = "USD";
117
+ $legalDocument = "";
118
+ }
119
+
120
+ $date = new DateTime($order->getCreatedAt());
121
+ $date = date('c', strtotime($order->getCreatedAt()));
122
+
123
+ $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
124
+ $clearsaleOrder->ID = $order->getRealOrderId();
125
+ $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
126
+ $clearsaleOrder->Currency = $currency;
127
+ $clearsaleOrder->Date = $date;
128
+ $clearsaleOrder->Reanalysis = $isReanalysis;
129
+ $clearsaleOrder->Email = $email;
130
+ $clearsaleOrder->TotalOrder = number_format(floatval($order->getGrandTotal()), 2, ".", "");
131
+
132
+ $StatusHandle = new Clearsale_Total_Model_Utils_Status();
133
+ $statusCS = $StatusHandle->toClearSaleStatus($order->getStatus());
134
+ $clearsaleOrder->Status = $statusCS;
135
+ echo "Status :".$statusCS."<br />";
136
+
137
+ if($obs != "")
138
+ {
139
+ $clearsaleOrder->Obs = $obs;
140
+ }
141
+
142
+ $items = $order->getAllItems();
143
+ $payment = $order->getPayment();
144
+
145
+ $billingAddress = $order->getBillingAddress();
146
+ $shippingAddress = $order->getShippingAddress();
147
+ $dob = $customer->getDob();
148
+ $dob = $date;
149
+
150
+ if(!$billingAddress)
151
+ {
152
+ $billingAddress = $shippingAddress;
153
+ }
154
+
155
+ if(!$shippingAddress)
156
+ {
157
+ $shippingAddress = $billingAddress;
158
+ }
159
+
160
+ $billingName = $billingAddress->getFirstname() . " " . $billingAddress->getMiddlename() . " " . $billingAddress->getLastname();
161
+ $billingName = trim(str_replace(" ", " ", $billingName));
162
+ $billingCountry = Mage::getModel('directory/country')->loadByCode($billingAddress->getCountry());
163
+ $billingPhone = preg_replace('/[^0-9]/', '', $billingAddress->getTelephone());
164
+
165
+ $shippingName = $shippingAddress->getFirstname() . " " . $shippingAddress->getMiddlename() . " " . $shippingAddress->getLastname();
166
+ $shippingName = trim(str_replace(" ", " ", $shippingName));
167
+ $shippingCountry = Mage::getModel('directory/country')->loadByCode($shippingAddress->getCountry());
168
+ $shippingPhone = preg_replace('/[^0-9]/', '', $shippingAddress->getTelephone());
169
+
170
+ $paymentType = 1;
171
+ $creditcardBrand = 0;
172
+ $paymentIndex = 0;
173
+
174
+ $creditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
175
+
176
+ $clearsaleOrder->Payments[$paymentIndex] = new Clearsale_Total_Model_Order_Entity_Payment();
177
+ $clearsaleOrder->Payments[$paymentIndex]->Amount = number_format(floatval($order->getGrandTotal()), 2, ".", "");
178
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 14;
179
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = 4;
180
+ $clearsaleOrder->Payments[$paymentIndex]->Date = $date;
181
+
182
+ if ($payment->getMethodInstance()->getCode() == "authorizenet")
183
+ {
184
+
185
+ if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods)) {
186
+
187
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 1;
188
+
189
+ $creditcardBrand = 4;
190
+ $paymentData = $payment->getData("additional_data");
191
+
192
+ if (strripos($paymentData, "diners") !== false)
193
+ $creditcardBrand = 1;
194
+
195
+ if (strripos($paymentData, "mastercard") !== false)
196
+ $creditcardBrand = 2;
197
+
198
+ if (strripos($paymentData, "visa") !== false)
199
+ $creditcardBrand = 3;
200
+
201
+ if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
202
+ $creditcardBrand = 5;
203
+
204
+ if (strripos($paymentData, "hipercard") !== false)
205
+ $creditcardBrand = 6;
206
+
207
+ if (strripos($paymentData, "aura") !== false)
208
+ $creditcardBrand = 7;
209
+
210
+ if (strripos($paymentData, "carrefour") !== false)
211
+ $creditcardBrand = 8;
212
+
213
+ $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
214
+ $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getCcOwner();
215
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
216
+ $clearsaleOrder->Payments[$paymentIndex]->CardEndNumber = $payment->getCcLast4();
217
+ $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
218
+
219
+ }
220
+ }
221
+
222
+
223
+ $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
224
+ $clearsaleOrder->BillingData->ID = "1";
225
+ $clearsaleOrder->BillingData->Email = $email;
226
+ $clearsaleOrder->BillingData->BirthDate = $dob;
227
+ $clearsaleOrder->BillingData->Name = $billingName;
228
+ $clearsaleOrder->BillingData->Type = 1;
229
+ $clearsaleOrder->BillingData->Gender = 'M';
230
+ $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
231
+ $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreetFull();
232
+ $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
233
+ $clearsaleOrder->BillingData->Address->Number = $billingAddress->getStreet(2);
234
+ $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
235
+ $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
236
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
237
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
238
+ $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
239
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
240
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
241
+
242
+ $clearsaleOrder->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
243
+ $clearsaleOrder->ShippingData->ID = "1";
244
+ $clearsaleOrder->ShippingData->Email = $email;
245
+ $clearsaleOrder->ShippingData->LegalDocument = $legalDocument;
246
+ $clearsaleOrder->ShippingData->BirthDate = $dob;
247
+ $clearsaleOrder->ShippingData->Name = 'teste';
248
+ $clearsaleOrder->ShippingData->Gender = 'M';
249
+ $clearsaleOrder->ShippingData->Type = 1;
250
+
251
+ $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
252
+ $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreetFull();
253
+ $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
254
+ $clearsaleOrder->ShippingData->Address->Number = $shippingAddress->getStreet(2);
255
+ $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
256
+ $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
257
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
258
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
259
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
260
+ $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
261
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
262
+
263
+ $itemIndex = 0;
264
+ $TotalItems = 0;
265
+
266
+ foreach ($items as $item) {
267
+ $clearsaleOrder->Items[$itemIndex] = new Clearsale_Total_Model_Order_Entity_Item();
268
+ $clearsaleOrder->Items[$itemIndex]->Price = number_format(floatval($item->getPrice()), 2, ".", "");
269
+ $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
270
+ $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
271
+ $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
272
+ //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
273
+ $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
274
+ $itemIndex++;
275
+ }
276
+
277
+ $clearsaleOrder->TotalOrder = $order->getGrandTotal();
278
+ $clearsaleOrder->TotalItems = $TotalItems;
279
+ $clearsaleOrder->TotalShipping = $order->getShippingInclTax();
280
+ $clearsaleOrder->SessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
281
+
282
+
283
+ return $clearsaleOrder;
284
+
285
+ } catch (Exception $e) {
286
+ $csLog = Mage::getSingleton('total/log');
287
+ $csLog->log($e->getMessage());
288
+ }
289
+ }
290
+
291
+
292
+ public function getClearsaleOrderStatus()
293
+ {
294
+ require_once('app/Mage.php');
295
+ Mage::app();
296
+
297
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
298
+
299
+
300
+ if ($isActive)
301
+ {
302
+
303
+ $orders = Mage::getModel('sales/order')->getCollection()
304
+ ->addFieldToFilter('status', 'analysing_clearsale');
305
+
306
+ if($orders)
307
+ {
308
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
309
+ $authBO = Mage::getModel('total/auth_business_object');
310
+ $authResponse = $authBO->login($environment);
311
+ $orderBO = Mage::getModel('total/order_business_object');
312
+
313
+ if($authResponse)
314
+ {
315
+ foreach ($orders as $order) {
316
+
317
+ $orderId = $order->getRealOrderId();
318
+ $requestOrder = Mage::getModel('total/order_entity_requestorder');
319
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
320
+ $requestOrder->LoginToken = $authResponse->Token->Value;;
321
+ $requestOrder->AnalysisLocation = "USA";//Mage::getStoreConfig("clearsale_total/general/analysislocation");
322
+ $requestOrder->Orders = array();
323
+ $requestOrder->Orders[0] = $orderId;
324
+ $ResponseOrder = $orderBO->get($requestOrder,$environment);
325
+ $orderBO->Update($ResponseOrder->Orders[0]);
326
+
327
+ $order = $order->loadByIncrementId($orderId);
328
+ if($order->getStatus() == 'approved_clearsale')
329
+ {
330
+ $createInvoice = Mage::getStoreConfig("clearsale_total/general/create_invoice");
331
+ if($createInvoice)
332
+ {
333
+ echo "Criar Invoice <br />";
334
+ $this->createInvoice($order);
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }
342
+
343
+ public function toClearsaleOrderObject(Mage_Sales_Model_Order $order,$isReanalysis,$location){
344
+
345
+ try {
346
+
347
+ $customerModel = Mage::getModel('customer/customer');
348
+ $customer = $customerModel->load($order->getCustomerId());
349
+ $email =$customer->getEmail();
350
+
351
+ if (!$email)
352
+ {
353
+ $email = $order->getBillingAddress()->getEmail();
354
+ }
355
+
356
+ if($location == "BRA")
357
+ {
358
+ $legalDocument = preg_replace('/[^0-9]/', '', $customer->getTaxvat());
359
+ $currency = "BRL";
360
+ }else
361
+ {
362
+ $currency = "USD";
363
+ $legalDocument = "";
364
+ }
365
+
366
+ $date = new DateTime($order->getCreatedAt());
367
+ $date = date('c', strtotime($order->getCreatedAt()));
368
+
369
+ $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
370
+ $clearsaleOrder->ID = $order->getRealOrderId();
371
+ $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
372
+ $clearsaleOrder->Currency = $currency;
373
+ $clearsaleOrder->Date = $date;
374
+ $clearsaleOrder->Reanalysis = $isReanalysis;
375
+ $clearsaleOrder->Email = $email;
376
+ $clearsaleOrder->TotalOrder = number_format(floatval($order->getGrandTotal()), 2, ".", "");
377
+
378
+ $items = $order->getAllItems();
379
+ $payment = $order->getPayment();
380
+
381
+ $billingAddress = $order->getBillingAddress();
382
+ $shippingAddress = $order->getShippingAddress();
383
+ $dob = $customer->getDob();
384
+ $dob = $date;
385
+
386
+ if(!$billingAddress)
387
+ {
388
+ $billingAddress = $shippingAddress;
389
+ }
390
+
391
+ if(!$shippingAddress)
392
+ {
393
+ $shippingAddress = $billingAddress;
394
+ }
395
+
396
+ $billingName = $billingAddress->getFirstname() . " " . $billingAddress->getMiddlename() . " " . $billingAddress->getLastname();
397
+ $billingName = trim(str_replace(" ", " ", $billingName));
398
+ $billingCountry = Mage::getModel('directory/country')->loadByCode($billingAddress->getCountry());
399
+ $billingPhone = preg_replace('/[^0-9]/', '', $billingAddress->getTelephone());
400
+
401
+ $shippingName = $shippingAddress->getFirstname() . " " . $shippingAddress->getMiddlename() . " " . $shippingAddress->getLastname();
402
+ $shippingName = trim(str_replace(" ", " ", $shippingName));
403
+ $shippingCountry = Mage::getModel('directory/country')->loadByCode($shippingAddress->getCountry());
404
+ $shippingPhone = preg_replace('/[^0-9]/', '', $shippingAddress->getTelephone());
405
+
406
+ $paymentType = 1;
407
+ $creditcardBrand = 0;
408
+ $paymentIndex = 0;
409
+
410
+ $creditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
411
+
412
+ $clearsaleOrder->Payments[$paymentIndex] = new Clearsale_Total_Model_Order_Entity_Payment();
413
+ $clearsaleOrder->Payments[$paymentIndex]->Amount = number_format(floatval($order->getGrandTotal()), 2, ".", "");
414
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 14;
415
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = 4;
416
+ $clearsaleOrder->Payments[$paymentIndex]->Date = $date;
417
+
418
+ //if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods))
419
+ if($payment->getAdditionalInformation('clearsaleCCNumber'))
420
+ {
421
+
422
+ if (in_array($payment->getMethodInstance()->getCode(), $creditcardMethods)) {
423
+
424
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 1;
425
+
426
+ $creditcardBrand = 4;
427
+ $paymentData = $payment->getData("additional_data");
428
+
429
+ if (strripos($paymentData, "diners") !== false)
430
+ $creditcardBrand = 1;
431
+
432
+ if (strripos($paymentData, "mastercard") !== false)
433
+ $creditcardBrand = 2;
434
+
435
+ if (strripos($paymentData, "visa") !== false)
436
+ $creditcardBrand = 3;
437
+
438
+ if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
439
+ $creditcardBrand = 5;
440
+
441
+ if (strripos($paymentData, "hipercard") !== false)
442
+ $creditcardBrand = 6;
443
+
444
+ if (strripos($paymentData, "aura") !== false)
445
+ $creditcardBrand = 7;
446
+
447
+ if (strripos($paymentData, "carrefour") !== false)
448
+ $creditcardBrand = 8;
449
+
450
+
451
+ $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
452
+ $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getCcOwner();
453
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
454
+ $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
455
+ }
456
+ }
457
+
458
+
459
+ $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
460
+ $clearsaleOrder->BillingData->ID = "1";
461
+ $clearsaleOrder->BillingData->Email = $email;
462
+ $clearsaleOrder->BillingData->BirthDate = $dob;
463
+ //$clearsaleOrder->BillingData->LegalDocument = '11111111111';
464
+ $clearsaleOrder->BillingData->Name = $billingName;
465
+ $clearsaleOrder->BillingData->Type = 1;
466
+ $clearsaleOrder->BillingData->Gender = 'M';
467
+ $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
468
+ $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreetFull();
469
+ $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
470
+ $clearsaleOrder->BillingData->Address->Number = $billingAddress->getStreet(2);
471
+ $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
472
+ $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
473
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
474
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
475
+ $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
476
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
477
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
478
+
479
+ $clearsaleOrder->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
480
+ $clearsaleOrder->ShippingData->ID = "1";
481
+ $clearsaleOrder->ShippingData->Email = $email;
482
+ $clearsaleOrder->ShippingData->LegalDocument = $legalDocument;
483
+ $clearsaleOrder->ShippingData->BirthDate = $dob;
484
+ $clearsaleOrder->ShippingData->Name = 'teste';
485
+ $clearsaleOrder->ShippingData->Gender = 'M';
486
+ $clearsaleOrder->ShippingData->Type = 1;
487
+
488
+ $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
489
+ $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreetFull();
490
+ $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
491
+ $clearsaleOrder->ShippingData->Address->Number = $shippingAddress->getStreet(2);
492
+ $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
493
+ $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
494
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
495
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
496
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
497
+ $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
498
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
499
+
500
+ $itemIndex = 0;
501
+ $TotalItems = 0;
502
+
503
+ foreach ($items as $item) {
504
+ $clearsaleOrder->Items[$itemIndex] = new Clearsale_Total_Model_Order_Entity_Item();
505
+ $clearsaleOrder->Items[$itemIndex]->Price = number_format(floatval($item->getPrice()), 2, ".", "");
506
+ $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
507
+ $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
508
+ $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
509
+ //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
510
+ $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
511
+ $itemIndex++;
512
+ }
513
+
514
+ $clearsaleOrder->TotalOrder = $order->getGrandTotal();
515
+ $clearsaleOrder->TotalItems = $TotalItems;
516
+ $clearsaleOrder->TotalShipping = $order->getShippingInclTax();
517
+ $clearsaleOrder->SessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
518
+
519
+
520
+ return $clearsaleOrder;
521
+
522
+ } catch (Exception $e) {
523
+ $csLog = Mage::getSingleton('total/log');
524
+ $csLog->log($e->getMessage());
525
+ }
526
+ }
527
+
528
+
529
+ public function getCategoryName($product)
530
+ {
531
+ $categoryIds = $product->getCategoryIds();
532
+ $categoryname = "";
533
+ if(count($categoryIds) ){
534
+ $firstCategoryId = $categoryIds[0];
535
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
536
+
537
+ $categoryname = $_category->getName();
538
+ }
539
+ return $categoryname;
540
+ }
541
+
542
+
543
+ public function getCountryCode($countryName)
544
+ {
545
+ $countryId = '';
546
+ $countryCollection = Mage::getModel('directory/country')->getCollection();
547
+ foreach ($countryCollection as $country) {
548
+ if ($countryName == $country->getName()) {
549
+ $countryId = $country->getCountryId();
550
+ break;
551
+ }
552
+ }
553
+ return $countryId;
554
+ }
555
+
556
+
557
+ public function createInvoice($order)
558
+ {
559
+ $invoice = $order->prepareInvoice()
560
+ ->setTransactionId($order->getId())
561
+ ->addComment("Invoice auto created by Clearsale approvement configuration.")
562
+ ->register()
563
+ ->pay();
564
+
565
+ $transaction_save = Mage::getModel('core/resource_transaction')
566
+ ->addObject($invoice)
567
+ ->addObject($invoice->getOrder());
568
+
569
+ $transaction_save->save();
570
+
571
+ $shipment = $order->prepareShipment();
572
+ if( $shipment ) {
573
+ $shipment->register();
574
+ $order->setIsInProcess(true);
575
+
576
+ $transaction_save = Mage::getModel('core/resource_transaction')
577
+ ->addObject($shipment)
578
+ ->addObject($shipment->getOrder())
579
+ ->save();
580
+ }
581
+ }
582
+
583
+ public function getCCInfo($order) {
584
+
585
+ $payment = $order->getPayment();
586
+ $cc = $payment->getCcNumber();
587
+
588
+ if(isset($cc))
589
+ {
590
+
591
+ $payment = $order->getPayment();
592
+ $last4 = substr($payment->getCcNumber(),(strlen($cc)-4),4);
593
+ $bin = substr($payment->getCcNumber(),0,6);
594
+
595
+ $number = $bin."XX-XXXXX-".$last4;
596
+ $payment->setAdditionalInformation('clearsaleCCBin', $bin);
597
+ $payment->setAdditionalInformation('clearsaleCCLast4', $last4);
598
+ $payment->setAdditionalInformation('clearsaleCCNumber', $number);
599
+ $payment->setAdditionalInformation('clearsaleCcOwner', $payment->getCcOwner());
600
+
601
+ }
602
+ }
603
+ }
app/code/community/Clearsale/Total/Model/Order/Business/Object.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Business_Object
4
  {
5
  public $StatusHandle;
6
  public $Http;
7
 
8
  function __construct() {
9
- $this->StatusHandle = new ClearSale_Total_Model_Utils_Status();
10
- $this->Http = new ClearSale_Total_Model_Utils_HttpHelper();
11
  }
12
 
13
  public function send($requestSend,$enviroment) {
@@ -26,20 +26,20 @@ class ClearSale_Total_Model_Order_Business_Object
26
 
27
  public function save($order)
28
  {
29
- $this->insertClearSaleOrderDiagnostic($order);
30
  $magentoStatus = $this->StatusHandle->toMagentoStatus($order->Status);
31
  $this->setOrderStatus($order->ID,$magentoStatus);
32
  }
33
 
34
  public function update($Order)
35
  {
36
- $this->updateClearSaleOrderDiagnostic($Order);
37
  $magentoStatus = $this->StatusHandle->toMagentoStatus($Order->Status);
38
  $this->setOrderStatus($Order->ID,$magentoStatus);
39
 
40
  }
41
 
42
- public function insertClearSaleOrderDiagnostic($Order)
43
  {
44
  try{
45
  $orderArray = $this->objectOrderToArray($Order);
@@ -55,7 +55,7 @@ class ClearSale_Total_Model_Order_Business_Object
55
  }
56
 
57
 
58
- public function updateClearSaleOrderDiagnostic($Order)
59
  {
60
  try {
61
  $orderArray = $this->objectOrderToArray($Order);
@@ -79,7 +79,7 @@ class ClearSale_Total_Model_Order_Business_Object
79
  if($order->getStatus() != $status)
80
  {
81
  $order->setStatus($status);
82
- $order->addStatusToHistory($status, 'ClearSale Status Update', false);
83
  $order->save();
84
  }
85
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Business_Object
4
  {
5
  public $StatusHandle;
6
  public $Http;
7
 
8
  function __construct() {
9
+ $this->StatusHandle = new Clearsale_Total_Model_Utils_Status();
10
+ $this->Http = new Clearsale_Total_Model_Utils_HttpHelper();
11
  }
12
 
13
  public function send($requestSend,$enviroment) {
26
 
27
  public function save($order)
28
  {
29
+ $this->insertClearsaleOrderDiagnostic($order);
30
  $magentoStatus = $this->StatusHandle->toMagentoStatus($order->Status);
31
  $this->setOrderStatus($order->ID,$magentoStatus);
32
  }
33
 
34
  public function update($Order)
35
  {
36
+ $this->updateClearsaleOrderDiagnostic($Order);
37
  $magentoStatus = $this->StatusHandle->toMagentoStatus($Order->Status);
38
  $this->setOrderStatus($Order->ID,$magentoStatus);
39
 
40
  }
41
 
42
+ public function insertClearsaleOrderDiagnostic($Order)
43
  {
44
  try{
45
  $orderArray = $this->objectOrderToArray($Order);
55
  }
56
 
57
 
58
+ public function updateClearsaleOrderDiagnostic($Order)
59
  {
60
  try {
61
  $orderArray = $this->objectOrderToArray($Order);
79
  if($order->getStatus() != $status)
80
  {
81
  $order->setStatus($status);
82
+ $order->addStatusToHistory($status, 'Clearsale Status Update', false);
83
  $order->save();
84
  }
85
  }
app/code/community/Clearsale/Total/Model/Order/Entity/Address.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Address
4
  {
5
  public $Street;
6
  public $City;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Address
4
  {
5
  public $Street;
6
  public $City;
app/code/community/Clearsale/Total/Model/Order/Entity/CustomField.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_CustomField
4
  {
5
  public $Type;
6
  public $FieldName;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_CustomField
4
  {
5
  public $Type;
6
  public $FieldName;
app/code/community/Clearsale/Total/Model/Order/Entity/Diagnostic.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Diagnostic
4
  {
5
  public $order_id;
6
  public $clearsale_status;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Diagnostic
4
  {
5
  public $order_id;
6
  public $clearsale_status;
app/code/community/Clearsale/Total/Model/Order/Entity/Item.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Item
4
  {
5
  public $ProductId;
6
  public $ProductTitle;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Item
4
  {
5
  public $ProductId;
6
  public $ProductTitle;
app/code/community/Clearsale/Total/Model/Order/Entity/Order.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class ClearSale_Total_Model_Order_Entity_Order
3
  {
4
  public $ID;
5
  public $Date;
@@ -18,8 +18,8 @@ class ClearSale_Total_Model_Order_Entity_Order
18
  public $Reanalysis;
19
 
20
  function __construct() {
21
- $this->ShippingData = new ClearSale_Total_Model_Order_Entity_Person();
22
- $this->BillingData = new ClearSale_Total_Model_Order_Entity_Person();
23
  $this->Items = array();
24
  $this->Reanalysis = false;
25
  }
1
  <?php
2
+ class Clearsale_Total_Model_Order_Entity_Order
3
  {
4
  public $ID;
5
  public $Date;
18
  public $Reanalysis;
19
 
20
  function __construct() {
21
+ $this->ShippingData = new Clearsale_Total_Model_Order_Entity_Person();
22
+ $this->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
23
  $this->Items = array();
24
  $this->Reanalysis = false;
25
  }
app/code/community/Clearsale/Total/Model/Order/Entity/Payment.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Payment
4
  {
5
  public $Date;
6
  public $Type;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Payment
4
  {
5
  public $Date;
6
  public $Type;
app/code/community/Clearsale/Total/Model/Order/Entity/Person.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Person
4
  {
5
  public $ID;
6
  public $Type;
@@ -14,7 +14,7 @@ class ClearSale_Total_Model_Order_Entity_Person
14
  public $Phones;
15
 
16
  function __construct() {
17
- $this->Address = new ClearSale_Total_Model_Order_Entity_Address();
18
  $this->Phones = array();
19
 
20
  }
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Person
4
  {
5
  public $ID;
6
  public $Type;
14
  public $Phones;
15
 
16
  function __construct() {
17
+ $this->Address = new Clearsale_Total_Model_Order_Entity_Address();
18
  $this->Phones = array();
19
 
20
  }
app/code/community/Clearsale/Total/Model/Order/Entity/Phone.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Phone
4
  {
5
  public $Type;
6
  public $CountryCode;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Phone
4
  {
5
  public $Type;
6
  public $CountryCode;
app/code/community/Clearsale/Total/Model/Order/Entity/RequestOrder.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_RequestOrder
4
  {
5
  public $ApiKey ;
6
  public $LoginToken;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_RequestOrder
4
  {
5
  public $ApiKey ;
6
  public $LoginToken;
app/code/community/Clearsale/Total/Model/Order/Entity/ResponseOrder.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class ClearSale_Total_Model_Order_Entity_ResponseOrder
3
  {
4
  public $Orders;
5
  public $TransactionID;
1
  <?php
2
+ class Clearsale_Total_Model_Order_Entity_ResponseOrder
3
  {
4
  public $Orders;
5
  public $TransactionID;
app/code/community/Clearsale/Total/Model/Order/Entity/Status.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Order_Entity_Status
4
  {
5
  public $ID;
6
  public $Status;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Order_Entity_Status
4
  {
5
  public $ID;
6
  public $Status;
app/code/community/Clearsale/Total/Model/System/Config/Source/Analysislocation/Values.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_System_Config_Source_Analysislocation_Values
4
  {
5
  public function toOptionArray()
6
  {
1
  <?php
2
 
3
+ class Clearsale_Total_Model_System_Config_Source_Analysislocation_Values
4
  {
5
  public function toOptionArray()
6
  {
app/code/community/Clearsale/Total/Model/System/Config/Source/Cron/Values.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_System_Config_Source_Cron_Values
4
  {
5
  public function toOptionArray()
6
  {
1
  <?php
2
 
3
+ class Clearsale_Total_Model_System_Config_Source_Cron_Values
4
  {
5
  public function toOptionArray()
6
  {
app/code/community/Clearsale/Total/Model/System/Config/Source/Environment/Values.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_System_Config_Source_Environment_Values
4
  {
5
  public function toOptionArray()
6
  {
1
  <?php
2
 
3
+ class Clearsale_Total_Model_System_Config_Source_Environment_Values
4
  {
5
  public function toOptionArray()
6
  {
app/code/community/Clearsale/Total/Model/System/Config/Source/OrderStatus/Values.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_System_Config_Source_OrderStatus_Values
4
  {
5
  public function toOptionArray() {
6
 
1
  <?php
2
 
3
+ class Clearsale_Total_Model_System_Config_Source_OrderStatus_Values
4
  {
5
  public function toOptionArray() {
6
 
app/code/community/Clearsale/Total/Model/System/Config/Source/Paymentmethod/Values.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_System_Config_Source_Paymentmethod_Values
4
  {
5
  public function toOptionArray() {
6
 
1
  <?php
2
 
3
+ class Clearsale_Total_Model_System_Config_Source_Paymentmethod_Values
4
  {
5
  public function toOptionArray() {
6
 
app/code/community/Clearsale/Total/Model/Utils/HttpHelper.php CHANGED
@@ -1,22 +1,22 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Utils_HttpHelper
4
  {
5
 
6
  public function PostData($data, $url) {
7
 
8
- $return = new ClearSale_Total_Model_Utils_HttpMessage();
9
 
10
- $data_string = json_encode($data);
11
-
12
  $ch = curl_init($url);
13
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
14
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
15
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
16
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
17
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
18
  'Content-Type: application/json',
19
- 'Content-Length: ' . strlen($data_string))
20
  );
21
 
22
  $return->Body = curl_exec($ch);
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Utils_HttpHelper
4
  {
5
 
6
  public function PostData($data, $url) {
7
 
8
+ $return = new Clearsale_Total_Model_Utils_HttpMessage();
9
 
10
+ $dataString = json_encode($data);
11
+
12
  $ch = curl_init($url);
13
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
14
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
15
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
16
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
17
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
18
  'Content-Type: application/json',
19
+ 'Content-Length: ' . strlen($dataString))
20
  );
21
 
22
  $return->Body = curl_exec($ch);
app/code/community/Clearsale/Total/Model/Utils/HttpMessage.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ClearSale_Total_Model_Utils_HttpMessage
4
  {
5
  public $HttpCode;
6
  public $HttpMessage;
1
  <?php
2
 
3
+ class Clearsale_Total_Model_Utils_HttpMessage
4
  {
5
  public $HttpCode;
6
  public $HttpMessage;
app/code/community/Clearsale/Total/Model/Utils/Status.php CHANGED
@@ -1,25 +1,42 @@
1
- <?php
2
-
3
- class ClearSale_Total_Model_Utils_Status
4
- {
5
- public function toMagentoStatus($clearSaleStatus)
6
- {
7
- switch($clearSaleStatus)
8
- {
9
- case "NVO" :
10
- case "AMA" : $status = "analysing_clearsale";break;
11
- case "RPM" :
12
- case "SUS" :
13
- case "FRD" :
14
- case "RPA" :
15
- case "RPP" : $status = "reproved_clearsale";break;
16
- case "APM" :
17
- case "APA" : $status = "approved_clearsale";break;
18
- case "CAN" : $status = "canceled_clearsale";break;
19
- break;
20
- }
21
-
22
- return $status;
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Utils_Status
4
+ {
5
+ public function toMagentoStatus($clearSaleStatus)
6
+ {
7
+ switch($clearSaleStatus)
8
+ {
9
+ case "NVO" :
10
+ case "AMA" : $status = "analysing_clearsale";break;
11
+ case "RPM" :
12
+ case "SUS" :
13
+ case "FRD" :
14
+ case "RPA" :
15
+ case "RPP" : $status = "reproved_clearsale";break;
16
+ case "APM" :
17
+ case "APA" : $status = "approved_clearsale";break;
18
+ case "CAN" : $status = "canceled_clearsale";break;
19
+ break;
20
+ }
21
+
22
+ return $status;
23
+ }
24
+
25
+ public function toClearSaleStatus($magentoStatus)
26
+ {
27
+ $status = "";
28
+
29
+ switch($magentoStatus)
30
+ {
31
+ case "shipped" :
32
+ case "closed" :
33
+ case "invoiced" :
34
+ case "complete" : $status = "APM";break;
35
+ case "canceled" : $status = "CAN";break;
36
+ case "fraud" : $status = "RPM";break;
37
+ }
38
+
39
+ return $status;
40
+ }
41
+ }
42
 
app/code/community/Clearsale/Total/controllers/Adminhtml/TotalbackendController.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class ClearSale_Total_Adminhtml_TotalbackendController extends Mage_Adminhtml_Controller_Action
3
  {
4
  public function indexAction()
5
  {
1
  <?php
2
+ class Clearsale_Total_Adminhtml_TotalbackendController extends Mage_Adminhtml_Controller_Action
3
  {
4
  public function indexAction()
5
  {
app/code/community/Clearsale/Total/controllers/IndexController.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  <?php
3
- class ClearSale_Total_IndexController extends Mage_Core_Controller_Front_Action
4
  {
5
  public function indexAction()
6
  {
1
  <?php
2
  <?php
3
+ class Clearsale_Total_IndexController extends Mage_Core_Controller_Front_Action
4
  {
5
  public function indexAction()
6
  {
app/code/community/Clearsale/Total/etc/config.xml CHANGED
@@ -1,33 +1,33 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <ClearSale_Total>
5
- <version>1.0.0</version>
6
- </ClearSale_Total>
7
  </modules>
8
  <global>
9
  <helpers>
10
  <total>
11
- <class>ClearSale_Total_Helper</class>
12
  </total>
13
  </helpers>
14
  <models>
15
  <total>
16
- <class>Clearsale_Total_Model</class>
17
- <resourceModel>total_mysql4</resourceModel>
18
- </total>
19
- <total_mysql4>
20
  <class>Clearsale_Total_Model_Mysql4</class>
21
  <entities>
22
- <clearsaleorderdiagnostic>
23
- <table>clearsale_order_diagnostic</table>
24
- </clearsaleorderdiagnostic>
25
  </entities>
26
  </total_mysql4>
27
  </models>
28
  <blocks>
29
  <total>
30
- <class>ClearSale_Total_Block</class>
31
  </total>
32
  <adminhtml>
33
  </adminhtml>
@@ -37,7 +37,7 @@
37
  <resources>
38
  <total_setup>
39
  <setup>
40
- <module>ClearSale_Total</module>
41
  </setup>
42
  <connection>
43
  <use>core_setup</use>
@@ -55,13 +55,22 @@
55
  </total_read>
56
  </resources>
57
  <events>
 
 
 
 
 
 
 
 
 
58
  <checkout_onepage_controller_success_action>
59
  <observers>
60
- <sendorder>
61
  <type>singleton</type>
62
- <class>ClearSale_Total_Model_Observer</class>
63
- <method>SendOrder</method>
64
- </sendorder>
65
  </observers>
66
  </checkout_onepage_controller_success_action>
67
  </events>
@@ -85,8 +94,8 @@
85
  <total>
86
  <use>admin</use>
87
  <args>
88
- <module>ClearSale_Total</module>
89
- <frontName>admin_total</frontName>
90
  </args>
91
  </total>
92
  </routers>
@@ -96,7 +105,7 @@
96
  <total>
97
  <use>standard</use>
98
  <args>
99
- <module>ClearSale_Total</module>
100
  <frontName>clearsale</frontName>
101
  </args>
102
  </total>
@@ -112,13 +121,13 @@
112
  <adminhtml>
113
  <menu>
114
  <total module="total">
115
- <title>ClearSale</title>
116
  <sort_order>100</sort_order>
117
  <children>
118
  <totalbackend module="total">
119
  <title>Dashboard</title>
120
  <sort_order>0</sort_order>
121
- <action>admin_total/adminhtml_totalbackend</action>
122
  </totalbackend>
123
  </children>
124
  </total>
@@ -131,7 +140,7 @@
131
  <admin>
132
  <children>
133
  <total translate="title" module="total">
134
- <title>ClearSale</title>
135
  <sort_order>1000</sort_order>
136
  <children>
137
  <totalbackend translate="title">
@@ -145,10 +154,10 @@
145
  <children>
146
  <config>
147
  <children>
148
- <tab1>
149
- <title>ClearSale</title>
150
  <!-- Used in resources tree -->
151
- </tab1>
152
  </children>
153
  </config>
154
  </children>
@@ -169,10 +178,10 @@
169
  <jobs>
170
  <total>
171
  <schedule>
172
- <cron_expr>clearsale/total/cron_settings_send</cron_expr>
173
  </schedule>
174
  <run>
175
- <model>total/observer::GetClearSaleOrderStatus</model>
176
  </run>
177
  </total>
178
  </jobs>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <Clearsale_Total>
5
+ <version>1.0.1</version>
6
+ </Clearsale_Total>
7
  </modules>
8
  <global>
9
  <helpers>
10
  <total>
11
+ <class>Clearsale_Total_Helper</class>
12
  </total>
13
  </helpers>
14
  <models>
15
  <total>
16
+ <class>Clearsale_Total_Model</class>
17
+ <resourceModel>total_mysql4</resourceModel>
18
+ </total>
19
+ <total_mysql4>
20
  <class>Clearsale_Total_Model_Mysql4</class>
21
  <entities>
22
+ <clearsaleorderdiagnostic>
23
+ <table>clearsale_order_diagnostic</table>
24
+ </clearsaleorderdiagnostic>
25
  </entities>
26
  </total_mysql4>
27
  </models>
28
  <blocks>
29
  <total>
30
+ <class>Clearsale_Total_Block</class>
31
  </total>
32
  <adminhtml>
33
  </adminhtml>
37
  <resources>
38
  <total_setup>
39
  <setup>
40
+ <module>Clearsale_Total</module>
41
  </setup>
42
  <connection>
43
  <use>core_setup</use>
55
  </total_read>
56
  </resources>
57
  <events>
58
+ <sales_order_payment_place_start>
59
+ <observers>
60
+ <clearsale_total>
61
+ <type>singleton</type>
62
+ <class>Clearsale_Total_Model_Observer</class>
63
+ <method>getCCInfo</method>
64
+ </clearsale_total>
65
+ </observers>
66
+ </sales_order_payment_place_start>
67
  <checkout_onepage_controller_success_action>
68
  <observers>
69
+ <clearsale_total>
70
  <type>singleton</type>
71
+ <class>Clearsale_Total_Model_Observer</class>
72
+ <method>sendOrder</method>
73
+ </clearsale_total>
74
  </observers>
75
  </checkout_onepage_controller_success_action>
76
  </events>
94
  <total>
95
  <use>admin</use>
96
  <args>
97
+ <module>Clearsale_Total</module>
98
+ <frontName>clearsale</frontName>
99
  </args>
100
  </total>
101
  </routers>
105
  <total>
106
  <use>standard</use>
107
  <args>
108
+ <module>Clearsale_Total</module>
109
  <frontName>clearsale</frontName>
110
  </args>
111
  </total>
121
  <adminhtml>
122
  <menu>
123
  <total module="total">
124
+ <title>Clearsale</title>
125
  <sort_order>100</sort_order>
126
  <children>
127
  <totalbackend module="total">
128
  <title>Dashboard</title>
129
  <sort_order>0</sort_order>
130
+ <action>clearsale/adminhtml_totalbackend</action>
131
  </totalbackend>
132
  </children>
133
  </total>
140
  <admin>
141
  <children>
142
  <total translate="title" module="total">
143
+ <title>Clearsale</title>
144
  <sort_order>1000</sort_order>
145
  <children>
146
  <totalbackend translate="title">
154
  <children>
155
  <config>
156
  <children>
157
+ <clearsale_total>
158
+ <title>Clearsale</title>
159
  <!-- Used in resources tree -->
160
+ </clearsale_total>
161
  </children>
162
  </config>
163
  </children>
178
  <jobs>
179
  <total>
180
  <schedule>
181
+ <cron_expr>clearsale/total/cron_settings_clearsalesend</cron_expr>
182
  </schedule>
183
  <run>
184
+ <model>total/observer::getClearsaleOrderStatus</model>
185
  </run>
186
  </total>
187
  </jobs>
app/code/community/Clearsale/Total/etc/system.xml CHANGED
@@ -7,7 +7,7 @@
7
  </clearsaleconf>
8
  </tabs>
9
  <sections>
10
- <tab1 translate="label" module="total">
11
  <label>Total</label>
12
  <tab>clearsaleconf</tab>
13
  <sort_order>10</sort_order>
@@ -50,7 +50,7 @@
50
  </clientid>
51
  <clientsecret>
52
  <label>Client Secret</label>
53
- <frontend_type>text</frontend_type>
54
  <sort_order>4</sort_order>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
@@ -67,7 +67,7 @@
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>1</show_in_store>
69
  </environment>
70
- <!-- -->
71
  <analysislocation translate="label">
72
  <label>Analysis Location</label>
73
  <frontend_type>label</frontend_type>
@@ -78,6 +78,7 @@
78
  <show_in_website>1</show_in_website>
79
  <show_in_store>1</show_in_store>
80
  </analysislocation>
 
81
  <credicardmethod translate="label">
82
  <label>Credit Card Methods</label>
83
  <frontend_type>multiselect</frontend_type>
@@ -108,7 +109,7 @@
108
  </fields>
109
  </general>
110
  </groups>
111
- </tab1>
112
  </sections>
113
  </config>
114
 
7
  </clearsaleconf>
8
  </tabs>
9
  <sections>
10
+ <clearsale_total translate="label" module="total">
11
  <label>Total</label>
12
  <tab>clearsaleconf</tab>
13
  <sort_order>10</sort_order>
50
  </clientid>
51
  <clientsecret>
52
  <label>Client Secret</label>
53
+ <frontend_type>obscure</frontend_type>
54
  <sort_order>4</sort_order>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>1</show_in_store>
69
  </environment>
70
+ <!--
71
  <analysislocation translate="label">
72
  <label>Analysis Location</label>
73
  <frontend_type>label</frontend_type>
78
  <show_in_website>1</show_in_website>
79
  <show_in_store>1</show_in_store>
80
  </analysislocation>
81
+ -->
82
  <credicardmethod translate="label">
83
  <label>Credit Card Methods</label>
84
  <frontend_type>multiselect</frontend_type>
109
  </fields>
110
  </general>
111
  </groups>
112
+ </clearsale_total>
113
  </sections>
114
  </config>
115
 
app/code/community/Clearsale/Total/sql/total_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ CREATE TABLE clearsale_order_description (
6
+ order_id VARCHAR(20) ,
7
+ clearsale_status VARCHAR(50),
8
+ score VARCHAR(5),
9
+ diagnostics VARCHAR(255),
10
+ dt_sent TIMESTAMP,
11
+ dt_update TIMESTAMP
12
+ );
13
+ SQLTEXT;
14
+
15
+ $installer->run($sql);
16
+
17
+ $status = Mage::getModel('sales/order_status');
18
+ $status->setStatus('approved_clearsale');
19
+ $status->setLabel('Approved ClearSale');
20
+ $status->save();
21
+
22
+ $status = Mage::getModel('sales/order_status');
23
+ $status->setStatus('reproved_clearsale');
24
+ $status->setLabel('Reproved ClearSale');
25
+ $status->save();
26
+
27
+ $status = Mage::getModel('sales/order_status');
28
+ $status->setStatus('canceled_clearsale');
29
+ $status->setLabel('Canceled ClearSale');
30
+ $status->save();
31
+
32
+ $status = Mage::getModel('sales/order_status');
33
+ $status->setStatus('analysing_clearsale');
34
+ $status->setLabel('Analysing ClearSale');
35
+ $status->save();
36
+
37
+
38
+ $installer->endSetup();
39
+
app/design/adminhtml/default/default/template/total/totalbackend.phtml ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+
4
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
5
+
6
+ if($isActive)
7
+ {
8
+ $apiKey = Mage::getStoreConfig("clearsale_total/general/key");
9
+ $password = Mage::getStoreConfig("clearsale_total/general/clientsecret");
10
+ $user = Mage::getStoreConfig("clearsale_total/general/clientid");
11
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment");
12
+
13
+ $obj = Mage::getModel('total/observer');
14
+
15
+ $authBO = Mage::getModel('total/auth_business_object');
16
+ $authResponse = $authBO->login($environment);
17
+ $token = "";
18
+
19
+ if($authResponse)
20
+ {
21
+ $token = $authResponse->Token->Value;
22
+ }
23
+ $interval = "4";
24
+ $script = "<script>";
25
+ $script .= "var apiKey = \"".$apiKey."\";";
26
+ $script .= "var loginToken = \"".$token."\";";
27
+ $script .= "var user = \"".$user."\";";
28
+ $script .= "var password = \"".$password."\";";
29
+ $script .= "var interval = ".$interval.";";
30
+ $script .= "var prefix = \"".$environment."\";";
31
+ $script .= "</script>";
32
+
33
+ echo $script;
34
+
35
+ $baseDir = Mage::getBaseUrl('js');
36
+
37
+ echo "<script src=\"". $baseDir ."/clearsale/total/Graphs/graph-data.js\" ></script>";
38
+ }
39
+ ?>
40
+
41
+ <?php
42
+ if ($isActive) :
43
+ ?>
44
+
45
+
46
+ <div class="container">
47
+ <div class="block-header">
48
+ <h2>Dashboard</h2>
49
+
50
+ <ul class="actions">
51
+ <li class="width: 200px">
52
+ <i class="md md-event"></i>TIME VIEW
53
+ </li>
54
+ <li>
55
+ <select id="ReportFilter">
56
+ <option value="1">Today</option>
57
+ <option value="2">Last Week</option>
58
+ <option value="3">Last Month</option>
59
+ <option value="4">Last Year</option>
60
+ </select>
61
+ <i class=\"md md-signal-cellular-4-bar\"></i>
62
+ </li>
63
+ </ul>
64
+
65
+ </div>
66
+
67
+
68
+ <div class="mini-charts">
69
+ <div class="row">
70
+ <div class="col-sm-6 col-md-4">
71
+ <div class="mini-charts-item bgm-orange">
72
+ <div class="clearfix">
73
+ <div class="chart"><i class="md md-vertical-align-bottom"></i></div>
74
+ <div class="count">
75
+ <small>SUBMITTED</small>
76
+ <h2 id="Submited">Loading...</h2>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+
82
+ <div class="col-sm-6 col-md-4">
83
+ <div class="mini-charts-item bgm-lightgreen">
84
+ <div class="clearfix">
85
+ <div class="chart"><i class="md md-done-all"></i></div>
86
+ <div class="count">
87
+ <small>APPROVAL RATE</small>
88
+ <h2 id="ApprovalRate">Loading...</h2>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="col-sm-6 col-md-4">
95
+ <div class="mini-charts-item bgm-cyan">
96
+ <div class="clearfix">
97
+ <div class="chart"><i class="md md-multitrack-audio"></i></div>
98
+ <div class="count">
99
+ <small>IN ANALYSIS</small>
100
+ <h2 id="InAnlaysis">Loading...</h2>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </div>
105
+
106
+ </div>
107
+ </div>
108
+
109
+
110
+ <div class="dash-widgets">
111
+ <div class="row">
112
+ <div class="col-md-3 col-sm-6">
113
+ <div class="card">
114
+ <div class="card-header">
115
+ <h2>Approval</h2>
116
+ </div>
117
+
118
+ <div class="card-body card-padding">
119
+ <div id="approval-chart" class="flot-chart-pie"></div>
120
+ <div class="flc-donut"></div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+ <div class="col-md-3 col-sm-6">
126
+ <div class="card">
127
+ <div class="card-header">
128
+ <h2>Decline</h2>
129
+ </div>
130
+
131
+ <div class="card-body card-padding">
132
+ <div id="decline-chart" class="flot-chart-pie"></div>
133
+ <div class="flc-donut"></div>
134
+ </div>
135
+ </div>
136
+ </div>
137
+
138
+ <div class="col-md-6 col-sm-12">
139
+ <div class="card">
140
+ <div class="card-header">
141
+ <h2>SLA Description</h2>
142
+ </div>
143
+
144
+ <div class="card-body card-padding-sm">
145
+ <div id="description-chart" class="flot-chart"></div>
146
+ <div class="flc-bar"></div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+
152
+ </div>
153
+ </div>
154
+
155
+ <div class="row bgm-white" style="margin:0 0px 50px 0">
156
+ <div class="col-xs-12 col-md-3 col-sm-3">
157
+
158
+ <div class="card-header">
159
+ <h2>Last actions</h2>
160
+ </div>
161
+
162
+ <div style="padding: 10px">
163
+ <div class="col-xs-6 col-md-6 col-sm-6" style="padding:0">
164
+ <div class="f-500 c-green">APPROVED</div>
165
+ <div id="lastOrderApproved" class="c-green numbers">#</div>
166
+
167
+ <div class="f-500 c-brown">DECLINED</div>
168
+ <div id="lastOrderDeclined" class=" c-brown numbers">#</div>
169
+
170
+ </div>
171
+ <div class="col-xs-6 col-md-6 col-sm-6" style="padding:0">
172
+ <div class="f-500 c-cyan">ANALYSING</div>
173
+ <div id="lastOrderAnalysing" class="c-cyan numbers">#</div>
174
+
175
+ <div class="f-500 c-red">CANCELED</div>
176
+ <div id="lastOrderCanceled" class="c-red numbers">#</div>
177
+ </div>
178
+ </div>
179
+
180
+ </div>
181
+ <div id="lastorders" class="col-xs-12 col-md-9 col-sm-9" style="padding:0">
182
+
183
+ </div>
184
+ </div>
185
+ <div class="row">
186
+ <div class="col-md-12">
187
+ <div class="card">
188
+ <div class="card-header">
189
+ <h2>submit total and approvals (US$)</h2>
190
+ </div>
191
+ <div class="card-body">
192
+ <div class="chart-edge">
193
+ <div id="curved-line-chart" class="flot-chart"></div>
194
+ <div class="flc-chart-edge"></div>
195
+ </div>
196
+
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ </div>
202
+ <?php else : ?>
203
+ <div class="container">
204
+ <div class="block-header">
205
+ <h2>The ClearSale Total module is disabled.</h2>
206
+ <br />
207
+ <span>Please, verify the module configuration at System>Configuration>ClearSale>Total.</span>
208
+ </div>
209
+ </div>
210
+ <?php endif; ?>
app/design/frontend/base/default/layout/total.xml CHANGED
@@ -1,4 +1,4 @@
1
- <layout version="0.1.0">
2
  <checkout_onepage_index>
3
  <reference name="head">
4
  <block type="core/template" name="meta_checkout" template="total/meta_checkout.phtml" />
@@ -58,4 +58,14 @@
58
  <block type="core/template" name="mapper" template="total/mapper.phtml" />
59
  </reference>
60
  </contacts_index_index>
 
 
 
 
 
 
 
 
 
 
61
  </layout>
1
+ <layout version="1.0.0">
2
  <checkout_onepage_index>
3
  <reference name="head">
4
  <block type="core/template" name="meta_checkout" template="total/meta_checkout.phtml" />
58
  <block type="core/template" name="mapper" template="total/mapper.phtml" />
59
  </reference>
60
  </contacts_index_index>
61
+ <cms_index_index>
62
+ <reference name="content">
63
+ <reference name="head">
64
+ <block type="core/template" name="meta_contact" template="total/meta_home.phtml" />
65
+ </reference>
66
+ <reference name="content">
67
+ <block type="core/template" name="mapper" template="total/mapper.phtml" />
68
+ </reference>
69
+ </reference>
70
+ </cms_index_index>
71
  </layout>
app/design/frontend/base/default/template/total/fingerprint.phtml CHANGED
@@ -1,16 +1,19 @@
1
 
2
  <?php
3
 
4
- require_once("/app/Mage.php");
5
-
6
- $user = Mage::getStoreConfig("tab1/general/clientid");
7
- $prefix = Mage::getStoreConfig("tab1/general/environment");
8
  $sessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
9
 
 
 
 
 
 
10
  ?>
11
 
12
  <?php
13
- $isActive = Mage::getStoreConfig("tab1/general/active");
14
 
15
  if ($isActive)
16
  {
1
 
2
  <?php
3
 
4
+ $user = Mage::getStoreConfig("clearsale_total/general/clientid");
5
+ $prefix = Mage::getStoreConfig("clearsale_total/general/environment");
 
 
6
  $sessionID = Mage::getSingleton("core/session")->getEncryptedSessionId();
7
 
8
+ if(strlen($user) > 10)
9
+ {
10
+ $user = substr($user, 0, 10);
11
+ }
12
+
13
  ?>
14
 
15
  <?php
16
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
17
 
18
  if ($isActive)
19
  {
app/design/frontend/base/default/template/total/mapper.phtml CHANGED
@@ -1,14 +1,17 @@
1
 
2
  <?php
3
 
4
- require_once("/app/Mage.php");
5
 
6
- $user = Mage::getStoreConfig("tab1/general/clientid");
 
 
 
7
 
8
  ?>
9
 
10
  <?php
11
- $isActive = Mage::getStoreConfig("tab1/general/active");
12
 
13
  if ($isActive)
14
  {
1
 
2
  <?php
3
 
4
+ $user = Mage::getStoreConfig("clearsale_total/general/clientid");
5
 
6
+ if(strlen($user) > 10)
7
+ {
8
+ $user = substr($user, 0, 10);
9
+ }
10
 
11
  ?>
12
 
13
  <?php
14
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
15
 
16
  if ($isActive)
17
  {
app/design/frontend/base/default/template/total/meta_cart.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_checkout.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_contact.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_home.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_pass_fail.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_password_reset.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/design/frontend/base/default/template/total/meta_product.html CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $isActive = Mage::getStoreConfig("tab1/general/active");
3
 
4
  if ($isActive)
5
  {
1
  <?php
2
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
3
 
4
  if ($isActive)
5
  {
app/etc/modules/{ClearSale_Total.xml → Clearsale_Total.xml} RENAMED
@@ -1,10 +1,10 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <ClearSale_Total>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.0</version>
8
- </ClearSale_Total>
9
  </modules>
10
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <Clearsale_Total>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.0.1</version>
8
+ </Clearsale_Total>
9
  </modules>
10
  </config>
js/clearsale/total/Graphs/graph-data.js CHANGED
@@ -26,7 +26,7 @@ var isUpdate = false;
26
 
27
 
28
  jQuery(document).ready(function () {
29
-
30
  SetRequestDashboard();
31
  BindChart();
32
 
@@ -53,22 +53,22 @@ function logArrayElements(element, index, array) {
53
  function RequestLogin() {
54
 
55
  var requestLogin = {
56
- Login: {
57
- Apikey: apiKey,
58
- ClientID: user,
59
- ClientSecret: password
60
  }
61
  };
62
 
63
  requestLogin = JSON.stringify(requestLogin);
64
 
65
  jQuery.ajax({
66
- url: prefix + "api/auth/Login",
67
- type: "POST",
68
- contentType: "application/json",
69
- data: requestLogin,
70
- async: false,
71
- success: function (result) {
72
  loginToken = result.Token.Value;
73
  }, error: function (xhr, textStatus, errorThrown) {
74
  console.log(textStatus + ':' + errorThrown + ' | ' + xhr.responseText);
@@ -255,17 +255,17 @@ async: true
255
  if(!isUpdate)
256
  {
257
  SLAChart = new Morris.Bar({
258
- element: 'description-chart',
259
- data: SLAData,
260
- xkey: 'Label',
261
- ykeys: ['Value'],
262
- labels: ['Total'],
263
- barColors: ['#FAA519'],
264
- barRatio: 0.4,
265
- xLabelAngle: 35,
266
- hideHover: 'auto',
267
- resize: true
268
- });
269
  }else
270
  {
271
  SLAChart.setData(SLAData);
@@ -295,11 +295,11 @@ async: true
295
  if(!isUpdate)
296
  {
297
  ApprovalChart = Morris.Donut({
298
- element: 'approval-chart',
299
- data: ApprovalData,
300
- colors: ['#009900', '#990000'],
301
- resize: true
302
- });
303
  }else
304
  {
305
  ApprovalChart.setData(ApprovalData);
@@ -345,16 +345,11 @@ function MountTableLastOrders(LastOrders) {
345
 
346
  html += "<tr>";
347
  html += "<td>"+jQuery.timeago(data.OrderActionData)+"</td>";
348
- html += "<td>"+"<a href=" + "https://pci.clearsale.com.br/Appv4/Operacao/Analise/PedidoPorCodigoEntidade?codigoEntidade="
349
  + data.ClientOrderId + "&entidadeID=10&visualizacao=true&t=" + loginToken + "&a=" + apiKey + " target=\"_blank\">" + data.ClientOrderId +"</a></td>";
350
- html += "<td>"+ "$ 4,340,00" +"</td>";
351
  html += setStatus(data.Status);
352
  html += "</tr>";
353
-
354
- //html += "<a href=" + "https://pci.clearsale.com.br/Appv4/Operacao/Analise/PedidoPorCodigoEntidade?codigoEntidade="
355
- // + data.ClientOrderId + "&entidadeID=10&visualizacao=true&t=" + loginToken + "&a=" + apiKey + " target=\"_blank\">";
356
- //html += "<span class=\"badge\">" + jQuery.timeago(data.OrderActionData) + "</span> <i class=\"fa fa-fw fa-check\"></i>" + data.ClientOrderId + " " + data.Status;
357
- //html += "</a>";
358
  });
359
 
360
  html+="</tbody>";
26
 
27
 
28
  jQuery(document).ready(function () {
29
+ jQuery.support.cors = true;
30
  SetRequestDashboard();
31
  BindChart();
32
 
53
  function RequestLogin() {
54
 
55
  var requestLogin = {
56
+ Login: {
57
+ Apikey: apiKey,
58
+ ClientID: user,
59
+ ClientSecret: password
60
  }
61
  };
62
 
63
  requestLogin = JSON.stringify(requestLogin);
64
 
65
  jQuery.ajax({
66
+ url: prefix + "api/auth/Login",
67
+ type: "POST",
68
+ contentType: "application/json",
69
+ data: requestLogin,
70
+ async: false,
71
+ success: function (result) {
72
  loginToken = result.Token.Value;
73
  }, error: function (xhr, textStatus, errorThrown) {
74
  console.log(textStatus + ':' + errorThrown + ' | ' + xhr.responseText);
255
  if(!isUpdate)
256
  {
257
  SLAChart = new Morris.Bar({
258
+ element: 'description-chart',
259
+ data: SLAData,
260
+ xkey: 'Label',
261
+ ykeys: ['Value'],
262
+ labels: ['Total'],
263
+ barColors: ['#FAA519'],
264
+ barRatio: 0.4,
265
+ xLabelAngle: 35,
266
+ hideHover: 'auto',
267
+ resize: true
268
+ });
269
  }else
270
  {
271
  SLAChart.setData(SLAData);
295
  if(!isUpdate)
296
  {
297
  ApprovalChart = Morris.Donut({
298
+ element: 'approval-chart',
299
+ data: ApprovalData,
300
+ colors: ['#009900', '#990000'],
301
+ resize: true
302
+ });
303
  }else
304
  {
305
  ApprovalChart.setData(ApprovalData);
345
 
346
  html += "<tr>";
347
  html += "<td>"+jQuery.timeago(data.OrderActionData)+"</td>";
348
+ html += "<td>"+"<a href=" + prefix+ "/App/Operacao/Analise/PedidoPorCodigoEntidade?codigoEntidade="
349
  + data.ClientOrderId + "&entidadeID=10&visualizacao=true&t=" + loginToken + "&a=" + apiKey + " target=\"_blank\">" + data.ClientOrderId +"</a></td>";
350
+ html += "<td>"+ "$ "+ data.TotalOrderValue.toFixed(2) +"</td>";
351
  html += setStatus(data.Status);
352
  html += "</tr>";
 
 
 
 
 
353
  });
354
 
355
  html+="</tbody>";
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ClearSale_Total</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -13,11 +13,12 @@ Because of the nature of the market the country was born in, considered one of t
13
  We offer a 100% chargeback guarantee and a fully outsourced fraud management solution. We give you the final decision: (a) to sell - the order has a minimum risk of becoming a chargeback or (b) do not sell - we already checked the order and know that that order is a fraudulent one. As no order is automatically turned down, these orders have to be analyzed by people with special skills and training to detect subtle details to avoid turning down good customers.&#xD;
14
  We charge a fixed % only for approved transactions, regardless of whether the decision was automatic or not. The more orders we approve and the lower our client&#x2019;s chargebacks, the more Clearsale benefits. We also have an incentive to increase our instant decisions, since this improves our cost structure and the buying experience of our clients. &#xD;
15
  More than offering tools, Clearsale is always looking for the optimum balance between chargeback losses, orders rejected and response time.</description>
16
- <notes>Official ClearSale Module - First Version</notes>
 
17
  <authors><author><name>Filippe Farias</name><user>clearsale_dev</user><email>filippe.farias@clearsale.com.br</email></author></authors>
18
- <date>2015-10-21</date>
19
- <time>07:52:59</time>
20
- <contents><target name="magecommunity"><dir name="Clearsale"><dir name="Total"><dir name="Block"><dir name="Adminhtml"><file name="Totalbackend.php" hash="bf3d3c8c2cfef581dc62a2b8beb36574"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7fe9624e3b5d12ee4fb546ba14c02787"/></dir><dir name="Model"><dir name="Auth"><dir name="Business"><file name="Object.php" hash="4eb716abd8b432fdaff8fa6aef8259ec"/></dir><dir name="Entity"><file name="Credentials.php" hash="d8ff6a36386ac64e7e766d644e961b35"/><file name="RequestAuth.php" hash="df37f81b53b45ddac20458c5dad7d1f3"/><file name="ResponseAuth.php" hash="c7b3eada52068f1e8c4bd31c011b286f"/><file name="Token.php" hash="2063b5f0d8f298a76ec49a20f06f32a6"/></dir></dir><file name="Log.php" hash="be56332eb8a2a2dade25506a19875960"/><dir name="Mysql4"><dir name="Clearsaleorderdiagnostic"><file name="Collection.php" hash="65f6cd54dabc45d595de8b3c08918ee1"/></dir><file name="Clearsaleorderdiagnostic.php" hash="2063f0474c2f5ca8a83c436dbfdb9669"/></dir><file name="Observer.php" hash="4fa75a21c6c80224d02dc49aacb7ae76"/><dir name="Order"><dir name="Business"><file name="Object.php" hash="2b9be2d90e4baf6855874ea254424fc1"/></dir><dir name="Entity"><file name="Address.php" hash="0ac63b0aa32dd575a5cdb53537302876"/><file name="CustomField.php" hash="ef6a3f0ea7d0cfe0e337dfdbab284eca"/><file name="Diagnostic.php" hash="33a5ab29c4922eb1c346be728adcb744"/><file name="Item.php" hash="fb98f2820542ca7ba5fa59ffa52f4939"/><file name="Order.php" hash="33b6ec200b3efb86aa7fd7f12c95ef21"/><file name="Payment.php" hash="3e6ce3d532dfc39f43a281a28a652f01"/><file name="Person.php" hash="a8fe79c1969e66d05abb63695b9568a4"/><file name="Phone.php" hash="8d83b00a7b44aff9c65bcfd2ef016f23"/><file name="RequestOrder.php" hash="82acb64cc57474702a9de41d7bf55fef"/><file name="ResponseOrder.php" hash="6ea560c46c7c27e9d5c5e3dcfd111d4f"/><file name="Status.php" hash="75764850032d86c26d916c35eabcab9e"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Analysislocation"><file name="Values.php" hash="497e350002e5fb4d838d8dbe12bd7326"/></dir><dir name="Cron"><file name="Values.php" hash="bc7800dc2d2448c9c08d6750c61076e0"/></dir><dir name="Environment"><file name="Values.php" hash="98e50167e8876af3ddead50fcea5415a"/></dir><dir name="OrderStatus"><file name="Values.php" hash="609e547b49f3e9796e5c4b560fda526e"/></dir><dir name="Paymentmethod"><file name="Values.php" hash="a386e0181e0cd501e8c66c4ca8b18891"/></dir></dir></dir></dir><dir name="Utils"><file name="HttpHelper.php" hash="93f2f1a2479b681180e349eaa7485016"/><file name="HttpMessage.php" hash="1c451cce82d936e9a469dfe93206dce4"/><file name="Status.php" hash="be9db40193c88b9c7fcd91e1d6b8f5f9"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="TotalbackendController.php" hash="5c205a0cc263e651564f006e75d6f15b"/></dir><file name="IndexController.php" hash="61b59a9c52a8d4307639502c0949a1d8"/></dir><dir name="etc"><file name="config.xml" hash="a663bd29aea83f727298ad2510f4d14b"/><file name="system.xml" hash="0e642819ad7668919f0368078bad7984"/></dir><dir name="sql"><dir name="total_setup"><file name="mysql4-install-1.0.0.php" hash="b0af1f97fb704abfa3b9000dd37e3d2a"/></dir></dir></dir><file name="community - Atalho.lnk" hash="4b4457bb2e78c84dc97106da8cc0c598"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="total.xml " hash="b20fb23ff3df99b69874c8b6513b148f"/><file name="total.xml " hash="b20fb23ff3df99b69874c8b6513b148f"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="total.xml" hash="d7bde1fe02b175995340c5e2f3c71a45"/></dir><dir name="template"><dir name="total"><file name="fingerprint.phtml" hash="be3e9cbd03d479c8ba345ce19f487063"/><file name="mapper.phtml" hash="2e72faca91b0f0839d77c1db4e7d31b3"/><file name="meta_account_create.phtml" hash="9942098ce07732b0011e513da0fea91b"/><file name="meta_account_edit.phtml" hash="9f992ff686789d059a9a5ff4801e3884"/><file name="meta_cart.phtml" hash="c1bc637442009fc508f739955e87e32b"/><file name="meta_checkout.phtml" hash="1b116bfeeef54d69b662a4fa00ecb2fc"/><file name="meta_contact.phtml" hash="5d94309afc6cc08f2e9eed779215c8ee"/><file name="meta_home.phtml" hash="a5a2b442732d44a80bf129e2379d3f8d"/><file name="meta_pass_fail.phtml" hash="229549782a2f32a4eef327edbe22d035"/><file name="meta_password_reset.phtml" hash="d56ffddd342fc472bfb20151b150a8a7"/><file name="meta_product.html" hash="d91c0a3c7d1afbb1daa35dfce1dd1d5e"/><file name="meta_purchase_confirmation.phtml" hash="2ee03b7ee3f60bd1489c103020b215ab"/><file name="meta_search.phtml" hash="bb769f2a8d27d26b9b109dc8ad6ef064"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ClearSale_Total.xml" hash="52bf9a4e009edc9c011adb1c84d8716d"/></dir></target><target name="mage"><dir name="js"><dir name="clearsale"><dir name="total"><dir name="Graphs"><file name="graph-data.js" hash="efecaa29900ee4aac6c8a3e9619374e1"/><file name="graph-data.old.js" hash="a0544164a24cb574d3060518fbd4983c"/></dir><dir name="Plugin"><file name="morris.min.js" hash="fadac462637afd6cdc0cb0a0137629af"/><file name="raphael.min.js" hash="df3aee40d12beaa16159fa297d28c132"/></dir><file name="bootstrap.min.js" hash="046ba2b5f4cff7d2eaaa1af55caa9fd8"/><file name="formats.js" hash="6084ce895fb54436ecc842d78751b53d"/><file name="jquery-1.11.1.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-2.1.1.min.js" hash="e40ec2161fe7993196f23c8a07346306"/><file name="jquery.clearsale.js" hash="94e83745ccf9ab784331e181c029bd9b"/><file name="jquery.js" hash="3c9137d88a00b1ae0b41ff6a70571615"/><file name="noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="timeago.js" hash="b1e1d1a0576a9a952d2fdac4c3dd321f"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="clearsale"><dir name="font"><file name="klavikalight-osf-webfont.eot" hash="70c694623ae6e600d65b17cb767ec64a"/><file name="klavikalight-osf-webfont.svg" hash="318c533f3c8563ca910f9b74bb0acf41"/><file name="klavikalight-osf-webfont.ttf" hash="53adda2104cc31f2e2d332e372bd020e"/><file name="klavikalight-osf-webfont.woff" hash="2a0466f4aa6715c05dff3a62c37bec3d"/><file name="klavikalight-osf-webfont.woff2" hash="85bbd3b7ba594c02340da194b5b2d1b3"/><file name="klavikalight-plain-webfont.eot" hash="b83fe7b442d00705780147aa583d34f9"/><file name="klavikalight-plain-webfont.svg" hash="a0f73c6fc6dffbf3d18c63ec6c3b5191"/><file name="klavikalight-plain-webfont.ttf" hash="94609b6db82cfc5adb6a4b29603f551d"/><file name="klavikalight-plain-webfont.woff" hash="f704cce62e9b346845cc1111cc0f604b"/><file name="klavikalight-plain-webfont.woff2" hash="bcf62c18730f756a848bc1cb5b631bd3"/><file name="klavikamedium-osf-webfont.eot" hash="a6435da6686dfe15caf1b7b916a71d96"/><file name="klavikamedium-osf-webfont.svg" hash="c4ebeb1cb0df09e2717345b233555855"/><file name="klavikamedium-osf-webfont.ttf" hash="290323eee0539406adde3637294bae2b"/><file name="klavikamedium-osf-webfont.woff" hash="f35c8871e39ae9bad7b173bf02c2c111"/><file name="klavikamedium-osf-webfont.woff2" hash="d43a2625c3252dcf5405617c058be2b6"/><file name="klavikaregular-osf-webfont.eot" hash="8146f953bb696559fd3c277dad2e3075"/><file name="klavikaregular-osf-webfont.svg" hash="fa60750a7d4c93ed7a621e67321140cd"/><file name="klavikaregular-osf-webfont.ttf" hash="de531bd4e7e99df5d672bc253b886969"/><file name="klavikaregular-osf-webfont.woff" hash="f168b99aad67559207101a9a792f6a24"/><file name="klavikaregular-osf-webfont.woff2" hash="4d45eb7fd558c191c91bc0da5190784e"/></dir><dir name="total"><file name="app.css" hash="437bd0c5441986efc8ce0a53eeb4654f"/><file name="bootstrap.css" hash="d2ab08de4855f3f73d2ecec6da794293"/><file name="bootstrap.min.css" hash="3ab3438f85ad9f9e27e1af1facf0a9c4"/><file name="dashboard.css" hash="547897957c8a66d307a36ea9ae3c2fe0"/><dir name="fonts"><file name="Material-Design-Iconic-Font.eot" hash="83d896ed524d89eb7cb1273e26be3ea6"/><file name="Material-Design-Iconic-Font.svg" hash="6383f1e33e4159197aa854dfac4676e1"/><file name="Material-Design-Iconic-Font.ttf" hash="aa1af632841550199ebdf0c3cc1e47a6"/><file name="Material-Design-Iconic-Font.woff" hash="a2a1ba89e7f9d29f7d5aee76e8b9f7ab"/></dir><file name="material-design-iconic-font.min.css" hash="ed31cc228d731ae1f667d440cc00fceb"/><file name="morris.css" hash="36e70bf949fcdb7d0fe55fc16ce86445"/></dir></dir></dir></dir></dir></target></contents>
21
  <compatible/>
22
  <dependencies><required><php><min>4.4.1</min><max>5.6.13</max></php></required></dependencies>
23
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ClearSale_Total</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
13
  We offer a 100% chargeback guarantee and a fully outsourced fraud management solution. We give you the final decision: (a) to sell - the order has a minimum risk of becoming a chargeback or (b) do not sell - we already checked the order and know that that order is a fraudulent one. As no order is automatically turned down, these orders have to be analyzed by people with special skills and training to detect subtle details to avoid turning down good customers.&#xD;
14
  We charge a fixed % only for approved transactions, regardless of whether the decision was automatic or not. The more orders we approve and the lower our client&#x2019;s chargebacks, the more Clearsale benefits. We also have an incentive to increase our instant decisions, since this improves our cost structure and the buying experience of our clients. &#xD;
15
  More than offering tools, Clearsale is always looking for the optimum balance between chargeback losses, orders rejected and response time.</description>
16
+ <notes>Fix Sensitive Case bug&#xD;
17
+ </notes>
18
  <authors><author><name>Filippe Farias</name><user>clearsale_dev</user><email>filippe.farias@clearsale.com.br</email></author></authors>
19
+ <date>2015-11-17</date>
20
+ <time>18:09:52</time>
21
+ <contents><target name="magecommunity"><dir name="Clearsale"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><file name="Totalbackend.php" hash="9c218cb0199bdf5ec891bedb9072d43d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f2a142d88f110d7d200b87ab810605c0"/></dir><dir name="Model"><dir name="Auth"><dir name="Business"><file name="Object.php" hash="894450976750ba0902643ecf0528178e"/></dir><dir name="Entity"><file name="Credentials.php" hash="a0c74f0eb00025a4fa0ea1a5632cff25"/><file name="RequestAuth.php" hash="3b07965ef09be73b7ad672b97efb2a82"/><file name="ResponseAuth.php" hash="d4236e408c52abc32b19b90c2ae9ed67"/><file name="Token.php" hash="ab6b05a2b1bafe66bf42ef1c68a74008"/></dir></dir><dir name="Gateway"><file name="Authorizenet.php" hash="96f4eb08996b0e98f6d6cceddab97927"/></dir><file name="Log.php" hash="4ef1d30b39450a84919284b093b3f9b8"/><dir name="Mysql4"><dir name="Clearsaleorderdiagnostic"><file name="Collection.php" hash="65f6cd54dabc45d595de8b3c08918ee1"/></dir><file name="Clearsaleorderdiagnostic.php" hash="2063f0474c2f5ca8a83c436dbfdb9669"/></dir><file name="Observer.php" hash="7d32c019e467b20ef5dfe9d3c88fb4c4"/><dir name="Order"><dir name="Business"><file name="Object.php" hash="fb64b166ce833b355654a0509d5f2850"/></dir><dir name="Entity"><file name="Address.php" hash="ce9b49b7e914fd8578689c7a4f307771"/><file name="CustomField.php" hash="bfbe2c97fa78575a887d470d864dd723"/><file name="Diagnostic.php" hash="d96e05ff7fad3f619418b30729bec133"/><file name="Item.php" hash="9fe1b333deb3c7651c33e8ea0a769352"/><file name="Order.php" hash="74d8d917208014ad32c0ec22c8bd5874"/><file name="Payment.php" hash="f76c5abf01a17350fb10d06ac5b8e451"/><file name="Person.php" hash="19492db5e1a66cdff3a3725712dd55ff"/><file name="Phone.php" hash="9a47b48b2915685ea978e0d44c732dfc"/><file name="RequestOrder.php" hash="70d661afbb78db499b1ef665056567c9"/><file name="ResponseOrder.php" hash="21968f83636cadf91b6e5d7cb7db21a8"/><file name="Status.php" hash="de2201c06c9109ba28ae37eea9cc5a98"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Analysislocation"><file name="Values.php" hash="12cae58f6a03ca7c5f4fdef2562d27a9"/></dir><dir name="Cron"><file name="Values.php" hash="33d5913a2f4dd9ba0df91a10c729ee3f"/></dir><dir name="Environment"><file name="Values.php" hash="6a16de834d4510794a1814ae79699d0f"/></dir><dir name="OrderStatus"><file name="Values.php" hash="4a1eaedb47e5607001cbcd5c56878154"/></dir><dir name="Paymentmethod"><file name="Values.php" hash="00023fd6ebb78fc692cfe5f4d8757257"/></dir></dir></dir></dir><dir name="Utils"><file name="HttpHelper.php" hash="7c6d95a582702abf2257856ff88ab8fa"/><file name="HttpMessage.php" hash="81a7aab4bf241d7e9838a8edacf772e9"/><file name="Status.php" hash="249258c22c2ca482331679fb5c0f4d7d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="TotalbackendController.php" hash="b478a5e1cd956c2754766954ae632fa1"/></dir><file name="IndexController.php" hash="133738b83677f2bbf82163b4e11c4d84"/></dir><dir name="etc"><file name="config.xml" hash="f19514d4d6cc11a06b22bae2518d812c"/><file name="system.xml" hash="90ea1ff6f6eeb5453dd8282836476b53"/></dir><dir name="sql"><dir name="total_setup"><file name="mysql4-install-1.0.1.php" hash="b0af1f97fb704abfa3b9000dd37e3d2a"/></dir></dir></dir><dir name="Total"><dir name="Block"><dir name="Adminhtml"><file name="Totalbackend.php" hash="9c218cb0199bdf5ec891bedb9072d43d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f2a142d88f110d7d200b87ab810605c0"/></dir><dir name="Model"><dir name="Auth"><dir name="Business"><file name="Object.php" hash="894450976750ba0902643ecf0528178e"/></dir><dir name="Entity"><file name="Credentials.php" hash="a0c74f0eb00025a4fa0ea1a5632cff25"/><file name="RequestAuth.php" hash="3b07965ef09be73b7ad672b97efb2a82"/><file name="ResponseAuth.php" hash="d4236e408c52abc32b19b90c2ae9ed67"/><file name="Token.php" hash="ab6b05a2b1bafe66bf42ef1c68a74008"/></dir></dir><dir name="Gateway"><file name="Authorizenet.php" hash="96f4eb08996b0e98f6d6cceddab97927"/></dir><file name="Log.php" hash="4ef1d30b39450a84919284b093b3f9b8"/><dir name="Mysql4"><dir name="Clearsaleorderdiagnostic"><file name="Collection.php" hash="65f6cd54dabc45d595de8b3c08918ee1"/></dir><file name="Clearsaleorderdiagnostic.php" hash="2063f0474c2f5ca8a83c436dbfdb9669"/></dir><file name="Observer.php" hash="7d32c019e467b20ef5dfe9d3c88fb4c4"/><dir name="Order"><dir name="Business"><file name="Object.php" hash="fb64b166ce833b355654a0509d5f2850"/></dir><dir name="Entity"><file name="Address.php" hash="ce9b49b7e914fd8578689c7a4f307771"/><file name="CustomField.php" hash="bfbe2c97fa78575a887d470d864dd723"/><file name="Diagnostic.php" hash="d96e05ff7fad3f619418b30729bec133"/><file name="Item.php" hash="9fe1b333deb3c7651c33e8ea0a769352"/><file name="Order.php" hash="74d8d917208014ad32c0ec22c8bd5874"/><file name="Payment.php" hash="f76c5abf01a17350fb10d06ac5b8e451"/><file name="Person.php" hash="19492db5e1a66cdff3a3725712dd55ff"/><file name="Phone.php" hash="9a47b48b2915685ea978e0d44c732dfc"/><file name="RequestOrder.php" hash="70d661afbb78db499b1ef665056567c9"/><file name="ResponseOrder.php" hash="21968f83636cadf91b6e5d7cb7db21a8"/><file name="Status.php" hash="de2201c06c9109ba28ae37eea9cc5a98"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Analysislocation"><file name="Values.php" hash="12cae58f6a03ca7c5f4fdef2562d27a9"/></dir><dir name="Cron"><file name="Values.php" hash="33d5913a2f4dd9ba0df91a10c729ee3f"/></dir><dir name="Environment"><file name="Values.php" hash="6a16de834d4510794a1814ae79699d0f"/></dir><dir name="OrderStatus"><file name="Values.php" hash="4a1eaedb47e5607001cbcd5c56878154"/></dir><dir name="Paymentmethod"><file name="Values.php" hash="00023fd6ebb78fc692cfe5f4d8757257"/></dir></dir></dir></dir><dir name="Utils"><file name="HttpHelper.php" hash="7c6d95a582702abf2257856ff88ab8fa"/><file name="HttpMessage.php" hash="81a7aab4bf241d7e9838a8edacf772e9"/><file name="Status.php" hash="249258c22c2ca482331679fb5c0f4d7d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="TotalbackendController.php" hash="b478a5e1cd956c2754766954ae632fa1"/></dir><file name="IndexController.php" hash="133738b83677f2bbf82163b4e11c4d84"/></dir><dir name="etc"><file name="config.xml" hash="f19514d4d6cc11a06b22bae2518d812c"/><file name="system.xml" hash="90ea1ff6f6eeb5453dd8282836476b53"/></dir><dir name="sql"><dir name="total_setup"><file name="mysql4-install-1.0.1.php" hash="b0af1f97fb704abfa3b9000dd37e3d2a"/></dir></dir></dir><file name="community - Atalho.lnk" hash="4b4457bb2e78c84dc97106da8cc0c598"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="total.xml" hash="b20fb23ff3df99b69874c8b6513b148f"/></dir><dir name="template"><dir name="total"><file name="totalbackend.phtml" hash="57444b324c4cb61339e38410a43a752f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="total.xml" hash="f168b9cc007978873d595847cb457ec0"/></dir><dir name="template"><dir name="total"><file name="fingerprint.phtml" hash="e8904b02661505ebdc06f002930d4520"/><file name="mapper.phtml" hash="6b3b2c690d4c0509d497fc94433aaab9"/><file name="meta_account_create.phtml" hash="9942098ce07732b0011e513da0fea91b"/><file name="meta_account_edit.phtml" hash="9f992ff686789d059a9a5ff4801e3884"/><file name="meta_cart.phtml" hash="013250fb64b4dc6cf50082898c345657"/><file name="meta_checkout.phtml" hash="10e00a4bc18f4e07050fd440d3c3f290"/><file name="meta_contact.phtml" hash="7eef5f6c488368ca91dc43827f6d4fdc"/><file name="meta_home.phtml" hash="e53aeefb23c4e4b3a1380c659d49494e"/><file name="meta_pass_fail.phtml" hash="1404a1f3c07d0574fce666b72f770e32"/><file name="meta_password_reset.phtml" hash="a6ecdc56b080695e03499cad8f93dea5"/><file name="meta_product.html" hash="21e064ad8b3b6c8587b4e48a229a97b0"/><file name="meta_purchase_confirmation.phtml" hash="2ee03b7ee3f60bd1489c103020b215ab"/><file name="meta_search.phtml" hash="bb769f2a8d27d26b9b109dc8ad6ef064"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Clearsale_Total.xml" hash="c96beaaa6a467e1f5707a25f2a5ffec5"/></dir></target><target name="mage"><dir name="js"><dir name="clearsale"><dir name="total"><dir name="Graphs"><file name="graph-data.js" hash="cdff5f378f713d2863910bbad10f00c9"/><file name="graph-data.old.js" hash="a0544164a24cb574d3060518fbd4983c"/></dir><dir name="Plugin"><file name="morris.min.js" hash="fadac462637afd6cdc0cb0a0137629af"/><file name="raphael.min.js" hash="df3aee40d12beaa16159fa297d28c132"/></dir><file name="bootstrap.min.js" hash="046ba2b5f4cff7d2eaaa1af55caa9fd8"/><file name="formats.js" hash="6084ce895fb54436ecc842d78751b53d"/><file name="jquery-1.11.1.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-2.1.1.min.js" hash="e40ec2161fe7993196f23c8a07346306"/><file name="jquery.clearsale.js" hash="94e83745ccf9ab784331e181c029bd9b"/><file name="jquery.js" hash="3c9137d88a00b1ae0b41ff6a70571615"/><file name="noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="timeago.js" hash="b1e1d1a0576a9a952d2fdac4c3dd321f"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="clearsale"><dir name="font"><file name="klavikalight-osf-webfont.eot" hash="70c694623ae6e600d65b17cb767ec64a"/><file name="klavikalight-osf-webfont.svg" hash="318c533f3c8563ca910f9b74bb0acf41"/><file name="klavikalight-osf-webfont.ttf" hash="53adda2104cc31f2e2d332e372bd020e"/><file name="klavikalight-osf-webfont.woff" hash="2a0466f4aa6715c05dff3a62c37bec3d"/><file name="klavikalight-osf-webfont.woff2" hash="85bbd3b7ba594c02340da194b5b2d1b3"/><file name="klavikalight-plain-webfont.eot" hash="b83fe7b442d00705780147aa583d34f9"/><file name="klavikalight-plain-webfont.svg" hash="a0f73c6fc6dffbf3d18c63ec6c3b5191"/><file name="klavikalight-plain-webfont.ttf" hash="94609b6db82cfc5adb6a4b29603f551d"/><file name="klavikalight-plain-webfont.woff" hash="f704cce62e9b346845cc1111cc0f604b"/><file name="klavikalight-plain-webfont.woff2" hash="bcf62c18730f756a848bc1cb5b631bd3"/><file name="klavikamedium-osf-webfont.eot" hash="a6435da6686dfe15caf1b7b916a71d96"/><file name="klavikamedium-osf-webfont.svg" hash="c4ebeb1cb0df09e2717345b233555855"/><file name="klavikamedium-osf-webfont.ttf" hash="290323eee0539406adde3637294bae2b"/><file name="klavikamedium-osf-webfont.woff" hash="f35c8871e39ae9bad7b173bf02c2c111"/><file name="klavikamedium-osf-webfont.woff2" hash="d43a2625c3252dcf5405617c058be2b6"/><file name="klavikaregular-osf-webfont.eot" hash="8146f953bb696559fd3c277dad2e3075"/><file name="klavikaregular-osf-webfont.svg" hash="fa60750a7d4c93ed7a621e67321140cd"/><file name="klavikaregular-osf-webfont.ttf" hash="de531bd4e7e99df5d672bc253b886969"/><file name="klavikaregular-osf-webfont.woff" hash="f168b99aad67559207101a9a792f6a24"/><file name="klavikaregular-osf-webfont.woff2" hash="4d45eb7fd558c191c91bc0da5190784e"/></dir><dir name="total"><file name="app.css" hash="437bd0c5441986efc8ce0a53eeb4654f"/><file name="bootstrap.css" hash="d2ab08de4855f3f73d2ecec6da794293"/><file name="bootstrap.min.css" hash="3ab3438f85ad9f9e27e1af1facf0a9c4"/><file name="dashboard.css" hash="547897957c8a66d307a36ea9ae3c2fe0"/><dir name="fonts"><file name="Material-Design-Iconic-Font.eot" hash="83d896ed524d89eb7cb1273e26be3ea6"/><file name="Material-Design-Iconic-Font.svg" hash="6383f1e33e4159197aa854dfac4676e1"/><file name="Material-Design-Iconic-Font.ttf" hash="aa1af632841550199ebdf0c3cc1e47a6"/><file name="Material-Design-Iconic-Font.woff" hash="a2a1ba89e7f9d29f7d5aee76e8b9f7ab"/></dir><file name="material-design-iconic-font.min.css" hash="ed31cc228d731ae1f667d440cc00fceb"/><file name="morris.css" hash="36e70bf949fcdb7d0fe55fc16ce86445"/></dir></dir></dir></dir></dir></target></contents>
22
  <compatible/>
23
  <dependencies><required><php><min>4.4.1</min><max>5.6.13</max></php></required></dependencies>
24
  </package>