ClearSale_Total - Version 1.1.0

Version Notes

New Features.

Multi-store location.
Retry Cron Job.
Get Order Status Update.

Download this release

Release Info

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


Code changes from version 1.0.2 to 1.1.0

Files changed (64) hide show
  1. app/code/community/Clearsale/Integration/Block/Adminhtml/Totalbackend.php +0 -5
  2. app/code/community/Clearsale/Integration/Helper/Data.php +0 -5
  3. app/code/community/Clearsale/Integration/Model/Auth/Business/Object.php +0 -33
  4. app/code/community/Clearsale/Integration/Model/Auth/Entity/Credentials.php +0 -9
  5. app/code/community/Clearsale/Integration/Model/Auth/Entity/RequestAuth.php +0 -9
  6. app/code/community/Clearsale/Integration/Model/Auth/Entity/ResponseAuth.php +0 -9
  7. app/code/community/Clearsale/Integration/Model/Auth/Entity/Token.php +0 -7
  8. app/code/community/Clearsale/Integration/Model/Gateway/Authorizenet.php +0 -15
  9. app/code/community/Clearsale/Integration/Model/Log.php +0 -19
  10. app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic.php +0 -8
  11. app/code/community/Clearsale/Integration/Model/Mysql4/Clearsaleorderdiagnostic/Collection.php +0 -12
  12. app/code/community/Clearsale/Integration/Model/Observer.php +0 -603
  13. app/code/community/Clearsale/Integration/Model/Order/Business/Object.php +0 -98
  14. app/code/community/Clearsale/Integration/Model/Order/Entity/Address.php +0 -11
  15. app/code/community/Clearsale/Integration/Model/Order/Entity/CustomField.php +0 -9
  16. app/code/community/Clearsale/Integration/Model/Order/Entity/Diagnostic.php +0 -12
  17. app/code/community/Clearsale/Integration/Model/Order/Entity/Item.php +0 -10
  18. app/code/community/Clearsale/Integration/Model/Order/Entity/Order.php +0 -28
  19. app/code/community/Clearsale/Integration/Model/Order/Entity/Payment.php +0 -15
  20. app/code/community/Clearsale/Integration/Model/Order/Entity/Person.php +0 -23
  21. app/code/community/Clearsale/Integration/Model/Order/Entity/Phone.php +0 -9
  22. app/code/community/Clearsale/Integration/Model/Order/Entity/RequestOrder.php +0 -12
  23. app/code/community/Clearsale/Integration/Model/Order/Entity/ResponseOrder.php +0 -11
  24. app/code/community/Clearsale/Integration/Model/Order/Entity/Status.php +0 -14
  25. app/code/community/Clearsale/Integration/Model/System/Config/Source/Analysislocation/Values.php +0 -18
  26. app/code/community/Clearsale/Integration/Model/System/Config/Source/Cron/Values.php +0 -30
  27. app/code/community/Clearsale/Integration/Model/System/Config/Source/Environment/Values.php +0 -18
  28. app/code/community/Clearsale/Integration/Model/System/Config/Source/OrderStatus/Values.php +0 -24
  29. app/code/community/Clearsale/Integration/Model/System/Config/Source/Paymentmethod/Values.php +0 -20
  30. app/code/community/Clearsale/Integration/Model/Utils/HttpHelper.php +0 -45
  31. app/code/community/Clearsale/Integration/Model/Utils/HttpMessage.php +0 -9
  32. app/code/community/Clearsale/Integration/Model/Utils/Status.php +0 -42
  33. app/code/community/Clearsale/Integration/controllers/Adminhtml/TotalbackendController.php +0 -12
  34. app/code/community/Clearsale/Integration/controllers/IndexController.php +0 -14
  35. app/code/community/Clearsale/Integration/etc/config.xml +0 -189
  36. app/code/community/Clearsale/Integration/etc/system.xml +0 -115
  37. app/code/community/Clearsale/Integration/sql/total_setup/mysql4-install-1.0.1.php +0 -39
  38. app/code/community/Clearsale/Total/Block/Adminhtml/Totalbackend.php +4 -4
  39. app/code/community/Clearsale/Total/Helper/Data.php +4 -4
  40. app/code/community/Clearsale/Total/Model/Auth/Business/Object.php +18 -2
  41. app/code/community/Clearsale/Total/Model/Authorizenet.php +30 -0
  42. app/code/community/Clearsale/Total/Model/Gateway/Authorizenet.php +15 -15
  43. app/code/community/Clearsale/Total/Model/Mysql4/Clearsaleorderdiagnostic.php +7 -7
  44. app/code/community/Clearsale/Total/Model/Mysql4/Clearsaleorderdiagnostic/Collection.php +11 -11
  45. app/code/community/Clearsale/Total/Model/Observer.php +442 -100
  46. app/code/community/Clearsale/Total/Model/Order/Business/Object.php +83 -19
  47. app/code/community/Clearsale/Total/Model/Order/Entity/RequestOrder.php +0 -12
  48. app/code/community/Clearsale/Total/Model/System/Config/Source/Analysislocation/Values.php +9 -9
  49. app/code/community/Clearsale/Total/Model/System/Config/Source/Cron/Values.php +21 -21
  50. app/code/community/Clearsale/Total/Model/System/Config/Source/Environment/Values.php +9 -9
  51. app/code/community/Clearsale/Total/Model/System/Config/Source/OrderStatus/Values.php +21 -21
  52. app/code/community/Clearsale/Total/Model/Utils/HttpHelper.php +31 -5
  53. app/code/community/Clearsale/Total/controllers/Adminhtml/TotalbackendController.php +11 -11
  54. app/code/community/Clearsale/Total/controllers/IndexController.php +13 -13
  55. app/code/community/Clearsale/Total/etc/config.xml +32 -24
  56. app/code/community/Clearsale/Total/etc/system.xml +24 -17
  57. app/code/community/Clearsale/Total/sql/total_setup/mysql4-install-1.0.1.php +38 -38
  58. app/code/community/Clearsale/Total/sql/total_setup/mysql4-upgrade-1.0.3-1.1.0.php +21 -0
  59. app/code/community/Clearsale/community - Atalho.lnk +0 -0
  60. app/design/frontend/base/default/template/total/fingerprint.phtml +13 -0
  61. app/etc/modules/Clearsale_Total.xml +1 -1
  62. clearsalegetorders.php +19 -0
  63. clearsaleretry.php +28 -0
  64. package.xml +11 -6
app/code/community/Clearsale/Integration/Block/Adminhtml/Totalbackend.php DELETED
@@ -1,5 +0,0 @@
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 DELETED
@@ -1,5 +0,0 @@
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 DELETED
@@ -1,33 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,19 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,603 +0,0 @@
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 DELETED
@@ -1,98 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,24 +0,0 @@
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 DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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 DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,42 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,189 +0,0 @@
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 DELETED
@@ -1,115 +0,0 @@
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/Integration/sql/total_setup/mysql4-install-1.0.1.php DELETED
@@ -1,39 +0,0 @@
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/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
@@ -17,7 +17,15 @@ public function login($enviroment) {
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) {
@@ -27,7 +35,15 @@ public function logout($enviroment) {
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
 
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
+
21
+ $credentials = "";
22
+
23
+ if($response->HttpCode == 200)
24
+ {
25
+ $credentials = json_decode($response->Body);
26
+ }
27
+
28
+ return $credentials;
29
  }
30
 
31
  public function logout($enviroment) {
35
  $authRequest->Login->ClientSecret =Mage::getStoreConfig("clearsale_total/general/clientsecret");
36
  $url = $enviroment."api/auth/logout/";
37
  $response = $this->Http->postData($authRequest, $url);
38
+
39
+ $credentials = "";
40
+
41
+ if($response->HttpCode == 200)
42
+ {
43
+ $credentials = json_decode($response->Body);
44
+ }
45
+
46
+ return $credentials;
47
  }
48
  }
