Maxima_Cielo - Version 1.5.0

Version Notes

Testado nas verões 1.4 e superiores do Magento Community Edition.

Download this release

Release Info

Developer Fillipe Almeida Dutra
Extension Maxima_Cielo
Version 1.5.0
Comparing to
See all releases


Version 1.5.0

Files changed (53) hide show
  1. app/code/community/Maxima/Cielo/Block/Adminhtml/Order/Invoice/Totals.php +55 -0
  2. app/code/community/Maxima/Cielo/Block/Adminhtml/Order/Totals.php +56 -0
  3. app/code/community/Maxima/Cielo/Block/Adminhtml/Order/View.php +73 -0
  4. app/code/community/Maxima/Cielo/Block/Form/Cc.php +234 -0
  5. app/code/community/Maxima/Cielo/Block/Form/Dc.php +111 -0
  6. app/code/community/Maxima/Cielo/Block/Info/Cc.php +43 -0
  7. app/code/community/Maxima/Cielo/Block/Info/Dc.php +43 -0
  8. app/code/community/Maxima/Cielo/Block/Sales/Order/Totals.php +53 -0
  9. app/code/community/Maxima/Cielo/Block/Verify.php +95 -0
  10. app/code/community/Maxima/Cielo/Helper/Data.php +167 -0
  11. app/code/community/Maxima/Cielo/Model/Adminhtml/BuyPage.php +58 -0
  12. app/code/community/Maxima/Cielo/Model/Adminhtml/CardTypes.php +72 -0
  13. app/code/community/Maxima/Cielo/Model/Adminhtml/Environment.php +58 -0
  14. app/code/community/Maxima/Cielo/Model/Cc.php +460 -0
  15. app/code/community/Maxima/Cielo/Model/Cc/InstallmentType.php +44 -0
  16. app/code/community/Maxima/Cielo/Model/Cc/MaxInstallments.php +55 -0
  17. app/code/community/Maxima/Cielo/Model/Cc/Types.php +133 -0
  18. app/code/community/Maxima/Cielo/Model/Dc.php +405 -0
  19. app/code/community/Maxima/Cielo/Model/Dc/Types.php +73 -0
  20. app/code/community/Maxima/Cielo/Model/Order/Invoice/Interest.php +38 -0
  21. app/code/community/Maxima/Cielo/Model/Quote/Address/Interest.php +84 -0
  22. app/code/community/Maxima/Cielo/Model/WebServiceOrder.php +547 -0
  23. app/code/community/Maxima/Cielo/controllers/AdminController.php +179 -0
  24. app/code/community/Maxima/Cielo/controllers/PayController.php +172 -0
  25. app/code/community/Maxima/Cielo/etc/config.xml +203 -0
  26. app/code/community/Maxima/Cielo/etc/system.xml +354 -0
  27. app/code/community/Maxima/Cielo/sql/Maxima_Cielo_setup/mysql4-upgrade-1.0.1-1.1.0.php +84 -0
  28. app/code/community/Maxima/Cielo/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.crt +28 -0
  29. app/design/adminhtml/default/default/template/cielo/info/cc.phtml +346 -0
  30. app/design/adminhtml/default/default/template/cielo/info/dc.phtml +308 -0
  31. app/design/frontend/default/default/layout/cielo.xml +50 -0
  32. app/design/frontend/default/default/template/cielo/failure.phtml +58 -0
  33. app/design/frontend/default/default/template/cielo/form/cc.phtml +188 -0
  34. app/design/frontend/default/default/template/cielo/form/dc.phtml +139 -0
  35. app/design/frontend/default/default/template/cielo/info/cc.phtml +63 -0
  36. app/design/frontend/default/default/template/cielo/info/dc.phtml +62 -0
  37. app/design/frontend/default/default/template/cielo/success.phtml +58 -0
  38. app/etc/modules/Maxima_Cielo.xml +34 -0
  39. package.xml +22 -0
  40. skin/adminhtml/default/default/images/cielo/window/bottom_left.png +0 -0
  41. skin/adminhtml/default/default/images/cielo/window/bottom_right.png +0 -0
  42. skin/adminhtml/default/default/images/cielo/window/close.png +0 -0
  43. skin/adminhtml/default/default/images/cielo/window/header.png +0 -0
  44. skin/adminhtml/default/default/images/cielo/window/top_left.png +0 -0
  45. skin/adminhtml/default/default/images/cielo/window/top_right.png +0 -0
  46. skin/frontend/default/default/images/cielo/Amex.png +0 -0
  47. skin/frontend/default/default/images/cielo/Diners.png +0 -0
  48. skin/frontend/default/default/images/cielo/Discover.png +0 -0
  49. skin/frontend/default/default/images/cielo/Elo.png +0 -0
  50. skin/frontend/default/default/images/cielo/Master-maestro.png +0 -0
  51. skin/frontend/default/default/images/cielo/Master.png +0 -0
  52. skin/frontend/default/default/images/cielo/Visa-Electron.png +0 -0
  53. skin/frontend/default/default/images/cielo/Visa.png +0 -0