49
 
app/code/community/Clearsale/Total/Model/Authorizenet.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Clearsale_Total_Model_Authorizenet extends Mage_Paygate_Model_Authorizenet
4
+ {
5
+ protected function _registercard(varien_object $response, mage_sales_model_order_payment $payment)
6
+ {
7
+
8
+ try
9
+ {
10
+
11
+ $csLog = Mage::getSingleton('total/log');
12
+ $csLog->log("Teste");
13
+
14
+ $cardInfo = parent::_registercard($response,$payment);
15
+
16
+ $avs =$response->getAvsResultCode();
17
+
18
+ $responseCode = $response->getCardCodeResponseCode();
19
+
20
+ $payment->setAdditionalInformation('clearsaleCCAvs', $avs);
21
+ $payment->setAdditionalInformation('clearsaleCCResponseCode', $responseCode);
22
+ return $cardInfo;
23
+
24
+ }catch (Exception $e) {
25
+ $csLog = Mage::getSingleton('total/log');
26
+ $csLog->log($e->getMessage());
27
+ }
28
+
29
+ }
30
+ }
app/code/community/Clearsale/Total/Model/Gateway/Authorizenet.php CHANGED
@@ -1,15 +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
- }
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/Mysql4/Clearsaleorderdiagnostic.php CHANGED
@@ -1,8 +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
  }
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/Total/Model/Mysql4/Clearsaleorderdiagnostic/Collection.php CHANGED
@@ -1,12 +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
 
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/Total/Model/Observer.php CHANGED
@@ -1,5 +1,16 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
3
  class Clearsale_Total_Model_Observer
4
  {
5
 
@@ -17,36 +28,52 @@ class Clearsale_Total_Model_Observer
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
 
@@ -69,35 +96,45 @@ class Clearsale_Total_Model_Observer
69
 
70
  if($orders)
71
  {
72
- $environment = Mage::getStoreConfig("clearsale_total/general/environment");
 
 
 
 
 
 
73
  $authBO = Mage::getModel('total/auth_business_object');
74
  $authResponse = $authBO->login($environment);
75
- $orderBO = Mage::getModel('total/order_business_object');
76
 
77
- if($authResponse)
78
- {
79
- foreach ($orders as $order) {
80
-
81
  $orderId = $order->getRealOrderId();
82
  $requestOrder = Mage::getModel('total/order_entity_requestorder');
83
- $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
84
  $requestOrder->LoginToken = $authResponse->Token->Value;;
85
- $requestOrder->AnalysisLocation = "USA";//Mage::getStoreConfig("clearsale_total/general/analysislocation");
86
  $requestOrder->Orders = array();
87
  $requestOrder->Orders[0] = $orderId;
88
- $ResponseOrder = $orderBO->get($requestOrder,$environment);
89
- $orderBO->Update($ResponseOrder->Orders[0]);
90
-
91
- $order = $order->loadByIncrementId($orderId);
92
- if($order->getStatus() == 'approved_clearsale')
93
  {
94
- $createInvoice = Mage::getStoreConfig("clearsale_total/general/create_invoice");
95
- if($createInvoice)
 
 
 
96
  {
97
- echo "Criar Invoice <br />";
98
- $this->createInvoice($order);
 
 
 
 
 
99
  }
100
- }
101
  }
102
  }
103
  }
@@ -115,7 +152,7 @@ class Clearsale_Total_Model_Observer
115
  if (!$email)
116
  {
117
  $email = $order->getBillingAddress()->getEmail();
118
- }
119
 
120
  if($location == "BRA")
121
  {
@@ -132,7 +169,7 @@ class Clearsale_Total_Model_Observer
132
 
133
  $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
134
  $clearsaleOrder->ID = $order->getRealOrderId();
135
- $clearsaleOrder->IP = Mage::helper('core/http')->getRemoteAddr();
136
  $clearsaleOrder->Currency = $currency;
137
  $clearsaleOrder->Date = $date;
138
  $clearsaleOrder->Reanalysis = $isReanalysis;
@@ -144,8 +181,13 @@ class Clearsale_Total_Model_Observer
144
 
145
  $billingAddress = $order->getBillingAddress();
146
  $shippingAddress = $order->getShippingAddress();
 
147
  $dob = $customer->getDob();
148
- $dob = $date;
 
 
 
 
149
 
150
  if(!$billingAddress)
151
  {
@@ -181,48 +223,28 @@ class Clearsale_Total_Model_Observer
181
 
182
  if($payment->getAdditionalInformation('clearsaleCCNumber'))
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
- $paymentData = $payment->getData('cc_type');
193
-
194
- if($paymentData)
195
- {
196
- $paymentData = strtolower($paymentData);
197
- }
198
-
199
- if (strripos($paymentData, "diners") !== false)
200
- $creditcardBrand = 1;
201
-
202
- if (strripos($paymentData, "mastercard") !== false)
203
- $creditcardBrand = 2;
204
-
205
- if (strripos($paymentData, "visa") !== false)
206
- $creditcardBrand = 3;
207
-
208
- if ((strripos($paymentData, "amex") !== false) || (strripos($paymentData, "american express") !== false))
209
- $creditcardBrand = 5;
210
-
211
- if (strripos($paymentData, "hipercard") !== false)
212
- $creditcardBrand = 6;
213
-
214
- if (strripos($paymentData, "aura") !== false)
215
- $creditcardBrand = 7;
216
-
217
- if (strripos($paymentData, "carrefour") !== false)
218
- $creditcardBrand = 8;
219
-
220
- $clearsaleOrder->Payments[$paymentIndex]->CardEndNumber = $payment->getAdditionalInformation('clearsaleCCLast4');
221
- $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
222
- $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getAdditionalInformation('clearsaleCCHolderName');
223
- $clearsaleOrder->Payments[$paymentIndex]->CardType = $creditcardBrand;
224
- $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  }
227
  }
228
 
@@ -233,6 +255,7 @@ class Clearsale_Total_Model_Observer
233
  $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
234
  $clearsaleOrder->BillingData->ID = "1";
235
  $clearsaleOrder->BillingData->Email = $email;
 
236
  $clearsaleOrder->BillingData->BirthDate = $dob;
237
  $clearsaleOrder->BillingData->Name = $billingName;
238
  $clearsaleOrder->BillingData->Type = 1;
@@ -240,15 +263,48 @@ class Clearsale_Total_Model_Observer
240
  $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
241
  $clearsaleOrder->BillingData->Address->Country = $countryname;
242
  $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
 
 
 
 
 
243
  $arr = explode(' ',trim($billingAddress->getStreetFull()));
244
  $clearsaleOrder->BillingData->Address->Number = $arr[0];
245
- $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
246
- $clearsaleOrder->BillingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
247
- $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
248
- $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
249
- $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
250
- $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
251
- $clearsaleOrder->BillingData->Phones[0]->Type = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  $countryCode = $shippingAddress->getCountry();
254
  $country = Mage::getModel('directory/country')->loadByCode($countryCode);
@@ -266,15 +322,51 @@ class Clearsale_Total_Model_Observer
266
  $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
267
  $clearsaleOrder->ShippingData->Address->Country = $countryname;
268
  $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
 
 
 
 
 
 
269
  $arr = explode(' ',trim($shippingAddress->getStreetFull()));
270
  $clearsaleOrder->ShippingData->Address->Number = $arr[0];
271
- $clearsaleOrder->ShippingData->Address->State = $shippingAddress->getRegion();
272
- $clearsaleOrder->ShippingData->Address->ZipCode = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
273
- $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
274
- $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 3);
275
- $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
276
- $clearsaleOrder->ShippingData->Phones[0]->Number = $shippingPhone;
277
- $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
  $itemIndex = 0;
280
  $TotalItems = 0;
@@ -285,7 +377,6 @@ class Clearsale_Total_Model_Observer
285
  $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
286
  $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
287
  $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
288
- //$clearsaleOrder->Items[0]->Category = getCategoryName($item);
289
  $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
290
  $itemIndex++;
291
  }
@@ -304,7 +395,46 @@ class Clearsale_Total_Model_Observer
304
  }
305
  }
306
 
307
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  public function getCategoryName($product)
310
  {
@@ -362,22 +492,234 @@ class Clearsale_Total_Model_Observer
362
 
363
  public function getCCInfo($order) {
364
 
365
- $payment = $order->getPayment();
366
- $cc = $payment->getCcNumber();
367
-
368
- if(isset($cc))
369
  {
370
-
371
  $payment = $order->getPayment();
372
- $last4 = substr($payment->getCcNumber(),(strlen($cc)-4),4);
373
- $bin = substr($payment->getCcNumber(),0,6);
374
 
375
- $number = $bin."XX-XXXXX-".$last4;
376
- $payment->setAdditionalInformation('clearsaleCCBin', $bin);
377
- $payment->setAdditionalInformation('clearsaleCCLast4', $last4);
378
- $payment->setAdditionalInformation('clearsaleCCNumber', $number);
379
- $payment->setAdditionalInformation('clearsaleCcOwner', $payment->getCcOwner());
 
 
 
 
 
 
 
 
 
 
 
380
 
 
 
 
381
  }
382
  }
383
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
13
+
14
  class Clearsale_Total_Model_Observer
15
  {
16
 
28
  $isReanalysis = false;
29
  $payment = $order->getPayment();
30
  $environment = Mage::getStoreConfig("clearsale_total/general/environment");
31
+ $analysisLocation = Mage::getStoreConfig("clearsale_total/general/analysislocation");
32
  $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
33
 
34
  if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
35
  {
36
  $authBO = Mage::getModel('total/auth_business_object');
37
  $authResponse = $authBO->login($environment);
38
+ $clearSaleOrder = $this->toClearsaleOrderObject($order,$isReanalysis,$analysisLocation);
39
  $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
40
  $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key");
41
  $requestOrder->LoginToken = $authResponse->Token->Value;
42
+ $requestOrder->AnalysisLocation = $analysisLocation;
43
  $requestOrder->Orders[0] = $clearSaleOrder;
44
 
45
  $orderBO = Mage::getModel('total/order_business_object');
46
+
47
+ $response = $orderBO->send($requestOrder,$environment);
48
 
49
+ if($response->HttpCode == 200)
50
  {
51
+ $orderResponse = json_decode($response->Body);
52
+
53
+ if($orderResponse)
54
  {
55
+ if($orderResponse->Orders)
56
+ {
57
+ $orderBO->save($orderResponse->Orders[0]);
58
+ }
59
  }
60
+ }else
61
+ {
62
+ $message[1] = $response->Body;
63
+ $orderBO->createOrderControl($order->getRealOrderId(),json_encode($message));
64
+ }
65
  }
66
  }
67
  }
68
  catch (Exception $e) {
69
+
70
  $csLog = Mage::getSingleton('total/log');
71
+ $csLog->log($e->getMessage());
72
+ $message = array();
73
+ $message[1] = $e->getMessage();
74
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
75
+ $orderBO = Mage::getModel('total/order_business_object');
76
+ $orderBO->createOrderControl($incrementId,json_encode($message));
77
 
78
  }
79
 
96
 
97
  if($orders)
98
  {
99
+
100
+ foreach ($orders as $order) {
101
+
102
+ $storeId = $order->getStoreId();
103
+
104
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment",$storeId);
105
+ $analysisLocation = Mage::getStoreConfig("clearsale_total/general/analysislocation",$storeId);
106
  $authBO = Mage::getModel('total/auth_business_object');
107
  $authResponse = $authBO->login($environment);
108
+ $orderBO = Mage::getModel('total/order_business_object');
109
 
110
+ if($authResponse)
111
+ {
 
 
112
  $orderId = $order->getRealOrderId();
113
  $requestOrder = Mage::getModel('total/order_entity_requestorder');
114
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key",$storeId);
115
  $requestOrder->LoginToken = $authResponse->Token->Value;;
116
+ $requestOrder->AnalysisLocation = $analysisLocation;
117
  $requestOrder->Orders = array();
118
  $requestOrder->Orders[0] = $orderId;
119
+ $response = $orderBO->get($requestOrder,$environment);
120
+
121
+ if($response->HttpCode == 200)
 
 
122
  {
123
+ $responseOrder = json_decode($response->Body);
124
+ $orderBO->Update($responseOrder->Orders[0]);
125
+
126
+ $order = $order->loadByIncrementId($orderId);
127
+ if($order->getStatus() == 'approved_clearsale')
128
  {
129
+ $createInvoice = Mage::getStoreConfig("clearsale_total/general/create_invoice");
130
+
131
+ if($createInvoice)
132
+ {
133
+ echo "Criar Invoice <br />";
134
+ $this->createInvoice($order);
135
+ }
136
  }
137
+ }
138
  }
139
  }
140
  }
152
  if (!$email)
153
  {
154
  $email = $order->getBillingAddress()->getEmail();
155
+ }
156
 
157
  if($location == "BRA")