app/code/community/Maxima/Cielo/Block/Adminhtml/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Adminhtml_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
28
+ {
29
+ /**
30
+ * Initialize order totals array
31
+ *
32
+ * @return Mage_Sales_Block_Order_Totals
33
+ */
34
+ protected function _initTotals()
35
+ {
36
+ parent::_initTotals();
37
+
38
+ $source = $this->getSource();
39
+
40
+ if($this->getSource()->getInterest() > 0)
41
+ {
42
+ $this->addTotalBefore(new Varien_Object(array
43
+ (
44
+ 'code' => 'interest',
45
+ 'strong' => true,
46
+ 'value' => $this->getSource()->getInterest(),
47
+ 'base_value' => $this->getSource()->getBaseInterest(),
48
+ 'label' => $this->__('Interest'),
49
+ 'area' => 'footer'
50
+ )), 'grand_total');
51
+ }
52
+
53
+ return $this;
54
+ }
55
+ }
app/code/community/Maxima/Cielo/Block/Adminhtml/Order/Totals.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Adminhtml_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
28
+ {
29
+ /**
30
+ * Initialize order totals array
31
+ *
32
+ * @return Mage_Sales_Block_Order_Totals
33
+ */
34
+ protected function _initTotals()
35
+ {
36
+ parent::_initTotals();
37
+
38
+ $source = $this->getSource();
39
+
40
+ if($this->getSource()->getInterest() > 0)
41
+ {
42
+ $this->addTotalBefore(new Varien_Object(array
43
+ (
44
+ 'code' => 'interest',
45
+ 'strong' => true,
46
+ 'value' => $this->getSource()->getInterest(),
47
+ 'base_value' => $this->getSource()->getBaseInterest(),
48
+ 'label' => $this->__('Interest'),
49
+ 'area' => 'footer'
50
+ )), 'grand_total');
51
+ }
52
+
53
+ return $this;
54
+ }
55
+ }
56
+
app/code/community/Maxima/Cielo/Block/Adminhtml/Order/View.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Adminhtml_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
28
+ {
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+
33
+ $payment = $this->getOrder()->getPayment();
34
+ $method = $payment->getMethodInstance()->getCode();
35
+ $tid = $payment->getAdditionalInformation('Cielo_tid');
36
+
37
+ if(!$tid)
38
+ {
39
+ return;
40
+ }
41
+
42
+ if($method == "Maxima_Cielo_Cc")
43
+ {
44
+ $this->_addButton('maxima_cielo_capture', array
45
+ (
46
+ 'label' => Mage::helper('Maxima_Cielo')->__('Capture'),
47
+ 'onclick' => "captureCieloOrder('" . $tid . "', " . $this->getOrder()->getId() . ");",
48
+ 'class' => 'go'
49
+ ));
50
+ }
51
+
52
+ if($method == "Maxima_Cielo_Cc" || $method == "Maxima_Cielo_Dc")
53
+ {
54
+ $this->_addButton('maxima_cielo_consult', array
55
+ (
56
+ 'label' => Mage::helper('Maxima_Cielo')->__('Consult WebService'),
57
+ 'onclick' => "loadCieloWebServiceData('" . $tid . "', " . $this->getOrder()->getId() . ");",
58
+ 'class' => 'go'
59
+ ));
60
+ }
61
+
62
+ if($method == "Maxima_Cielo_Cc")
63
+ {
64
+ $this->_addButton('maxima_cielo_cancel', array
65
+ (
66
+ 'label' => Mage::helper('Maxima_Cielo')->__('Cancel on Cielo'),
67
+ 'onclick' => "cancelCieloOrder('" . $tid . "', " . $this->getOrder()->getId() . ");",
68
+ 'class' => 'go'
69
+ ));
70
+ }
71
+ }
72
+ }
73
+
app/code/community/Maxima/Cielo/Block/Form/Cc.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Form_Cc extends Mage_Payment_Block_Form
28
+ {
29
+ protected function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('cielo/form/cc.phtml');
33
+ }
34
+
35
+
36
+ /**
37
+ *
38
+ * Lista opcoes de meses
39
+ *
40
+ */
41
+
42
+ public function getMonths()
43
+ {
44
+ $months = array();
45
+
46
+ for($i = 1; $i <= 12; $i++)
47
+ {
48
+ $label = ($i < 10) ? ("0" . $i) : $i;
49
+
50
+ $months[] = array("num" => $i, "label" => $this->htmlEscape($label));
51
+ }
52
+
53
+ return $months;
54
+ }
55
+
56
+ /**
57
+ *
58
+ * Lista opcoes de anos
59
+ *
60
+ */
61
+
62
+ public function getYears()
63
+ {
64
+ $years = array();
65
+
66
+ $initYear = (int) date("Y");
67
+
68
+ for($i = $initYear; $i <= $initYear + 10; $i++)
69
+ {
70
+ $years[] = array("num" => $i, "label" => $i);
71
+ }
72
+
73
+ return $years;
74
+ }
75
+
76
+
77
+ /**
78
+ *
79
+ * Lista opcoes de parcelamento
80
+ *
81
+ */
82
+
83
+ public function getInstallments()
84
+ {
85
+ // pega dados de parcelamento
86
+ $maxInstallments = intval(Mage::getStoreConfig('payment/Maxima_Cielo_Cc/max_parcels_number'));
87
+ $minInstallmentValue = floatval(Mage::getStoreConfig('payment/Maxima_Cielo_Cc/min_parcels_value'));
88
+
89
+ $minInstallmentValue = ($minInstallmentValue <= 5.01) ? 5.01 : $minInstallmentValue;
90
+
91
+ // atualiza taxa de juros para 0,
92
+ // caso o usuario tenha voltado na navegacao
93
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
94
+ $quote->setInterest(0.0);
95
+ $quote->setBaseInterest(0.0);
96
+
97
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
98
+ $quote->save();
99
+
100
+ // pega dados de juros
101
+ $withoutInterest = intval(Mage::getStoreConfig('payment/Maxima_Cielo_Cc/installment_without_interest'));
102
+ $interestValue = floatval(Mage::getStoreConfig('payment/Maxima_Cielo_Cc/installment_interest_value'));
103
+
104
+ // pega valores do pedido
105
+ $total = Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal();
106
+
107
+ $installments = array();
108
+
109
+ for($i = 1; $i <= $maxInstallments; $i++)
110
+ {
111
+ // caso nao haja juros na parcela
112
+ if($i <= $withoutInterest)
113
+ {
114
+ $orderTotal = $total;
115
+ $installmentValue = round($orderTotal / $i, 2);
116
+ }
117
+ // caso haja juros
118
+ else
119
+ {
120
+ $installmentValue = round(Mage::helper('Maxima_Cielo')->calcInstallmentValue($total, $interestValue / 100, $i), 2);
121
+ $orderTotal = $i * $installmentValue;
122
+ }
123
+
124
+
125
+
126
+ // confere se a parcela nao estah abaixo do minimo
127
+ if($minInstallmentValue >= 0 && $installmentValue < $minInstallmentValue)
128
+ {
129
+ break;
130
+ }
131
+
132
+ // monta o texto da parcela
133
+ if($i == 1)
134
+ {
135
+ $label = "&#192; vista (" . Mage::helper('core')->currency(($total), true, false) . ")";
136
+ }
137
+ else
138
+ {
139
+ if($i <= $withoutInterest)
140
+ {
141
+ $label = $i . "x sem juros (" . Mage::helper('core')->currency(($installmentValue), true, false) . " cada)";
142
+ }
143
+ else
144
+ {
145
+ $label = $i . "x (" . Mage::helper('core')->currency(($installmentValue), true, false) . " cada)";
146
+ }
147
+ }
148
+
149
+ // adiciona no vetor de parcelas
150
+ $installments[] = array("num" => $i, "label" => $this->htmlEscape($label));
151
+ }
152
+
153
+ // caso o valor da parcela minima seja maior do que o valor da compra,
154
+ // deixa somente opcao a vista
155
+ if($minInstallmentValue > $total)
156
+ {
157
+ $label = "&#192; vista (" . Mage::helper('core')->currency(($total), true, false) . ")";
158
+ $installments[] = array("num" => 1, "label" => $this->htmlEscape($label));
159
+ }
160
+
161
+ return $installments;
162
+ }
163
+
164
+ /**
165
+ *
166
+ * Retorna vetor com os codigos dos cartoes habilitados
167
+ *
168
+ */
169
+
170
+ public function getAllowedCards()
171
+ {
172
+ $allowedCards = explode(",", Mage::getStoreConfig('payment/Maxima_Cielo_Cc/card_types'));
173
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toOptionArray();
174
+
175
+ $validCards = array();
176
+
177
+ foreach($allCards as $card)
178
+ {
179
+ if(in_array($card['value'], $allowedCards))
180
+ {
181
+ $validCards[] = $card;
182
+ }
183
+ }
184
+
185
+ return $validCards;
186
+ }
187
+
188
+ /**
189
+ *
190
+ * Retorna vetor com numero maximo de parcelamento aceito
191
+ * para cada bandeira
192
+ *
193
+ */
194
+
195
+ public function getMaxCardsInstallments()
196
+ {
197
+ $maxInstallments = intval(Mage::getStoreConfig('payment/Maxima_Cielo_Cc/max_parcels_number'));
198
+ $installmentType = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/installments_type');
199
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toOptionArray();
200
+
201
+ $installmentsArray = array();
202
+
203
+ foreach($allCards as $card)
204
+ {
205
+ $installmentsNumber = $maxInstallments;
206
+
207
+ // caso loja
208
+ if($installmentType == '2')
209
+ {
210
+ $installmentsNumber = ($installmentsNumber > $card['inst_s']) ? $card['inst_s'] : $installmentsNumber;
211
+ }
212
+ // caso administradora
213
+ else if($installmentType == '3')
214
+ {
215
+ $installmentsNumber = ($installmentsNumber > $card['inst_a']) ? $card['inst_a'] : $installmentsNumber;
216
+ }
217
+
218
+ $installmentsArray[$card['value']] = $installmentsNumber;
219
+ }
220
+
221
+ return $installmentsArray;
222
+ }
223
+
224
+ /**
225
+ *
226
+ * Pega os valores da configuracao do modulo
227
+ *
228
+ */
229
+
230
+ public function getConfigData($config)
231
+ {
232
+ return Mage::getStoreConfig('payment/Maxima_Cielo_Cc/' . $config);
233
+ }
234
+ }
app/code/community/Maxima/Cielo/Block/Form/Dc.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Form_Dc extends Mage_Payment_Block_Form
28
+ {
29
+ protected function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('cielo/form/dc.phtml');
33
+ }
34
+
35
+ /**
36
+ *
37
+ * Lista opcoes de meses
38
+ *
39
+ */
40
+
41
+ public function getMonths()
42
+ {
43
+ $months = array();
44
+
45
+ for($i = 1; $i <= 12; $i++)
46
+ {
47
+ $label = ($i < 10) ? ("0" . $i) : $i;
48
+
49
+ $months[] = array("num" => $i, "label" => $this->htmlEscape($label));
50
+ }
51
+
52
+ return $months;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * Lista opcoes de anos
58
+ *
59
+ */
60
+
61
+ public function getYears()
62
+ {
63
+ $years = array();
64
+
65
+ $initYear = (int) date("Y");
66
+
67
+ for($i = $initYear; $i <= $initYear + 10; $i++)
68
+ {
69
+ $years[] = array("num" => $i, "label" => $i);
70
+ }
71
+
72
+ return $years;
73
+ }
74
+
75
+
76
+ /**
77
+ *
78
+ * Retorna vetor com os codigos dos cartoes habilitados
79
+ *
80
+ */
81
+
82
+ public function getAllowedCards()
83
+ {
84
+ $allowedCards = explode(",", Mage::getStoreConfig('payment/Maxima_Cielo_Dc/card_types'));
85
+ $allCards = Mage::getModel('Maxima_Cielo/dc_types')->toOptionArray();
86
+
87
+ $validCards = array();
88
+
89
+ foreach($allCards as $card)
90
+ {
91
+ if(in_array($card['value'], $allowedCards))
92
+ {
93
+ $validCards[] = $card;
94
+ }
95
+ }
96
+
97
+ return $validCards;
98
+ }
99
+
100
+
101
+ /**
102
+ *
103
+ * Pega os valores da configuracao do modulo
104
+ *
105
+ */
106
+
107
+ public function getConfigData($config)
108
+ {
109
+ return Mage::getStoreConfig('payment/Maxima_Cielo_Dc/' . $config);
110
+ }
111
+ }
app/code/community/Maxima/Cielo/Block/Info/Cc.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Info_Cc extends Mage_Payment_Block_Info
28
+ {
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('cielo/info/cc.phtml');
36
+ }
37
+
38
+ public function toPdf()
39
+ {
40
+ $this->setTemplate('payment/info/pdf/cc.phtml');
41
+ return $this->toHtml();
42
+ }
43
+ }
app/code/community/Maxima/Cielo/Block/Info/Dc.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Info_Dc extends Mage_Payment_Block_Info
28
+ {
29
+ /**
30
+ * Init default template for block
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $this->setTemplate('cielo/info/dc.phtml');
36
+ }
37
+
38
+ public function toPdf()
39
+ {
40
+ $this->setTemplate('payment/info/pdf/cc.phtml');
41
+ return $this->toHtml();
42
+ }
43
+ }
app/code/community/Maxima/Cielo/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
28
+ {
29
+ /**
30
+ * Initialize order totals array
31
+ *
32
+ * @return Mage_Sales_Block_Order_Totals
33
+ */
34
+ protected function _initTotals()
35
+ {
36
+ parent::_initTotals();
37
+
38
+ $source = $this->getSource();
39
+
40
+ if($this->getSource()->getInterest() > 0)
41
+ {
42
+ $this->addTotalBefore(new Varien_Object(array
43
+ (
44
+ 'code' => 'interest',
45
+ 'field' => 'interest',
46
+ 'value' => $this->getSource()->getInterest(),
47
+ 'label' => $this->__('Interest')
48
+ )), 'grand_total');
49
+ }
50
+
51
+ return $this;
52
+ }
53
+ }
app/code/community/Maxima/Cielo/Block/Verify.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Block_Verify extends Mage_Checkout_Block_Onepage_Success
28
+ {
29
+ private $_cieloStatus = -1;
30
+ private $_cieloTid = -1;
31
+
32
+
33
+ /**
34
+ *
35
+ * Define mensagem mostrada ao fim da compra
36
+ *
37
+ * @return string
38
+ *
39
+ */
40
+
41
+ public function getCieloDataHtml()
42
+ {
43
+ $html = "";
44
+
45
+ if($this->_cieloStatus == 6 || $this->_cieloStatus == 4)
46
+ {
47
+ $html .= "Sua compra foi faturada com êxito.<br />O ID da sua transação na Cielo é <b>" . $this->_cieloTid . "</b>.";
48
+ }
49
+ else if($this->_cieloStatus == 1 || $this->_cieloStatus == 2 || $this->_cieloStatus == 10)
50
+ {
51
+ $html .= "Sua compra foi faturada com êxito.<br />O ID da sua transação na Cielo é <b>" . $this->_cieloTid . "</b>.";
52
+ }
53
+ else
54
+ {
55
+ $statusMsg = Mage::helper('Maxima_Cielo')->getStatusMessage($this->_cieloStatus);
56
+
57
+ $html .= "Seu pagamento não foi realizado com sucesso.<br />
58
+ O TID da sua transação na Cielo é <b>" . $this->_cieloTid . "</b>.<br />
59
+ Mensagem de retorno da Cielo: <b>" . $statusMsg . "</b>.<br />
60
+ Para maiores informações, por favor acesse o link do pedido acima ou entre em contato conosco.";
61
+ }
62
+
63
+ return $html;
64
+ }
65
+
66
+
67
+
68
+ /**
69
+ *
70
+ * Getters and Setters
71
+ *
72
+ */
73
+
74
+ public function setCieloStatus($st)
75
+ {
76
+ $this->_cieloStatus = $st;
77
+ }
78
+
79
+ public function getCieloStatus()
80
+ {
81
+ return $this->_cieloStatus;
82
+ }
83
+
84
+ public function setCieloTid($tid)
85
+ {
86
+ $this->_cieloTid = $tid;
87
+ }
88
+
89
+ public function getCieloTid()
90
+ {
91
+ return $this->_cieloTid;
92
+ }
93
+
94
+ }
95
+
app/code/community/Maxima/Cielo/Helper/Data.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Helper_Data extends Mage_Core_Helper_Abstract
28
+ {
29
+
30
+ /**
31
+ * Formata o valor da compra de acordo com a definicao da Cielo
32
+ *
33
+ * @param string $originalValue
34
+ * @return string
35
+ */
36
+ public function formatValueForCielo($originalValue)
37
+ {
38
+ if(strpos($originalValue, ".") == false)
39
+ {
40
+ $value = $originalValue . "00";
41
+ }
42
+ else
43
+ {
44
+ list($integers, $decimals) = explode(".", $originalValue);
45
+
46
+ if(strlen($decimals) > 2)
47
+ {
48
+ $decimals = substr($decimals, 0, 2);
49
+ }
50
+
51
+ while(strlen($decimals) < 2)
52
+ {
53
+ $decimals .= "0";
54
+ }
55
+
56
+ $value = $integers . $decimals;
57
+ }
58
+
59
+ return $value;
60
+ }
61
+
62
+ /**
63
+ * Retorna mensagem adequada ao codigo de retorno da cielo
64
+ *
65
+ * @param string $statusCode
66
+ * @return string
67
+ */
68
+ public function getStatusMessage($statusCode)
69
+ {
70
+ switch($statusCode)
71
+ {
72
+ case 1:
73
+ $label = "Em andamento";
74
+ break;
75
+ case 2:
76
+ $label = "Autenticada";
77
+ break;
78
+ case 3:
79
+ $label = "N�o autenticada";
80
+ break;
81
+ case 4:
82
+ $label = "Autorizada";
83
+ break;
84
+ case 5:
85
+ $label = "N�o autorizada";
86
+ break;
87
+ case 6:
88
+ $label = "Conclu�da";
89
+ break;
90
+ case 9:
91
+ $label = "Cancelada";
92
+ break;
93
+ case 10:
94
+ $label = "Em autentica��o";
95
+ break;
96
+ case 10:
97
+ $label = "Em cancelamento";
98
+ break;
99
+ default:
100
+ $label = "Erro (" . $statusCode . ")";
101
+ }
102
+
103
+ return htmlentities($label);
104
+ }
105
+
106
+
107
+ /**
108
+ * Retorna o valor de uma parcela, dados o valor total a ser parcelado,
109
+ * a taxa de juros e o numero de prestacoes
110
+ *
111
+ * @param string $total
112
+ * @param string $interest
113
+ * @param string $periods
114
+ * @return string
115
+ */
116
+ public function calcInstallmentValue($total, $interest, $periods)
117
+ {
118
+ /*
119
+ * Formula do coeficiente:
120
+ *
121
+ * juros / ( 1 - 1 / (1 + i)^n )
122
+ *
123
+ */
124
+
125
+
126
+ // calcula o coeficiente, seguindo a formula acima
127
+ $coefficient = pow((1 + $interest), $periods);
128
+ $coefficient = 1 / $coefficient;
129
+ $coefficient = 1 - $coefficient;
130
+ $coefficient = $interest / $coefficient;
131
+
132
+ // retorna o valor da parcela
133
+ return ($total * $coefficient);
134
+ }
135
+
136
+
137
+ /**
138
+ *
139
+ * Percorre um objeto XML, passando-o para HTML
140
+ *
141
+ */
142
+
143
+ public function xmlToHtml($xmlNode, $tab = 0)
144
+ {
145
+ if(count($xmlNode) > 0)
146
+ {
147
+ $childrenNode = $xmlNode->children();
148
+ $childrenString = "";
149
+
150
+ // monta o valor do noh
151
+ foreach($childrenNode as $cn)
152
+ {
153
+ $childrenString .= $this->xmlToHtml($cn, $tab + 1);
154
+ }
155
+
156
+ $nodeString = "<div style='margin-left: " . ($tab * 25) . "px;'><b>" . $xmlNode->getName() . "</b></div>";
157
+
158
+ return $nodeString . $childrenString;
159
+ }
160
+ else
161
+ {
162
+ $nodeString = "<div style='margin-left: " . ($tab * 25) . "px;'><b>" . $xmlNode->getName() . ":</b> " . ((string) $xmlNode) . "</div>";
163
+ return $nodeString;
164
+ }
165
+ }
166
+
167
+ }
app/code/community/Maxima/Cielo/Model/Adminhtml/BuyPage.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Adminhtml_BuyPage
28
+ {
29
+
30
+ /**
31
+ * Formato vetor de vetores
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ return array
38
+ (
39
+ array('value' => 'cielo', 'label'=>Mage::helper('adminhtml')->__('Buy Page Cielo')),
40
+ array('value' => 'loja', 'label'=>Mage::helper('adminhtml')->__('Buy Page Loja')),
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Formato chave-valor
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray()
50
+ {
51
+ return array
52
+ (
53
+ 'cielo' => Mage::helper('adminhtml')->__('Buy Page Cielo'),
54
+ 'loja' => Mage::helper('adminhtml')->__('Buy Page Loja'),
55
+ );
56
+ }
57
+
58
+ }
app/code/community/Maxima/Cielo/Model/Adminhtml/CardTypes.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Maxima_Cielo_Model_Adminhtml_CardTypes
4
+ {
5
+
6
+ /**
7
+ * Formato vetor de vetores
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ return array
14
+ (
15
+ array
16
+ (
17
+ 'value' => 'visa',
18
+ 'label' => Mage::helper('adminhtml')->__('Visa'),
19
+ 'image' => 'Visa.png'
20
+ ),
21
+ array
22
+ (
23
+ 'value' => 'mastercard',
24
+ 'label' => Mage::helper('adminhtml')->__('Mastercard'),
25
+ 'image' => 'Master.png'
26
+ ),
27
+ array
28
+ (
29
+ 'value' => 'diners',
30
+ 'label' => Mage::helper('adminhtml')->__('Diners Club'),
31
+ 'image' => 'Diners.png'
32
+ ),
33
+ array
34
+ (
35
+ 'value' => 'discover',
36
+ 'label' => Mage::helper('adminhtml')->__('Discover'),
37
+ 'image' => 'Discover.png'
38
+ ),
39
+ array
40
+ (
41
+ 'value' => 'elo',
42
+ 'label' => Mage::helper('adminhtml')->__('Elo'),
43
+ 'image' => 'Elo.png'
44
+ ),
45
+ array
46
+ (
47
+ 'value' => 'amex',
48
+ 'label' => Mage::helper('adminhtml')->__('American Express'),
49
+ 'image' => 'Amex.png'
50
+ )
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Formato chave-valor
56
+ *
57
+ * @return array
58
+ */
59
+ public function toArray()
60
+ {
61
+ return array
62
+ (
63
+ 'visa' => Mage::helper('adminhtml')->__('Visa'),
64
+ 'mastercard' => Mage::helper('adminhtml')->__('Mastercard'),
65
+ 'diners' => Mage::helper('adminhtml')->__('Diners'),
66
+ 'discover' => Mage::helper('adminhtml')->__('Discover'),
67
+ 'elo' => Mage::helper('adminhtml')->__('Elo'),
68
+ 'amex' => Mage::helper('adminhtml')->__('American Express'),
69
+ );
70
+ }
71
+
72
+ }
app/code/community/Maxima/Cielo/Model/Adminhtml/Environment.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Adminhtml_Environment
28
+ {
29
+
30
+ /**
31
+ * Formato vetor de vetores
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ return array
38
+ (
39
+ array('value' => 'https://qasecommerce.cielo.com.br', 'label'=>Mage::helper('adminhtml')->__('Teste')),
40
+ array('value' => 'https://ecommerce.cielo.com.br', 'label'=>Mage::helper('adminhtml')->__('Produção')),
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Formato chave-valor
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray()
50
+ {
51
+ return array
52
+ (
53
+ 'https://qasecommerce.cielo.com.br' => Mage::helper('adminhtml')->__('Teste'),
54
+ 'https://ecommerce.cielo.com.br' => Mage::helper('adminhtml')->__('Produção'),
55
+ );
56
+ }
57
+
58
+ }
app/code/community/Maxima/Cielo/Model/Cc.php ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Cc extends Mage_Payment_Model_Method_Abstract
28
+ {
29
+
30
+ protected $_code = 'Maxima_Cielo_Cc';
31
+ protected $_formBlockType = 'Maxima_Cielo/form_cc';
32
+ protected $_infoBlockType = 'Maxima_Cielo/info_cc';
33
+ protected $_canUseInternal = true;
34
+ protected $_canUseForMultishipping = false;
35
+
36
+ /**
37
+ * Assign data to info model instance
38
+ *
39
+ * @param mixed $data
40
+ * @return Mage_Payment_Model_Info
41
+ */
42
+ public function assignData($data)
43
+ {
44
+ if (!($data instanceof Varien_Object))
45
+ {
46
+ $data = new Varien_Object($data);
47
+ }
48
+
49
+ // salva a bandeira e o numero de parcelas
50
+ $info = $this->getInfoInstance();
51
+ $additionaldata = array
52
+ (
53
+ 'parcels_number' => $data->getParcelsNumber()
54
+ );
55
+
56
+ $info->setCcType($data->getCcType())
57
+ ->setCcNumber(Mage::helper('core')->encrypt($data->getCcNumber()))
58
+ ->setCcOwner($data->getCcOwner())
59
+ ->setCcExpMonth($data->getCcExpMonth())
60
+ ->setCcExpYear($data->getCcExpYear())
61
+ ->setCcCid(Mage::helper('core')->encrypt($data->getCcCid()))
62
+ ->setAdditionalData(serialize($additionaldata));
63
+
64
+
65
+ // pega dados de juros
66
+ $withoutInterest = intval($this->getConfigData('installment_without_interest', $this->getStoreId()));
67
+ $interestValue = floatval($this->getConfigData('installment_interest_value', $this->getStoreId()));
68
+
69
+
70
+ // verifica se há juros
71
+ if($data->getParcelsNumber() > $withoutInterest)
72
+ {
73
+ $installmentValue = Mage::helper('Maxima_Cielo')->calcInstallmentValue
74
+ (
75
+ $info->getQuote()->getGrandTotal(),
76
+ $interestValue / 100,
77
+ $data->getParcelsNumber()
78
+ );
79
+ $installmentValue = round($installmentValue, 2);
80
+ $interest = ($installmentValue * $data->getParcelsNumber()) - $info->getQuote()->getGrandTotal();
81
+
82
+ $info->getQuote()->setInterest($info->getQuote()->getStore()->convertPrice($interest, false));
83
+ $info->getQuote()->setBaseInterest($interest);
84
+
85
+ $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals();
86
+ $info->getQuote()->save();
87
+ }
88
+ else
89
+ {
90
+ $info->getQuote()->setInterest(0.0);
91
+ $info->getQuote()->setBaseInterest(0.0);
92
+
93
+ $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals();
94
+ $info->getQuote()->save();
95
+ }
96
+
97
+
98
+ return $this;
99
+ }
100
+
101
+
102
+ /**
103
+ * Valida dados
104
+ *
105
+ * @param Mage_Payment_Model_Info $info
106
+ * @return Mage_Payment_Model_Abstract
107
+ */
108
+ public function validate()
109
+ {
110
+ /*
111
+ * chama validacao do metodo abstrato
112
+ */
113
+ parent::validate();
114
+
115
+ $info = $this->getInfoInstance();
116
+ $errorMsg = false;
117
+
118
+ if($this->getConfigData('buypage', $this->getStoreId()) != "loja")
119
+ return $this;
120
+
121
+ $availableTypes = Mage::getModel('Maxima_Cielo/cc_types')->getCodes();
122
+ $ccNumber = Mage::helper('core')->decrypt($info->getCcNumber());
123
+
124
+ // remove delimitadores do cartao, como "-" e espaco
125
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
126
+ $info->setCcNumber(Mage::helper('core')->encrypt($ccNumber));
127
+
128
+ $ccType = '';
129
+
130
+ // valida o numero do cartao de credito
131
+ if(in_array($info->getCcType(), $availableTypes))
132
+ {
133
+ if ($this->validateCcNum($ccNumber))
134
+ {
135
+ $ccType = 'OT';
136
+ $ccTypeRegExpList = array
137
+ (
138
+ //Solo, Switch or Maestro. International safe
139
+ /*
140
+ // Maestro / Solo
141
+ 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})'
142
+ . '|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})'
143
+ . '|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/',
144
+ */
145
+ // Solo only
146
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
147
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)'
148
+ . '|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)'
149
+ . '|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))'
150
+ . '|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))'
151
+ . '|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
152
+ // Visa
153
+ 'visa' => '/^4[0-9]{12}([0-9]{3})?$/',
154
+ // Master Card
155
+ 'mastercard' => '/^5[1-5][0-9]{14}$/',
156
+ // American Express
157
+ 'amex' => '/^3[47][0-9]{13}$/',
158
+ // Discovery
159
+ 'discover' => '/^6011[0-9]{12}$/',
160
+ // JCB
161
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/',
162
+ // Diners Club
163
+ 'diners' => '/^3[0,6,8]\d{12}$/'
164
+ );
165
+
166
+ foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp)
167
+ {
168
+ if (preg_match($ccTypeRegExp, $ccNumber))
169
+ {
170
+ $ccType = $ccTypeMatch;
171
+ break;
172
+ }
173
+ }
174
+
175
+ if ($info->getCcType() != 'elo' && ($ccType != $info->getCcType()))
176
+ {
177
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card number mismatch with credit card type.');
178
+ }
179
+ }
180
+ else
181
+ {
182
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Invalid Credit Card Number');
183
+ }
184
+
185
+ }
186
+ else
187
+ {
188
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card type is not allowed for this payment method.');
189
+ }
190
+
191
+ // valida o numero de verificacao
192
+ if ($errorMsg === false)
193
+ {
194
+ $verificationRegEx = $this->getVerificationRegEx();
195
+ $regExp = isset($verificationRegEx[$info->getCcType()]) ? $verificationRegEx[$info->getCcType()] : '';
196
+
197
+ if ($regExp != '' && (!$info->getCcCid() || !preg_match($regExp, Mage::helper('core')->decrypt($info->getCcCid()))))
198
+ {
199
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Please enter a valid credit card verification number.');
200
+ }
201
+ }
202
+
203
+ if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth()))
204
+ {
205
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Incorrect credit card expiration date.');
206
+ }
207
+
208
+ if($errorMsg)
209
+ {
210
+ Mage::throwException($errorMsg);
211
+ }
212
+
213
+ //This must be after all validation conditions
214
+ //if ($this->getIsCentinelValidationEnabled())
215
+ //{
216
+ // $this->getCentinelValidator()->validate($this->getCentinelValidationData());
217
+ //}
218
+
219
+ return $this;
220
+ }
221
+
222
+
223
+ /**
224
+ * Validacao retirada do modelo cc da versao 1.7 do Magento
225
+ *
226
+ * @param string $cc_number
227
+ * @return bool
228
+ */
229
+ public function validateCcNum($ccNumber)
230
+ {
231
+ $cardNumber = strrev($ccNumber);
232
+ $numSum = 0;
233
+
234
+ for ($i=0; $i<strlen($cardNumber); $i++)
235
+ {
236
+ $currentNum = substr($cardNumber, $i, 1);
237
+
238
+ /**
239
+ * Double every second digit
240
+ */
241
+ if ($i % 2 == 1)
242
+ {
243
+ $currentNum *= 2;
244
+ }
245
+
246
+ /**
247
+ * Add digits of 2-digit numbers together
248
+ */
249
+ if ($currentNum > 9)
250
+ {
251
+ $firstNum = $currentNum % 10;
252
+ $secondNum = ($currentNum - $firstNum) / 10;
253
+ $currentNum = $firstNum + $secondNum;
254
+ }
255
+
256
+ $numSum += $currentNum;
257
+ }
258
+
259
+ /**
260
+ * If the total has no remainder it's OK
261
+ */
262
+
263
+ return ($numSum % 10 == 0);
264
+ }
265
+
266
+
267
+ /**
268
+ * Expressao regular retirada do modelo cc da versao 1.7 do Magento
269
+ *
270
+ * @return strig regExp
271
+ */
272
+
273
+ public function getVerificationRegEx()
274
+ {
275
+ $verificationExpList = array
276
+ (
277
+ 'visa' => '/^[0-9]{3}$/', // Visa
278
+ 'mastercard' => '/^[0-9]{3}$/', // Master Card
279
+ 'amex' => '/^[0-9]{4}$/', // American Express
280
+ 'discover' => '/^[0-9]{3}$/', // Discovery
281
+ 'SS' => '/^[0-9]{3,4}$/',
282
+ 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
283
+ 'SO' => '/^[0-9]{3,4}$/', // Solo
284
+ 'OT' => '/^[0-9]{3,4}$/',
285
+ 'JCB' => '/^[0-9]{3,4}$/' //JCB
286
+ );
287
+ return $verificationExpList;
288
+ }
289
+
290
+
291
+ /**
292
+ * Validacao retirada do modelo cc da versao 1.7 do Magento
293
+ *
294
+ * @return strig regExp
295
+ */
296
+
297
+ protected function _validateExpDate($expYear, $expMonth)
298
+ {
299
+ $date = Mage::app()->getLocale()->date();
300
+
301
+ if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
302
+ || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1)))
303
+ {
304
+ return false;
305
+ }
306
+
307
+ return true;
308
+ }
309
+
310
+
311
+
312
+
313
+ /**
314
+ * Getter da instancia do pedido
315
+ *
316
+ * @return Mage_Sales_Model_Order
317
+ */
318
+ public function getOrder()
319
+ {
320
+ if ($this->_order == null) {}
321
+
322
+ return $this->_order;
323
+ }
324
+
325
+ /**
326
+ * Setter do pedido
327
+ *
328
+ * @param Mage_Sales_Model_Order $order
329
+ */
330
+ public function setOrder($order)
331
+ {
332
+ if ($order instanceof Mage_Sales_Model_Order)
333
+ {
334
+ $this->_order = $order;
335
+ }
336
+ elseif (is_numeric($order))
337
+ {
338
+ $this->_order = Mage::getModel('sales/order')->load($order);
339
+ }
340
+ else
341
+ {
342
+ $this->_order = null;
343
+ }
344
+ return $this;
345
+ }
346
+
347
+
348
+
349
+
350
+
351
+ /**
352
+ * Abre transacao com a Cielo para uma compra e redirectiona para a
353
+ * pagina de pagamento na Cielo. Em caso de erro, redireciona para pagina
354
+ * de erro.
355
+ *
356
+ * @return string
357
+ */
358
+ public function getOrderPlaceRedirectUrl()
359
+ {
360
+ $info = $this->getInfoInstance();
361
+ $order = $info->getQuote();
362
+ $storeId = $this->getStoreId();
363
+ $payment = $order->getPayment();
364
+ $additionaldata = unserialize($payment->getData('additional_data'));
365
+
366
+ // coleta os dados necessarios
367
+ $value = Mage::helper('Maxima_Cielo')->formatValueForCielo($order->getGrandTotal());
368
+ $paymentType = $additionaldata["parcels_number"];
369
+ $ccType = $payment->getCcType();
370
+ $paymentParcels = $this->getConfigData('installments_type', $storeId);
371
+ $cieloNumber = $this->getConfigData('cielo_number', $storeId);
372
+ $cieloKey = $this->getConfigData('cielo_key', $storeId);
373
+ $autoCapture = $this->getConfigData('auto_capture', $storeId);
374
+ $environment = $this->getConfigData('environment', $storeId);
375
+ $sslFile = $this->getConfigData('ssl_file', $storeId);
376
+
377
+ // cria instancia do pedido
378
+ $webServiceOrder = Mage::getModel('Maxima_Cielo/webServiceOrder', array('enderecoBase' => $environment, 'caminhoCertificado' => $sslFile));
379
+
380
+ // preenche dados coletados
381
+ $webServiceOrderData = array
382
+ (
383
+ 'ccType' => $ccType,
384
+ 'cieloNumber' => $cieloNumber,
385
+ 'cieloKey' => $cieloKey,
386
+ 'capture' => ($autoCapture == 1) ? 'true' : 'false',
387
+ 'autorize' => '1',
388
+ 'clientOrderNumber' => $payment->getId(),
389
+ 'clientOrderValue' => $value,
390
+ 'postbackURL' => Mage::getUrl('cielo/pay/verify'),
391
+ 'clientSoftDesc' => $this->getConfigData('softdescriptor', $storeId)
392
+ );
393
+
394
+ // conforme mostrado no manual versao 2.0, pagina 11,
395
+ // caso o cartao seja Dinners, Discover, Elo ou Amex
396
+ // o valor do flag autorizar deve ser 3
397
+ if($ccType == "diners" ||
398
+ $ccType == "discover" ||
399
+ $ccType == "elo" ||
400
+ $ccType == "amex" ||
401
+ !$this->getConfigData('autenticate', $storeId))
402
+ {
403
+ $webServiceOrderData['autorize'] = '3';
404
+ }
405
+
406
+ if($paymentType == "1")
407
+ {
408
+ $webServiceOrderData['paymentType'] = $paymentType;
409
+ $webServiceOrderData['paymentParcels'] = 1;
410
+ }
411
+ else
412
+ {
413
+ $webServiceOrderData['paymentType'] = $paymentParcels;
414
+ $webServiceOrderData['paymentParcels'] = $paymentType;
415
+ }
416
+
417
+ $webServiceOrder->setData($webServiceOrderData);
418
+
419
+
420
+ // caso seja buy page loja, passa dados do cliente
421
+ if($this->getConfigData('buypage', $storeId) == "loja")
422
+ {
423
+ $ccExpMonth = $info->getCcExpMonth();
424
+ $ccExpMonth = ($ccExpMonth < 10) ? ("0" . $ccExpMonth) : $ccExpMonth;
425
+
426
+ $ownerData = array
427
+ (
428
+ 'number' => Mage::helper('core')->decrypt($info->getCcNumber()),
429
+ 'exp_date' => $info->getCcExpYear() . $ccExpMonth,
430
+ 'sec_code' => Mage::helper('core')->decrypt($info->getCcCid()),
431
+ 'name' => $info->getCcOwner()
432
+ );
433
+ }
434
+ else
435
+ {
436
+ $ownerData = false;
437
+ }
438
+
439
+ $redirectUrl = $webServiceOrder->requestTransaction($ownerData);
440
+ Mage::getSingleton('core/session')->setData('cielo-transaction', $webServiceOrder);
441
+
442
+ if($redirectUrl == false)
443
+ {
444
+ // caso nao haja autenticacao, enviar para o tratamento final do pedido
445
+ if(($this->getConfigData('buypage', $storeId) == "loja") && ($webServiceOrderData['autorize'] == '3'))
446
+ {
447
+ return Mage::getUrl('cielo/pay/verify');
448
+ }
449
+ // erro nao indentificado
450
+ else
451
+ {
452
+ return Mage::getUrl('cielo/pay/failure');
453
+ }
454
+ }
455
+ else
456
+ {
457
+ return $redirectUrl;
458
+ }
459
+ }
460
+ }
app/code/community/Maxima/Cielo/Model/Cc/InstallmentType.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Cc_InstallmentType
28
+ {
29
+ /**
30
+ *
31
+ * Opcoes de tipo de parcelamento
32
+ *
33
+ */
34
+
35
+ public function toOptionArray()
36
+ {
37
+ $options = array();
38
+
39
+ $options['2'] = Mage::helper('adminhtml')->__('Loja');
40
+ $options['3'] = Mage::helper('adminhtml')->__('Administradora');
41
+
42
+ return $options;
43
+ }
44
+ }
app/code/community/Maxima/Cielo/Model/Cc/MaxInstallments.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Cc_MaxInstallments
28
+ {
29
+ /**
30
+ *
31
+ * Opcoes de numero de parcelas
32
+ *
33
+ */
34
+
35
+ public function toOptionArray()
36
+ {
37
+ $options = array();
38
+
39
+ $options['1'] = Mage::helper('adminhtml')->__('1x - Sem parcelamento');
40
+ $options['2'] = Mage::helper('adminhtml')->__('2x');
41
+ $options['3'] = Mage::helper('adminhtml')->__('3x');
42
+ $options['4'] = Mage::helper('adminhtml')->__('4x');
43
+ $options['5'] = Mage::helper('adminhtml')->__('5x');
44
+ $options['6'] = Mage::helper('adminhtml')->__('6x');
45
+ $options['7'] = Mage::helper('adminhtml')->__('7x');
46
+ $options['8'] = Mage::helper('adminhtml')->__('8x');
47
+ $options['9'] = Mage::helper('adminhtml')->__('9x');
48
+ $options['10'] = Mage::helper('adminhtml')->__('10x');
49
+ $options['11'] = Mage::helper('adminhtml')->__('11x');
50
+ $options['12'] = Mage::helper('adminhtml')->__('12x');
51
+
52
+
53
+ return $options;
54
+ }
55
+ }
app/code/community/Maxima/Cielo/Model/Cc/Types.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Cc_Types
28
+ {
29
+
30
+ /**
31
+ * Formato vetor de vetores
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ /**
38
+ * value: indice
39
+ * label: descricao
40
+ * image: nome da imagem
41
+ * inst_s: numero maximo de parcelas para parcelamento na loja
42
+ * inst_a: numero maximo de parcelas para parcelamento na administradora
43
+ */
44
+
45
+ return array
46
+ (
47
+ array
48
+ (
49
+ 'value' => 'visa',
50
+ 'label' => Mage::helper('adminhtml')->__('Visa'),
51
+ 'image' => 'Visa.png',
52
+ 'inst_s' => 12,
53
+ 'inst_a' => 1
54
+ ),
55
+ array
56
+ (
57
+ 'value' => 'mastercard',
58
+ 'label' => Mage::helper('adminhtml')->__('Mastercard'),
59
+ 'image' => 'Master.png',
60
+ 'inst_s' => 12,
61
+ 'inst_a' => 1
62
+ ),
63
+ array
64
+ (
65
+ 'value' => 'diners',
66
+ 'label' => Mage::helper('adminhtml')->__('Diners Club'),
67
+ 'image' => 'Diners.png',
68
+ 'inst_s' => 10,
69
+ 'inst_a' => 1
70
+ ),
71
+ array
72
+ (
73
+ 'value' => 'discover',
74
+ 'label' => Mage::helper('adminhtml')->__('Discover'),
75
+ 'image' => 'Discover.png',
76
+ 'inst_s' => 1,
77
+ 'inst_a' => 1
78
+ ),
79
+ array
80
+ (
81
+ 'value' => 'elo',
82
+ 'label' => Mage::helper('adminhtml')->__('Elo'),
83
+ 'image' => 'Elo.png',
84
+ 'inst_s' => 12,
85
+ 'inst_a' => 1
86
+ ),
87
+ array
88
+ (
89
+ 'value' => 'amex',
90
+ 'label' => Mage::helper('adminhtml')->__('American Express'),
91
+ 'image' => 'Amex.png',
92
+ 'inst_s' => 10,
93
+ 'inst_a' => 24
94
+ )
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Formato chave-valor
100
+ *
101
+ * @return array
102
+ */
103
+ public function toArray()
104
+ {
105
+ return array
106
+ (
107
+ 'visa' => Mage::helper('adminhtml')->__('Visa'),
108
+ 'mastercard' => Mage::helper('adminhtml')->__('Mastercard'),
109
+ 'diners' => Mage::helper('adminhtml')->__('Diners Club'),
110
+ 'discover' => Mage::helper('adminhtml')->__('Discover'),
111
+ 'elo' => Mage::helper('adminhtml')->__('Elo'),
112
+ 'amex' => Mage::helper('adminhtml')->__('American Express'),
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Formato chave
118
+ *
119
+ * @return array
120
+ */
121
+ public function getCodes()
122
+ {
123
+ return array
124
+ (
125
+ 'visa',
126
+ 'mastercard',
127
+ 'diners',
128
+ 'discover',
129
+ 'elo',
130
+ 'amex'
131
+ );
132
+ }
133
+ }
app/code/community/Maxima/Cielo/Model/Dc.php ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Dc extends Mage_Payment_Model_Method_Abstract
28
+ {
29
+
30
+ protected $_code = 'Maxima_Cielo_Dc';
31
+ protected $_formBlockType = 'Maxima_Cielo/form_dc';
32
+ protected $_infoBlockType = 'Maxima_Cielo/info_dc';
33
+ protected $_canUseInternal = true;
34
+ protected $_canUseForMultishipping = false;
35
+
36
+ /**
37
+ * Assign data to info model instance
38
+ *
39
+ * @param mixed $data
40
+ * @return Mage_Payment_Model_Info
41
+ */
42
+ public function assignData($data)
43
+ {
44
+ if (!($data instanceof Varien_Object))
45
+ {
46
+ $data = new Varien_Object($data);
47
+ }
48
+
49
+ // salva a bandeira
50
+ $info = $this->getInfoInstance();
51
+
52
+ // converte nomenclatura da bandeira
53
+ if($data->getCcType() == "visa-electron")
54
+ {
55
+ $cardType = "visa";
56
+ }
57
+ else
58
+ {
59
+ $cardType = $data->getCcType();
60
+ }
61
+
62
+ $info->setCcType($cardType)
63
+ ->setCcNumber(Mage::helper('core')->encrypt($data->getCcNumber()))
64
+ ->setCcOwner($data->getCcOwner())
65
+ ->setCcExpMonth($data->getCcExpMonth())
66
+ ->setCcExpYear($data->getCcExpYear())
67
+ ->setCcCid(Mage::helper('core')->encrypt($data->getCcCid()));
68
+
69
+
70
+ return $this;
71
+ }
72
+
73
+
74
+ /**
75
+ * Valida dados
76
+ *
77
+ * @param Mage_Payment_Model_Info $info
78
+ * @return Mage_Payment_Model_Abstract
79
+ */
80
+ public function validate()
81
+ {
82
+ /*
83
+ * chama validacao do metodo abstrato
84
+ */
85
+ parent::validate();
86
+
87
+ if($this->getConfigData('buypage', $this->getStoreId()) != "loja")
88
+ return $this;
89
+
90
+ $info = $this->getInfoInstance();
91
+ $errorMsg = false;
92
+
93
+ $availableTypes = Mage::getModel('Maxima_Cielo/dc_types')->getCodes();
94
+ $ccNumber = Mage::helper('core')->decrypt($info->getCcNumber());
95
+
96
+ // remove delimitadores do cartao, como "-" e espaco
97
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
98
+ $info->setCcNumber(Mage::helper('core')->encrypt($ccNumber));
99
+
100
+ $ccType = '';
101
+
102
+ // valida o numero do cartao de credito
103
+ if(in_array($info->getCcType(), $availableTypes))
104
+ {
105
+ if ($this->validateCcNum($ccNumber))
106
+ {
107
+ $ccType = 'OT';
108
+ $ccTypeRegExpList = array
109
+ (
110
+ //Solo, Switch or Maestro. International safe
111
+ /*
112
+ // Maestro / Solo
113
+ 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})'
114
+ . '|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})'
115
+ . '|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/',
116
+ */
117
+ // Solo only
118
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/',
119
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)'
120
+ . '|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)'
121
+ . '|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))'
122
+ . '|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))'
123
+ . '|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
124
+ // Visa
125
+ 'visa' => '/^4[0-9]{12}([0-9]{3})?$/',
126
+ // Master Card
127
+ 'mastercard' => '/^5[1-5][0-9]{14}$/',
128
+ // American Express
129
+ 'amex' => '/^3[47][0-9]{13}$/',
130
+ // Discovery
131
+ 'discover' => '/^6011[0-9]{12}$/',
132
+ // JCB
133
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/',
134
+ // Diners Club
135
+ 'diners' => '/^3[0,6,8]\d{12}$/'
136
+ );
137
+
138
+ foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp)
139
+ {
140
+ if (preg_match($ccTypeRegExp, $ccNumber))
141
+ {
142
+ $ccType = $ccTypeMatch;
143
+ break;
144
+ }
145
+ }
146
+
147
+ if ($info->getCcType() != 'elo' && ($ccType != $info->getCcType()))
148
+ {
149
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card number mismatch with credit card type.');
150
+ }
151
+ }
152
+ else
153
+ {
154
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Invalid Credit Card Number');
155
+ }
156
+
157
+ }
158
+ else
159
+ {
160
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card type is not allowed for this payment method.');
161
+ }
162
+
163
+ // valida o numero de verificacao
164
+ if ($errorMsg === false)
165
+ {
166
+ $verificationRegEx = $this->getVerificationRegEx();
167
+ $regExp = isset($verificationRegEx[$info->getCcType()]) ? $verificationRegEx[$info->getCcType()] : '';
168
+
169
+ if ($regExp != '' && (!$info->getCcCid() || !preg_match($regExp, Mage::helper('core')->decrypt($info->getCcCid()))))
170
+ {
171
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Please enter a valid credit card verification number.');
172
+ }
173
+ }
174
+
175
+ if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth()))
176
+ {
177
+ $errorMsg = Mage::helper('Maxima_Cielo')->__('Incorrect credit card expiration date.');
178
+ }
179
+
180
+ if($errorMsg)
181
+ {
182
+ Mage::throwException($errorMsg);
183
+ }
184
+
185
+ //This must be after all validation conditions
186
+ //if ($this->getIsCentinelValidationEnabled())
187
+ //{
188
+ // $this->getCentinelValidator()->validate($this->getCentinelValidationData());
189
+ //}
190
+
191
+ return $this;
192
+ }
193
+
194
+
195
+ /**
196
+ * Validacao retirada do modelo cc da versao 1.7 do Magento
197
+ *
198
+ * @param string $cc_number
199
+ * @return bool
200
+ */
201
+ public function validateCcNum($ccNumber)
202
+ {
203
+ $cardNumber = strrev($ccNumber);
204
+ $numSum = 0;
205
+
206
+ for ($i=0; $i<strlen($cardNumber); $i++)
207
+ {
208
+ $currentNum = substr($cardNumber, $i, 1);
209
+
210
+ /**
211
+ * Double every second digit
212
+ */
213
+ if ($i % 2 == 1)
214
+ {
215
+ $currentNum *= 2;
216
+ }
217
+
218
+ /**
219
+ * Add digits of 2-digit numbers together
220
+ */
221
+ if ($currentNum > 9)
222
+ {
223
+ $firstNum = $currentNum % 10;
224
+ $secondNum = ($currentNum - $firstNum) / 10;
225
+ $currentNum = $firstNum + $secondNum;
226
+ }
227
+
228
+ $numSum += $currentNum;
229
+ }
230
+
231
+ /**
232
+ * If the total has no remainder it's OK
233
+ */
234
+
235
+ return ($numSum % 10 == 0);
236
+ }
237
+
238
+
239
+ /**
240
+ * Expressao regular retirada do modelo cc da versao 1.7 do Magento
241
+ *
242
+ * @return strig regExp
243
+ */
244
+
245
+ public function getVerificationRegEx()
246
+ {
247
+ $verificationExpList = array
248
+ (
249
+ 'visa' => '/^[0-9]{3}$/', // Visa
250
+ 'mastercard' => '/^[0-9]{3}$/', // Master Card
251
+ 'amex' => '/^[0-9]{4}$/', // American Express
252
+ 'discover' => '/^[0-9]{3}$/', // Discovery
253
+ 'SS' => '/^[0-9]{3,4}$/',
254
+ 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
255
+ 'SO' => '/^[0-9]{3,4}$/', // Solo
256
+ 'OT' => '/^[0-9]{3,4}$/',
257
+ 'JCB' => '/^[0-9]{3,4}$/' //JCB
258
+ );
259
+ return $verificationExpList;
260
+ }
261
+
262
+
263
+ /**
264
+ * Validacao retirada do modelo cc da versao 1.7 do Magento
265
+ *
266
+ * @return strig regExp
267
+ */
268
+
269
+ protected function _validateExpDate($expYear, $expMonth)
270
+ {
271
+ $date = Mage::app()->getLocale()->date();
272
+
273
+ if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
274
+ || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1)))
275
+ {
276
+ return false;
277
+ }
278
+
279
+ return true;
280
+ }
281
+
282
+
283
+
284
+
285
+ /**
286
+ * Getter da instancia do pedido
287
+ *
288
+ * @return Mage_Sales_Model_Order
289
+ */
290
+ public function getOrder()
291
+ {
292
+ if ($this->_order == null) {}
293
+
294
+ return $this->_order;
295
+ }
296
+
297
+ /**
298
+ * Setter da instancia do pedido
299
+ *
300
+ * @param Mage_Sales_Model_Order $order
301
+ */
302
+ public function setOrder($order)
303
+ {
304
+ if ($order instanceof Mage_Sales_Model_Order)
305
+ {
306
+ $this->_order = $order;
307
+ }
308
+ elseif (is_numeric($order))
309
+ {
310
+ $this->_order = Mage::getModel('sales/order')->load($order);
311
+ }
312
+ else
313
+ {
314
+ $this->_order = null;
315
+ }
316
+ return $this;
317
+ }
318
+
319
+
320
+ /**
321
+ * Formata o valor da compra de acordo com a definicao da Cielo
322
+ *
323
+ * @param string $originalValue
324
+ * @return string
325
+ */
326
+ public function getOrderPlaceRedirectUrl()
327
+ {
328
+ $info = $this->getInfoInstance();
329
+ $order = $info->getQuote();
330
+ $storeId = $this->getStoreId();
331
+ $payment = $order->getPayment();
332
+ $additionaldata = unserialize($payment->getData('additional_data'));
333
+
334
+ // coleta os dados necessarios
335
+ $value = Mage::helper('Maxima_Cielo')->formatValueForCielo($order->getGrandTotal());
336
+ $paymentType = $additionaldata["parcels_number"];
337
+ $ccType = $payment->getCcType();
338
+ $paymentParcels = $this->getConfigData('installments_type', $storeId);
339
+ $cieloNumber = $this->getConfigData('cielo_number', $storeId);
340
+ $cieloKey = $this->getConfigData('cielo_key', $storeId);
341
+ $environment = $this->getConfigData('environment', $storeId);
342
+ $sslFile = $this->getConfigData('ssl_file', $storeId);
343
+
344
+ // cria instancia do pedido
345
+ $webServiceOrder = Mage::getModel('Maxima_Cielo/webServiceOrder', array('enderecoBase' => $environment, 'caminhoCertificado' => $sslFile));
346
+
347
+ // preenche dados coletados
348
+ $webServiceOrderData = array
349
+ (
350
+ 'ccType' => $ccType,
351
+ 'cieloNumber' => $cieloNumber,
352
+ 'cieloKey' => $cieloKey,
353
+ 'capture' => 'true',
354
+ 'autorize' => '1',
355
+ 'clientOrderNumber' => $payment->getId(),
356
+ 'clientOrderValue' => $value,
357
+ 'postbackURL' => Mage::getUrl('cielo/pay/verify'),
358
+ 'paymentType' => 'A',
359
+ 'paymentParcels' => 1,
360
+ 'clientSoftDesc' => $this->getConfigData('softdescriptor', $storeId)
361
+ );
362
+
363
+ $webServiceOrder->setData($webServiceOrderData);
364
+
365
+ // caso seja buy page loja, passa dados do cliente
366
+ if($this->getConfigData('buypage', $storeId) == "loja")
367
+ {
368
+ $ccExpMonth = $info->getCcExpMonth();
369
+ $ccExpMonth = ($ccExpMonth < 10) ? ("0" . $ccExpMonth) : $ccExpMonth;
370
+
371
+ $ownerData = array
372
+ (
373
+ 'number' => Mage::helper('core')->decrypt($info->getCcNumber()),
374
+ 'exp_date' => $info->getCcExpYear() . $ccExpMonth,
375
+ 'sec_code' => Mage::helper('core')->decrypt($info->getCcCid()),
376
+ 'name' => $info->getCcOwner()
377
+ );
378
+ }
379
+ else
380
+ {
381
+ $ownerData = false;
382
+ }
383
+
384
+ $redirectUrl = $webServiceOrder->requestTransaction($ownerData);
385
+ Mage::getSingleton('core/session')->setData('cielo-transaction', $webServiceOrder);
386
+
387
+ if($redirectUrl == false)
388
+ {
389
+ // caso nao haja autenticacao, enviar para o tratamento final do pedido
390
+ if(($this->getConfigData('buypage', $storeId) == "loja"))
391
+ {
392
+ return Mage::getUrl('cielo/pay/verify');
393
+ }
394
+ // erro nao indentificado
395
+ else
396
+ {
397
+ return Mage::getUrl('cielo/pay/failure');
398
+ }
399
+ }
400
+ else
401
+ {
402
+ return $redirectUrl;
403
+ }
404
+ }
405
+ }
app/code/community/Maxima/Cielo/Model/Dc/Types.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Dc_Types
28
+ {
29
+
30
+ /**
31
+ * Formato vetor de vetores
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ return array
38
+ (
39
+ array
40
+ (
41
+ 'value' => 'visa-electron',
42
+ 'label' => Mage::helper('adminhtml')->__('Visa Electron (somente Bradesco)'),
43
+ 'image' => 'Visa-Electron.png'
44
+ )
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Formato chave-valor
50
+ *
51
+ * @return array
52
+ */
53
+ public function toArray()
54
+ {
55
+ return array
56
+ (
57
+ 'visa' => Mage::helper('adminhtml')->__('Visa Electron')
58
+ );
59
+ }
60
+
61
+ /**
62
+ * Formato chave
63
+ *
64
+ * @return array
65
+ */
66
+ public function getCodes()
67
+ {
68
+ return array
69
+ (
70
+ 'visa'
71
+ );
72
+ }
73
+ }
app/code/community/Maxima/Cielo/Model/Order/Invoice/Interest.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Order_Invoice_Interest extends Mage_Sales_Model_Order_Invoice_Total_Abstract
28
+ {
29
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
30
+ {
31
+ $order = $invoice->getOrder();
32
+
33
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $order->getInterest());
34
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $order->getBaseInterest());
35
+
36
+ return $this;
37
+ }
38
+ }
app/code/community/Maxima/Cielo/Model/Quote/Address/Interest.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_Quote_Address_Interest extends Mage_Sales_Model_Quote_Address_Total_Abstract
28
+ {
29
+ /**
30
+ * Constructor that should initiaze
31
+ */
32
+ public function __construct()
33
+ {
34
+ $this->setCode('interest');
35
+ }
36
+
37
+ /**
38
+ * Used each time when collectTotals is invoked
39
+ *
40
+ * @param Mage_Sales_Model_Quote_Address $address
41
+ * @return Your_Module_Model_Total_Custom
42
+ */
43
+
44
+ public function collect(Mage_Sales_Model_Quote_Address $address)
45
+ {
46
+ if ($address->getData('address_type') == 'billing') return $this;
47
+
48
+ $this->_setAddress($address);
49
+
50
+
51
+ if($ammount = $address->getQuote()->getInterest())
52
+ {
53
+ $this->_setBaseAmount($ammount);
54
+ $this->_setAmount($address->getQuote()->getStore()->convertPrice($ammount, false));
55
+ $address->setInterest($ammount);
56
+ }
57
+ else
58
+ {
59
+ $this->_setBaseAmount(0.00);
60
+ $this->_setAmount(0.00);
61
+ }
62
+
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * Used each time when totals are displayed
68
+ *
69
+ * @param Mage_Sales_Model_Quote_Address $address
70
+ * @return Your_Module_Model_Total_Custom
71
+ */
72
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
73
+ {
74
+ if ($address->getInterest() != 0)
75
+ {
76
+ $address->addTotal(array
77
+ (
78
+ 'code' => $this->getCode(),
79
+ 'title' => Mage::helper('Maxima_Cielo')->__('Interest'),
80
+ 'value' => $address->getInterest()
81
+ ));
82
+ }
83
+ }
84
+ }
app/code/community/Maxima/Cielo/Model/WebServiceOrder.php ADDED
@@ -0,0 +1,547 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_Model_WebServiceOrder
28
+ {
29
+ public $ccType; // bandeira do cartao de credito
30
+ public $paymentType; // forma de pagameto (debito, credito - a vista ou parcelado)
31
+ public $paymentParcels; // numero de parcelas
32
+
33
+ public $clientOrderNumber; // clientOrderNumber
34
+ public $clientOrderValue; // clientOrderValue
35
+ public $clientOrderCurrency = "986"; // numero de indice da moeda utilizada (R$)
36
+ public $clientOrderDate; // data da operacao
37
+ public $clientOrderDescription; // descricao
38
+ public $clientOrderLocale = "PT"; // idioma
39
+ public $clientSoftDesc; // identificador que aparece na fatura do cliente
40
+
41
+ public $cieloNumber; // identificador da loja na cielo
42
+ public $cieloKey; // chave da loja a cielo
43
+
44
+ public $capture; // flag indicando quando pedido deve ser capturado
45
+ public $autorize; // flag indicando quando pedido deve ser autorizado
46
+ public $postbackURL; // url para qual o pagamento retornara o resultado da operacao
47
+ public $tid; // id da transacao
48
+ public $status; // status da transacao
49
+ private $_xmlResponse; // texto xml vindo da resposta da transacao
50
+ private $_transactionError; // erro ocorrido na transicao
51
+
52
+ private $_webServiceURL; // url do webservice da cielo
53
+ private $_SSLCertificatePath; // caminho no sistema de arquivos do certificado SSL
54
+ private $_URLAuthTag = "url-autenticacao"; // tag que armazena a url de autenticacao da transacao
55
+
56
+ const ENCODING = "ISO-8859-1"; // codificacao do xml
57
+ const VERSION = "1.2.0"; // versao do webservice da cielo
58
+
59
+
60
+ function __construct($params)
61
+ {
62
+ $baseURL = (isset($params['enderecoBase'])) ? $params['enderecoBase'] : "https://qasecommerce.cielo.com.br";
63
+ $certificatePath = (isset($params['caminhoCertificado']) &&
64
+ $params['caminhoCertificado'] != "") ? $params['caminhoCertificado'] : Mage::getModuleDir('', 'Maxima_Cielo') . "/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.crt";
65
+
66
+ $this->_webServiceURL = $baseURL . "/servicos/ecommwsec.do";
67
+ $this->_SSLCertificatePath = $certificatePath;
68
+ }
69
+
70
+
71
+ /**
72
+ *
73
+ * funcao utilizada para atribuir os valores base
74
+ * do pedido da cielo
75
+ *
76
+ * @param string $index
77
+ * @param string $value
78
+ *
79
+ * ou
80
+ *
81
+ * @param array $index
82
+ */
83
+
84
+ public function setData($index, $value = null)
85
+ {
86
+ if(is_array($index))
87
+ {
88
+ foreach($index as $i => $v)
89
+ {
90
+ $this->$i = $v;
91
+ }
92
+ }
93
+ else
94
+ {
95
+ $this->$index = $value;
96
+ }
97
+ }
98
+
99
+
100
+
101
+ /**
102
+ *
103
+ * funcao responsavel por montar o xml de requisicao e
104
+ * realizar a criacao da transacao na cielo
105
+ *
106
+ * @param boolean $ownerIncluded
107
+ * @return boolean
108
+ *
109
+ */
110
+
111
+ public function requestTransaction($ownerData)
112
+ {
113
+ $msg = $this->_getXMLHeader() . "\n";
114
+
115
+ $msg .= '<requisicao-transacao id="' . md5(date("YmdHisu")) . '" versao="' . self::VERSION . '">' . "\n ";
116
+ $msg .= $this->_getXMLCieloData() . "\n ";
117
+ $msg .= $this->_getXMLOwnerData($ownerData) . "\n ";
118
+ $msg .= $this->_getXMLOrderData() . "\n ";
119
+ $msg .= $this->_getXMLPaymentData() . "\n ";
120
+ $msg .= $this->_getXMLPostbackURL() . "\n ";
121
+ $msg .= $this->_getXMLAutorize() . "\n ";
122
+ $msg .= $this->_getXMLCapture() . "\n ";
123
+ $msg .= '</requisicao-transacao>';
124
+
125
+ $maxAttempts = 3;
126
+
127
+ while($maxAttempts > 0)
128
+ {
129
+ if($this->_sendRequest("mensagem=" . $msg, "Transacao"))
130
+ {
131
+ if($this->_hasConsultationError())
132
+ {
133
+ Mage::log($this->_transactionError);
134
+ return false;
135
+ }
136
+
137
+ $xml = simplexml_load_string($this->_xmlResponse);
138
+
139
+ // pega dados do xml
140
+ $this->tid = (string) $xml->tid;
141
+ $URLAuthTag = $this->_URLAuthTag;
142
+
143
+ return ((string) $xml->$URLAuthTag);
144
+ }
145
+
146
+ $maxAttempts--;
147
+ }
148
+
149
+ if($maxAttempts == 0)
150
+ {
151
+ Mage::log("[CIELO] Não conseguiu consultar o servidor.");
152
+ }
153
+
154
+ return false;
155
+ }
156
+
157
+
158
+ /**
159
+ *
160
+ * funcao responsavel por montar o xml de requisicao e
161
+ * realizar a consulta do status da transacao
162
+ *
163
+ * @return boolean | string
164
+ *
165
+ */
166
+
167
+ public function requestConsultation()
168
+ {
169
+ $msg = $this->_getXMLHeader() . "\n";
170
+ $msg .= '<requisicao-consulta id="' . md5(date("YmdHisu")) . '" versao="' . self::VERSION . '">' . "\n ";
171
+ $msg .= '<tid>' . $this->tid . '</tid>' . "\n ";
172
+ $msg .= $this->_getXMLCieloData() . "\n ";
173
+ $msg .= '</requisicao-consulta>';
174
+
175
+ $maxAttempts = 3;
176
+
177
+ while($maxAttempts > 0)
178
+ {
179
+ if($this->_sendRequest("mensagem=" . $msg, "Consulta"))
180
+ {
181
+ if($this->_hasConsultationError())
182
+ {
183
+ Mage::log($this->_transactionError);
184
+ return false;
185
+ }
186
+
187
+ $xml = simplexml_load_string($this->_xmlResponse);
188
+ $this->status = (string) $xml->status;
189
+
190
+ return $this->status;
191
+ }
192
+
193
+ $maxAttempts--;
194
+ }
195
+
196
+ if($maxAttempts == 0)
197
+ {
198
+ Mage::log("[CIELO] Não conseguiu consultar o servidor.");
199
+ }
200
+
201
+ return false;
202
+ }
203
+
204
+
205
+
206
+ /**
207
+ *
208
+ * funcao responsavel por montar o xml de requisicao e
209
+ * realizar a captura da transacao
210
+ *
211
+ * @return boolean | string
212
+ *
213
+ */
214
+
215
+ public function requestCapture($value)
216
+ {
217
+ $msg = $this->_getXMLHeader() . "\n";
218
+ $msg .= '<requisicao-captura id="' . md5(date("YmdHisu")) . '" versao="' . self::VERSION . '">' . "\n ";
219
+ $msg .= '<tid>' . $this->tid . '</tid>' . "\n ";
220
+ $msg .= $this->_getXMLCieloData() . "\n ";
221
+ $msg .= '<valor>' . $value . '</valor>' . "\n ";
222
+ $msg .= '</requisicao-captura>';
223
+
224
+ $maxAttempts = 3;
225
+
226
+ while($maxAttempts > 0)
227
+ {
228
+ if($this->_sendRequest("mensagem=" . $msg, "Captura"))
229
+ {
230
+ if($this->_hasConsultationError())
231
+ {
232
+ Mage::log($this->_transactionError);
233
+ return false;
234
+ }
235
+
236
+ $xml = simplexml_load_string($this->_xmlResponse);
237
+ $this->status = (string) $xml->status;
238
+
239
+ return $this->status;
240
+ }
241
+
242
+ $maxAttempts--;
243
+ }
244
+
245
+ if($maxAttempts == 0)
246
+ {
247
+ Mage::log("[CIELO] Não conseguiu consultar o servidor.");
248
+ }
249
+
250
+ return false;
251
+ }
252
+
253
+
254
+
255
+ /**
256
+ *
257
+ * funcao responsavel por montar o xml de requisicao e
258
+ * realizar o cancelamento da transacao
259
+ *
260
+ * @return boolean | string
261
+ *
262
+ */
263
+
264
+ public function requestCancellation()
265
+ {
266
+ $msg = $this->_getXMLHeader() . "\n";
267
+ $msg .= '<requisicao-cancelamento id="' . md5(date("YmdHisu")) . '" versao="' . self::VERSION . '">' . "\n ";
268
+ $msg .= '<tid>' . $this->tid . '</tid>' . "\n ";
269
+ $msg .= $this->_getXMLCieloData() . "\n ";
270
+ $msg .= '</requisicao-cancelamento>';
271
+
272
+ $maxAttempts = 3;
273
+
274
+ while($maxAttempts > 0)
275
+ {
276
+ if($this->_sendRequest("mensagem=" . $msg, "Cancelamento"))
277
+ {
278
+ if($this->_hasConsultationError())
279
+ {
280
+ Mage::log($this->_transactionError);
281
+ return false;
282
+ }
283
+
284
+ $xml = simplexml_load_string($this->_xmlResponse);
285
+ $this->status = (string) $xml->status;
286
+
287
+ return $this->status;
288
+ }
289
+
290
+ $maxAttempts--;
291
+ }
292
+
293
+ if($maxAttempts == 0)
294
+ {
295
+ Mage::log("[CIELO] Não conseguiu consultar o servidor.");
296
+ }
297
+
298
+ return false;
299
+ }
300
+
301
+
302
+
303
+ /**
304
+ *
305
+ * funcao responsavel por conferir se houve erro na requisicao
306
+ *
307
+ * @return boolean
308
+ *
309
+ */
310
+
311
+ private function _hasConsultationError()
312
+ {
313
+ // certificao SSL invalido
314
+ if(stripos($this->_xmlResponse, "SSL certificate problem") !== false)
315
+ {
316
+ $this->_transactionError = "Certificado SSL inválido.";
317
+ return true;
318
+ }
319
+
320
+ $xml = simplexml_load_string($this->_xmlResponse);
321
+
322
+ // tempo de requisicao expirou
323
+ if($xml == null)
324
+ {
325
+ $this->_transactionError = "Tempo de espera na requisição expirou.";
326
+ return true;
327
+ }
328
+
329
+ // retorno de erro da cielo
330
+ if($xml->getName() == "erro")
331
+ {
332
+ $this->_transactionError = "[CIELO: " . $xml->codigo . "] " . utf8_decode($xml->mensagem);
333
+ return true;
334
+ }
335
+
336
+ return false;
337
+ }
338
+
339
+
340
+ /**
341
+ *
342
+ * retorna a msg de erro da requisicao
343
+ *
344
+ * @return string
345
+ *
346
+ */
347
+
348
+ public function getError()
349
+ {
350
+ return $this->_transactionError;
351
+ }
352
+
353
+
354
+ /**
355
+ *
356
+ * funcao que realiza a requisicao
357
+ *
358
+ * @param string $postMsg
359
+ * @param string $transacao
360
+ *
361
+ * @return string | boolean
362
+ *
363
+ */
364
+
365
+ private function _sendRequest($postMsg, $transacao)
366
+ {
367
+ $curl_session = curl_init();
368
+
369
+ curl_setopt($curl_session, CURLOPT_URL, $this->_webServiceURL);
370
+ curl_setopt($curl_session, CURLOPT_FAILONERROR, true);
371
+ curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, true);
372
+ curl_setopt($curl_session, CURLOPT_SSL_VERIFYHOST, 2);
373
+ curl_setopt($curl_session, CURLOPT_CAINFO, $this->_SSLCertificatePath);
374
+ curl_setopt($curl_session, CURLOPT_SSLVERSION, 3);
375
+ curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 10);
376
+ curl_setopt($curl_session, CURLOPT_TIMEOUT, 40);
377
+ curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
378
+ curl_setopt($curl_session, CURLOPT_POST, true);
379
+ curl_setopt($curl_session, CURLOPT_POSTFIELDS, $postMsg );
380
+
381
+ $this->_xmlResponse = curl_exec($curl_session);
382
+
383
+ if(!$this->_xmlResponse)
384
+ {
385
+ return false;
386
+ }
387
+
388
+ curl_close($curl_session);
389
+
390
+ return true;
391
+ }
392
+
393
+ /**
394
+ *
395
+ * funcao que que consulta o retorno xml
396
+ *
397
+ * @return string | boolean
398
+ *
399
+ */
400
+
401
+ public function getXmlResponse()
402
+ {
403
+ try
404
+ {
405
+ return simplexml_load_string($this->_xmlResponse);
406
+ }
407
+ catch(Exception $e)
408
+ {
409
+ return false;
410
+ }
411
+ }
412
+
413
+ /**
414
+ *
415
+ * funcoes que montam o conteudo xml da requisicao
416
+ *
417
+ * @return string
418
+ *
419
+ */
420
+
421
+ private function _getXMLHeader()
422
+ {
423
+ return '<?xml version="1.0" encoding="' . self::ENCODING . '" ?>';
424
+ }
425
+
426
+ private function _getXMLCieloData()
427
+ {
428
+ $msg = '<dados-ec>' . "\n " .
429
+ '<numero>'
430
+ . $this->cieloNumber .
431
+ '</numero>' . "\n " .
432
+ '<chave>'
433
+ . $this->cieloKey .
434
+ '</chave>' . "\n " .
435
+ '</dados-ec>';
436
+
437
+ return $msg;
438
+ }
439
+
440
+ private function _getXMLOwnerData($ownerData)
441
+ {
442
+ if(!$ownerData)
443
+ {
444
+ return "";
445
+ }
446
+
447
+
448
+ $msg = '<dados-portador>' . "\n " .
449
+ '<numero>'
450
+ . $ownerData['number'] .
451
+ '</numero>' . "\n " .
452
+ '<validade>'
453
+ . $ownerData['exp_date'] .
454
+ '</validade>' . "\n " .
455
+ '<indicador>'
456
+ . "1" .
457
+ '</indicador>' . "\n " .
458
+ '<codigo-seguranca>'
459
+ . $ownerData['sec_code'] .
460
+ '</codigo-seguranca>' . "\n " .
461
+ '<nome-portador>'
462
+ . $ownerData['name'] .
463
+ '</nome-portador>' . "\n " .
464
+ '</dados-portador>';
465
+
466
+ return $msg;
467
+ }
468
+
469
+ private function _getXMLOrderData()
470
+ {
471
+ $this->clientOrderDate = date("Y-m-d") . "T" . date("H:i:s");
472
+
473
+ $msg = '<dados-pedido>' . "\n " .
474
+ '<numero>'
475
+ . $this->clientOrderNumber .
476
+ '</numero>' . "\n " .
477
+ '<valor>'
478
+ . $this->clientOrderValue.
479
+ '</valor>' . "\n " .
480
+ '<moeda>'
481
+ . $this->clientOrderCurrency .
482
+ '</moeda>' . "\n " .
483
+ '<data-hora>'
484
+ . $this->clientOrderDate .
485
+ '</data-hora>' . "\n ";
486
+
487
+ if($this->clientOrderDescription != null && $this->clientOrderDescription != "")
488
+ {
489
+ $msg .= '<descricao>'
490
+ . $this->clientOrderDescription .
491
+ '</descricao>' . "\n ";
492
+ }
493
+
494
+ $msg .= '<idioma>'
495
+ . $this->clientOrderLocale .
496
+ '</idioma>' . "\n ";
497
+
498
+ if($this->clientSoftDesc != null && $this->clientSoftDesc != "")
499
+ {
500
+ '<softDescriptor>'
501
+ . $this->clientSoftDesc .
502
+ '</softDescriptor>' . "\n ";
503
+ }
504
+
505
+ $msg .= '</dados-pedido>';
506
+
507
+ return $msg;
508
+ }
509
+
510
+ private function _getXMLPaymentData()
511
+ {
512
+ $msg = '<forma-pagamento>' . "\n " .
513
+ '<bandeira>'
514
+ . $this->ccType .
515
+ '</bandeira>' . "\n " .
516
+ '<produto>'
517
+ . $this->paymentType .
518
+ '</produto>' . "\n " .
519
+ '<parcelas>'
520
+ . $this->paymentParcels .
521
+ '</parcelas>' . "\n " .
522
+ '</forma-pagamento>';
523
+
524
+ return $msg;
525
+ }
526
+
527
+ private function _getXMLPostbackURL()
528
+ {
529
+ $msg = '<url-retorno>' . $this->postbackURL . '</url-retorno>';
530
+
531
+ return $msg;
532
+ }
533
+
534
+ private function _getXMLAutorize()
535
+ {
536
+ $msg = '<autorizar>' . $this->autorize . '</autorizar>';
537
+
538
+ return $msg;
539
+ }
540
+
541
+ private function _getXMLCapture()
542
+ {
543
+ $msg = '<capturar>' . $this->capture . '</capturar>';
544
+
545
+ return $msg;
546
+ }
547
+ }
app/code/community/Maxima/Cielo/controllers/AdminController.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_AdminController extends Mage_Adminhtml_Controller_Action
28
+ {
29
+ /**
30
+ *
31
+ * Funcao responsavel por consultar o status de uma transacao no WebService da
32
+ * Cielo
33
+ *
34
+ */
35
+
36
+ public function consultAction()
37
+ {
38
+ // verifica se o usuario estah logado na administracao do magento
39
+ Mage::getSingleton('core/session', array('name' => 'adminhtml'));
40
+ $session = Mage::getSingleton('admin/session');
41
+
42
+ if (!$session->isLoggedIn())
43
+ {
44
+ return;
45
+ }
46
+
47
+ // pega pedido correspondente
48
+ $orderId = $this->getRequest()->getParam('order');
49
+ $order = Mage::getModel('sales/order')->load($orderId);
50
+
51
+ // pega os dados para requisicao e realiza a consulta
52
+ $methodCode = $order->getPayment()->getMethodInstance()->getCode();
53
+ $cieloNumber = Mage::getStoreConfig('payment/' . $methodCode . '/cielo_number');
54
+ $cieloKey = Mage::getStoreConfig('payment/' . $methodCode . '/cielo_key');
55
+ $environment = Mage::getStoreConfig('payment/' . $methodCode . '/environment');
56
+ $sslFile = Mage::getStoreConfig('payment/' . $methodCode . '/ssl_file');
57
+
58
+ $model = Mage::getModel('Maxima_Cielo/webServiceOrder', array('enderecoBase' => $environment, 'caminhoCertificado' => $sslFile));
59
+
60
+ $model->tid = $this->getRequest()->getParam('tid');
61
+ $model->cieloNumber = $cieloNumber;
62
+ $model->cieloKey = $cieloKey;
63
+
64
+ $model->requestConsultation();
65
+ $xml = $model->getXmlResponse();
66
+
67
+ $this->getResponse()->setBody(Mage::helper('Maxima_Cielo')->xmlToHtml($xml));
68
+ }
69
+
70
+
71
+ /**
72
+ *
73
+ * Funcao responsavel por enviar o pedido de captura para o WebService da Cielo
74
+ *
75
+ */
76
+
77
+ public function captureAction()
78
+ {
79
+ // verifica se o usuario estah logado na administracao do magento
80
+ Mage::getSingleton('core/session', array('name' => 'adminhtml'));
81
+ $session = Mage::getSingleton('admin/session');
82
+
83
+ if (!$session->isLoggedIn())
84
+ {
85
+ return;
86
+ }
87
+
88
+ // pega pedido correspondente
89
+ $orderId = $this->getRequest()->getParam('order');
90
+ $order = Mage::getModel('sales/order')->load($orderId);
91
+ $value = Mage::helper('Maxima_Cielo')->formatValueForCielo($order->getGrandTotal());
92
+
93
+ // pega os dados para requisicao e realiza a consulta
94
+ $cieloNumber = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/cielo_number');
95
+ $cieloKey = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/cielo_key');
96
+ $environment = Mage::getStoreConfig('payment/' . $methodCode . '/environment');
97
+ $sslFile = Mage::getStoreConfig('payment/' . $methodCode . '/ssl_file');
98
+
99
+ $model = Mage::getModel('Maxima_Cielo/webServiceOrder', array('enderecoBase' => $environment, 'caminhoCertificado' => $sslFile));
100
+
101
+ $model->tid = $this->getRequest()->getParam('tid');
102
+ $model->cieloNumber = $cieloNumber;
103
+ $model->cieloKey = $cieloKey;
104
+
105
+ // requisita captura
106
+ $model->requestCapture($value);
107
+ $xml = $model->getXmlResponse();
108
+ $status = (string) $xml->status;
109
+
110
+ // tudo ok, transacao aprovada, cria fatura
111
+ if($status == 6)
112
+ {
113
+ $html = "<b>Pedido capturado com sucesso!</b> &nbsp; &nbsp;
114
+ <button type=\"button\" title=\"Atualizar Informações\" onclick=\"document.location.reload(true)\">
115
+ <span>Recarregar Página</span>
116
+ </button><br /><br />";
117
+
118
+ // atualiza os dados da compra
119
+ $payment = $order->getPayment();
120
+ $payment->setAdditionalInformation('Cielo_status', $status);
121
+ $payment->save();
122
+
123
+ if($order->canInvoice() && !$order->hasInvoices())
124
+ {
125
+ $invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(), array());
126
+ $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
127
+
128
+ // envia email de confirmacao de fatura
129
+ $invoice->sendEmail(true);
130
+ $invoice->setEmailSent(true);
131
+ $invoice->save();
132
+ }
133
+ }
134
+ else
135
+ {
136
+ $html = "";
137
+ }
138
+
139
+ $this->getResponse()->setBody($html . Mage::helper('Maxima_Cielo')->xmlToHtml($xml));
140
+ }
141
+
142
+
143
+ /**
144
+ *
145
+ * Funcao responsavel por enviar o pedido de cancelamento para o WebService da Cielo
146
+ *
147
+ */
148
+
149
+ public function cancelAction()
150
+ {
151
+ // verifica se o usuario estah logado na administracao do magento
152
+ Mage::getSingleton('core/session', array('name' => 'adminhtml'));
153
+ $session = Mage::getSingleton('admin/session');
154
+
155
+ if (!$session->isLoggedIn())
156
+ {
157
+ return;
158
+ }
159
+
160
+
161
+ // pega os dados para requisicao e realiza a consulta
162
+ $cieloNumber = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/cielo_number');
163
+ $cieloKey = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/cielo_key');
164
+ $environment = Mage::getStoreConfig('payment/' . $methodCode . '/environment');
165
+ $sslFile = Mage::getStoreConfig('payment/' . $methodCode . '/ssl_file');
166
+
167
+ $model = Mage::getModel('Maxima_Cielo/webServiceOrder', array('enderecoBase' => $environment, 'caminhoCertificado' => $sslFile));
168
+
169
+ $model->tid = $this->getRequest()->getParam('tid');
170
+ $model->cieloNumber = $cieloNumber;
171
+ $model->cieloKey = $cieloKey;
172
+
173
+ // requisita cancelamento
174
+ $model->requestCancellation();
175
+ $xml = $model->getXmlResponse();
176
+
177
+ $this->getResponse()->setBody(Mage::helper('Maxima_Cielo')->xmlToHtml($xml));
178
+ }
179
+ }
app/code/community/Maxima/Cielo/controllers/PayController.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ class Maxima_Cielo_PayController extends Mage_Core_Controller_Front_Action
28
+ {
29
+ /**
30
+ *
31
+ * Funcao responsavel por tratar o retorno da pagina de pagamento da Cielo.
32
+ * Confere a informacao retornada, limpa o objeto de requisicao da sessao e
33
+ * exibe mensagem com o resultado da acao.
34
+ *
35
+ */
36
+
37
+ public function verifyAction()
38
+ {
39
+ if(!Mage::getSingleton('core/session')->getData('cielo-transaction'))
40
+ {
41
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
42
+ Mage::app()->getFrontController()->getResponse()->setRedirect($url);
43
+ return;
44
+ }
45
+
46
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
47
+ $order = Mage::getModel('sales/order')->load($orderId);
48
+ $payment = $order->getPayment();
49
+
50
+ // pega o pedido armazenado
51
+ $webServiceOrder = Mage::getSingleton('core/session')->getData('cielo-transaction');
52
+ Mage::getSingleton('core/session')->unsetData('cielo-transaction');
53
+ $autoCapture = Mage::getStoreConfig('payment/Maxima_Cielo_Cc/auto_capture');
54
+
55
+ $this->loadLayout();
56
+ $block = $this->getLayout()->getBlock('Maxima_Cielo.success');
57
+
58
+ // realiza consulta ao status do pagamento
59
+ $status = $webServiceOrder->requestConsultation();
60
+ $xml = $webServiceOrder->getXmlResponse();
61
+ $eci = (isset($xml->autenticacao->eci)) ? ((string) $xml->autenticacao->eci) : "";
62
+
63
+ $block->setCieloStatus($status);
64
+ $block->setCieloTid($webServiceOrder->tid);
65
+ $payment->setAdditionalInformation('Cielo_tid', $webServiceOrder->tid);
66
+ $payment->setAdditionalInformation('Cielo_status', $status);
67
+ $payment->setAdditionalInformation('Cielo_cardType', $webServiceOrder->ccType);
68
+ $payment->setAdditionalInformation('Cielo_installments', $webServiceOrder->paymentParcels);
69
+ $payment->setAdditionalInformation('Cielo_eci', $eci);
70
+ $payment->save();
71
+
72
+ // possiveis status
73
+ // -1 nao foi possivel consultar
74
+ // 0 criada
75
+ // 1 em andamento
76
+ // 2 autenticada
77
+ // 3 nao autenticada
78
+ // 4 autorizada ou pendente de captura
79
+ // 5 nao autorizada
80
+ // 6 capturada
81
+ // 8 nao capturada
82
+ // 9 cancelada
83
+ // 10 em autenticacao
84
+
85
+ // tudo ok, transacao aprovada, salva no banco
86
+ if($block->getCieloStatus() == 6)
87
+ {
88
+ // se jah foi capturado e nao era pra ter sido, tem algo de errado
89
+ if(!$autoCapture && $payment->getMethodInstance()->getCode() == "Maxima_Cielo_Cc")
90
+ {
91
+ Mage::log("[Cielo] Pedido foi capturado, enquanto o flag indicava que nao deveria ter sido.");
92
+ }
93
+ else
94
+ {
95
+ if($order->canInvoice() && !$order->hasInvoices())
96
+ {
97
+ $invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(), array());
98
+ $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
99
+
100
+ // envia email de confirmacao de fatura
101
+ $invoice->sendEmail(true);
102
+ $invoice->setEmailSent(true);
103
+ $invoice->save();
104
+ }
105
+ }
106
+ }
107
+ // ainda em processo de autenticacao, nao faz nada... aguardar
108
+ else if($block->getCieloStatus() == 10)
109
+ {
110
+
111
+ }
112
+ // por algum motivo deu errado, deve tentar denovo
113
+ else
114
+ {
115
+
116
+ }
117
+
118
+ // envia email de nova compra
119
+ $order->sendNewOrderEmail();
120
+ $order->setEmailSent(true);
121
+ $order->save();
122
+
123
+ // limpa juros, caso nao tenha sido zerado
124
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
125
+
126
+ if($quote)
127
+ {
128
+ $quote->setInterest(0.0);
129
+ $quote->setBaseInterest(0.0);
130
+
131
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
132
+ $quote->save();
133
+ }
134
+
135
+ $this->renderLayout();
136
+ }
137
+
138
+ /**
139
+ *
140
+ * Funcao responsavel por tratar o caso de erro na comunicacao com o servidor da
141
+ * Cielo. Limpa objeto da sessao e mostra mensagem de erro.
142
+ *
143
+ */
144
+
145
+ public function failureAction()
146
+ {
147
+ if(!Mage::getSingleton('core/session')->getData('cielo-transaction'))
148
+ {
149
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
150
+ Mage::app()->getFrontController()->getResponse()->setRedirect($url);
151
+ return;
152
+ }
153
+
154
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
155
+ $order = Mage::getModel('sales/order')->load($orderId);
156
+ $payment = $order->getPayment();
157
+
158
+ // pega o pedido armazenado
159
+ $webServiceOrder = Mage::getSingleton('core/session')->getData('cielo-transaction');
160
+ Mage::getSingleton('core/session')->unsetData('cielo-transaction');
161
+
162
+ $this->loadLayout();
163
+ $block = $this->getLayout()->getBlock('Maxima_Cielo.failure');
164
+
165
+ // preenche erro
166
+ $payment->setAdditionalInformation('Cielo_error', true);
167
+ $payment->setAdditionalInformation('Cielo_error_msg', $webServiceOrder->getError());
168
+ $payment->save();
169
+
170
+ $this->renderLayout();
171
+ }
172
+ }
app/code/community/Maxima/Cielo/etc/config.xml ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ -->
26
+
27
+ <config>
28
+
29
+ <modules>
30
+ <Maxima_Cielo>
31
+ <version>1.5.0</version>
32
+ </Maxima_Cielo>
33
+ </modules>
34
+
35
+ <global>
36
+ <models>
37
+ <Maxima_Cielo>
38
+ <class>Maxima_Cielo_Model</class>
39
+ </Maxima_Cielo>
40
+ </models>
41
+ <resources>
42
+ <Maxima_Cielo_setup>
43
+ <setup>
44
+ <module>Maxima_Cielo</module>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </Maxima_Cielo_setup>
50
+ <Maxima_Cielo_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </Maxima_Cielo_write>
55
+ <Maxima_Cielo_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </Maxima_Cielo_read>
60
+ </resources>
61
+ <helpers>
62
+ <Maxima_Cielo>
63
+ <class>Maxima_Cielo_Helper</class>
64
+ </Maxima_Cielo>
65
+ </helpers>
66
+ <blocks>
67
+ <Maxima_Cielo>
68
+ <class>Maxima_Cielo_Block</class>
69
+ </Maxima_Cielo>
70
+ <sales>
71
+ <rewrite>
72
+ <order_totals>Maxima_Cielo_Block_Sales_Order_Totals</order_totals>
73
+ </rewrite>
74
+ </sales>
75
+ <adminhtml>
76
+ <rewrite>
77
+ <sales_order_totals>Maxima_Cielo_Block_Adminhtml_Order_Totals</sales_order_totals>
78
+ <sales_order_invoice_totals>Maxima_Cielo_Block_Adminhtml_Order_Invoice_Totals</sales_order_invoice_totals>
79
+ <sales_order_view>Maxima_Cielo_Block_Adminhtml_Order_View</sales_order_view>
80
+ </rewrite>
81
+ </adminhtml>
82
+ </blocks>
83
+ <sales>
84
+ <quote>
85
+ <totals>
86
+ <interest>
87
+ <class>Maxima_Cielo/quote_address_interest</class>
88
+ <after>shipping</after>
89
+ <before>grand_total</before>
90
+ </interest>
91
+ </totals>
92
+ </quote>
93
+ <order_invoice>
94
+ <totals>
95
+ <your_total>
96
+ <class>Maxima_Cielo/order_invoice_interest</class>
97
+ <after>shipping</after>
98
+ <before>grand_total</before>
99
+ </your_total>
100
+ </totals>
101
+ </order_invoice>
102
+ </sales>
103
+ <fieldsets>
104
+ <sales_convert_quote_address>
105
+ <interest>
106
+ <to_order>*</to_order>
107
+ </interest>
108
+ <base_interest>
109
+ <to_order>*</to_order>
110
+ </base_interest>
111
+ </sales_convert_quote_address>
112
+ <sales_convert_order>
113
+ <interest>
114
+ <to_invoice>*</to_invoice>
115
+ <to_shipment>*</to_shipment>
116
+ <to_cm>*</to_cm>
117
+ </interest>
118
+ <base_interest>
119
+ <to_invoice>*</to_invoice>
120
+ <to_shipment>*</to_shipment>
121
+ <to_cm>*</to_cm>
122
+ </base_interest>
123
+ </sales_convert_order>
124
+ </fieldsets>
125
+ </global>
126
+
127
+ <frontend>
128
+ <routers>
129
+ <Maxima_Cielo>
130
+ <use>standard</use>
131
+ <args>
132
+ <module>Maxima_Cielo</module>
133
+ <frontName>cielo</frontName>
134
+ </args>
135
+ </Maxima_Cielo>
136
+ </routers>
137
+ <layout>
138
+ <updates>
139
+ <Maxima_Cielo>
140
+ <file>cielo.xml</file>
141
+ </Maxima_Cielo>
142
+ </updates>
143
+ </layout>
144
+ <translate>
145
+ <modules>
146
+ <translations>
147
+ <files>
148
+ <default>Maxima_Cielo.csv</default>
149
+ </files>
150
+ </translations>
151
+ </modules>
152
+ </translate>
153
+ </frontend>
154
+
155
+ <adminhtml>
156
+ <translate>
157
+ <modules>
158
+ <translations>
159
+ <files>
160
+ <default>Maxima_Cielo.csv</default>
161
+ </files>
162
+ </translations>
163
+ </modules>
164
+ </translate>
165
+ </adminhtml>
166
+
167
+
168
+ <default>
169
+ <payment>
170
+ <Maxima_Cielo_Cc>
171
+ <model>Maxima_Cielo_Model_Cc</model>
172
+ <active>0</active>
173
+ <buypage>loja</buypage>
174
+ <environment>https://qasecommerce.cielo.com.br</environment>
175
+ <card_types>visa,mastercard,diners,discover,elo,amex</card_types>
176
+ <auto_capture>1</auto_capture>
177
+ <autenticate>1</autenticate>
178
+ <ssl_file></ssl_file>
179
+ <title>Cartão de Crédito</title>
180
+ <max_parcels_number>1</max_parcels_number>
181
+ <installments_type>2</installments_type>
182
+ <auto_capture>1</auto_capture>
183
+ <cielo_number>1006993069</cielo_number>
184
+ <cielo_key>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</cielo_key>
185
+ </Maxima_Cielo_Cc>
186
+ </payment>
187
+ <payment>
188
+ <Maxima_Cielo_Dc>
189
+ <model>Maxima_Cielo_Model_Dc</model>
190
+ <active>0</active>
191
+ <buypage>loja</buypage>
192
+ <environment>https://qasecommerce.cielo.com.br</environment>
193
+ <card_types>visa</card_types>
194
+ <ssl_file></ssl_file>
195
+ <title>Cartão de Débito</title>
196
+ <auto_capture>1</auto_capture>
197
+ <cielo_number>1001734898</cielo_number>
198
+ <cielo_key>e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832</cielo_key>
199
+ </Maxima_Cielo_Dc>
200
+ </payment>
201
+ </default>
202
+
203
+ </config>
app/code/community/Maxima/Cielo/etc/system.xml ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ -->
26
+
27
+ <config>
28
+ <sections>
29
+ <payment translate="label" module="payment">
30
+ <groups>
31
+ <Maxima_Cielo_Cc translate="label">
32
+
33
+ <label>Cartão de Crédito - Cielo - Máxima</label>
34
+ <sort_order>675</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+
39
+ <comment>
40
+ <![CDATA[
41
+ <div>
42
+ Versão: 1.5.0<br />
43
+ Este módulo foi desenvolvido por Fillipe Almeida Dutra<br />
44
+ Contato: lawsann@gmail.com
45
+ <br /><br /><hr />
46
+ </div>
47
+ ]]>
48
+ </comment>
49
+
50
+ <fields>
51
+
52
+ <active translate="label">
53
+ <label>Enabled</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>10</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </active>
61
+ <buypage translate="label">
62
+ <label>Modality</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>Maxima_Cielo/adminhtml_buyPage</source_model>
65
+ <sort_order>20</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
+ </buypage>
70
+ <title translate="label">
71
+ <label>Title</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>30</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <comment>
78
+ <![CDATA[
79
+ <div>
80
+ Título que aparecerá para o cliente
81
+ </div>
82
+ ]]>
83
+ </comment>
84
+ </title>
85
+ <softdescriptor translate="label">
86
+ <label>Soft Descriptor</label>
87
+ <frontend_type>text</frontend_type>
88
+ <sort_order>35</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ <comment>
93
+ <![CDATA[
94
+ <div>
95
+ Nome que será mostrado na fatura do cliente (máximo de 13 caracteres)
96
+ </div>
97
+ ]]>
98
+ </comment>
99
+ </softdescriptor>
100
+ <environment translate="label">
101
+ <label>Environment</label>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>Maxima_Cielo/adminhtml_environment</source_model>
104
+ <sort_order>40</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
+ </environment>
109
+ <card_types translate="label">
110
+ <label>Card Types</label>
111
+ <frontend_type>multiselect</frontend_type>
112
+ <source_model>Maxima_Cielo/cc_types</source_model>
113
+ <sort_order>50</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </card_types>
118
+ <auto_capture translate="label">
119
+ <label>Auto Capture</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_yesno</source_model>
122
+ <sort_order>60</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ </auto_capture>
127
+ <autenticate translate="label">
128
+ <label>Autenticate</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_yesno</source_model>
131
+ <sort_order>65</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ </autenticate>
136
+ <ssl_file translate="label">
137
+ <label>SSL File</label>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>70</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ <comment>
144
+ <![CDATA[
145
+ <div>
146
+ Caminho do arquivo SSL no servidor
147
+ </div>
148
+ ]]>
149
+ </comment>
150
+ </ssl_file>
151
+ <order_status translate="label">
152
+ <label>New Order Status</label>
153
+ <frontend_type>select</frontend_type>
154
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
155
+ <sort_order>80</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </order_status>
160
+ <installments_type translate="label">
161
+ <label>Installment Type</label>
162
+ <frontend_type>select</frontend_type>
163
+ <sort_order>90</sort_order>
164
+ <source_model>Maxima_Cielo_Model_Cc_InstallmentType</source_model>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ </installments_type>
169
+ <max_parcels_number translate="label">
170
+ <label>Max Installments</label>
171
+ <frontend_type>select</frontend_type>
172
+ <sort_order>100</sort_order>
173
+ <source_model>Maxima_Cielo_Model_Cc_MaxInstallments</source_model>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </max_parcels_number>
178
+ <min_parcels_value translate="label">
179
+ <label>Min Installment Value</label>
180
+ <frontend_type>text</frontend_type>
181
+ <sort_order>110</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <show_in_store>1</show_in_store>
185
+ </min_parcels_value>
186
+ <installment_without_interest translate="label">
187
+ <label>Installments Without Interest</label>
188
+ <frontend_type>text</frontend_type>
189
+ <sort_order>120</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>1</show_in_store>
193
+ </installment_without_interest>
194
+ <installment_interest_value translate="label">
195
+ <label>Installment Interest (%)</label>
196
+ <frontend_type>text</frontend_type>
197
+ <sort_order>130</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ </installment_interest_value>
202
+ <cielo_number translate="label">
203
+ <label>Cielo Merchant Number</label>
204
+ <frontend_type>text</frontend_type>
205
+ <sort_order>140</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ </cielo_number>
210
+ <cielo_key translate="label">
211
+ <label>Cielo Merchant Key</label>
212
+ <frontend_type>text</frontend_type>
213
+ <sort_order>150</sort_order>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>1</show_in_store>
217
+ </cielo_key>
218
+ </fields>
219
+ </Maxima_Cielo_Cc>
220
+
221
+
222
+ <Maxima_Cielo_Dc translate="label">
223
+
224
+ <label>Cartão de Débito - Cielo - Máxima</label>
225
+ <sort_order>675</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+
230
+ <comment>
231
+ <![CDATA[
232
+ <div>
233
+ Versão: 1.5.0<br />
234
+ Este módulo foi desenvolvido por Fillipe Almeida Dutra<br />
235
+ Contato: lawsann@gmail.com
236
+ <br /><br /><hr />
237
+ </div>
238
+ ]]>
239
+ </comment>
240
+
241
+ <fields>
242
+
243
+ <active translate="label">
244
+ <label>Enabled</label>
245
+ <frontend_type>select</frontend_type>
246
+ <source_model>adminhtml/system_config_source_yesno</source_model>
247
+ <sort_order>1</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ </active>
252
+ <buypage translate="label">
253
+ <label>Modality</label>
254
+ <frontend_type>select</frontend_type>
255
+ <source_model>Maxima_Cielo/adminhtml_buyPage</source_model>
256
+ <sort_order>20</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </buypage>
261
+ <title translate="label">
262
+ <label>Title</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>30</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ <comment>
269
+ <![CDATA[
270
+ <div>
271
+ Título que aparecerá para o cliente
272
+ </div>
273
+ ]]>
274
+ </comment>
275
+ </title>
276
+ <softdescriptor translate="label">
277
+ <label>Soft Descriptor</label>
278
+ <frontend_type>text</frontend_type>
279
+ <sort_order>35</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>1</show_in_store>
283
+ <comment>
284
+ <![CDATA[
285
+ <div>
286
+ Nome que será mostrado na fatura do cliente (máximo de 13 caracteres)
287
+ </div>
288
+ ]]>
289
+ </comment>
290
+ </softdescriptor>
291
+ <environment translate="label">
292
+ <label>Environment</label>
293
+ <frontend_type>select</frontend_type>
294
+ <source_model>Maxima_Cielo/adminhtml_environment</source_model>
295
+ <sort_order>40</sort_order>
296
+ <show_in_default>1</show_in_default>
297
+ <show_in_website>1</show_in_website>
298
+ <show_in_store>1</show_in_store>
299
+ </environment>
300
+ <card_types translate="label">
301
+ <label>Card Types</label>
302
+ <frontend_type>multiselect</frontend_type>
303
+ <source_model>Maxima_Cielo/dc_types</source_model>
304
+ <sort_order>50</sort_order>
305
+ <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ </card_types>
309
+ <ssl_file translate="label">
310
+ <label>SSL File</label>
311
+ <frontend_type>text</frontend_type>
312
+ <sort_order>60</sort_order>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ <comment>
317
+ <![CDATA[
318
+ <div>
319
+ Caminho do arquivo SSL no servidor
320
+ </div>
321
+ ]]>
322
+ </comment>
323
+ </ssl_file>
324
+ <order_status translate="label">
325
+ <label>New Order Status</label>
326
+ <frontend_type>select</frontend_type>
327
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
328
+ <sort_order>70</sort_order>
329
+ <show_in_default>1</show_in_default>
330
+ <show_in_website>1</show_in_website>
331
+ <show_in_store>1</show_in_store>
332
+ </order_status>
333
+ <cielo_number translate="label">
334
+ <label>Cielo Merchant Number</label>
335
+ <frontend_type>text</frontend_type>
336
+ <sort_order>80</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>1</show_in_store>
340
+ </cielo_number>
341
+ <cielo_key translate="label">
342
+ <label>Cielo Merchant Key</label>
343
+ <frontend_type>text</frontend_type>
344
+ <sort_order>90</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>1</show_in_store>
348
+ </cielo_key>
349
+ </fields>
350
+ </Maxima_Cielo_Dc>
351
+ </groups>
352
+ </payment>
353
+ </sections>
354
+ </config>
app/code/community/Maxima/Cielo/sql/Maxima_Cielo_setup/mysql4-upgrade-1.0.1-1.1.0.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+
28
+ $installer = Mage::getResourceModel('sales/setup', 'default_setup');
29
+
30
+ $installer->startSetup();
31
+
32
+
33
+ // criacao dos campos de juros para as entidades envolvidas na compra
34
+
35
+ $installer->addAttribute('order', 'base_interest', array
36
+ (
37
+ 'label' => 'Base Interest',
38
+ 'type' => 'decimal',
39
+ ));
40
+
41
+ $installer->addAttribute('quote', 'interest', array
42
+ (
43
+ 'label' => 'Interest',
44
+ 'type' => 'decimal',
45
+ ));
46
+
47
+ $installer->addAttribute('quote', 'base_interest', array
48
+ (
49
+ 'label' => 'Base Interest',
50
+ 'type' => 'decimal',
51
+ ));
52
+
53
+ $installer->addAttribute('order', 'interest', array
54
+ (
55
+ 'label' => 'Interest',
56
+ 'type' => 'decimal',
57
+ ));
58
+
59
+ $installer->addAttribute('invoice', 'base_interest', array
60
+ (
61
+ 'label' => 'Base Interest',
62
+ 'type' => 'decimal',
63
+ ));
64
+
65
+ $installer->addAttribute('invoice', 'interest', array
66
+ (
67
+ 'label' => 'Interest',
68
+ 'type' => 'decimal',
69
+ ));
70
+
71
+ $installer->addAttribute('creditmemo', 'base_interest', array
72
+ (
73
+ 'label' => 'Base Interest',
74
+ 'type' => 'decimal',
75
+ ));
76
+
77
+ $installer->addAttribute('creditmemo', 'interest', array
78
+ (
79
+ 'label' => 'Interest',
80
+ 'type' => 'decimal',
81
+ ));
82
+
83
+ $installer->endSetup();
84
+
app/code/community/Maxima/Cielo/ssl/VeriSignClass3PublicPrimaryCertificationAuthority-G5.crt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB
3
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
4
+ ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp
5
+ U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW
6
+ ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0
7
+ aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL
8
+ MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW
9
+ ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln
10
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp
11
+ U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y
12
+ aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1
13
+ nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex
14
+ t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz
15
+ SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG
16
+ BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+
17
+ rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/
18
+ NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E
19
+ BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH
20
+ BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
21
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv
22
+ MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE
23
+ p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y
24
+ 5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK
25
+ WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ
26
+ 4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N
27
+ hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
28
+ -----END CERTIFICATE-----
app/design/adminhtml/default/default/template/cielo/info/cc.phtml ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ Cartão de Crédito Cielo
29
+ <br /><br />
30
+ <?php
31
+
32
+
33
+ if($_info = $this->getInfo())
34
+ {
35
+ if($_info->getOrder())
36
+ {
37
+ $payment = $_info->getOrder()->getPayment();
38
+
39
+ if($payment->getAdditionalInformation ('Cielo_error'))
40
+ {
41
+ echo "Erro na transação: " . $payment->getAdditionalInformation ('Cielo_error');
42
+ }
43
+ else
44
+ {
45
+ $tid = $payment->getAdditionalInformation ('Cielo_tid');
46
+ $status = $payment->getAdditionalInformation ('Cielo_status');
47
+ $cardType = $payment->getAdditionalInformation ('Cielo_cardType');
48
+ $installments = $payment->getAdditionalInformation ('Cielo_installments');
49
+
50
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toArray();
51
+ $cardType = $allCards[$cardType];
52
+ $installments = ($installments == 1) ? '&#192; vista' : $installments . " vezes";
53
+
54
+ $html = "<b>ID Transação</b>: " . $tid . "<br />";
55
+ $html .= "<b>Status</b>: " . Mage::helper('Maxima_Cielo')->getStatusMessage($status) . "<br />";
56
+ $html .= "<b>Bandeira</b>: " . $cardType . "<br />";
57
+ $html .= "<b>Parcelamento</b>: " . $installments . "<br /><br />";
58
+
59
+ echo $html;
60
+ }
61
+ }
62
+ }
63
+ ?>
64
+
65
+ <script type="text/javascript">// <![CDATA[
66
+
67
+
68
+ function captureCieloOrder(tid, orderId)
69
+ {
70
+ var url = '<?php echo $this->getUrl('cielo/admin/capture') ?>';
71
+
72
+ new Ajax.Request(url,
73
+ {
74
+ method : 'post',
75
+ parameters : "tid=" + tid + "&order=" + orderId,
76
+ onComplete : function(transport)
77
+ {
78
+ maximaModalWindow("Captura de Dados", transport.responseText, 600, 400);
79
+ }
80
+ });
81
+ }
82
+
83
+
84
+ function loadCieloWebServiceData(tid, orderId)
85
+ {
86
+ var url = '<?php echo $this->getUrl('cielo/admin/consult') ?>';
87
+
88
+ new Ajax.Request(url,
89
+ {
90
+ method : 'post',
91
+ parameters : "tid=" + tid + "&order=" + orderId,
92
+ onComplete : function(transport)
93
+ {
94
+ maximaModalWindow("Dados Cielo", transport.responseText, 600, 400);
95
+ }
96
+ });
97
+ }
98
+
99
+
100
+ function cancelCieloOrder(tid, orderId)
101
+ {
102
+ var cancellation = confirm("<?php echo $this->__("Do You really want to cancel this transaction on Cielo?"); ?>");
103
+
104
+ if(cancellation)
105
+ {
106
+ var url = '<?php echo $this->getUrl('cielo/admin/cancel') ?>';
107
+
108
+ new Ajax.Request(url,
109
+ {
110
+ method : 'post',
111
+ parameters : "tid=" + tid + "&order=" + orderId,
112
+ onComplete : function(transport)
113
+ {
114
+ maximaModalWindow("Cancelamento na Cielo", transport.responseText, 600, 400);
115
+ }
116
+ });
117
+ }
118
+ }
119
+
120
+
121
+ function maximaModalWindow(title, content, width, height)
122
+ {
123
+ $$('HTML')[0].setStyle({overflow: 'hidden'});
124
+
125
+ var viewport = document.viewport;
126
+
127
+ var windowWidth = (width) ? width : 300;
128
+ var windowHeight = (height) ? height : 200;
129
+
130
+ var styleWidth = width + 'px';
131
+ var styleHeight = height + 'px';
132
+ var styleTop = (viewport.getScrollOffsets()[1] + (viewport.getHeight() / 2)- (windowHeight / 2)) + 'px';
133
+ var styleLeftMargin = "-" + (windowWidth / 2) + 'px';
134
+
135
+ var windowBodyWidth = (windowWidth - 80) + 'px';
136
+ var windowBodyHeight = (windowHeight - 50) + 'px';
137
+
138
+ // mascara que cobre o fundo da tela
139
+ var mask = document.createElement("div");
140
+ mask.id = 'maxima-page-mask';
141
+ mask.setStyle
142
+ ({
143
+ 'width' : viewport.getWidth() + "px",
144
+ 'height' : viewport.getHeight() + "px",
145
+ 'position' : 'absolute',
146
+ 'zIndex' : '9000',
147
+ 'backgroundColor' : '#333333',
148
+ 'top' : viewport.getScrollOffsets()[1] + 'px',
149
+ 'left' : '0',
150
+ 'display' : 'none'
151
+ });
152
+
153
+
154
+ // janela modal
155
+ var modalWindow = document.createElement("div");
156
+ modalWindow.id = 'maxima-modal-window';
157
+ $(modalWindow).setStyle
158
+ ({
159
+ 'width' : styleWidth,
160
+ 'height' : styleHeight,
161
+ 'top' : styleTop,
162
+ 'marginLeft' : styleLeftMargin,
163
+ 'position' : 'absolute',
164
+ 'zIndex' : '9001',
165
+ 'backgroundColor' : 'transparent',
166
+ 'left' : '50%',
167
+ 'display' : 'none',
168
+ 'color' : '#333333',
169
+ 'fontSize' : '11px'
170
+ });
171
+
172
+ // tabela que monta o layout da janela
173
+ var windowStructure = document.createElement("table");
174
+ var tableBody = document.createElement("tbody");
175
+
176
+ windowStructure.cellPadding = '0';
177
+ windowStructure.cellSpacing = '0';
178
+ windowStructure.border = '0';
179
+
180
+ var tr1WindowStructure = document.createElement("tr");
181
+ var tr2WindowStructure = document.createElement("tr");
182
+ var tr3WindowStructure = document.createElement("tr");
183
+
184
+ var td11WindowStructure = document.createElement("td");
185
+ var td12WindowStructure = document.createElement("td");
186
+ var td13WindowStructure = document.createElement("td");
187
+ var td21WindowStructure = document.createElement("td");
188
+ var td22WindowStructure = document.createElement("td");
189
+ var td23WindowStructure = document.createElement("td");
190
+ var td31WindowStructure = document.createElement("td");
191
+ var td32WindowStructure = document.createElement("td");
192
+ var td33WindowStructure = document.createElement("td");
193
+
194
+ var leftUpCorner = document.createElement("div");
195
+ $(leftUpCorner).setStyle
196
+ ({
197
+ 'height' : '10px',
198
+ 'width' : '10px',
199
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>top_left.png\')'
200
+ });
201
+ td11WindowStructure.appendChild(leftUpCorner);
202
+
203
+ $(td12WindowStructure).setStyle
204
+ ({
205
+ 'height' : '10px',
206
+ 'width' : (windowWidth - 20) + 'px',
207
+ 'backgroundColor' : '#333333'
208
+ });
209
+
210
+ var rightUpCorner = document.createElement("div");
211
+ $(rightUpCorner).setStyle
212
+ ({
213
+ 'height' : '10px',
214
+ 'width' : '10px',
215
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>top_right.png\')'
216
+ });
217
+ td13WindowStructure.appendChild(rightUpCorner);
218
+
219
+ $(td21WindowStructure).setStyle
220
+ ({
221
+ 'height' : (windowHeight - 20) + 'px',
222
+ 'width' : '10px',
223
+ 'backgroundColor' : '#333333'
224
+ });
225
+
226
+ $(td22WindowStructure).setStyle
227
+ ({
228
+ 'backgroundColor' : '#FFFFFF'
229
+ });
230
+
231
+ $(td23WindowStructure).setStyle
232
+ ({
233
+ 'height' : (windowHeight - 20) + 'px',
234
+ 'width' : '10px',
235
+ 'backgroundColor' : '#333333'
236
+ });
237
+
238
+ $(td31WindowStructure).setStyle
239
+ ({
240
+ 'height' : '10px',
241
+ 'width' : '10px',
242
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>bottom_left.png\')'
243
+ });
244
+
245
+ $(td32WindowStructure).setStyle
246
+ ({
247
+ 'height' : '10px',
248
+ 'width' : (windowWidth - 20) + 'px',
249
+ 'backgroundColor' : '#333333'
250
+ });
251
+
252
+ $(td33WindowStructure).setStyle
253
+ ({
254
+ 'height' : '10px',
255
+ 'width' : '10px',
256
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>bottom_right.png\')'
257
+ });
258
+
259
+ tr1WindowStructure.appendChild(td11WindowStructure);
260
+ tr1WindowStructure.appendChild(td12WindowStructure);
261
+ tr1WindowStructure.appendChild(td13WindowStructure);
262
+ tr2WindowStructure.appendChild(td21WindowStructure);
263
+ tr2WindowStructure.appendChild(td22WindowStructure);
264
+ tr2WindowStructure.appendChild(td23WindowStructure);
265
+ tr3WindowStructure.appendChild(td31WindowStructure);
266
+ tr3WindowStructure.appendChild(td32WindowStructure);
267
+ tr3WindowStructure.appendChild(td33WindowStructure);
268
+
269
+ tableBody.appendChild(tr1WindowStructure);
270
+ tableBody.appendChild(tr2WindowStructure);
271
+ tableBody.appendChild(tr3WindowStructure);
272
+
273
+ windowStructure.appendChild(tableBody);
274
+
275
+ modalWindow.appendChild(windowStructure);
276
+
277
+ // monta estrutura html
278
+ var windowHeader = document.createElement("div");
279
+ windowHeader.setStyle
280
+ ({
281
+ 'height' : '38px',
282
+ 'width' : '100%',
283
+ 'position' : 'relative',
284
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>header.png\')',
285
+ 'backgroundRepeat' : 'repeat-x'
286
+ });
287
+
288
+ var titleDiv = document.createElement('div');
289
+ titleDiv.setStyle
290
+ ({
291
+ 'position' : 'absolute',
292
+ 'top' : '8px',
293
+ 'left' : '10px',
294
+ 'color' : '#FFFFFF',
295
+ 'fontSize' : '12px',
296
+ 'fontWeight' : 'bold'
297
+ });
298
+ $(titleDiv).update(title);
299
+
300
+ var closeButton = document.createElement('div');
301
+ closeButton.setStyle
302
+ ({
303
+ 'position' : 'absolute',
304
+ 'width' : '16px',
305
+ 'height' : '16px',
306
+ 'top' : '8px',
307
+ 'right' : '5px',
308
+ 'cursor' : 'pointer',
309
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>close.png\')',
310
+ });
311
+
312
+ var windowBody = document.createElement("div");
313
+ windowBody.setStyle
314
+ ({
315
+ 'width' : '100%',
316
+ 'position' : 'relative',
317
+ 'padding' : '15px',
318
+ 'color' : '#333333',
319
+ 'fontSize' : '12px',
320
+ 'height' : windowHeight + "px",
321
+ 'width' : windowWidth + "px",
322
+ 'overflow' : 'auto'
323
+ });
324
+ $(windowBody).update(content);
325
+
326
+ windowHeader.appendChild(titleDiv);
327
+ windowHeader.appendChild(closeButton);
328
+ td22WindowStructure.appendChild(windowHeader);
329
+ td22WindowStructure.appendChild(windowBody);
330
+
331
+ document.body.appendChild(mask);
332
+ document.body.appendChild(modalWindow);
333
+
334
+ $(mask).appear({ duration: 0.2, from: 0, to: 0.5 });
335
+ $(modalWindow).appear({ duration: 0.2, from: 0, to: 1 });
336
+
337
+ $(closeButton).observe('click', function()
338
+ {
339
+ document.body.removeChild(mask);
340
+ document.body.removeChild(modalWindow);
341
+ $$('HTML')[0].setStyle({overflow: 'auto'});
342
+ });
343
+
344
+
345
+ }
346
+ // ]]></script>
app/design/adminhtml/default/default/template/cielo/info/dc.phtml ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ Cartão de Débito Cielo
29
+ <br /><br />
30
+ <?php
31
+
32
+
33
+ if($_info = $this->getInfo())
34
+ {
35
+ if($_info->getOrder())
36
+ {
37
+ $payment = $_info->getOrder()->getPayment();
38
+
39
+ if($payment->getAdditionalInformation ('Cielo_error'))
40
+ {
41
+ echo "Erro na transação: " . $payment->getAdditionalInformation ('Cielo_error');
42
+ }
43
+ else
44
+ {
45
+ $tid = $payment->getAdditionalInformation ('Cielo_tid');
46
+ $status = $payment->getAdditionalInformation ('Cielo_status');
47
+ $cardType = $payment->getAdditionalInformation ('Cielo_cardType');
48
+ $installments = $payment->getAdditionalInformation ('Cielo_installments');
49
+
50
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toArray();
51
+ $cardType = $allCards[$cardType];
52
+ $installments = ($installments == 1) ? '&#192; vista' : $installments . " vezes";
53
+
54
+ $html = "<b>ID Transação</b>: " . $tid . "<br />";
55
+ $html .= "<b>Status</b>: " . Mage::helper('Maxima_Cielo')->getStatusMessage($status) . "<br />";
56
+ $html .= "<b>Bandeira</b>: " . $cardType . "<br />";
57
+ $html .= "<b>Parcelamento</b>: " . $installments . "<br /><br />";
58
+
59
+ echo $html;
60
+ }
61
+ }
62
+ }
63
+ ?>
64
+
65
+ <script type="text/javascript">// <![CDATA[
66
+
67
+ function loadCieloWebServiceData(tid, orderId)
68
+ {
69
+ var url = '<?php echo $this->getUrl('cielo/admin/consult') ?>';
70
+
71
+ new Ajax.Request(url,
72
+ {
73
+ method : 'post',
74
+ parameters : "tid=" + tid + "&order=" + orderId,
75
+ onComplete : function(transport)
76
+ {
77
+ maximaModalWindow("Dados Cielo", transport.responseText, 600, 400);
78
+ }
79
+ });
80
+ }
81
+
82
+
83
+ function maximaModalWindow(title, content, width, height)
84
+ {
85
+ $$('HTML')[0].setStyle({overflow: 'hidden'});
86
+
87
+ var viewport = document.viewport;
88
+
89
+ var windowWidth = (width) ? width : 300;
90
+ var windowHeight = (height) ? height : 200;
91
+
92
+ var styleWidth = width + 'px';
93
+ var styleHeight = height + 'px';
94
+ var styleTop = (viewport.getScrollOffsets()[1] + (viewport.getHeight() / 2)- (windowHeight / 2)) + 'px';
95
+ var styleLeftMargin = "-" + (windowWidth / 2) + 'px';
96
+
97
+ var windowBodyWidth = (windowWidth - 80) + 'px';
98
+ var windowBodyHeight = (windowHeight - 50) + 'px';
99
+
100
+ // mascara que cobre o fundo da tela
101
+ var mask = document.createElement("div");
102
+ mask.id = 'maxima-page-mask';
103
+ mask.setStyle
104
+ ({
105
+ 'width' : viewport.getWidth() + "px",
106
+ 'height' : viewport.getHeight() + "px",
107
+ 'position' : 'absolute',
108
+ 'zIndex' : '9000',
109
+ 'backgroundColor' : '#333333',
110
+ 'top' : viewport.getScrollOffsets()[1] + 'px',
111
+ 'left' : '0',
112
+ 'display' : 'none'
113
+ });
114
+
115
+
116
+ // janela modal
117
+ var modalWindow = document.createElement("div");
118
+ modalWindow.id = 'maxima-modal-window';
119
+ $(modalWindow).setStyle
120
+ ({
121
+ 'width' : styleWidth,
122
+ 'height' : styleHeight,
123
+ 'top' : styleTop,
124
+ 'marginLeft' : styleLeftMargin,
125
+ 'position' : 'absolute',
126
+ 'zIndex' : '9001',
127
+ 'backgroundColor' : 'transparent',
128
+ 'left' : '50%',
129
+ 'display' : 'none',
130
+ 'color' : '#333333',
131
+ 'fontSize' : '11px'
132
+ });
133
+
134
+ // tabela que monta o layout da janela
135
+ var windowStructure = document.createElement("table");
136
+ var tableBody = document.createElement("tbody");
137
+
138
+ windowStructure.cellPadding = '0';
139
+ windowStructure.cellSpacing = '0';
140
+ windowStructure.border = '0';
141
+
142
+ var tr1WindowStructure = document.createElement("tr");
143
+ var tr2WindowStructure = document.createElement("tr");
144
+ var tr3WindowStructure = document.createElement("tr");
145
+
146
+ var td11WindowStructure = document.createElement("td");
147
+ var td12WindowStructure = document.createElement("td");
148
+ var td13WindowStructure = document.createElement("td");
149
+ var td21WindowStructure = document.createElement("td");
150
+ var td22WindowStructure = document.createElement("td");
151
+ var td23WindowStructure = document.createElement("td");
152
+ var td31WindowStructure = document.createElement("td");
153
+ var td32WindowStructure = document.createElement("td");
154
+ var td33WindowStructure = document.createElement("td");
155
+
156
+ var leftUpCorner = document.createElement("div");
157
+ $(leftUpCorner).setStyle
158
+ ({
159
+ 'height' : '10px',
160
+ 'width' : '10px',
161
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>top_left.png\')'
162
+ });
163
+ td11WindowStructure.appendChild(leftUpCorner);
164
+
165
+ $(td12WindowStructure).setStyle
166
+ ({
167
+ 'height' : '10px',
168
+ 'width' : (windowWidth - 20) + 'px',
169
+ 'backgroundColor' : '#333333'
170
+ });
171
+
172
+ var rightUpCorner = document.createElement("div");
173
+ $(rightUpCorner).setStyle
174
+ ({
175
+ 'height' : '10px',
176
+ 'width' : '10px',
177
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>top_right.png\')'
178
+ });
179
+ td13WindowStructure.appendChild(rightUpCorner);
180
+
181
+ $(td21WindowStructure).setStyle
182
+ ({
183
+ 'height' : (windowHeight - 20) + 'px',
184
+ 'width' : '10px',
185
+ 'backgroundColor' : '#333333'
186
+ });
187
+
188
+ $(td22WindowStructure).setStyle
189
+ ({
190
+ 'backgroundColor' : '#FFFFFF'
191
+ });
192
+
193
+ $(td23WindowStructure).setStyle
194
+ ({
195
+ 'height' : (windowHeight - 20) + 'px',
196
+ 'width' : '10px',
197
+ 'backgroundColor' : '#333333'
198
+ });
199
+
200
+ $(td31WindowStructure).setStyle
201
+ ({
202
+ 'height' : '10px',
203
+ 'width' : '10px',
204
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>bottom_left.png\')'
205
+ });
206
+
207
+ $(td32WindowStructure).setStyle
208
+ ({
209
+ 'height' : '10px',
210
+ 'width' : (windowWidth - 20) + 'px',
211
+ 'backgroundColor' : '#333333'
212
+ });
213
+
214
+ $(td33WindowStructure).setStyle
215
+ ({
216
+ 'height' : '10px',
217
+ 'width' : '10px',
218
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>bottom_right.png\')'
219
+ });
220
+
221
+ tr1WindowStructure.appendChild(td11WindowStructure);
222
+ tr1WindowStructure.appendChild(td12WindowStructure);
223
+ tr1WindowStructure.appendChild(td13WindowStructure);
224
+ tr2WindowStructure.appendChild(td21WindowStructure);
225
+ tr2WindowStructure.appendChild(td22WindowStructure);
226
+ tr2WindowStructure.appendChild(td23WindowStructure);
227
+ tr3WindowStructure.appendChild(td31WindowStructure);
228
+ tr3WindowStructure.appendChild(td32WindowStructure);
229
+ tr3WindowStructure.appendChild(td33WindowStructure);
230
+
231
+ tableBody.appendChild(tr1WindowStructure);
232
+ tableBody.appendChild(tr2WindowStructure);
233
+ tableBody.appendChild(tr3WindowStructure);
234
+
235
+ windowStructure.appendChild(tableBody);
236
+
237
+ modalWindow.appendChild(windowStructure);
238
+
239
+ // monta estrutura html
240
+ var windowHeader = document.createElement("div");
241
+ windowHeader.setStyle
242
+ ({
243
+ 'height' : '38px',
244
+ 'width' : '100%',
245
+ 'position' : 'relative',
246
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>header.png\')',
247
+ 'backgroundRepeat' : 'repeat-x'
248
+ });
249
+
250
+ var titleDiv = document.createElement('div');
251
+ titleDiv.setStyle
252
+ ({
253
+ 'position' : 'absolute',
254
+ 'top' : '8px',
255
+ 'left' : '10px',
256
+ 'color' : '#FFFFFF',
257
+ 'fontSize' : '12px',
258
+ 'fontWeight' : 'bold'
259
+ });
260
+ $(titleDiv).update(title);
261
+
262
+ var closeButton = document.createElement('div');
263
+ closeButton.setStyle
264
+ ({
265
+ 'position' : 'absolute',
266
+ 'width' : '16px',
267
+ 'height' : '16px',
268
+ 'top' : '8px',
269
+ 'right' : '5px',
270
+ 'cursor' : 'pointer',
271
+ 'backgroundImage' : 'url(\'<?php echo $this->getSkinUrl() . "images/cielo/window/"; ?>close.png\')',
272
+ });
273
+
274
+ var windowBody = document.createElement("div");
275
+ windowBody.setStyle
276
+ ({
277
+ 'width' : '100%',
278
+ 'position' : 'relative',
279
+ 'padding' : '15px',
280
+ 'color' : '#333333',
281
+ 'fontSize' : '12px',
282
+ 'height' : windowHeight + "px",
283
+ 'width' : windowWidth + "px",
284
+ 'overflow' : 'auto'
285
+ });
286
+ $(windowBody).update(content);
287
+
288
+ windowHeader.appendChild(titleDiv);
289
+ windowHeader.appendChild(closeButton);
290
+ td22WindowStructure.appendChild(windowHeader);
291
+ td22WindowStructure.appendChild(windowBody);
292
+
293
+ document.body.appendChild(mask);
294
+ document.body.appendChild(modalWindow);
295
+
296
+ $(mask).appear({ duration: 0.2, from: 0, to: 0.5 });
297
+ $(modalWindow).appear({ duration: 0.2, from: 0, to: 1 });
298
+
299
+ $(closeButton).observe('click', function()
300
+ {
301
+ document.body.removeChild(mask);
302
+ document.body.removeChild(modalWindow);
303
+ $$('HTML')[0].setStyle({overflow: 'auto'});
304
+ });
305
+
306
+
307
+ }
308
+ // ]]></script>
app/design/frontend/default/default/layout/cielo.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ -->
26
+
27
+ <layout>
28
+
29
+ <maxima_cielo_pay_verify translate="label">
30
+ <label>Verificacao do pagamento</label>
31
+ <reference name="root">
32
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
33
+ </reference>
34
+ <reference name="content">
35
+ <block type="Maxima_Cielo/verify" name="Maxima_Cielo.success" template="cielo/success.phtml"/>
36
+ </reference>
37
+ </maxima_cielo_pay_verify>
38
+
39
+ <maxima_cielo_pay_failure translate="label">
40
+ <label>Verificacao do pagamento</label>
41
+ <reference name="root">
42
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
43
+ </reference>
44
+ <reference name="content">
45
+ <block type="Core/template" name="Maxima_Cielo.failure" template="cielo/failure.phtml"/>
46
+ </reference>
47
+ </maxima_cielo_pay_failure>
48
+
49
+ </layout>
50
+
app/design/frontend/default/default/template/cielo/failure.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ <div class="page-title">
29
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
30
+ </div>
31
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
32
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
33
+
34
+ <?php if ($this->getOrderId()):?>
35
+ <?php if ($this->getCanViewOrder()) :?>
36
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
37
+ <?php else :?>
38
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
39
+ <?php endif;?>
40
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
41
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
42
+ <p>
43
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
44
+ <?php echo $this->getChildHtml() ?>
45
+ </p>
46
+ <?php endif;?>
47
+ <?php endif;?>
48
+
49
+ <?php if ($this->getAgreementRefId()): ?>
50
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
51
+ <?php endif;?>
52
+ <br />
53
+ <ul>
54
+ <li><?php echo $this->__('Houve um problema ao tentar realizar o pagamento. Para maiores informações, por favor entre em contato.'); ?></li>
55
+ </ul>
56
+ <div class="buttons-set">
57
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
58
+ </div>
app/design/frontend/default/default/template/cielo/form/cc.phtml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ <fieldset class="form-list">
29
+ <ul id="payment_form_Maxima_Cielo_Cc" style="display:none;">
30
+ <br />
31
+ <?php
32
+
33
+ $cardsData = $this->getAllowedCards();
34
+
35
+ $size = count($cardsData);
36
+
37
+ for($i = 0; $i < $size; $i++)
38
+ {
39
+ $value = $cardsData[$i]['value'];
40
+ $label = $cardsData[$i]['label'];
41
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . "frontend/default/default/images/cielo/" . $cardsData[$i]['image'];
42
+
43
+ // abre agrupamento de bandeiras
44
+ if($i % 3 == 0)
45
+ {
46
+ ?>
47
+ <li class="first">
48
+ <ul class="card-logo">
49
+ <?php
50
+ }
51
+
52
+ // bandeira em questao
53
+ ?>
54
+ <li style="width: 70px; float: left;">
55
+ <label for="card-<?php echo $value; ?>"><img src="<?php echo $img; ?>" style="width: 40px;" title="<?php echo $label; ?>" /><br>
56
+ <input name="payment[cc_type]" type="radio" value="<?php echo $value; ?>" id="card-<?php echo $value; ?>"
57
+ onclick="maximaCieloUpdateInstallments('<?php echo $value; ?>')" class="validate-one-required-by-name" />
58
+ </label>
59
+ </li>
60
+ <?php
61
+ // fecha agrupamento de bandeiras
62
+ if(($i == $size - 1))
63
+ {
64
+ ?>
65
+ </ul>
66
+ </li>
67
+ <?php
68
+ }
69
+ }
70
+
71
+ // dados do cartao
72
+ // somente mostrado em buy page loja
73
+
74
+ if($this->getConfigData('buypage') == "loja")
75
+ {
76
+ ?>
77
+ <li>
78
+ <label for="cielo-card-number" class="required"><em>*</em><?php echo $this->__('Card Number') ?></label><br />
79
+ <div class="input-box">
80
+ <input name="payment[cc_number]" type="text" value="" id="cielo-card-number" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-cc-number" maxlength="16" onkeydown="return denyNotNumber(this, event);" />
81
+ </div>
82
+ </li>
83
+ <li>
84
+ <label for="cielo-security-code" class="required"><em>*</em><?php echo $this->__('Verification Code') ?></label><br />
85
+ <div class="input-box">
86
+ <input name="payment[cc_cid]" type="text" value="" id="cielo-security-code" title="<?php echo $this->__('Verification Code') ?>" class="input-text required-entry" style="width: 50px;" maxlength="4" onkeydown="return denyNotNumber(this, event);" />
87
+ </div>
88
+ </li>
89
+ <li>
90
+ <label for="cielo-card_expiration-mh" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
91
+ <div class="input-box">
92
+ <div class="v-fix">
93
+ <select id="cielo-card_expiration-mh" name="payment[cc_exp_month]" class="month required-entry" autocomplete="off">
94
+ <option value="" selected="selected"><?php echo $this->__('Month') ?></option>
95
+ <?php foreach($this->getMonths() as $month): ?>
96
+ <option value="<?php echo $month['num'] ?>"><?php echo $month['label'] ?></option>
97
+ <?php endforeach ?>
98
+ </select>
99
+ </div>
100
+ <div class="v-fix">
101
+ <select id="cielo-card_expiration-yr" name="payment[cc_exp_year]" class="year required-entry" autocomplete="off">
102
+ <option value="" selected="selected"><?php echo $this->__('Year') ?></option>
103
+ <?php foreach($this->getYears() as $year): ?>
104
+ <option value="<?php echo $year['num'] ?>"><?php echo $year['label'] ?></option>
105
+ <?php endforeach ?>
106
+ </select>
107
+ </div>
108
+ </div>
109
+ <li>
110
+ <label for="cielo-card_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
111
+ <div class="input-box">
112
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="cielo-card_owner" name="payment[cc_owner]" value="" autocomplete="off">
113
+ </div>
114
+ </li>
115
+ </li>
116
+ <?php
117
+ }
118
+ ?>
119
+ <li>
120
+ <br />
121
+ <label for="cielo-installments" class="required"><em>*</em><?php echo $this->__('Installments') ?> </label>
122
+ <div class="input-box">
123
+ <select id="cielo-installments" name="payment[parcels_number]">
124
+ <?php foreach($this->getInstallments() as $parcel): ?>
125
+ <option value="<?php echo $parcel['num'] ?>"><?php echo $parcel['label'] ?></option>
126
+ <?php endforeach ?>
127
+ </select>
128
+ </div>
129
+ </li>
130
+ <br />
131
+ </ul>
132
+ </fieldset>
133
+ <script type="text/javascript">// <![CDATA[
134
+
135
+ function maximaCieloUpdateInstallments(cardType)
136
+ {
137
+ var installmentsField = document.getElementById('cielo-installments');
138
+
139
+ // monta array com maximo de parcelas x bandeira cartao
140
+ var installmentsArray = new Array();
141
+ <?php
142
+
143
+ $cardsMaxInstallments = $this->getMaxCardsInstallments();
144
+
145
+ foreach($cardsMaxInstallments as $card => $maxInstallments)
146
+ {
147
+ echo "installmentsArray." . $card . " = " . $maxInstallments . ";\n";
148
+ }
149
+
150
+ ?>
151
+
152
+ // ajusta valor do campo
153
+ if(installmentsField.value > installmentsArray[cardType])
154
+ {
155
+ installmentsField.value = 1;
156
+ }
157
+
158
+ // ajusta opcoes mostradas
159
+ for(var i = 0; i < installmentsField.options.length; i++)
160
+ {
161
+ if(installmentsArray[cardType] < (i + 1))
162
+ {
163
+ installmentsField.options[i].style.display = "none";
164
+ }
165
+ else
166
+ {
167
+ installmentsField.options[i].style.display = "block";
168
+ }
169
+ }
170
+ }
171
+
172
+ function denyNotNumber(field, event)
173
+ {
174
+ var keyCode = ('which' in event) ? event.which : event.keyCode;
175
+ var char = String.fromCharCode(keyCode);
176
+
177
+ // teclas backspace e delete
178
+ if(keyCode == 8 || keyCode == 46)
179
+ return true;
180
+
181
+ // impede caracteres nao numericos
182
+ if(isNaN(char))
183
+ return false;
184
+ else
185
+ return true;
186
+ }
187
+
188
+ // ]]></script>
app/design/frontend/default/default/template/cielo/form/dc.phtml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ <fieldset class="form-list">
29
+ <ul id="payment_form_Maxima_Cielo_Dc" style="display:none;">
30
+ <br />
31
+ <?php
32
+
33
+ $cardsData = $this->getAllowedCards();
34
+
35
+ $size = count($cardsData);
36
+
37
+ for($i = 0; $i < $size; $i++)
38
+ {
39
+ $value = $cardsData[$i]['value'];
40
+ $label = $cardsData[$i]['label'];
41
+ $img = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . "frontend/default/default/images/cielo/" . $cardsData[$i]['image'];
42
+
43
+ // abre agrupamento de bandeiras
44
+ if($i % 3 == 0)
45
+ {
46
+ ?>
47
+ <li class="first">
48
+ <ul class="card-logo">
49
+ <?php
50
+ }
51
+
52
+ // bandeira em questao
53
+ ?>
54
+ <li style="width: 70px; float: left;">
55
+ <label for="card-<?php echo $value; ?>"><img src="<?php echo $img; ?>" style="width: 40px;" title="<?php echo $label; ?>" /><br>
56
+ <input name="payment[cc_type]" type="radio" value="<?php echo $value; ?>" id="card-<?php echo $value; ?>" class="validate-one-required-by-name" />
57
+ </label>
58
+ </li>
59
+ <?php
60
+ // fecha agrupamento de bandeiras
61
+ if(($i == $size - 1))
62
+ {
63
+ ?>
64
+ </ul>
65
+ </li>
66
+ <?php
67
+ }
68
+ }
69
+
70
+ // dados do cartao
71
+ // somente mostrado em buy page loja
72
+
73
+ if($this->getConfigData('buypage') == "loja")
74
+ {
75
+ ?>
76
+ <li>
77
+ <label for="cielo-card-number" class="required"><em>*</em><?php echo $this->__('Card Number') ?></label><br />
78
+ <div class="input-box">
79
+ <input name="payment[cc_number]" type="text" value="" id="cielo-card-number" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-cc-number" maxlength="16" onkeydown="return denyNotNumber(this, event);" />
80
+ </div>
81
+ </li>
82
+ <li>
83
+ <label for="cielo-security-code" class="required"><em>*</em><?php echo $this->__('Verification Code') ?></label><br />
84
+ <div class="input-box">
85
+ <input name="payment[cc_cid]" type="text" value="" id="cielo-security-code" title="<?php echo $this->__('Verification Code') ?>" class="input-text required-entry" style="width: 50px;" maxlength="4" onkeydown="return denyNotNumber(this, event);" />
86
+ </div>
87
+ </li>
88
+ <li>
89
+ <label for="cielo-card_expiration-mh" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
90
+ <div class="input-box">
91
+ <div class="v-fix">
92
+ <select id="cielo-card_expiration-mh" name="payment[cc_exp_month]" class="month required-entry" autocomplete="off">
93
+ <option value="" selected="selected"><?php echo $this->__('Month') ?></option>
94
+ <?php foreach($this->getMonths() as $month): ?>
95
+ <option value="<?php echo $month['num'] ?>"><?php echo $month['label'] ?></option>
96
+ <?php endforeach ?>
97
+ </select>
98
+ </div>
99
+ <div class="v-fix">
100
+ <select id="cielo-card_expiration-yr" name="payment[cc_exp_year]" class="year required-entry" autocomplete="off">
101
+ <option value="" selected="selected"><?php echo $this->__('Year') ?></option>
102
+ <?php foreach($this->getYears() as $year): ?>
103
+ <option value="<?php echo $year['num'] ?>"><?php echo $year['label'] ?></option>
104
+ <?php endforeach ?>
105
+ </select>
106
+ </div>
107
+ </div>
108
+ <li>
109
+ <label for="cielo-card_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
110
+ <div class="input-box">
111
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="cielo-card_owner" name="payment[cc_owner]" value="" autocomplete="off" />
112
+ </div>
113
+ </li>
114
+ </li>
115
+ <?php
116
+ }
117
+ ?>
118
+ <br />
119
+ </ul>
120
+ </fieldset>
121
+ <script type="text/javascript">// <![CDATA[
122
+
123
+ function denyNotNumber(field, event)
124
+ {
125
+ var keyCode = ('which' in event) ? event.which : event.keyCode;
126
+ var char = String.fromCharCode(keyCode);
127
+
128
+ // teclas backspace e delete
129
+ if(keyCode == 8 || keyCode == 46)
130
+ return true;
131
+
132
+ // impede caracteres nao numericos
133
+ if(isNaN(char))
134
+ return false;
135
+ else
136
+ return true;
137
+ }
138
+
139
+ // ]]></script>
app/design/frontend/default/default/template/cielo/info/cc.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ Cartão de Crédito Cielo
29
+ <br /><br />
30
+ <?php
31
+
32
+
33
+ if($_info = $this->getInfo())
34
+ {
35
+ if($_info->getOrder())
36
+ {
37
+ $payment = $_info->getOrder()->getPayment();
38
+
39
+ if($payment->getAdditionalInformation ('Cielo_error'))
40
+ {
41
+ echo "Erro na transação";
42
+ }
43
+ else
44
+ {
45
+ $tid = $payment->getAdditionalInformation ('Cielo_tid');
46
+ $status = $payment->getAdditionalInformation ('Cielo_status');
47
+ $cardType = $payment->getAdditionalInformation ('Cielo_cardType');
48
+ $installments = $payment->getAdditionalInformation ('Cielo_installments');
49
+
50
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toArray();
51
+ $cardType = $allCards[$cardType];
52
+ $installments = ($installments == 1) ? '&#192; vista' : $installments . " vezes";
53
+
54
+ $html = "<b>ID Transação</b>: " . $tid . "<br />";
55
+ $html .= "<b>Status</b>: " . Mage::helper('Maxima_Cielo')->getStatusMessage($status) . "<br />";
56
+ $html .= "<b>Bandeira</b>: " . $cardType . "<br />";
57
+ $html .= "<b>Parcelamento</b>: " . $installments;
58
+
59
+ echo $html;
60
+ }
61
+ }
62
+ }
63
+ ?>
app/design/frontend/default/default/template/cielo/info/dc.phtml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ Cartão de Débito Cielo
29
+ <br /><br />
30
+ <?php
31
+
32
+
33
+ if($_info = $this->getInfo())
34
+ {
35
+ if($_info->getOrder())
36
+ {
37
+ $payment = $_info->getOrder()->getPayment();
38
+
39
+ if($payment->getAdditionalInformation ('Cielo_error'))
40
+ {
41
+ echo "Erro na transação";
42
+ }
43
+ else
44
+ {
45
+ $tid = $payment->getAdditionalInformation ('Cielo_tid');
46
+ $status = $payment->getAdditionalInformation ('Cielo_status');
47
+ $cardType = $payment->getAdditionalInformation ('Cielo_cardType');
48
+ $installments = $payment->getAdditionalInformation ('Cielo_installments');
49
+
50
+ $allCards = Mage::getModel('Maxima_Cielo/cc_types')->toArray();
51
+ $cardType = $allCards[$cardType];
52
+ $installments = ($installments == 1) ? '&#192; vista' : $installments . " vezes";
53
+
54
+ $html = "<b>ID Transação</b>: " . $tid . "<br />";
55
+ $html .= "<b>Status</b>: " . Mage::helper('Maxima_Cielo')->getStatusMessage($status) . "<br />";
56
+ $html .= "<b>Bandeira</b>: " . $cardType;
57
+
58
+ echo $html;
59
+ }
60
+ }
61
+ }
62
+ ?>
app/design/frontend/default/default/template/cielo/success.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ */
26
+
27
+ ?>
28
+ <div class="page-title">
29
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
30
+ </div>
31
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
32
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
33
+
34
+ <?php if ($this->getOrderId()):?>
35
+ <?php if ($this->getCanViewOrder()) :?>
36
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
37
+ <?php else :?>
38
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
39
+ <?php endif;?>
40
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
41
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
42
+ <p>
43
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
44
+ <?php echo $this->getChildHtml() ?>
45
+ </p>
46
+ <?php endif;?>
47
+ <?php endif;?>
48
+
49
+ <?php if ($this->getAgreementRefId()): ?>
50
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
51
+ <?php endif;?>
52
+ <br />
53
+ <ul>
54
+ <li><?php echo $this->getCieloDataHtml(); ?></li>
55
+ </ul>
56
+ <div class="buttons-set">
57
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
58
+ </div>
app/etc/modules/Maxima_Cielo.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Maxima Cielo Module - payment method module for Magento, integrating
5
+ * the billing forms with a Cielo's gateway Web Service.
6
+ * Copyright (C) 2012 Fillipe Almeida Dutra
7
+ * Belo Horizonte, Minas Gerais - Brazil
8
+ *
9
+ * Contact: lawsann@gmail.com
10
+ * Project link: http://code.google.com/p/magento-maxima-cielo/
11
+ * Group discussion: http://groups.google.com/group/cielo-magento
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+ -->
26
+
27
+ <config>
28
+ <modules>
29
+ <Maxima_Cielo>
30
+ <active>true</active>
31
+ <codePool>community</codePool>
32
+ </Maxima_Cielo>
33
+ </modules>
34
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Maxima_Cielo</name>
4
+ <version>1.5.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>M&#xF3;dulo de pagamento desenvolvido por Fillipe Almeida Dutra.</summary>
10
+ <description>Este m&#xF3;dulo realiza a integra&#xE7;&#xE3;o do Magento com Web Service da Cielo, sem utiliza&#xE7;&#xE3;o de interm&#xE9;dio de gateway de pagamentos, tornando assim, as taxas mais baratas.&#xD;
11
+ &#xD;
12
+ Habilita pagamentos com cart&#xE3;o de cr&#xE9;dito e d&#xE9;bito. S&#xE3;o aceitas as bandeiras Mastercard, Visa, American Express, Diners Club, Discover e Elo. H&#xE1; a compatibilidade com as modalidades Buy Page Loja e Buy Page Cielo, captura autom&#xE1;tica ou manual, autentica&#xE7;&#xE3;o, configura&#xE7;&#xE3;o de parcelamento (com quantidade de parcelas sem juros, juros compostos, parcelamento na loja ou na administradora, valor m&#xED;nimo da parcela) e configura&#xE7;&#xE3;o de SoftDescriptor.&#xD;
13
+ &#xD;
14
+ O m&#xF3;dulo foi desenvolvido por Fillipe Almeida Dutra e testado junto aos utilizadores da comunidade brasileira de Magento.</description>
15
+ <notes>Testado nas ver&#xF5;es 1.4 e superiores do Magento Community Edition.</notes>
16
+ <authors><author><name>Fillipe Almeida Dutra</name><user>lawsann</user><email>lawsann@gmail.com</email></author></authors>
17
+ <date>2012-10-06</date>
18
+ <time>13:18:52</time>
19
+ <contents><target name="magecommunity"><dir name="Maxima"><dir name="Cielo"><dir name="Block"><dir name="Adminhtml"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="fac7909671ed73fa52b5843996998f7b"/></dir><file name="Totals.php" hash="ab7f4d158554ebe0e550b32a249058fa"/><file name="View.php" hash="87b7f7dbc59e862c5ab796af31d098a1"/></dir></dir><dir name="Form"><file name="Cc.php" hash="88ebd0c542432f2fd9451014904fa0f1"/><file name="Dc.php" hash="4f6b580949ff4c9c1b5a8acc087eb548"/></dir><dir name="Info"><file name="Cc.php" hash="41586896cd9b0c652226afa15ddc07e4"/><file name="Dc.php" hash="bcc7d0eca2241b8720e6b9dc5b292eeb"/></dir><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="d878200b6122dc3631ddb083cd432342"/></dir></dir><file name="Verify.php" hash="664bbb607431c20e41beaf134db4db50"/></dir><dir name="Helper"><file name="Data.php" hash="5a435ed4d9ee103ff280cc8d2bdc8893"/></dir><dir name="Model"><dir name="Adminhtml"><file name="BuyPage.php" hash="562c6807376ea98a32cea268acb5880e"/><file name="CardTypes.php" hash="1696a0ccf67c7904f98ccb5c2efc161e"/><file name="Environment.php" hash="c3bd90c92988236041a91730181c27bd"/></dir><dir name="Cc"><file name="InstallmentType.php" hash="ef9f782ef96e7b18eb806ca4adbf17e7"/><file name="MaxInstallments.php" hash="2f256f13d8429f53ed78fee1bad07557"/><file name="Types.php" hash="8d473b6ee6ab5d93b33439b65bbf5a4c"/></dir><file name="Cc.php" hash="7d006bb80f4afc725875501c4e0e18ed"/><dir name="Dc"><file name="Types.php" hash="0b92591c77feadade51f2256004d04f7"/></dir><file name="Dc.php" hash="8b0421d4168e07cecb503c7cab2cff46"/><dir name="Order"><dir name="Invoice"><file name="Interest.php" hash="11e962528edf565b4406a075db7ea378"/></dir></dir><dir name="Quote"><dir name="Address"><file name="Interest.php" hash="c69a5a04d209ba2ca892b10d80969184"/></dir></dir><file name="WebServiceOrder.php" hash="178dafe1f3ae90e04ea8f9a5a19998ec"/></dir><dir name="controllers"><file name="AdminController.php" hash="5462b48b84b88f4c07630fa02e1a9ce8"/><file name="PayController.php" hash="1f693e025ddee8f5dd483b13dd6aa13e"/></dir><dir name="etc"><file name="config.xml" hash="898693b4b22f566a97af4a4a1811a9c6"/><file name="system.xml" hash="051b056ddf8335433001d9d3ec7c3093"/></dir><dir name="sql"><dir name="Maxima_Cielo_setup"><file name="mysql4-upgrade-1.0.1-1.1.0.php" hash="9bd53e35cc207dc9a360fcc681c8b254"/></dir></dir><dir name="ssl"><file name="VeriSignClass3PublicPrimaryCertificationAuthority-G5.crt" hash="6b5a035d28d43fe4977d1c46cb2a8b39"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Maxima_Cielo.xml" hash="00a3004d5beb73433796c5403860e213"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="cielo"><dir name="info"><file name="cc.phtml" hash="22a09e79c5c9725cae2fa735f1880427"/><file name="dc.phtml" hash="74a3c15f8b3827a185942a7dc580ae72"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cielo"><file name="failure.phtml" hash="6d6d4b84a77282db9ca31a1f605063ed"/><dir name="form"><file name="cc.phtml" hash="3f04d006265bd0b5d655ff6beec97e7c"/><file name="dc.phtml" hash="69fd0e54c7aadf0eea874d9268bfe256"/></dir><dir name="info"><file name="cc.phtml" hash="7115d06e31c6cfd12c7d22d3cccfd9b6"/><file name="dc.phtml" hash="9179a40d2f9db91a56ad5c65554e1f96"/></dir><file name="success.phtml" hash="20c2db462b509a8421396e18886b3748"/></dir></dir><dir name="layout"><file name="cielo.xml" hash="1c1bd75b9b3a4b7d8c870d7f1736c106"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><dir name="cielo"><file name="Amex.png" hash="34cf5f947ce582e8cafbc2f7ad3819d7"/><file name="Diners.png" hash="85745410a56fae7438ee731c7c61bcbd"/><file name="Discover.png" hash="c15f20d619d498ca0106d86bd1315aa7"/><file name="Elo.png" hash="fac91b0c17c3f0c21830934c091ae288"/><file name="Master-maestro.png" hash="36f46a64478e57d032e250a7ea57b7dd"/><file name="Master.png" hash="c34cfa7178ad74a5988f20d002d96da5"/><file name="Visa-Electron.png" hash="6f7106bec98706ab13c8ffd91edac9fa"/><file name="Visa.png" hash="61cebb52052e510837ac9292f5421bff"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="cielo"><dir name="window"><file name="bottom_left.png" hash="8dc6008d2ab38fdb20037d70f256a669"/><file name="bottom_right.png" hash="e95738920909e6a6efff2f8993433c0b"/><file name="close.png" hash="ecd60c76155c81f292269effe55455bd"/><file name="header.png" hash="7844dbe18eea13be882075ea6b9ca896"/><file name="top_left.png" hash="5ec9623ada46737745c8a5462e464e07"/><file name="top_right.png" hash="1c334c616db562dbcd3377aaf3696872"/></dir></dir></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.0.0</min><max>5.4.7</max></php></required></dependencies>
22
+ </package>
skin/adminhtml/default/default/images/cielo/window/bottom_left.png ADDED
Binary file
skin/adminhtml/default/default/images/cielo/window/bottom_right.png ADDED
Binary file
skin/adminhtml/default/default/images/cielo/window/close.png ADDED
Binary file
skin/adminhtml/default/default/images/cielo/window/header.png ADDED
Binary file
skin/adminhtml/default/default/images/cielo/window/top_left.png ADDED
Binary file
skin/adminhtml/default/default/images/cielo/window/top_right.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Amex.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Diners.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Discover.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Elo.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Master-maestro.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Master.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Visa-Electron.png ADDED
Binary file
skin/frontend/default/default/images/cielo/Visa.png ADDED
Binary file