158
  {
169
 
170
  $clearsaleOrder = new Clearsale_Total_Model_Order_Entity_Order();
171
  $clearsaleOrder->ID = $order->getRealOrderId();
172
+ $clearsaleOrder->IP = $order->getRemoteIp();
173
  $clearsaleOrder->Currency = $currency;
174
  $clearsaleOrder->Date = $date;
175
  $clearsaleOrder->Reanalysis = $isReanalysis;
181
 
182
  $billingAddress = $order->getBillingAddress();
183
  $shippingAddress = $order->getShippingAddress();
184
+
185
  $dob = $customer->getDob();
186
+
187
+ if(!$dob)
188
+ {
189
+ $dob = $date;
190
+ }
191
 
192
  if(!$billingAddress)
193
  {
223
 
224
  if($payment->getAdditionalInformation('clearsaleCCNumber'))
225
  {
226
+ $clearsaleOrder->Payments[$paymentIndex]->CardEndNumber = $payment->getAdditionalInformation('clearsaleCCLast4');
227
+ $clearsaleOrder->Payments[$paymentIndex]->CardBin = $payment->getAdditionalInformation('clearsaleCCBin');
228
+ $clearsaleOrder->Payments[$paymentIndex]->CardHolderName = $payment->getAdditionalInformation('clearsaleCcOwner');
229
+ $clearsaleOrder->Payments[$paymentIndex]->CardType = $this->cardType($payment->getAdditionalInformation('clearsaleCCNumber'));
230
+ $clearsaleOrder->Payments[$paymentIndex]->PaymentTypeID = 1;
231
+ $clearsaleOrder->Payments[$paymentIndex]->Type = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
 
233
+ if($payment->getAdditionalInformation('clearsaleCCAvs'))
234
+ {
235
+ $clearsaleOrder->CustomFields = array();
236
+
237
+ //AVS
238
+ $clearsaleOrder->CustomFields[0] = new Clearsale_Total_Model_Order_Entity_CustomField();
239
+ $clearsaleOrder->Customfields[0]->Type = "String";
240
+ $clearsaleOrder->Customfields[0]->FieldName = "AVS_RESPONSE";
241
+ $clearsaleOrder->Customfields[0]->Value = $payment->getAdditionalInformation('clearsaleCCBin');
242
+
243
+ //Credicard Response Code
244
+ $clearsaleOrder->CustomFields[1] = new Clearsale_Total_Model_Order_Entity_CustomField();
245
+ $clearsaleOrder->Customfields[1]->Type = "String";
246
+ $clearsaleOrder->Customfields[1]->FieldName = "CC_RESPONSE";
247
+ $clearsaleOrder->Customfields[1]->Value = $payment->getAdditionalInformation('clearsaleCCBin');
248
  }
249
  }
250
 
255
  $clearsaleOrder->BillingData = new Clearsale_Total_Model_Order_Entity_Person();
256
  $clearsaleOrder->BillingData->ID = "1";
257
  $clearsaleOrder->BillingData->Email = $email;
258
+ $clearsaleOrder->BillingData->LegalDocument = $legalDocument;
259
  $clearsaleOrder->BillingData->BirthDate = $dob;
260
  $clearsaleOrder->BillingData->Name = $billingName;
261
  $clearsaleOrder->BillingData->Type = 1;
263
  $clearsaleOrder->BillingData->Address->City = $billingAddress->getCity();
264
  $clearsaleOrder->BillingData->Address->Country = $countryname;
265
  $clearsaleOrder->BillingData->Address->Street = $billingAddress->getStreet(1);
266
+ $clearsaleOrder->BillingData->Address->Comp = $billingAddress->getStreet(2);
267
+ if($billingAddress->getStreet(4))
268
+ {
269
+ $clearsaleOrder->BillingData->Address->County = $billingAddress->getStreet(4);
270
+ }
271
  $arr = explode(' ',trim($billingAddress->getStreetFull()));
272
  $clearsaleOrder->BillingData->Address->Number = $arr[0];
273
+ if($shippingAddress->getRegion())
274
+ {
275
+ $clearsaleOrder->BillingData->Address->State = $shippingAddress->getRegion();
276
+ }else
277
+ {
278
+ $clearsaleOrder->BillingData->Address->State = "**";
279
+ }
280
+
281
+ $zipcodeBilling = preg_replace('/[^0-9]/', '', $billingAddress->getPostcode());
282
+
283
+ if($zipcodeBilling)
284
+ {
285
+ $clearsaleOrder->BillingData->Address->ZipCode = $zipcodeBilling;
286
+ }else
287
+ {
288
+ $clearsaleOrder->BillingData->Address->ZipCode = "XXX";
289
+ }
290
+
291
+ if($location == "BRA")
292
+ {
293
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
294
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 2);
295
+ $clearsaleOrder->BillingData->Phones[0]->Number = substr($billingPhone, 2, 9);
296
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "55";
297
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
298
+ }else
299
+ {
300
+ $clearsaleOrder->BillingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
301
+ $clearsaleOrder->BillingData->Phones[0]->AreaCode = substr($billingPhone, 0, 3);
302
+ $clearsaleOrder->BillingData->Phones[0]->Number = $billingPhone;
303
+ $clearsaleOrder->BillingData->Phones[0]->CountryCode = "1";
304
+ $clearsaleOrder->BillingData->Phones[0]->Type = 1;
305
+ }
306
+
307
+
308
 
309
  $countryCode = $shippingAddress->getCountry();
310
  $country = Mage::getModel('directory/country')->loadByCode($countryCode);
322
  $clearsaleOrder->ShippingData->Address->City = $shippingAddress->getCity();
323
  $clearsaleOrder->ShippingData->Address->Country = $countryname;
324
  $clearsaleOrder->ShippingData->Address->Street = $shippingAddress->getStreet(1);
325
+ $clearsaleOrder->ShippingData->Address->Comp = $shippingAddress->getStreet(2);
326
+
327
+ if($shippingAddress->getStreet(4))
328
+ {
329
+ $clearsaleOrder->ShippingData->Address->County = $shippingAddress->getStreet(4);
330
+ }
331
  $arr = explode(' ',trim($shippingAddress->getStreetFull()));
332
  $clearsaleOrder->ShippingData->Address->Number = $arr[0];
333
+
334
+ $shippingState = $shippingAddress->getRegion();
335
+
336
+ if($shippingState)
337
+ {
338
+ $clearsaleOrder->ShippingData->Address->State = $shippingState;
339
+ }else
340
+ {
341
+ $clearsaleOrder->ShippingData->Address->State = "**";
342
+ }
343
+
344
+ $zipcodeShipping = preg_replace('/[^0-9]/', '', $shippingAddress->getPostcode());
345
+
346
+ if($zipcodeShipping)
347
+ {
348
+ $clearsaleOrder->ShippingData->Address->ZipCode = $zipcodeShipping;
349
+ }else
350
+ {
351
+ $clearsaleOrder->ShippingData->Address->ZipCode = "XXX";
352
+ }
353
+
354
+
355
+ if($location == "BRA")
356
+ {
357
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
358
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 2);
359
+ $clearsaleOrder->ShippingData->Phones[0]->Number = substr($shippingPhone, 2, 9);
360
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "55";
361
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
362
+ }else
363
+ {
364
+ $clearsaleOrder->ShippingData->Phones[0] = new Clearsale_Total_Model_Order_Entity_Phone();
365
+ $clearsaleOrder->ShippingData->Phones[0]->AreaCode = substr($shippingPhone, 0, 3);
366
+ $clearsaleOrder->ShippingData->Phones[0]->Number = $shippingPhone;
367
+ $clearsaleOrder->ShippingData->Phones[0]->CountryCode = "1";
368
+ $clearsaleOrder->ShippingData->Phones[0]->Type = 1;
369
+ }
370
 
371
  $itemIndex = 0;
372
  $TotalItems = 0;
377
  $clearsaleOrder->Items[$itemIndex]->ProductId = $item->getSku();
378
  $clearsaleOrder->Items[$itemIndex]->ProductTitle = $item->getName();
379
  $clearsaleOrder->Items[$itemIndex]->Quantity = intval($item->getQtyOrdered());
 
380
  $TotalItems += $clearsaleOrder->Items[$itemIndex]->Price;
381
  $itemIndex++;
382
  }
395
  }
396
  }
397
 
398
+ public function cardType($number)
399
+ {
400
+ $number = preg_replace('/[^\d]/','',$number);
401
+
402
+ if (preg_match('/^3[47][0-9]{13}$/',$number))
403
+ {
404
+ //Amex
405
+ return 5;
406
+ }
407
+ elseif (preg_match('/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',$number))
408
+ {
409
+ //Diners
410
+ return 1;
411
+ }
412
+ elseif (preg_match('/^6(?:011|5[0-9][0-9])[0-9]{12}$/',$number))
413
+ {
414
+ // return 'Discover';
415
+ return 4;
416
+ }
417
+ elseif (preg_match('/^(?:2131|1800|35\d{3})\d{11}$/',$number))
418
+ {
419
+ // return 'JCB';
420
+ return 4;
421
+ }
422
+ elseif (preg_match('/^5[1-5][0-9]{14}$/',$number))
423
+ {
424
+ //return 'MasterCard';
425
+ return 2;
426
+ }
427
+ elseif (preg_match('/^4[0-9]{12}(?:[0-9]{3})?$/',$number))
428
+ {
429
+ // return 'Visa';
430
+ return 3;
431
+ }
432
+ else
433
+ {
434
+ return 4;
435
+ }
436
+ }
437
+
438
 
439
  public function getCategoryName($product)
440
  {
492
 
493
  public function getCCInfo($order) {
494
 
495
+ try
 
 
 
496
  {
 
497
  $payment = $order->getPayment();
498
+ $cc = $payment->getCcNumber();
 
499
 
500
+ if(isset($cc))
501
+ {
502
+ $payment = $order->getPayment();
503
+ $last4 = substr($payment->getCcNumber(),(strlen($cc)-4),4);
504
+ $bin = substr($payment->getCcNumber(),0,6);
505
+
506
+ $number = $bin."XX-XXXXX-".$last4;
507
+ $payment->setAdditionalInformation('clearsaleCCBin', $bin);
508
+ $payment->setAdditionalInformation('clearsaleCCLast4', $last4);
509
+ $payment->setAdditionalInformation('clearsaleCCNumber', $number);
510
+ $payment->setAdditionalInformation('clearsaleCcOwner', $payment->getCcOwner());
511
+
512
+ }
513
+
514
+ }
515
+ catch (Exception $e) {
516
 
517
+ $csLog = Mage::getSingleton('total/log');
518
+ $csLog->log($e->getMessage());
519
+
520
  }
521
  }
522
+
523
+ public function sendSpecificOrder($orderId)
524
+ {
525
+ try {
526
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
527
+
528
+ if ($isActive)
529
+ {
530
+
531
+ $order = new Mage_Sales_Model_Order();
532
+ $order->loadByIncrementId($orderId);
533
+ $isReanalysis = false;
534
+ $storeId = $order->getStoreId();
535
+ $payment = $order->getPayment();
536
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment",$storeId);
537
+ $analysisLocation = Mage::getStoreConfig("clearsale_total/general/analysislocation",$storeId);
538
+ $CreditcardMethods = explode(",", Mage::getStoreConfig("clearsale_total/general/credicardmethod"));
539
+
540
+ if (in_array($payment->getMethodInstance()->getCode(), $CreditcardMethods))
541
+ {
542
+ $authBO = Mage::getModel('total/auth_business_object');
543
+ $authResponse = $authBO->login($environment);
544
+ $clearSaleOrder = $this->toClearsaleOrderObject($order,$isReanalysis,$analysisLocation);
545
+ $requestOrder = new Clearsale_Total_Model_Order_Entity_RequestOrder();
546
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key",$storeId);
547
+ $requestOrder->LoginToken = $authResponse->Token->Value;
548
+ $requestOrder->AnalysisLocation = $analysisLocation;
549
+ $requestOrder->Orders[0] = $clearSaleOrder;
550
+
551
+ $orderBO = Mage::getModel('total/order_business_object');
552
+
553
+ $response = $orderBO->send($requestOrder,$environment);
554
+
555
+ return $response;
556
+ }
557
+ }
558
+ }
559
+ catch (Exception $e) {
560
+
561
+ $csLog = Mage::getSingleton('total/log');
562
+ $csLog->log($e->getMessage());
563
+ }
564
+
565
+
566
+ }
567
+
568
+
569
+ public function getSpecificOrder($orderID)
570
+ {
571
+ require_once('app/Mage.php');
572
+ Mage::app();
573
+
574
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
575
+
576
+
577
+ if ($isActive)
578
+ {
579
+ $order = new Mage_Sales_Model_Order();
580
+ $order->loadByIncrementId($orderID);
581
+
582
+ if($order)
583
+ {
584
+ $storeId = $order->getStoreId();
585
+
586
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment",$storeId);
587
+ $analysisLocation = Mage::getStoreConfig("clearsale_total/general/analysislocation",$storeId);
588
+ $authBO = Mage::getModel('total/auth_business_object');
589
+ $authResponse = $authBO->login($environment);
590
+ $orderBO = Mage::getModel('total/order_business_object');
591
+
592
+ if($authResponse)
593
+ {
594
+ $requestOrder = Mage::getModel('total/order_entity_requestorder');
595
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key",$storeId);
596
+ $requestOrder->LoginToken = $authResponse->Token->Value;;
597
+ $requestOrder->AnalysisLocation = $analysisLocation;
598
+ $requestOrder->Orders = array();
599
+ $requestOrder->Orders[0] = $orderID;
600
+ $ResponseOrder = $orderBO->get($requestOrder,$environment);
601
+ $orderBO->Update($ResponseOrder->Orders[0]);
602
+ }
603
+ }
604
+ }
605
+ }
606
+
607
+ public function getOrderAll()
608
+ {
609
+ require_once('app/Mage.php');
610
+ Mage::app();
611
+
612
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
613
+
614
+
615
+ if ($isActive)
616
+ {
617
+
618
+ $time = time();
619
+ $to = date('Y-m-d H:i:s', $time);
620
+ $lastTime = $time - 86400; // 60*60*24
621
+ $from = date('Y-m-d H:i:s', $lastTime);
622
+
623
+ echo "lastTime $lastTime <br />";
624
+
625
+ $orders = Mage::getModel('sales/order')->getCollection()
626
+ ->addFieldToFilter('status', array('null' => true))
627
+ ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to));
628
+
629
+ if($orders)
630
+ {
631
+ foreach ($orders as $order) {
632
+
633
+ $storeId = $order->getStoreId();
634
+
635
+ $environment = Mage::getStoreConfig("clearsale_total/general/environment",$storeId);
636
+ $analysisLocation = Mage::getStoreConfig("clearsale_total/general/analysislocation",$storeId);
637
+ $authBO = Mage::getModel('total/auth_business_object');
638
+ $authResponse = $authBO->login($environment);
639
+ $orderBO = Mage::getModel('total/order_business_object');
640
+
641
+ if($authResponse)
642
+ {
643
+ $orderId = $order->getRealOrderId();
644
+ $requestOrder = Mage::getModel('total/order_entity_requestorder');
645
+ $requestOrder->ApiKey = Mage::getStoreConfig("clearsale_total/general/key",$storeId);
646
+ $requestOrder->LoginToken = $authResponse->Token->Value;;
647
+ $requestOrder->AnalysisLocation = $analysisLocation;
648
+ $requestOrder->Orders = array();
649
+ $requestOrder->Orders[0] = $orderId;
650
+ $ResponseOrder = $orderBO->get($requestOrder,$environment);
651
+ $orderBO->Update($ResponseOrder->Orders[0]);
652
+ }
653
+
654
+ }
655
+ }
656
+ }
657
+
658
+ }
659
+
660
+ public function retry()
661
+ {
662
+
663
+ require_once('app/Mage.php');
664
+ Mage::app();
665
+
666
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
667
+ $csLog = Mage::getSingleton('total/log');
668
+
669
+
670
+ if ($isActive)
671
+ {
672
+
673
+ $orderBO = Mage::getModel('total/order_business_object');
674
+
675
+ $orders = $orderBO->getOrderControl();
676
+
677
+ if($orders)
678
+ {
679
+ foreach ($orders as $orderControl)
680
+ {
681
+ try
682
+ {
683
+
684
+ $orderId = $orderControl["order_id"];
685
+ $attemps = $orderControl["attempts"];
686
+
687
+ $message = $orderControl["diagnostics"];
688
+ $messages = array();
689
+ $messages = json_decode($message,true);
690
+ $attemps = $attemps + 1;
691
+
692
+ $response = $this->sendSpecificOrder($orderId);
693
+
694
+ if($response->HttpCode == 200)
695
+ {
696
+ $orderResponse = json_decode($response->Body);
697
+
698
+ if($orderResponse)
699
+ {
700
+ if($orderResponse->Orders)
701
+ {
702
+ $orderBO->save($orderResponse->Orders[0]);
703
+ $orderBO->setOrderControl($orderId,true,$attemps,$message);
704
+ }
705
+ }
706
+ }else
707
+ {
708
+ $messages[$attemps] = $response->Body;
709
+ $message= json_encode($messages);
710
+ $orderBO->setOrderControl($orderId,false,$attemps,$message);
711
+ }
712
+ } catch (Exception $e)
713
+ {
714
+ $csLog = Mage::getSingleton('total/log');
715
+ $csLog->log($e->getMessage());
716
+ }
717
+
718
+ }
719
+ }
720
+
721
+
722
+ }
723
+ }
724
+
725
+ }
app/code/community/Clearsale/Total/Model/Order/Business/Object.php CHANGED
@@ -26,26 +26,54 @@ 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);
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
  {
@@ -55,17 +83,28 @@ class Clearsale_Total_Model_Order_Business_Object
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
  }
@@ -73,17 +112,42 @@ class Clearsale_Total_Model_Order_Business_Object
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;
26
 
27
  public function save($order)
28
  {
 
29
  $magentoStatus = $this->StatusHandle->toMagentoStatus($order->Status);
30
+
31
+ if($magentoStatus)
32
+ {
33
+ if($magentoStatus != "")
34
+ {
35
+ $this->setOrderStatus($order->ID,$magentoStatus);
36
+ }
37
+ }
38
  }
39
 
40
  public function update($Order)
41
  {
 
42
  $magentoStatus = $this->StatusHandle->toMagentoStatus($Order->Status);
43
+
44
+ if($magentoStatus)
45
+ {
46
+ if($magentoStatus != "")
47
+ {
48
+ $this->setOrderStatus($Order->ID,$magentoStatus);
49
+ }
50
+ }
51
 
52
  }
53
+
54
+ public function setOrderStatus($orderid,$status)
55
+ {
56
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderid);
57
+ if($order->getStatus() != $status)
58
+ {
59
+ $order->setStatus($status);
60
+ $order->addStatusToHistory($status, 'Clearsale Status Update', false);
61
+ $order->save();
62
+ }
63
+ }
64
+
65
 
66
+ private function insertClearsaleOrderControl($orderId,$message)
67
  {
68
  try{
69
+ $orderArray["order_id"] = $orderId;
70
+ $orderArray["diagnostics"] = $message;
71
+ $orderArray["attempts"] = 1;
72
+ $orderArray["dt_update"] = date('Y-m-d H:i:s');
73
+ $orderArray["dt_sent"] = '';
74
+
75
  $connection = Mage::getSingleton('core/resource')->getconnection('core_write');
76
+ $connection->insert('clearsale_order_control', $orderArray);
77
  }
78
  catch (Exception $e)
79
  {
83
  }
84
 
85
 
86
+ private function updateClearsaleOrderControl($orderId,$message,$attempts,$sent)
87
  {
88
  try {
89
+ $orderArray["order_id"] = $orderId;
90
+ $orderArray["diagnostics"] = $message;
91
+ $orderArray["attempts"] = $attempts;
92
  $orderArray["dt_update"] = date('Y-m-d H:i:s');
93
+
94
+ echo "Tentativas $attempts";
95
+
96
+ if($sent)
97
+ {
98
+ $orderArray["dt_sent"] = date('Y-m-d H:i:s');
99
+ }
100
 
101
  $connection = Mage::getSingleton('core/resource')->getconnection('core_write');
102
  $__where = $connection->quoteInto('order_id = ?', $orderArray["order_id"]);
103
+ $connection->update('clearsale_order_control', $orderArray, $__where);
104
+ echo $__where;
105
 
106
  } catch (Exception $e){
107
+ echo "Error: ".$e->getMessage();
108
  $CSLog = Mage::getSingleton('total/log');
109
  $CSLog->log($e->getMessage());
110
  }
112
  }
113
 
114
 
115
+ private function selectClearsaleOrderControl($maxAttemps)
116
+ {
117
+ try {
118
+ $connection = Mage::getSingleton('core/resource')->getconnection('core_read');
119
+ $query = "SELECT * FROM `clearsale_order_control` WHERE `dt_sent` = '0000-00-00 00:00:00' AND `attempts` <=".$maxAttemps;
120
+ $results = $connection->fetchAll($query);
121
+
122
+ return $results;
123
+
124
+ } catch (Exception $e){
125
+ $CSLog = Mage::getSingleton('total/log');
126
+ $CSLog->log($e->getMessage());
127
+ }
128
+
129
+ }
130
+
131
+
132
+
133
+
134
+ public function createOrderControl($orderid,$message)
135
  {
136
+ $this->insertClearsaleOrderControl($orderid,$message);
 
 
 
 
 
 
137
  }
138
 
139
+ public function setOrderControl($orderId,$sent,$attemps,$message)
140
+ {
141
+ $this->updateClearsaleOrderControl($orderId,$message,$attemps,$sent);
142
+ }
143
+
144
+ public function getOrderControl()
145
+ {
146
+ $maxAttemps = 5;
147
+ return $this->selectClearsaleOrderControl($maxAttemps);
148
+ }
149
+
150
+
151
  public function objectOrderToArray($order)
152
  {
153
  $array_order["order_id"] = $order->ID;
app/code/community/Clearsale/Total/Model/Order/Entity/RequestOrder.php DELETED
@@ -1,12 +0,0 @@
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/Total/Model/System/Config/Source/Analysislocation/Values.php CHANGED
@@ -1,17 +1,17 @@
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
  }
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
  }
app/code/community/Clearsale/Total/Model/System/Config/Source/Cron/Values.php CHANGED
@@ -1,29 +1,29 @@
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
  }
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
  }
app/code/community/Clearsale/Total/Model/System/Config/Source/Environment/Values.php CHANGED
@@ -1,17 +1,17 @@
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
  }
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
  }
app/code/community/Clearsale/Total/Model/System/Config/Source/OrderStatus/Values.php CHANGED
@@ -1,24 +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
-
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/Total/Model/Utils/HttpHelper.php CHANGED
@@ -3,11 +3,19 @@
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");
@@ -30,16 +38,34 @@ class Clearsale_Total_Model_Utils_HttpHelper
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
  }
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 = $this->json_encode_unicode($data);
11
+
12
+ $isLogenabled = Mage::getStoreConfig("clearsale_total/general/enabled_log");
13
+
14
+ if($isLogenabled)
15
+ {
16
+ $csLog = Mage::getSingleton('total/log');
17
+ $csLog->log($dataString);
18
+ }
19
 
20
  $ch = curl_init($url);
21
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
38
 
39
  curl_close($ch);
40
 
41
+ $jsonReturn = $return->Body;
42
 
43
+ if($isLogenabled)
44
  {
45
+ $csLog = Mage::getSingleton('total/log');
46
+ $csLog->log($jsonReturn);
47
+ }
48
+
49
+ if($return->HttpCode != 200)
50
  {
51
  $csLog = Mage::getSingleton('total/log');
52
  $csLog->log($return->Body);
53
  }
54
+
55
+ return $return;
56
  }
57
 
58
+ public function json_encode_unicode($data) {
59
+ if (defined('JSON_UNESCAPED_UNICODE')) {
60
+ return json_encode($data, JSON_UNESCAPED_UNICODE);
61
+ }
62
+ return preg_replace_callback('/(?<!\\\\)\\\\u([0-9a-f]{4})/i',
63
+ function ($m) {
64
+ $d = pack("H*", $m[1]);
65
+ $r = mb_convert_encoding($d, "UTF8", "UTF-16BE");
66
+ return $r!=="?" && $r!=="" ? $r : $m[0];
67
+ }, json_encode($data)
68
+ );
69
+ }
70
 
71
  }
app/code/community/Clearsale/Total/controllers/Adminhtml/TotalbackendController.php CHANGED
@@ -1,12 +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
  }
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/Total/controllers/IndexController.php CHANGED
@@ -1,14 +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
  }
1
+ <?php
2
+
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/Total/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Clearsale_Total>
5
- <version>1.0.1</version>
6
  </Clearsale_Total>
7
  </modules>
8
  <global>
@@ -54,26 +54,26 @@
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>
@@ -176,14 +176,22 @@
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>
2
  <config>
3
  <modules>
4
  <Clearsale_Total>
5
+ <version>1.1.0</version>
6
  </Clearsale_Total>
7
  </modules>
8
  <global>
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>
176
  </adminhtml>
177
  <crontab>
178
  <jobs>
179
+ <total_get_orders>
180
  <schedule>
181
+ <cron_expr>*/5 * * * *</cron_expr>
182
  </schedule>
183
  <run>
184
  <model>total/observer::getClearsaleOrderStatus</model>
185
  </run>
186
+ </total_get_orders>
187
+ <total_get_orders>
188
+ <schedule>
189
+ <cron_expr>*/5 * * * *</cron_expr>
190
+ </schedule>
191
+ <run>
192
+ <model>total/observer::retry</model>
193
+ </run>
194
+ </total_get_orders>
195
  </jobs>
196
  </crontab>
197
  </config>
app/code/community/Clearsale/Total/etc/system.xml CHANGED
@@ -23,7 +23,7 @@
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>
@@ -33,7 +33,7 @@
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>
@@ -41,7 +41,7 @@
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>
@@ -49,16 +49,15 @@
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>
@@ -67,45 +66,53 @@
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>
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>
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>
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>
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
  <environment translate="label">
60
+ <label>Enviroment:</label>
61
  <frontend_type>select</frontend_type>
62
  <source_model>
63
  total/system_config_source_environment_values</source_model>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>1</show_in_store>
68
  </environment>
 
69
  <analysislocation translate="label">
70
+ <label>Analysis Location:</label>
71
+ <frontend_type>select</frontend_type>
72
  <source_model>
73
  total/system_config_source_analysislocation_values</source_model>
74
+ <sort_order>6</sort_order>
75
  <show_in_default>1</show_in_default>
76
  <show_in_website>1</show_in_website>
77
  <show_in_store>1</show_in_store>
78
  </analysislocation>
 
79
  <credicardmethod translate="label">
80
+ <label>Payments methods to send:</label>
81
  <frontend_type>multiselect</frontend_type>
82
  <source_model>
83
  total/system_config_source_paymentmethod_values</source_model>
84
+ <sort_order>7</sort_order>
85
  <show_in_default>1</show_in_default>
86
  <show_in_website>1</show_in_website>
87
  <show_in_store>1</show_in_store>
88
  </credicardmethod>
89
  <cron_settings_get>
90
+ <label>Get order status on each:</label>
91
  <frontend_type>select</frontend_type>
92
  <source_model>total/system_config_source_cron_values</source_model>
93
+ <sort_order>8</sort_order>
94
  <show_in_default>1</show_in_default>
95
  </cron_settings_get>
96
  <create_invoice translate="label">
97
+ <label>Create invoice on approved:</label>
98
  <frontend_type>select</frontend_type>
99
  <source_model>
100
  adminhtml/system_config_source_yesno</source_model>
101
+ <sort_order>9</sort_order>
102
  <show_in_default>1</show_in_default>
103
  <show_in_website>1</show_in_website>
104
  <show_in_store>1</show_in_store>
105
  </create_invoice>
106
+ <enabled_log translate="label">
107
+ <label>Enable transaction log:</label>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>
110
+ adminhtml/system_config_source_yesno</source_model>
111
+ <sort_order>10</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </enabled_log>
116
  </fields>
117
  </general>
118
  </groups>
app/code/community/Clearsale/Total/sql/total_setup/mysql4-install-1.0.1.php CHANGED
@@ -1,39 +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
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $sql=<<<SQLTEXT
6
+ CREATE TABLE IF NOT EXISTS `clearsale_order_diagnostic` (
7
+ order_id VARCHAR(20) ,
8
+ clearsale_status VARCHAR(50),
9
+ score VARCHAR(5),
10
+ diagnostics VARCHAR(255),
11
+ dt_sent TIMESTAMP,
12
+ dt_update TIMESTAMP
13
+ );
14
+ SQLTEXT;
15
+
16
+ $installer->run($sql);
17
+
18
+ $status = Mage::getModel('sales/order_status');
19
+ $status->setStatus('approved_clearsale');
20
+ $status->setLabel('Approved ClearSale');
21
+ $status->save();
22
+
23
+ $status = Mage::getModel('sales/order_status');
24
+ $status->setStatus('reproved_clearsale');
25
+ $status->setLabel('Reproved ClearSale');
26
+ $status->save();
27
+
28
+ $status = Mage::getModel('sales/order_status');
29
+ $status->setStatus('canceled_clearsale');
30
+ $status->setLabel('Canceled ClearSale');
31
+ $status->save();
32
+
33
+ $status = Mage::getModel('sales/order_status');
34
+ $status->setStatus('analysing_clearsale');
35
+ $status->setLabel('Analysing ClearSale');
36
+ $status->save();
37
+
38
+ $installer->endSetup();
39
 
app/code/community/Clearsale/Total/sql/total_setup/mysql4-upgrade-1.0.3-1.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $sql=<<<SQLTEXT
8
+ CREATE TABLE IF NOT EXISTS `clearsale_order_control` (
9
+ order_id VARCHAR(20) ,
10
+ diagnostics TEXT,
11
+ attempts INT,
12
+ dt_sent DATETIME DEFAULT NULL,
13
+ dt_update DATETIME DEFAULT NULL
14
+ );
15
+ SQLTEXT;
16
+
17
+ $installer->run($sql);
18
+
19
+
20
+ $installer->endSetup();
21
+
app/code/community/Clearsale/community - Atalho.lnk DELETED
Binary file
app/design/frontend/base/default/template/total/fingerprint.phtml CHANGED
@@ -29,6 +29,19 @@ if ($isActive)
29
  $script .= "</script>";
30
 
31
  echo $script;
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  ?>
29
  $script .= "</script>";
30
 
31
  echo $script;
32
+
33
+ $tmTags = "<!-- In�cio das tags de profiling -->";
34
+ $tmTags .= "<p style=\"background:url(https://h.online-metrix.net/fp/clear.png?org_id=k6dvnkdk&amp;session_id=".$sessionID."&amp;m=1)\">";
35
+ $tmTags .= "</p>";
36
+ $tmTags .= "<img src=\"https://h.online-metrix.net/fp/clear.png?org_id=k6dvnkdk&amp;session_id=".$sessionID."&amp;m=2\" alt=\"\" >";
37
+ $tmTags .= "<script src=\"https://h.online-metrix.net/fp/check.js?org_id=k6dvnkdk&amp;session_id=".$sessionID."\" type=\"text/javascript\">";
38
+ $tmTags .= "</script>";
39
+ $tmTags .= "<object type=\"application/x-shockwave-flash\" data=\"https://h.online-metrix.net/fp/fp.swf?org_id=k6dvnkdk&amp;session_id=".$sessionID."\" width=\"1\" height=\"1\" id=\"obj_id\">";
40
+ $tmTags .= "<param name=\"movie\" value=\"https://h.online-metrix.net/fp/fp.swf?org_id=k6dvnkdk&amp;session_id=".$sessionID."\" />";
41
+ $tmTags .= "</object>";
42
+ $tmTags .= "<!-- Fim das tags de profiling -->";
43
+
44
+ echo $tmTags;
45
  }
46
 
47
  ?>
app/etc/modules/Clearsale_Total.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Clearsale_Total>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.1</version>
8
  </Clearsale_Total>
9
  </modules>
10
  </config>
4
  <Clearsale_Total>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.1.0</version>
8
  </Clearsale_Total>
9
  </modules>
10
  </config>
clearsalegetorders.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'app/Mage.php';
4
+
5
+ Varien_Profiler::enable();
6
+ Mage::setIsDeveloperMode(true);
7
+ ini_set('display_errors', 1);
8
+
9
+ umask(0);
10
+ Mage::app();
11
+
12
+ $obj = Mage::getModel('total/observer');
13
+
14
+ $obj->getClearsaleOrderStatus();
15
+
16
+ echo "OK";
17
+
18
+
19
+
clearsaleretry.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once('app/Mage.php');
4
+ Mage::app();
5
+ Varien_Profiler::enable();
6
+ Mage::setIsDeveloperMode(true);
7
+ ini_set('display_errors', 1);
8
+ umask(0);
9
+
10
+ try{
11
+ $isActive = Mage::getStoreConfig("clearsale_total/general/active");
12
+ $csLog = Mage::getSingleton('total/log');
13
+
14
+ $maxTries = 5;
15
+
16
+ if ($isActive)
17
+ {
18
+ $obj = Mage::getModel('total/observer');
19
+ $obj->retry();
20
+ echo "ok";
21
+ }
22
+
23
+ }catch (Exception $e)
24
+ {
25
+ print_r($e->getMessage());
26
+ $csLog = Mage::getSingleton('total/log');
27
+ $csLog->log($e->getMessage());
28
+ }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ClearSale_Total</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -13,12 +13,17 @@ 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>Fix Country Code Error.&#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>2016-01-14</date>
20
- <time>23:40:19</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="950dc6d7a3817583fe8a16b978903640"/><dir name="Order"><dir name="Business"><file name="Object.php" hash="fb64b166ce833b355654a0509d5f2850"/></dir><dir name="Entity"><file name="Address.php" hash="5e48742951fba4fb53a4c690a7cb7bea"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ClearSale_Total</name>
4
+ <version>1.1.0</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>New Features.&#xD;
17
+ &#xD;
18
+ Multi-store location. &#xD;
19
+ Retry Cron Job.&#xD;
20
+ Get Order Status Update.&#xD;
21
+ &#xD;
22
+ </notes>
23
  <authors><author><name>Filippe Farias</name><user>clearsale_dev</user><email>filippe.farias@clearsale.com.br</email></author></authors>
24
+ <date>2016-03-02</date>
25
+ <time>10:53:29</time>
26
+ <contents><target name="magecommunity"><dir name="Clearsale"><dir name="Total"><dir name="Block"><dir name="Adminhtml"><file name="Totalbackend.php" hash="8bb5082623943fa6686af41de4f25119"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e2372ddf1f40626c1b85549d78f3eed2"/></dir><dir name="Model"><dir name="Auth"><dir name="Business"><file name="Object.php" hash="a75e924d9fde7432a39a87483799ded3"/></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><file name="Authorizenet.php" hash="3ef1f54376e6a4cef7ea9110c5b48344"/><dir name="Gateway"><file name="Authorizenet.php" hash="5facb6fd677fde085625bb510dab13e1"/></dir><file name="Log.php" hash="4ef1d30b39450a84919284b093b3f9b8"/><dir name="Mysql4"><dir name="Clearsaleorderdiagnostic"><file name="Collection.php" hash="5ecea4a48d5eb3b2bcd7cc413b40c9e9"/></dir><file name="Clearsaleorderdiagnostic.php" hash="cd81082bccda08a7f5725f24dc56fb19"/></dir><file name="Observer.php" hash="6a98e0c4bf74cf388df569090339b019"/><dir name="Order"><dir name="Business"><file name="Object.php" hash="63713dbcb313d1ddfe8005953dcac826"/></dir><dir name="Entity"><file name="Address.php" hash="5e48742951fba4fb53a4c690a7cb7bea"/><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="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="2bea7b2d240748262997c5255147dc43"/></dir><dir name="Cron"><file name="Values.php" hash="0039f5f91e8b31e46197cfc91f1db96f"/></dir><dir name="Environment"><file name="Values.php" hash="d2716bd93c212bb1717d7951a552eff3"/></dir><dir name="OrderStatus"><file name="Values.php" hash="2bff6581aa0320b3067b6914b86ac0f2"/></dir><dir name="Paymentmethod"><file name="Values.php" hash="00023fd6ebb78fc692cfe5f4d8757257"/></dir></dir></dir></dir><dir name="Utils"><file name="HttpHelper.php" hash="c1035d3caa764ff7a8b74fefc7a85440"/><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="246df39ec4bc19f9a65f57d6f4d5ff20"/></dir><file name="IndexController.php" hash="cf2e116d64c3a251da66c36af1a871bf"/></dir><dir name="etc"><file name="config.xml" hash="bee026d1b2f5c73a0e5da6323b37a101"/><file name="system.xml" hash="eddbfc51e5b60fb5bd10f6940edb9231"/></dir><dir name="sql"><dir name="total_setup"><file name="mysql4-install-1.0.1.php" hash="dc54c04d5b5f2f7715a24dbca414dcac"/><file name="mysql4-upgrade-1.0.3-1.1.0.php" hash="e4e7907b576eb2543e2ee9078e4927d4"/></dir></dir></dir></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="7ec23ab40ab28a0fc7f77d1421041721"/><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="ac3fac5026c185197811cee3088aff61"/></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><target name="mageweb"><dir name="."><file name="clearsalegetorders.php" hash="6012a01a456a3a26256a8a75c1c269eb"/><file name="clearsaleretry.php" hash="a5cd59cc326cd5a7b125567901477b03"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>4.4.1</min><max>5.6.13</max></php></required></dependencies>
29
  </package>