Mundipagg_Integracao - Version 2.6.1

Version Notes

Hotfix on 2.6.0 migration

Download this release

Release Info

Developer MundiPagg
Extension Mundipagg_Integracao
Version 2.6.1
Comparing to
See all releases


Version 2.6.1

Files changed (181) hide show
  1. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Form/Field/Installments.php +49 -0
  2. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php +57 -0
  3. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Invoice/Totals.php +57 -0
  4. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Invoice/View.php +55 -0
  5. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Totals.php +57 -0
  6. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Transactions/Detail/Grid.php +46 -0
  7. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/System/Config/Form/Button.php +76 -0
  8. app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Version.php +37 -0
  9. app/code/community/Uecommerce/Mundipagg/Block/Checkout/Onepage/Payment/Methods.php +45 -0
  10. app/code/community/Uecommerce/Mundipagg/Block/Info.php +76 -0
  11. app/code/community/Uecommerce/Mundipagg/Block/Parcelamento.php +100 -0
  12. app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Creditmemo/Totals.php +57 -0
  13. app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Invoice/Totals.php +57 -0
  14. app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Totals.php +57 -0
  15. app/code/community/Uecommerce/Mundipagg/Block/Standard/Boleto.php +47 -0
  16. app/code/community/Uecommerce/Mundipagg/Block/Standard/Cancel.php +59 -0
  17. app/code/community/Uecommerce/Mundipagg/Block/Standard/Debit.php +56 -0
  18. app/code/community/Uecommerce/Mundipagg/Block/Standard/Fcancel.php +43 -0
  19. app/code/community/Uecommerce/Mundipagg/Block/Standard/Form.php +90 -0
  20. app/code/community/Uecommerce/Mundipagg/Block/Standard/Partial.php +176 -0
  21. app/code/community/Uecommerce/Mundipagg/Block/Standard/Redirect.php +175 -0
  22. app/code/community/Uecommerce/Mundipagg/Block/Standard/Success.php +179 -0
  23. app/code/community/Uecommerce/Mundipagg/Controller/Abstract.php +80 -0
  24. app/code/community/Uecommerce/Mundipagg/Helper/Data.php +506 -0
  25. app/code/community/Uecommerce/Mundipagg/Helper/Installments.php +336 -0
  26. app/code/community/Uecommerce/Mundipagg/Helper/Log.php +63 -0
  27. app/code/community/Uecommerce/Mundipagg/Helper/Util.php +9 -0
  28. app/code/community/Uecommerce/Mundipagg/Helper/Version.php +107 -0
  29. app/code/community/Uecommerce/Mundipagg/Model/.DS_Store +0 -0
  30. app/code/community/Uecommerce/Mundipagg/Model/Api.php +1809 -0
  31. app/code/community/Uecommerce/Mundipagg/Model/Boleto.php +138 -0
  32. app/code/community/Uecommerce/Mundipagg/Model/Cardonfile.php +44 -0
  33. app/code/community/Uecommerce/Mundipagg/Model/Creditcard.php +198 -0
  34. app/code/community/Uecommerce/Mundipagg/Model/Creditcardoneinstallment.php +174 -0
  35. app/code/community/Uecommerce/Mundipagg/Model/Customer/Session.php +17 -0
  36. app/code/community/Uecommerce/Mundipagg/Model/Customers.php +39 -0
  37. app/code/community/Uecommerce/Mundipagg/Model/Debit.php +122 -0
  38. app/code/community/Uecommerce/Mundipagg/Model/Fivecreditcards.php +249 -0
  39. app/code/community/Uecommerce/Mundipagg/Model/Fourcreditcards.php +229 -0
  40. app/code/community/Uecommerce/Mundipagg/Model/Observer.php +356 -0
  41. app/code/community/Uecommerce/Mundipagg/Model/Offlineretry.php +17 -0
  42. app/code/community/Uecommerce/Mundipagg/Model/Order/Invoice/Interest.php +42 -0
  43. app/code/community/Uecommerce/Mundipagg/Model/Providervalidation.php +15 -0
  44. app/code/community/Uecommerce/Mundipagg/Model/Quote/Address/Interest.php +89 -0
  45. app/code/community/Uecommerce/Mundipagg/Model/Recurrency.php +412 -0
  46. app/code/community/Uecommerce/Mundipagg/Model/Resource/Cardonfile.php +39 -0
  47. app/code/community/Uecommerce/Mundipagg/Model/Resource/Cardonfile/Collection.php +49 -0
  48. app/code/community/Uecommerce/Mundipagg/Model/Resource/Customers.php +39 -0
  49. app/code/community/Uecommerce/Mundipagg/Model/Resource/Customers/Collection.php +43 -0
  50. app/code/community/Uecommerce/Mundipagg/Model/Resource/Offlineretry.php +7 -0
  51. app/code/community/Uecommerce/Mundipagg/Model/Resource/Offlineretry/Collection.php +20 -0
  52. app/code/community/Uecommerce/Mundipagg/Model/Resource/Setup.php +34 -0
  53. app/code/community/Uecommerce/Mundipagg/Model/Source/Antifraud.php +20 -0
  54. app/code/community/Uecommerce/Mundipagg/Model/Source/Banks.php +41 -0
  55. app/code/community/Uecommerce/Mundipagg/Model/Source/CctypeProductInstallments.php +47 -0
  56. app/code/community/Uecommerce/Mundipagg/Model/Source/Cctypes.php +53 -0
  57. app/code/community/Uecommerce/Mundipagg/Model/Source/Debit.php +44 -0
  58. app/code/community/Uecommerce/Mundipagg/Model/Source/Environment.php +41 -0
  59. app/code/community/Uecommerce/Mundipagg/Model/Source/FControlEnvironment.php +27 -0
  60. app/code/community/Uecommerce/Mundipagg/Model/Source/Frequency.php +50 -0
  61. app/code/community/Uecommerce/Mundipagg/Model/Source/Installments.php +49 -0
  62. app/code/community/Uecommerce/Mundipagg/Model/Source/PaymentAction.php +52 -0
  63. app/code/community/Uecommerce/Mundipagg/Model/Source/PaymentMethods.php +62 -0
  64. app/code/community/Uecommerce/Mundipagg/Model/Standard.php +1869 -0
  65. app/code/community/Uecommerce/Mundipagg/Model/System/Config/Backend/Installments.php +52 -0
  66. app/code/community/Uecommerce/Mundipagg/Model/Threecreditcards.php +212 -0
  67. app/code/community/Uecommerce/Mundipagg/Model/Twocreditcards.php +195 -0
  68. app/code/community/Uecommerce/Mundipagg/Test/Selenium/Abstract.php +441 -0
  69. app/code/community/Uecommerce/Mundipagg/Test/Selenium/BoletoTest.php +81 -0
  70. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes.php +234 -0
  71. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/CreditcardTest.php +34 -0
  72. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/CreditcardoneinstallmentTest.php +37 -0
  73. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/FivecreditcardsTest.php +33 -0
  74. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/FourcheditcardsTest.php +36 -0
  75. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/ThreecreditcardsTest.php +38 -0
  76. app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/TwocreditcardsTest.php +38 -0
  77. app/code/community/Uecommerce/Mundipagg/Test/Selenium/DebitTest.php +98 -0
  78. app/code/community/Uecommerce/Mundipagg/controllers/Adminhtml/IndexController.php +92 -0
  79. app/code/community/Uecommerce/Mundipagg/controllers/ClearsaleController.php +28 -0
  80. app/code/community/Uecommerce/Mundipagg/controllers/FcontrolController.php +98 -0
  81. app/code/community/Uecommerce/Mundipagg/controllers/StandardController.php +443 -0
  82. app/code/community/Uecommerce/Mundipagg/controllers/StoneController.php +28 -0
  83. app/code/community/Uecommerce/Mundipagg/etc/config.xml +363 -0
  84. app/code/community/Uecommerce/Mundipagg/etc/jstranslator.xml +15 -0
  85. app/code/community/Uecommerce/Mundipagg/etc/system.xml +1144 -0
  86. app/code/community/Uecommerce/Mundipagg/etc/wsdl.xml +62 -0
  87. app/code/community/Uecommerce/Mundipagg/etc/xtest.xml +143 -0
  88. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/install-0.3.0.php +92 -0
  89. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.0-0.3.5.php +81 -0
  90. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.5-0.4.0.php +89 -0
  91. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.5-1.0.1.php +89 -0
  92. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.0-1.0.1.php +89 -0
  93. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.1-0.4.2.php +148 -0
  94. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.1-1.0.1.php +89 -0
  95. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.0-1.0.1.php +89 -0
  96. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.1-1.0.2.php +35 -0
  97. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.10-1.0.11.php +35 -0
  98. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.11-2.0.0.php +92 -0
  99. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.2-1.0.3.php +35 -0
  100. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.3-1.0.4.php +35 -0
  101. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.4-1.0.5.php +35 -0
  102. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.5-1.0.6.php +35 -0
  103. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.6-1.0.7.php +35 -0
  104. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.7-1.0.8.php +35 -0
  105. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.8-1.0.9.php +35 -0
  106. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.9-1.0.10.php +35 -0
  107. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.0-2.0.1.php +55 -0
  108. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.0-2.1.0.php +81 -0
  109. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.1-2.0.2.php +42 -0
  110. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.2-2.0.3.php +35 -0
  111. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.3-2.0.4.php +35 -0
  112. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.4-2.0.5.php +35 -0
  113. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.5-2.0.6.php +35 -0
  114. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.6-2.0.7.php +35 -0
  115. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.7-2.0.8.php +35 -0
  116. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.8-2.0.9.php +35 -0
  117. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.9-2.1.0.php +104 -0
  118. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.1.2-2.1.3.php +41 -0
  119. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.5.7-2.5.8.php +11 -0
  120. app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.5.8-2.6.0.php +16 -0
  121. app/design/adminhtml/default/default/layout/mundipagg.xml +39 -0
  122. app/design/adminhtml/default/default/template/mundipagg/boleto.phtml +29 -0
  123. app/design/adminhtml/default/default/template/mundipagg/form.phtml +379 -0
  124. app/design/adminhtml/default/default/template/mundipagg/payment/.DS_Store +0 -0
  125. app/design/adminhtml/default/default/template/mundipagg/payment/info/mundipagg.phtml +234 -0
  126. app/design/adminhtml/default/default/template/mundipagg/system/config/button.phtml +28 -0
  127. app/design/frontend/base/default/layout/mundipagg.xml +156 -0
  128. app/design/frontend/base/default/template/mundipagg/antifraud/clearsale.phtml +61 -0
  129. app/design/frontend/base/default/template/mundipagg/antifraud/fcontrol.phtml +59 -0
  130. app/design/frontend/base/default/template/mundipagg/antifraud/stone.phtml +61 -0
  131. app/design/frontend/base/default/template/mundipagg/boleto.phtml +30 -0
  132. app/design/frontend/base/default/template/mundipagg/cancel.phtml +36 -0
  133. app/design/frontend/base/default/template/mundipagg/debit.phtml +51 -0
  134. app/design/frontend/base/default/template/mundipagg/extras.phtml +1 -0
  135. app/design/frontend/base/default/template/mundipagg/fcancel.phtml +36 -0
  136. app/design/frontend/base/default/template/mundipagg/form.phtml +381 -0
  137. app/design/frontend/base/default/template/mundipagg/parcelamento.phtml +8 -0
  138. app/design/frontend/base/default/template/mundipagg/partial.phtml +147 -0
  139. app/design/frontend/base/default/template/mundipagg/payment/info/mundipagg.phtml +95 -0
  140. app/design/frontend/base/default/template/mundipagg/redirect.phtml +50 -0
  141. app/design/frontend/base/default/template/mundipagg/success.phtml +224 -0
  142. app/design/frontend/base/default/template/mundipagg/totals.phtml +52 -0
  143. app/design/frontend/rwd/default/template/mundipagg/debit.phtml +52 -0
  144. app/design/frontend/rwd/default/template/mundipagg/form.phtml +381 -0
  145. app/etc/modules/Uecommerce_Mundipagg.xml +9 -0
  146. app/locale/en_US/Uecommerce_Mundipagg.csv +151 -0
  147. app/locale/pt_BR/Uecommerce_Mundipagg.csv +199 -0
  148. js/uecommerce/mundipagg.js +872 -0
  149. package.xml +22 -0
  150. skin/adminhtml/default/default/images/mundipagg/.DS_Store +0 -0
  151. skin/adminhtml/default/default/images/mundipagg/ajax-loader.gif +0 -0
  152. skin/adminhtml/default/default/images/mundipagg/boleto.jpg +0 -0
  153. skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png +0 -0
  154. skin/frontend/base/default/css/mundipagg.css +129 -0
  155. skin/frontend/base/default/images/mundipagg/.DS_Store +0 -0
  156. skin/frontend/base/default/images/mundipagg/001.png +0 -0
  157. skin/frontend/base/default/images/mundipagg/237.png +0 -0
  158. skin/frontend/base/default/images/mundipagg/341.png +0 -0
  159. skin/frontend/base/default/images/mundipagg/AE.png +0 -0
  160. skin/frontend/base/default/images/mundipagg/DI.png +0 -0
  161. skin/frontend/base/default/images/mundipagg/EL.png +0 -0
  162. skin/frontend/base/default/images/mundipagg/HI.png +0 -0
  163. skin/frontend/base/default/images/mundipagg/MC.png +0 -0
  164. skin/frontend/base/default/images/mundipagg/VBV.jpg +0 -0
  165. skin/frontend/base/default/images/mundipagg/VBV.png +0 -0
  166. skin/frontend/base/default/images/mundipagg/VI.png +0 -0
  167. skin/frontend/base/default/images/mundipagg/ajax-loader.gif +0 -0
  168. skin/frontend/base/default/images/mundipagg/boleto.jpg +0 -0
  169. skin/frontend/base/default/images/mundipagg/cc_types.png +0 -0
  170. skin/frontend/base/default/images/mundipagg/cielo_mastercard.png +0 -0
  171. skin/frontend/base/default/images/mundipagg/cielo_visa.png +0 -0
  172. skin/frontend/default/default/images/mundipagg/.DS_Store +0 -0
  173. skin/frontend/default/default/images/mundipagg/EL.png +0 -0
  174. skin/frontend/default/default/images/mundipagg/HI.png +0 -0
  175. skin/frontend/default/default/images/mundipagg/ae.png +0 -0
  176. skin/frontend/default/default/images/mundipagg/boleto.jpg +0 -0
  177. skin/frontend/default/default/images/mundipagg/cielo_mastercard.png +0 -0
  178. skin/frontend/default/default/images/mundipagg/cielo_visa.png +0 -0
  179. skin/frontend/default/default/images/mundipagg/di.png +0 -0
  180. skin/frontend/default/default/images/mundipagg/mc.png +0 -0
  181. skin/frontend/default/default/images/mundipagg/vi.png +0 -0
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Form/Field/Installments.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ class Uecommerce_Mundipagg_Block_Adminhtml_Form_Field_Installments extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
31
+ {
32
+ protected function _prepareToRender()
33
+ {
34
+ $this->addColumn('installment_boundary', array(
35
+ 'label' => Mage::helper('mundipagg')->__('Amount (incl.)'),
36
+ 'style' => 'width:100px',
37
+ ));
38
+ $this->addColumn('installment_frequency', array(
39
+ 'label' => Mage::helper('mundipagg')->__('Maximum Number of Installments'),
40
+ 'style' => 'width:100px',
41
+ ));
42
+ $this->addColumn('installment_interest', array(
43
+ 'label' => Mage::helper('mundipagg')->__('Interest Rate (%)'),
44
+ 'style' => 'width:100px',
45
+ ));
46
+ $this->_addAfter = false;
47
+ $this->_addButtonLabel = Mage::helper('mundipagg')->__('Add Installment Boundary');
48
+ }
49
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Invoice/View.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Invoice_View extends Mage_Adminhtml_Block_Sales_Order_Invoice_View
32
+ {
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+
37
+ $this->_removeButton('void');
38
+
39
+ $orderPayment = $this->getInvoice()->getOrder()->getPayment();
40
+
41
+ if ($this->_isAllowedAction('creditmemo') ) {
42
+ if (($orderPayment->canRefundPartialPerInvoice()
43
+ && $this->getInvoice()->canRefund()
44
+ && $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded())
45
+ || ($orderPayment->canRefund() && !$this->getInvoice()->getIsUsedForRefund())) {
46
+ $this->_addButton('capture', array( // capture?
47
+ 'label' => Mage::helper('sales')->__('Credit Memo'),
48
+ 'class' => 'go',
49
+ 'onclick' => 'setLocation(\''.$this->getCreditMemoUrl().'\')'
50
+ )
51
+ );
52
+ }
53
+ }
54
+ }
55
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Sales/Transactions/Detail/Grid.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Sales_Transactions_Detail_Grid extends Mage_Adminhtml_Block_Sales_Transactions_Detail_Grid
32
+ {
33
+ /**
34
+ * Retrieve Transaction addtitional info
35
+ *
36
+ * FIX: Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS inside getAdditionalInformation()
37
+ * was causing no Transaction Details display
38
+ *
39
+ * @return array
40
+ */
41
+ public function getTransactionAdditionalInfo()
42
+ {
43
+ $info = Mage::registry('current_transaction')->getAdditionalInformation();
44
+ return (is_array($info)) ? $info : array();
45
+ }
46
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/System/Config/Form/Button.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
32
+ {
33
+ /**
34
+ * Set template
35
+ */
36
+ protected function _construct() {
37
+ parent::_construct();
38
+ $this->setTemplate('mundipagg/system/config/button.phtml');
39
+ }
40
+
41
+ /**
42
+ * Return element html
43
+ *
44
+ * @param Varien_Data_Form_Element_Abstract $element
45
+ * @return string
46
+ */
47
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
48
+ {
49
+ return $this->_toHtml();
50
+ }
51
+
52
+ /**
53
+ * Return ajax url for button
54
+ *
55
+ * @return string
56
+ */
57
+ public function getAjaxOldSettingsUrl(){
58
+ return Mage::helper('adminhtml')->getUrl('mundipagg/adminhtml_index/setoldsettings');
59
+ }
60
+
61
+ /**
62
+ * Generate button html
63
+ *
64
+ * @return string
65
+ */
66
+ public function getButtonHtml(){
67
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'id' => 'mundipagg_button',
70
+ 'label' => $this->helper('adminhtml')->__('Set old settings'),
71
+ 'onclick' => 'javascript:setOldSettings(); return false;'
72
+ ));
73
+
74
+ return $button->toHtml();
75
+ }
76
+ }
app/code/community/Uecommerce/Mundipagg/Block/Adminhtml/Version.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field
32
+ {
33
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ {
35
+ return (string) Mage::helper('mundipagg')->getExtensionVersion();
36
+ }
37
+ }
app/code/community/Uecommerce/Mundipagg/Block/Checkout/Onepage/Payment/Methods.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Block_Checkout_Onepage_Payment_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $payment = $this->getRequest()->getParam('payment');
8
+ $session = Mage::getSingleton('checkout/session');
9
+ $paymentMethod = $session->getData('payment_method_in_session');
10
+
11
+ if(isset($payment['method'])) {
12
+ // If payment method in request is different from the value set in the session
13
+ if($paymentMethod != $payment['method']) {
14
+ // Reset payment
15
+ $this->setPaymentMethod('');
16
+ // Set new payment method
17
+ $this->setPaymentMethod($payment['method']);
18
+ // Set new payment in session
19
+ $session->setData('payment_method_in_session', $payment['method']);
20
+ }
21
+ } else {
22
+ // Reset payment
23
+ $this->setPaymentMethod('');
24
+ }
25
+
26
+ parent::_construct();
27
+ }
28
+
29
+ /**
30
+ * Set payment and remove discounts.
31
+ * @param string $paymentCode
32
+ */
33
+ protected function setPaymentMethod($paymentCode = '')
34
+ {
35
+ $quote = $this->getQuote();
36
+ $quote->getPayment()->setMethod($paymentCode);
37
+ $quote->getBillingAddress()->setPaymentMethod($paymentCode);
38
+ $quote->getShippingAddress()->setPaymentMethod($paymentCode);
39
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
40
+
41
+ $cart = Mage::getSingleton('checkout/cart');
42
+ $cart->init();
43
+ $cart->save();
44
+ }
45
+ }
app/code/community/Uecommerce/Mundipagg/Block/Info.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Info extends Mage_Payment_Block_Info
32
+ {
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+ $this->setTemplate('mundipagg/payment/info/mundipagg.phtml');
37
+ }
38
+
39
+ /**
40
+ * Retrieve order model instance
41
+ *
42
+ * @return Mage_Sales_Model_Order
43
+ */
44
+ public function getOrder()
45
+ {
46
+ return Mage::registry('current_order');
47
+ }
48
+
49
+ /**
50
+ * Retrieve invoice model instance
51
+ *
52
+ * @return Mage_Sales_Model_Order_Invoice
53
+ */
54
+ public function getInvoice()
55
+ {
56
+ return Mage::registry('current_invoice');
57
+ }
58
+
59
+ /**
60
+ * Retrieve shipment model instance
61
+ *
62
+ * @return Mage_Sales_Model_Order_Shipment
63
+ */
64
+ public function getShipment()
65
+ {
66
+ return Mage::registry('current_shipment');
67
+ }
68
+
69
+ /**
70
+ * Retrieve payment method
71
+ */
72
+ public function getFormaPagamento()
73
+ {
74
+ return $this->getInfo()->getAdditionalInformation('PaymentMethod');
75
+ }
76
+ }
app/code/community/Uecommerce/Mundipagg/Block/Parcelamento.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Parcelamento extends Mage_Core_Block_Template
32
+ {
33
+ protected $_price = null;
34
+
35
+ protected function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->setTemplate('mundipagg/parcelamento.phtml');
39
+
40
+
41
+ }
42
+
43
+ protected function _beforeToHtml()
44
+ {
45
+ $this->setPrice($this->getData('price'));
46
+ $this->setParcelamentoProduto($this->getData('parcelamento_produto'));
47
+ }
48
+
49
+ public function setPrice($price)
50
+ {
51
+ $this->_price = $price;
52
+ }
53
+
54
+ public function getPrice()
55
+ {
56
+ return $this->_price;
57
+ }
58
+
59
+ public function setParcelamentoProduto($parcelamento)
60
+ {
61
+ $this->_parcelamento = $parcelamento;
62
+ }
63
+
64
+ public function getParcelamentoProduto()
65
+ {
66
+ return $this->_parcelamento;
67
+ }
68
+
69
+ /**
70
+ * Call it on category or product page
71
+ * echo $this->getLayout()->createBlock("mundipagg/parcelamento")->setData('price', $_product->getPrice())->toHtml();
72
+ */
73
+ public function getParcelamento()
74
+ {
75
+ $active = Mage::getStoreConfig('payment/mundipagg_creditcard/active');
76
+
77
+ if ($active) {
78
+ $parcelamento = Mage::getStoreConfig('payment/mundipagg_standard/product_pages_installment_default');
79
+
80
+ $installmentsHelper = Mage::helper('mundipagg/installments');
81
+ $installmentsHelper->displayTotal = false;
82
+ $parcelamentoMax = $installmentsHelper->getInstallmentForCreditCardType($parcelamento, $this->getPrice());
83
+
84
+ return end($parcelamentoMax);
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Call it on category or product page
90
+ * echo $this->getLayout()->createBlock("mundipagg/parcelamento")->setData('price', $_product->getPrice())->setData('parcelamento_produto', $_product->getParcelamento())->toHtml();
91
+ */
92
+ public function getParcelamentoCustom()
93
+ {
94
+ if ($this->getParcelamentoProduto() == '') {
95
+ return 3;
96
+ } else {
97
+ return $this->getParcelamentoProduto();
98
+ }
99
+ }
100
+ }
app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Creditmemo/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Sales_Order_Creditmemo_Totals extends Mage_Sales_Block_Order_Creditmemo_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Sales_Order_Invoice_Totals extends Mage_Sales_Block_Order_Invoice_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
32
+ {
33
+ /**
34
+ * Initialize order totals array
35
+ *
36
+ * @return Mage_Sales_Block_Order_Totals
37
+ */
38
+ protected function _initTotals()
39
+ {
40
+ parent::_initTotals();
41
+
42
+ $source = $this->getSource();
43
+
44
+ if($this->getSource()->getMundipaggInterest() > 0)
45
+ {
46
+ $this->addTotalBefore(new Varien_Object(array
47
+ (
48
+ 'code' => 'mundipagg_interest',
49
+ 'field' => 'interest',
50
+ 'value' => $this->getSource()->getMundipaggInterest(),
51
+ 'label' => $this->__('Interest')
52
+ )), 'grand_total');
53
+ }
54
+
55
+ return $this;
56
+ }
57
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Boleto.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Boleto extends Mage_Payment_Block_Form
32
+ {
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+
37
+ $this->setTemplate('mundipagg/boleto.phtml');
38
+ }
39
+
40
+ /**
41
+ * Return Standard model
42
+ */
43
+ public function getStandard()
44
+ {
45
+ return Mage::getModel('mundipagg/standard');
46
+ }
47
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Cancel.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Cancel extends Mage_Core_Block_Template
32
+ {
33
+ /**
34
+ * Internal constructor
35
+ * Set template for redirect
36
+ *
37
+ */
38
+ public function __construct()
39
+ {
40
+ parent::_construct();
41
+ $this->setTemplate('mundipagg/cancel.phtml');
42
+ }
43
+
44
+ /**
45
+ * Get Error Description
46
+ * @return string
47
+ **/
48
+ public function getErrorDescription()
49
+ {
50
+ $session = Mage::getSingleton('checkout/session');
51
+ $session->setQuoteId($session->getMundipaggStandardQuoteId(true));
52
+
53
+ if ($session->getLastRealOrderId()) {
54
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
55
+
56
+ return $order->getPayment()->getAdditionalInformation('ErrorDescription');
57
+ }
58
+ }
59
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Debit.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2015 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Debit extends Mage_Payment_Block_Form
32
+ {
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+
37
+ $this->setTemplate('mundipagg/debit.phtml');
38
+ }
39
+
40
+ /**
41
+ * Debit Types
42
+ */
43
+ public function getDebitTypes()
44
+ {
45
+ $debitTypes = Mage::getStoreConfig('payment/mundipagg_debit/debit_types');
46
+
47
+ if ($debitTypes != '') {
48
+ $debitTypes = explode(",", $debitTypes);
49
+ }
50
+ else {
51
+ $debitTypes = array();
52
+ }
53
+
54
+ return $debitTypes;
55
+ }
56
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Fcancel.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Fcancel extends Mage_Core_Block_Template
32
+ {
33
+ /**
34
+ * Internal constructor
35
+ * Set template for redirect
36
+ *
37
+ */
38
+ public function __construct()
39
+ {
40
+ parent::_construct();
41
+ $this->setTemplate('mundipagg/fcancel.phtml');
42
+ }
43
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Form.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Form extends Mage_Payment_Block_Form
32
+ {
33
+ protected function _construct()
34
+ {
35
+ parent::_construct();
36
+
37
+ $this->setTemplate('mundipagg/form.phtml');
38
+
39
+ // Get Customer Credit Cards Saved On File
40
+ if ($this->helper('customer')->isLoggedIn()) {
41
+ $entityId = Mage::getSingleton('customer/session')->getId();
42
+
43
+ $ccsCollection = Mage::getResourceModel('mundipagg/cardonfile_collection')
44
+ ->addEntityIdFilter($entityId)
45
+ ->addExpiresAtFilter();
46
+
47
+ $this->setCcs($ccsCollection);
48
+ } else if (Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerId()) {
49
+ $entityId = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerId();
50
+
51
+ $ccsCollection = Mage::getResourceModel('mundipagg/cardonfile_collection')
52
+ ->addEntityIdFilter($entityId)
53
+ ->addExpiresAtFilter();
54
+
55
+ $this->setCcs($ccsCollection);
56
+ } else {
57
+ $this->setCcs(array());
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Return Standard model
63
+ */
64
+ public function getStandard()
65
+ {
66
+ return Mage::getModel('mundipagg/standard');
67
+ }
68
+
69
+ /**
70
+ * Get installments
71
+ */
72
+ public function getInstallments($ccType = null)
73
+ {
74
+ $session = Mage::getSingleton('admin/session');
75
+
76
+ if ($session->isLoggedIn()) {
77
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
78
+ } else {
79
+ $quote =(Mage::getModel('checkout/type_onepage') !== false)? Mage::getModel('checkout/type_onepage')->getQuote(): Mage::getModel('checkout/session')->getQuote();;
80
+ }
81
+
82
+ $quote->setMundipaggInterest(0.0);
83
+ $quote->setMundipaggBaseInterest(0.0);
84
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
85
+ $quote->save();
86
+
87
+ return Mage::helper('mundipagg/installments')->getInstallmentForCreditCardType($ccType);
88
+
89
+ }
90
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Partial.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Partial extends Mage_Checkout_Block_Onepage_Payment_Methods
32
+ {
33
+ /**
34
+ * Internal constructor
35
+ * Set template for redirect
36
+ *
37
+ */
38
+ public function __construct()
39
+ {
40
+ parent::_construct();
41
+
42
+ $this->setTemplate('mundipagg/partial.phtml');
43
+
44
+ // Get Customer Credit Cards Saved On File
45
+ if ($this->helper('customer')->isLoggedIn()) {
46
+ $entityId = Mage::getSingleton('customer/session')->getId();
47
+
48
+ $ccsCollection = Mage::getResourceModel('mundipagg/cardonfile_collection')
49
+ ->addEntityIdFilter($entityId)
50
+ ->addExpiresAtFilter();
51
+
52
+ $this->setCcs($ccsCollection);
53
+ } else {
54
+ $this->setCcs(array());
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Initialize data and prepare it for output
60
+ */
61
+ protected function _beforeToHtml()
62
+ {
63
+ //return parent::_beforeToHtml();
64
+ }
65
+
66
+ /**
67
+ * Return Standard model
68
+ */
69
+ public function getStandard()
70
+ {
71
+ return Mage::getModel('mundipagg/standard');
72
+ }
73
+
74
+ /**
75
+ * Return creditcard model
76
+ */
77
+ public function getCreditcard()
78
+ {
79
+ return Mage::getModel('mundipagg/creditcard');
80
+ }
81
+
82
+ /**
83
+ * Return twocreditcards model
84
+ */
85
+ public function getTwocreditcards()
86
+ {
87
+ return Mage::getModel('mundipagg/twocreditcards');
88
+ }
89
+
90
+ /**
91
+ * Return threecreditcards model
92
+ */
93
+ public function getThreecreditcards()
94
+ {
95
+ return Mage::getModel('mundipagg/threecreditcards');
96
+ }
97
+
98
+ /**
99
+ * Return fourcreditcards model
100
+ */
101
+ public function getFourcreditcards()
102
+ {
103
+ return Mage::getModel('mundipagg/fourcreditcards');
104
+ }
105
+
106
+ /**
107
+ * Return fivecreditcards model
108
+ */
109
+ public function getFivecreditcards()
110
+ {
111
+ return Mage::getModel('mundipagg/fivecreditcards');
112
+ }
113
+
114
+ /**
115
+ * Get last quote that is in session
116
+ */
117
+ public function getQuote()
118
+ {
119
+ $lastQuoteId = Mage::getSingleton('checkout/session')->getLastSuccessQuoteId();
120
+
121
+ return Mage::getModel('sales/quote')->load($lastQuoteId);
122
+ }
123
+
124
+ /**
125
+ * Get last order that is in session
126
+ */
127
+ public function getOrder()
128
+ {
129
+ $session = Mage::getSingleton('checkout/session');
130
+
131
+ $session->setQuoteId($session->getMundipaggStandardQuoteId(true));
132
+
133
+ if ($session->getLastRealOrderId()) {
134
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
135
+
136
+ return $order;
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Get last order baseGrandTotal that is in session
142
+ */
143
+ public function getQuoteBaseGrandTotal()
144
+ {
145
+ return $this->getOrder()->getBaseGrandTotal();
146
+ }
147
+
148
+ /**
149
+ * Retrieve availale payment methods
150
+ *
151
+ * @return array
152
+ */
153
+ public function getMethods()
154
+ {
155
+ $methods = $this->getData('methods');
156
+ if (is_null($methods)) {
157
+ $quote = $this->getQuote();
158
+ $store = $quote ? $quote->getStoreId() : null;
159
+ $methods = $this->helper('payment')->getStoreMethods($store, $quote);
160
+ $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
161
+
162
+ foreach ($methods as $key => $method) {
163
+ if ($this->_canUseMethod($method)
164
+ && ($total != 0
165
+ || $method->getCode() == 'free'
166
+ || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles()))) {
167
+ $this->_assignMethod($method);
168
+ } else {
169
+ unset($methods[$key]);
170
+ }
171
+ }
172
+ $this->setData('methods', $methods);
173
+ }
174
+ return $methods;
175
+ }
176
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Redirect.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Redirect extends Mage_Core_Block_Template
32
+ {
33
+ /**
34
+ * @deprecated after 1.4.0.1
35
+ */
36
+ private $_order;
37
+
38
+ /**
39
+ * Retrieve identifier of created order
40
+ *
41
+ * @return string
42
+ * @deprecated after 1.4.0.1
43
+ */
44
+ public function getOrderId()
45
+ {
46
+ return $this->_getData('order_id');
47
+ }
48
+
49
+ /**
50
+ * Check order print availability
51
+ *
52
+ * @return bool
53
+ * @deprecated after 1.4.0.1
54
+ */
55
+ public function canPrint()
56
+ {
57
+ return $this->_getData('can_view_order');
58
+ }
59
+
60
+ /**
61
+ * Get url for order detale print
62
+ *
63
+ * @return string
64
+ * @deprecated after 1.4.0.1
65
+ */
66
+ public function getPrintUrl()
67
+ {
68
+ return $this->_getData('print_url');
69
+ }
70
+
71
+ /**
72
+ * Get url for view order details
73
+ *
74
+ * @return string
75
+ * @deprecated after 1.4.0.1
76
+ */
77
+ public function getViewOrderUrl()
78
+ {
79
+ return $this->_getData('view_order_id');
80
+ }
81
+
82
+ /**
83
+ * See if the order has state, visible on frontend
84
+ *
85
+ * @return bool
86
+ */
87
+ public function isOrderVisible()
88
+ {
89
+ return (bool)$this->_getData('is_order_visible');
90
+ }
91
+
92
+ /**
93
+ * Get payment method
94
+ *
95
+ * @return string
96
+ */
97
+ public function getPaymentMethod()
98
+ {
99
+ return $this->_getData('payment_method');
100
+ }
101
+
102
+ /**
103
+ * Getter for recurring profile view page
104
+ *
105
+ * @param $profile
106
+ */
107
+ public function getProfileUrl(Varien_Object $profile)
108
+ {
109
+ return $this->getUrl('sales/recurring_profile/view', array('profile' => $profile->getId()));
110
+ }
111
+
112
+ /**
113
+ * Internal constructor
114
+ * Set template for redirect
115
+ *
116
+ */
117
+ public function __construct() {
118
+ parent::_construct();
119
+ $this->setTemplate('mundipagg/redirect.phtml');
120
+ }
121
+
122
+ /**
123
+ * Initialize data and prepare it for output
124
+ */
125
+ protected function _beforeToHtml()
126
+ {
127
+ $this->_prepareLastOrder();
128
+ return parent::_beforeToHtml();
129
+ }
130
+
131
+ /**
132
+ * Get last order ID from session, fetch it and check whether it can be viewed, printed etc
133
+ */
134
+ protected function _prepareLastOrder()
135
+ {
136
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
137
+ if ($orderId) {
138
+ $order = Mage::getModel('sales/order')->load($orderId);
139
+ if ($order->getId()) {
140
+ $isVisible = !in_array($order->getState(),
141
+ Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
142
+ $this->addData(array(
143
+ 'is_order_visible' => $isVisible,
144
+ 'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
145
+ 'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
146
+ 'can_print_order' => $isVisible,
147
+ 'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
148
+ 'order_id' => $order->getIncrementId(),
149
+ 'payment_method' => $order->getPayment()->getAdditionalInformation('PaymentMethod'),
150
+ ));
151
+ }
152
+ }
153
+ }
154
+
155
+ public function getInfoInstance()
156
+ {
157
+ return Mage::getModel('mundipagg/standard')->getInfoInstance();
158
+ }
159
+
160
+ /**
161
+ * Return Boleto URL in order to print it
162
+ * @return string
163
+ **/
164
+ public function getBoletoUrl()
165
+ {
166
+ $session = Mage::getSingleton('checkout/session');
167
+ $session->setQuoteId($session->getMundipaggStandardQuoteId(true));
168
+
169
+ if ($session->getLastRealOrderId()) {
170
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
171
+
172
+ return $order->getPayment()->getAdditionalInformation('BoletoUrl');
173
+ }
174
+ }
175
+ }
app/code/community/Uecommerce/Mundipagg/Block/Standard/Success.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Block_Standard_Success extends Mage_Sales_Block_Items_Abstract
32
+ {
33
+ /**
34
+ * @deprecated after 1.4.0.1
35
+ */
36
+ private $_order;
37
+
38
+ /**
39
+ * Retrieve identifier of created order
40
+ *
41
+ * @return string
42
+ * @deprecated after 1.4.0.1
43
+ */
44
+ public function getOrderId()
45
+ {
46
+ return $this->_getData('order_id');
47
+ }
48
+
49
+ public function getBaseGrandTotal()
50
+ {
51
+ return $this->_getData('base_grand_total');
52
+ }
53
+
54
+ /**
55
+ * Check order print availability
56
+ *
57
+ * @return bool
58
+ * @deprecated after 1.4.0.1
59
+ */
60
+ public function canPrint()
61
+ {
62
+ return $this->_getData('can_view_order');
63
+ }
64
+
65
+ /**
66
+ * Get url for order detale print
67
+ *
68
+ * @return string
69
+ * @deprecated after 1.4.0.1
70
+ */
71
+ public function getPrintUrl()
72
+ {
73
+ return $this->_getData('print_url');
74
+ }
75
+
76
+ /**
77
+ * Get url for view order details
78
+ *
79
+ * @return string
80
+ * @deprecated after 1.4.0.1
81
+ */
82
+ public function getViewOrderUrl()
83
+ {
84
+ return $this->_getData('view_order_id');
85
+ }
86
+
87
+ /**
88
+ * See if the order has state, visible on frontend
89
+ *
90
+ * @return bool
91
+ */
92
+ public function isOrderVisible()
93
+ {
94
+ return (bool)$this->_getData('is_order_visible');
95
+ }
96
+
97
+ /**
98
+ * Get payment method
99
+ *
100
+ * @return string
101
+ */
102
+ public function getPaymentMethod()
103
+ {
104
+ return $this->_getData('payment_method');
105
+ }
106
+
107
+ /**
108
+ * Getter for recurring profile view page
109
+ *
110
+ * @param $profile
111
+ */
112
+ public function getProfileUrl(Varien_Object $profile)
113
+ {
114
+ return $this->getUrl('sales/recurring_profile/view', array('profile' => $profile->getId()));
115
+ }
116
+
117
+ /**
118
+ * Internal constructor
119
+ * Set template for redirect
120
+ *
121
+ */
122
+ public function __construct()
123
+ {
124
+ parent::_construct();
125
+ $this->setTemplate('mundipagg/success.phtml');
126
+ }
127
+
128
+ /**
129
+ * Initialize data and prepare it for output
130
+ */
131
+ protected function _beforeToHtml()
132
+ {
133
+ $this->_prepareLastOrder();
134
+ return parent::_beforeToHtml();
135
+ }
136
+
137
+ /**
138
+ * Get last order ID from session, fetch it and check whether it can be viewed, printed etc
139
+ */
140
+ protected function _prepareLastOrder()
141
+ {
142
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
143
+ if ($orderId) {
144
+ $order = Mage::getModel('sales/order')->load($orderId);
145
+ if ($order->getId()) {
146
+ $isVisible = !in_array($order->getState(),
147
+ Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
148
+ $this->addData(array(
149
+ 'is_order_visible' => $isVisible,
150
+ 'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
151
+ 'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
152
+ 'can_print_order' => $isVisible,
153
+ 'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
154
+ 'order_id' => $order->getIncrementId(),
155
+ 'payment_method' => $order->getPayment()->getAdditionalInformation('PaymentMethod'),
156
+ 'base_grand_total' => $order->getBaseGrandTotal(),
157
+ ));
158
+ }
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Return Boleto URL in order to print it
164
+ * @return string
165
+ **/
166
+ public function getBoletoUrl()
167
+ {
168
+ $session = Mage::getSingleton('checkout/session');
169
+ $session->setQuoteId($session->getMundipaggStandardQuoteId(true));
170
+
171
+ if ($session->getLastRealOrderId()) {
172
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
173
+
174
+ $boleto = $order->getPayment()->getAdditionalInformation('BoletoUrl');
175
+
176
+ return $boleto;
177
+ }
178
+ }
179
+ }
app/code/community/Uecommerce/Mundipagg/Controller/Abstract.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Controller_Abstract extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+
8
+ $environment = Mage::getStoreConfig('payment/mundipagg_standard/environment');
9
+
10
+ if ($environment == 'production') {
11
+ if ($this->requestIsValid() == false) {
12
+ echo $this->getResponseForInvalidRequest();
13
+ die();
14
+ }
15
+ }
16
+ }
17
+
18
+ protected function jsonResponse($responseArray) {
19
+ $json = json_encode($responseArray);
20
+
21
+ $this->getResponse()->setHeader('Content-type', 'application/json');
22
+ $this->getResponse()->setBody($json);
23
+ }
24
+
25
+ protected function requestIsValid() {
26
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
27
+ $serverHost = $_SERVER['HTTP_HOST'];
28
+ $request = $this->getRequest();
29
+
30
+ //getting request origin
31
+ $requestServer = $request->getServer();
32
+ $requestServerName = $requestServer['SERVER_NAME'];
33
+
34
+ //validating if the request is from the store and is ajax
35
+ if ($requestServerName == $serverHost && $request->isXmlHttpRequest()) {
36
+ return true;
37
+
38
+ } else {
39
+ $logMessage = "[SecurityAlert] Someone have tried to get data from a controller outside of the server.";
40
+
41
+ $helperLog->warning($logMessage);
42
+ $helperLog->warning(print_r($requestServer, true));
43
+
44
+ return false;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * @return string
50
+ */
51
+ protected function getResponseForInvalidRequest() {
52
+ return "Bad guy... Go away, we have data about you now.";
53
+ }
54
+
55
+ public function reportErrorAction() {
56
+
57
+ try {
58
+ $message = $this->getRequest()->getPost('errorMessage');
59
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
60
+ $api = new Uecommerce_Mundipagg_Model_Api();
61
+
62
+ $helperLog->error($message);
63
+ $api->mailError($message);
64
+
65
+ } catch (Exception $e) {
66
+ }
67
+ }
68
+
69
+ protected function getSessionId() {
70
+ $sessionId = Uecommerce_Mundipagg_Model_Customer_Session::getSessionId();
71
+
72
+ if (is_null($sessionId) || $sessionId == false || empty($sessionId)) {
73
+ $sessionId = uniqid('mund19-');
74
+ Uecommerce_Mundipagg_Model_Customer_Session::setSessionId($sessionId);
75
+ }
76
+
77
+ return $sessionId;
78
+ }
79
+
80
+ }
app/code/community/Uecommerce/Mundipagg/Helper/Data.php ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Helper_Data extends Mage_Core_Helper_Abstract
32
+ {
33
+ protected $config_juros;
34
+
35
+ /**
36
+ * Get extension version
37
+ */
38
+ public function getExtensionVersion()
39
+ {
40
+ return (string) Mage::getConfig()->getNode()->modules->Uecommerce_Mundipagg->version;
41
+ }
42
+
43
+ /**
44
+ * Return issuer
45
+ * @param varchar $cardType
46
+ */
47
+ public function issuer($cardType)
48
+ {
49
+ if ( $cardType == '') {
50
+ return '';
51
+ } else {
52
+ $issuers = array(
53
+ 'VI' => 'Visa',
54
+ 'MC' => 'Mastercard',
55
+ 'AE' => 'Amex',
56
+ 'DI' => 'Diners',
57
+ 'HI' => 'Hipercard',
58
+ 'EL' => 'Elo',
59
+ );
60
+
61
+ foreach ($issuers as $key => $issuer) {
62
+ if ($key == $cardType) {
63
+ return $issuer;
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Return cardType
71
+ * @param string $issuer
72
+ */
73
+ public function getCardTypeByIssuer($issuer){
74
+ if ( $issuer == '') {
75
+ return '';
76
+ } else {
77
+ $issuers = array(
78
+ 'VI' => 'Visa',
79
+ 'MC' => 'Mastercard',
80
+ 'AE' => 'Amex',
81
+ 'DI' => 'Diners',
82
+ 'HI' => 'Hipercard',
83
+ 'EL' => 'Elo',
84
+ );
85
+
86
+ foreach ($issuers as $key => $cardType) {
87
+ if ($cardType == $issuer) {
88
+ return $key;
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Get credit cards number
96
+ */
97
+ public function getCreditCardsNumber($payment_method)
98
+ {
99
+ $num = 1;
100
+
101
+ switch ($payment_method) {
102
+ case 'mundipagg_creditcardoneinstallment':
103
+ $num = 0;
104
+ break;
105
+
106
+ case 'mundipagg_creditcard':
107
+ $num = 1;
108
+ break;
109
+
110
+ case 'mundipagg_twocreditcards':
111
+ $num = 2;
112
+ break;
113
+
114
+ case 'mundipagg_threecreditcards':
115
+ $num = 3;
116
+ break;
117
+
118
+ case 'mundipagg_fourcreditcards':
119
+ $num = 4;
120
+ break;
121
+
122
+ case 'mundipagg_fivecreditcards':
123
+ $num = 5;
124
+ break;
125
+ }
126
+
127
+ return $num;
128
+ }
129
+
130
+ /**
131
+ * Return payment method
132
+ */
133
+ public function getPaymentMethod($num)
134
+ {
135
+ $method = '';
136
+
137
+ switch ($num) {
138
+ case '0':
139
+ $method = 'mundipagg_creditcardoneinstallment';
140
+ break;
141
+ case '1':
142
+ $method = 'mundipagg_creditcard';
143
+ break;
144
+ case '2':
145
+ $method = 'mundipagg_twocreditcards';
146
+ break;
147
+ case '3':
148
+ $method = 'mundipagg_threecreditcards';
149
+ break;
150
+ case '4':
151
+ $method = 'mundipagg_fourcreditcards';
152
+ break;
153
+ case '5':
154
+ $method = 'mundipagg_fivecreditcards';
155
+ break;
156
+ }
157
+
158
+ return $method;
159
+ }
160
+
161
+ public function validateExpDate($expYear, $expMonth)
162
+ {
163
+ $date = Mage::app()->getLocale()->date();
164
+ if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1)
165
+ || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1))
166
+ ) {
167
+ return false;
168
+ }
169
+ return true;
170
+ }
171
+
172
+ /**
173
+ * Validate credit card number
174
+ *
175
+ * @param string $cc_number
176
+ * @return bool
177
+ */
178
+ public function validateCcNum($ccNumber)
179
+ {
180
+ $cardNumber = strrev($ccNumber);
181
+ $numSum = 0;
182
+
183
+ for ($i=0; $i<strlen($cardNumber); $i++) {
184
+ $currentNum = substr($cardNumber, $i, 1);
185
+
186
+ /**
187
+ * Double every second digit
188
+ */
189
+ if ($i % 2 == 1) {
190
+ $currentNum *= 2;
191
+ }
192
+
193
+ /**
194
+ * Add digits of 2-digit numbers together
195
+ */
196
+ if ($currentNum > 9) {
197
+ $firstNum = $currentNum % 10;
198
+ $secondNum = ($currentNum - $firstNum) / 10;
199
+ $currentNum = $firstNum + $secondNum;
200
+ }
201
+
202
+ $numSum += $currentNum;
203
+ }
204
+
205
+ /**
206
+ * If the total has no remainder it's OK
207
+ */
208
+ return ($numSum % 10 == 0);
209
+ }
210
+
211
+ /**
212
+ * Validate CPF
213
+ */
214
+ public function validateCPF($cpf)
215
+ {
216
+ // Verifiva se o número digitado contém todos os digitos
217
+ $cpf = preg_replace('[\D]', '', $cpf);
218
+
219
+ // Verifica se nenhuma das sequências abaixo foi digitada, caso seja, retorna falso
220
+ if (strlen($cpf) != 11 ||
221
+ $cpf == '00000000000' ||
222
+ $cpf == '11111111111' ||
223
+ $cpf == '22222222222' ||
224
+ $cpf == '33333333333' ||
225
+ $cpf == '44444444444' ||
226
+ $cpf == '55555555555' ||
227
+ $cpf == '66666666666' ||
228
+ $cpf == '77777777777' ||
229
+ $cpf == '88888888888' ||
230
+ $cpf == '99999999999') {
231
+ return false;
232
+ } else { // Calcula os números para verificar se o CPF é verdadeiro
233
+ for ($t = 9; $t < 11; $t++) {
234
+ for ($d = 0, $c = 0; $c < $t; $c++) {
235
+ $d += $cpf{$c} * (($t + 1) - $c);
236
+ }
237
+
238
+ $d = ((10 * $d) % 11) % 10;
239
+
240
+ if ($cpf{$c} != $d) {
241
+ return false;
242
+ }
243
+ }
244
+
245
+ return true;
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Validate CNPJ
251
+ */
252
+ public function validateCNPJ($value)
253
+ {
254
+ $cnpj = str_replace(array("-"," ","/","."), "", $value);
255
+ $digitosIguais = 1;
256
+
257
+ if (strlen($cnpj) < 14 && strlen($cnpj) < 15) {
258
+ return false;
259
+ }
260
+ for ($i = 0; $i < strlen($cnpj) - 1; $i++) {
261
+
262
+ if ($cnpj{$i} != $cnpj{$i + 1}) {
263
+ $digitosIguais = 0;
264
+ break;
265
+ }
266
+ }
267
+
268
+ if (!$digitosIguais) {
269
+ $tamanho = strlen($cnpj) - 2;
270
+ $numeros = substr($cnpj, 0, $tamanho);
271
+ $digitos = substr($cnpj, $tamanho);
272
+ $soma = 0;
273
+ $pos = $tamanho - 7;
274
+ for ($i = $tamanho; $i >= 1; $i--) {
275
+ $soma += $numeros{$tamanho - $i} * $pos--;
276
+ if ($pos < 2) {
277
+ $pos = 9;
278
+ }
279
+ }
280
+ $resultado = ($soma % 11 < 2 ? 0 : 11 - $soma % 11);
281
+ if ($resultado != $digitos{0}) {
282
+ return false;
283
+ }
284
+ $tamanho = $tamanho + 1;
285
+ $numeros = substr($cnpj, 0, $tamanho);
286
+ $soma = 0;
287
+ $pos = $tamanho - 7;
288
+ for ($i = $tamanho; $i >= 1; $i--) {
289
+ $soma += $numeros{$tamanho - $i} * $pos--;
290
+ if ($pos < 2) {
291
+ $pos = 9;
292
+ }
293
+ }
294
+ $resultado = ($soma % 11 < 2 ? 0 : 11 - $soma % 11);
295
+ if ($resultado != $digitos{1}) {
296
+ return false;
297
+ } else {
298
+ return true;
299
+ }
300
+ } else {
301
+ return false;
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Apply telephone mask
307
+ */
308
+ public function applyTelephoneMask($string)
309
+ {
310
+ $string = preg_replace('[\D]', '', $string);
311
+
312
+ $length = strlen($string);
313
+
314
+ switch ($length) {
315
+ case 10:
316
+ $mask = '(##)########';
317
+ break;
318
+
319
+ case 11:
320
+ $mask = '(##)#########';
321
+ break;
322
+
323
+ default:
324
+ return '';
325
+ }
326
+
327
+ for($i=0;$i<strlen($string);$i++) {
328
+ $mask[strpos($mask,"#")] = $string[$i];
329
+ }
330
+
331
+ return '55'.$mask;
332
+ }
333
+
334
+ /**
335
+ * PhoneRequestCollection
336
+ *
337
+ * @param $order Mage_Sales_Model_Order
338
+ * @return array
339
+ */
340
+ public function getPhoneRequestCollection(Mage_Sales_Model_Order $order)
341
+ {
342
+ $billingAddress = $order->getBillingAddress();
343
+ $telephone = $billingAddress->getTelephone();
344
+
345
+ $telephone = $this->applyTelephoneMask($telephone);
346
+
347
+ if(!$telephone) {
348
+ $telephone = '55(21)88888888';
349
+ }
350
+
351
+ $phoneTypeEnum = 'Residential';
352
+ if($this->validateCNPJ($order->getCustomerTaxvat())) {
353
+ $phoneTypeEnum = 'Comercial';
354
+ }
355
+
356
+ $dataReturn = array(
357
+ array(
358
+ 'AreaCode' => substr($telephone, 3, 2),
359
+ 'CountryCode' => substr($telephone, 0, 2),
360
+ 'Extension' => '',
361
+ 'PhoneNumber' => substr($telephone, 6, strlen($telephone)),
362
+ 'PhoneTypeEnum' => $phoneTypeEnum
363
+ )
364
+ );
365
+
366
+ return $dataReturn;
367
+ }
368
+
369
+ /**
370
+ * Retorna o valor de uma parcela
371
+ * - valor total a ser parcelado
372
+ * - taxa de juros
373
+ * - numero de prestacoes
374
+ *
375
+ * Thanks to Fillipe Almeida Dutra
376
+ */
377
+ public function calcInstallmentValue($total, $interest, $periods)
378
+ {
379
+ /*
380
+ * Formula do coeficiente:
381
+ *
382
+ * juros / ( 1 - 1 / (1 + i)^n )
383
+ *
384
+ */
385
+
386
+ // calcula o coeficiente, seguindo a formula acima
387
+ $coefficient = pow((1 + $interest), $periods);
388
+ $coefficient = 1 / $coefficient;
389
+ $coefficient = 1 - $coefficient;
390
+ $coefficient = $interest / $coefficient;
391
+
392
+ // retorna o valor da parcela
393
+ return ($total * $coefficient);
394
+ }
395
+
396
+ public function getJurosParcela($total, $parcela)
397
+ {
398
+ $juros = $this->getJurosParcelaEscolhida($parcela);
399
+
400
+ if ($juros) {
401
+ return $total * $juros / $parcela;
402
+ } else {
403
+ return $total / $parcela;
404
+ }
405
+ }
406
+
407
+ public function getTotalJuros($total, $parcela)
408
+ {
409
+ return $this->getJurosParcela($total, $parcela) * $parcela;
410
+ }
411
+
412
+ public function getConfigJuros($position)
413
+ {
414
+ if (empty($this->config_juros)) {
415
+ $storeId = Mage::app()->getStore()->getStoreId();
416
+
417
+ $value2 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_2', $storeId);
418
+ $value3 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_3', $storeId);
419
+ $value4 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_4', $storeId);
420
+ $value5 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_5', $storeId);
421
+ $value6 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_6', $storeId);
422
+ $value7 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_7', $storeId);
423
+ $value8 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_8', $storeId);
424
+ $value9 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_9', $storeId);
425
+ $value10 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_10', $storeId);
426
+ $value11 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_11', $storeId);
427
+ $value12 = Mage::getStoreConfig('payment/mundipagg_standard/installment_interest_value_12', $storeId);
428
+
429
+ $this->config_juros = array(
430
+ $this->prepareCalc($value2?$value2:0),
431
+ $this->prepareCalc($value3?$value3:0),
432
+ $this->prepareCalc($value4?$value4:0),
433
+ $this->prepareCalc($value5?$value5:0),
434
+ $this->prepareCalc($value6?$value6:0),
435
+ $this->prepareCalc($value7?$value7:0),
436
+ $this->prepareCalc($value8?$value8:0),
437
+ $this->prepareCalc($value9?$value9:0),
438
+ $this->prepareCalc($value10?$value10:0),
439
+ $this->prepareCalc($value11?$value11:0),
440
+ $this->prepareCalc($value12?$value12:0)
441
+ );
442
+ }
443
+
444
+ return $this->config_juros[$position];
445
+ }
446
+
447
+ public function prepareCalc($value)
448
+ {
449
+ return (float) $value;
450
+ }
451
+
452
+ public function getJurosParcelaEscolhida($parcela)
453
+ {
454
+ $juros = 0;
455
+
456
+ if ($parcela == 2) {
457
+ $juros = $this->getConfigJuros(0);
458
+ }
459
+
460
+ if ($parcela > 2 && $parcela <= 3) {
461
+ $juros = $this->getConfigJuros(1);
462
+ }
463
+
464
+ if ($parcela > 3 && $parcela <= 4) {
465
+ $juros = $this->getConfigJuros(2);
466
+ }
467
+
468
+ if ($parcela > 4 && $parcela <= 5) {
469
+ $juros = $this->getConfigJuros(3);
470
+ }
471
+
472
+ if ($parcela > 5 && $parcela <= 6) {
473
+ $juros = $this->getConfigJuros(4);
474
+ }
475
+
476
+ if ($parcela > 6 && $parcela <= 7) {
477
+ $juros = $this->getConfigJuros(5);
478
+ }
479
+
480
+ if ($parcela > 7 && $parcela <= 8) {
481
+ $juros = $this->getConfigJuros(6);
482
+ }
483
+
484
+ if ($parcela > 8 && $parcela <= 9) {
485
+ $juros = $this->getConfigJuros(7);
486
+ }
487
+
488
+ if ($parcela > 9 && $parcela <= 10) {
489
+ $juros = $this->getConfigJuros(8);
490
+ }
491
+
492
+ if ($parcela > 10 && $parcela <= 11) {
493
+ $juros = $this->getConfigJuros(9);
494
+ }
495
+
496
+ if ($parcela > 11) {
497
+ $juros = $this->getConfigJuros(10);
498
+ }
499
+
500
+ return $juros;
501
+ }
502
+
503
+
504
+
505
+
506
+ }
app/code/community/Uecommerce/Mundipagg/Helper/Installments.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Helper_Installments extends Mage_Core_Helper_Abstract
32
+ {
33
+
34
+ public $displayTotal = true;
35
+ protected function _fixQty($qty)
36
+ {
37
+ return (!empty($qty) ? (float)$qty : null);
38
+ }
39
+
40
+ public function getInstallments($store = null, $ccType = "installments")
41
+ {
42
+ $value = Mage::getStoreConfig("payment/mundipagg_standard/".$ccType, $store);
43
+ $value = $this->_unserializeValue($value);
44
+
45
+ return $value;
46
+ }
47
+
48
+ protected function _unserializeValue($value)
49
+ {
50
+ if (is_string($value) && !empty($value)) {
51
+ return unserialize($value);
52
+ } else {
53
+ return array();
54
+ }
55
+ }
56
+
57
+ protected function _isEncodedArrayFieldValue($value)
58
+ {
59
+ if (!is_array($value)) {
60
+ return false;
61
+ }
62
+
63
+ unset($value['__empty']);
64
+
65
+ foreach ($value as $_id => $row) {
66
+ if (!is_array($row) || !array_key_exists('installment_boundary', $row) || !array_key_exists('installment_frequency', $row ) || !array_key_exists('installment_interest', $row )) {
67
+ return false;
68
+ }
69
+ }
70
+
71
+ return true;
72
+ }
73
+
74
+ protected function _decodeArrayFieldValue(array $value)
75
+ {
76
+ $result = array();
77
+ unset($value['__empty']);
78
+
79
+ foreach ($value as $_id => $row) {
80
+ if (!is_array($row) || !array_key_exists('installment_boundary', $row) || !array_key_exists('installment_frequency', $row) || !array_key_exists('installment_interest', $row)) {
81
+ continue;
82
+ }
83
+
84
+ $boundary = $row['installment_boundary'];
85
+ $frequency = $row['installment_frequency'];
86
+ $interest = $row['installment_interest'];
87
+ $result[] = array($boundary,$frequency,$interest);
88
+ }
89
+
90
+ return $result;
91
+ }
92
+
93
+ protected function _encodeArrayFieldValue(array $value)
94
+ {
95
+ $result = array();
96
+
97
+ foreach ($value as $triplet) {
98
+ $boundary = (isset($triplet[0])) ? $triplet[0] : "";
99
+ $frequency = (isset($triplet[1])) ? $triplet[1] : "";
100
+ $interest = (isset($triplet[2])) ? $triplet[2] : "";
101
+
102
+ $_id = Mage::helper('core')->uniqHash('_');
103
+
104
+ $result[$_id] = array(
105
+ 'installment_boundary' => $boundary,
106
+ 'installment_frequency' => $frequency,
107
+ 'installment_interest' => $interest
108
+ );
109
+ }
110
+
111
+ return $result;
112
+ }
113
+
114
+ protected function _serializeValue($value)
115
+ {
116
+ return serialize($value);
117
+ }
118
+
119
+ public function makeArrayFieldValue($value)
120
+ {
121
+ $value = $this->_unserializeValue($value);
122
+
123
+ if (!$this->_isEncodedArrayFieldValue($value)) {
124
+ $value = $this->_encodeArrayFieldValue($value);
125
+ }
126
+
127
+ return $value;
128
+ }
129
+
130
+ public function makeStorableArrayFieldValue($value)
131
+ {
132
+ if ($this->_isEncodedArrayFieldValue($value)) {
133
+ $value = $this->_decodeArrayFieldValue($value);
134
+ }
135
+
136
+ $value = $this->_serializeValue($value);
137
+
138
+ return $value;
139
+ }
140
+
141
+ public function getConfigValue($amount, $store = null, $ccType = "installments")
142
+ {
143
+ $value = $this->getInstallments($store, $ccType);
144
+
145
+ if ($this->_isEncodedArrayFieldValue($value)) {
146
+ $value = $this->_decodeArrayFieldValue($value);
147
+ }
148
+
149
+ $cur_minimal_boundary = -1;
150
+ $resulting_freq = 1;
151
+
152
+ foreach ($value as $row) {
153
+ list($boundary,$frequency) = $row;
154
+
155
+ if($amount <= $boundary && ($boundary <= $cur_minimal_boundary || $cur_minimal_boundary == -1) ) {
156
+ $cur_minimal_boundary = $boundary;
157
+ $resulting_freq = $frequency;
158
+ }
159
+ if($boundary == "" && $cur_minimal_boundary == -1){
160
+ $resulting_freq = $frequency;
161
+ }
162
+ }
163
+
164
+ return $resulting_freq;
165
+ }
166
+
167
+ public function isInstallmentsEnabled($store = null)
168
+ {
169
+ $value = Mage::getStoreConfig("payment/mundipagg_standard/enable_installments", $store);
170
+
171
+ return $value;
172
+ }
173
+
174
+ public function getMaxInstallments($ccType = null,$amount = null)
175
+ {
176
+ $session = Mage::getSingleton('admin/session');
177
+
178
+ if ($session->isLoggedIn()) {
179
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
180
+ } else {
181
+ $quote = (Mage::getModel('checkout/type_onepage') !== false)? Mage::getModel('checkout/type_onepage')->getQuote(): Mage::getModel('checkout/session')->getQuote();;
182
+ }
183
+
184
+ if(!$amount) {
185
+ // Get pre-authorized amount
186
+ $authorizedAmount = Mage::getSingleton('checkout/session')->getAuthorizedAmount();
187
+
188
+ $amount = (double)$quote->getGrandTotal()-$quote->getMundipaggInterest()-$authorizedAmount;
189
+ }
190
+
191
+ $amount = str_replace(',','.',$amount);
192
+ $ccTypeInstallments = "installments_".$ccType;
193
+
194
+ $all_installments = $this->getInstallments(null, $ccTypeInstallments);
195
+
196
+ if(empty($all_installments)) {
197
+ $ccTypeInstallments = null;
198
+ } else {
199
+ $max_installments = $this->getConfigValue($amount, null, $ccTypeInstallments);
200
+ }
201
+
202
+ if($ccTypeInstallments == null) {
203
+ $max_installments = $this->getConfigValue($amount, null);
204
+ $all_installments = $this->getInstallments();
205
+ }
206
+
207
+ if(!$max_installments){
208
+ $max_installments = 1;
209
+ }
210
+
211
+ return $max_installments;
212
+ }
213
+
214
+ public function getInstallmentForCreditCardType($ccType = null,$amount = null)
215
+ {
216
+ $session = Mage::getSingleton('admin/session');
217
+
218
+ if ($session->isLoggedIn()) {
219
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
220
+ } else {
221
+ $quote = (Mage::getModel('checkout/type_onepage') !== false)? Mage::getModel('checkout/type_onepage')->getQuote(): Mage::getModel('checkout/session')->getQuote();
222
+ }
223
+
224
+ if(!$amount) {
225
+ // Get pre-authorized amount
226
+ $authorizedAmount = Mage::getSingleton('checkout/session')->getAuthorizedAmount();
227
+
228
+ $amount = (double)$quote->getGrandTotal()-$quote->getMundipaggInterest()-$authorizedAmount;
229
+ }
230
+
231
+ $result = array();
232
+ $result[1] = "1x ".Mage::helper('core')->formatPrice($amount, false);
233
+
234
+ $amount = str_replace(',','.',$amount);
235
+ $ccTypeInstallments = "installments_".$ccType;
236
+
237
+ $all_installments = $this->getInstallments(null, $ccTypeInstallments);
238
+
239
+ if(empty($all_installments)) {
240
+ $ccTypeInstallments = null;
241
+ } else {
242
+ $max_installments = $this->getConfigValue($amount, null, $ccTypeInstallments);
243
+ }
244
+
245
+ // Fallback to the default installments if creditcard type has no one configured
246
+ if($ccTypeInstallments == null) {
247
+ $max_installments = $this->getConfigValue($amount, null);
248
+ $all_installments = $this->getInstallments();
249
+ }
250
+ $displayTotal = Mage::getStoreConfig('payment/mundipagg_standard/display_total');
251
+ if(!$max_installments){
252
+ $max_installments = 0;
253
+ }
254
+ // result array here
255
+ for($i=1;$i<=$max_installments;$i++) {
256
+ // check if installment has extra interest
257
+ $key = $i-1;
258
+ if(!array_key_exists($key,$all_installments)){
259
+ $all_installments[$key] = array();
260
+ }
261
+ $installment = $all_installments[$key];
262
+ if(isset($installment[2]) && $installment[2] > 0) {
263
+ $total_amount_with_interest = $amount + ($amount * ($installment[2] / 100));
264
+ $message = ' '.$this->__('with interest');
265
+ if($displayTotal && $this->displayTotal){
266
+ $message .= ' (Total: '.Mage::helper('core')->formatPrice(round((($total_amount_with_interest)/$i),2) * $i,false).')';
267
+ }
268
+ } else {
269
+ $total_amount_with_interest = $amount;
270
+ $message = ' '.$this->__('without interest');
271
+ }
272
+
273
+ $partial_amount = ((double)$total_amount_with_interest)/$i;
274
+ $result[(string)$i] = $i."x ".Mage::helper('core')->formatPrice($partial_amount, false).$message;
275
+ }
276
+
277
+
278
+
279
+ return $result;
280
+ }
281
+
282
+ public function getInterestForCard($installments = 1 , $ccType = null,$grandTotal = null)
283
+ {
284
+ $session = Mage::getSingleton('admin/session');
285
+
286
+ if ($session->isLoggedIn()) {
287
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
288
+ } else {
289
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
290
+ }
291
+
292
+ if($installments > 0) {
293
+ $ccTypeInstallments = "installments_".$ccType;
294
+ //Mage::log( 'ccTypeInstallments' );
295
+ //Mage::log( print_r($ccTypeInstallments,1) );
296
+ $all_installments = $this->getInstallments(null, $ccTypeInstallments);
297
+ //Mage::log( 'all_installments' );
298
+ //Mage::log( print_r($all_installments,1) );
299
+ if(empty($all_installments)) {
300
+ $all_installments = $this->getInstallments();
301
+ }
302
+
303
+ //Mage::log( 'if empty all_installments' );
304
+ //Mage::log( print_r($all_installments,1) );
305
+
306
+ $installmentKey = $installments - 1;
307
+
308
+ if(!$installmentKey){
309
+ return 0;
310
+ }
311
+ $installment = $all_installments[$installmentKey];
312
+
313
+ if($installment != null && is_array($installment)) {
314
+ // check if interest rate is filled in
315
+ if(isset($installment[2]) && $installment[2] > 0) {
316
+ $interestRate = $installment[2];
317
+
318
+ if(!$grandTotal) {
319
+ $grandTotal = $quote->getGrandTotal();
320
+ }
321
+ $grandTotal = str_replace(',','.',$grandTotal);
322
+
323
+ $grandTotalInterest = $grandTotal + ($grandTotal * ($interestRate / 100));
324
+
325
+ $fee = (round(($grandTotalInterest/$installments),2) * $installments) - $grandTotal;
326
+
327
+ $balance = round($fee,2);
328
+
329
+ return $balance;
330
+ }
331
+ }
332
+ }
333
+
334
+ return 0;
335
+ }
336
+ }
app/code/community/Uecommerce/Mundipagg/Helper/Log.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Log helper
5
+ * @author Ruan Azevedo <razvedo@mundipagg.com>
6
+ */
7
+ class Uecommerce_Mundipagg_Helper_Log extends Mage_Core_Helper_Abstract {
8
+
9
+ private $level;
10
+ private $method;
11
+ private $logLabel = '';
12
+
13
+ public function __construct($method = '') { $this->method = $method; }
14
+
15
+ public function setMethod($method) {
16
+ $this->method = $method;
17
+ }
18
+
19
+ public function setLogLabel($logLabel) {
20
+ $this->logLabel = $logLabel;
21
+ }
22
+
23
+ public function info($msg) {
24
+ $this->level = Zend_Log::INFO;
25
+ $this->write($msg);
26
+ }
27
+
28
+ public function debug($msg) {
29
+ $this->level = Zend_Log::DEBUG;
30
+ $this->write($msg);
31
+ }
32
+
33
+ public function warning($msg) {
34
+ $this->level = Zend_Log::WARN;
35
+ $this->write($msg);
36
+ }
37
+
38
+ public function error($msg, $logExceptionFile = false) {
39
+ $exception = new Exception($msg);
40
+ $this->level = Zend_Log::ERR;
41
+ $this->write($msg);
42
+
43
+ if ($logExceptionFile) {
44
+ Mage::logException($exception);
45
+ }
46
+ }
47
+
48
+ private function write($msg) {
49
+ $file = "Mundipagg_Integracao_" . date('Y-m-d') . ".log";
50
+
51
+ if (!empty($this->method)) {
52
+ if (!empty($this->logLabel)) {
53
+ $msg = "[{$this->method}] {$this->logLabel} | {$msg}";
54
+
55
+ } else {
56
+ $msg = "[{$this->method}] {$msg}";
57
+ }
58
+ }
59
+
60
+ Mage::log($msg, $this->level, $file);
61
+ }
62
+
63
+ }
app/code/community/Uecommerce/Mundipagg/Helper/Util.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Helper_Util extends Mage_Core_Helper_Abstract {
4
+
5
+ public function jsonEncodePretty($input) {
6
+ return json_encode($input, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
7
+ }
8
+
9
+ }
app/code/community/Uecommerce/Mundipagg/Helper/Version.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento version/edition helper for determining the Magento BASE version (regardless of edition) and adds functions to check if Enterprise, Professional or Community are being run.
4
+ * Adds isMageCommunity(), isMageProfessional() and isMageEnterprise()
5
+ *
6
+ * @category TBT
7
+ * @package TBT_Rewards
8
+ * @author WDCA Sweet Tooth Team <contact@sweettoothhq.com>
9
+ */
10
+ class Uecommerce_Mundipagg_Helper_Version extends Mage_Core_Helper_Abstract
11
+ {
12
+ /**
13
+ * True if the version of Magento currently being rune is Enterprise Edition
14
+ */
15
+ public function isMageEnterprise()
16
+ {
17
+ return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
18
+ }
19
+
20
+
21
+ /**
22
+ * True if the version of Magento currently being rune is Enterprise Edition
23
+ */
24
+ public function isMageProfessional()
25
+ {
26
+ return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
27
+ }
28
+
29
+
30
+
31
+ /**
32
+ * True if the version of Magento currently being rune is Enterprise Edition
33
+ */
34
+ public function isMageCommunity()
35
+ {
36
+ return !$this->isMageEnterprise() && !$this->isMageProfessional();
37
+ }
38
+
39
+
40
+ /**
41
+ * attempt to convert an Enterprise, Professional, Community magento version number to its compatable Community version
42
+ *
43
+ * @param string $task fix problems where direct version numbers cant be changed to a community release without knowing the intent of the task
44
+ */
45
+ public function convertVersionToCommunityVersion($version, $task = null)
46
+ {
47
+ /* Enterprise -
48
+ * 1.9 | 1.8 | 1.5
49
+ */
50
+ if ($this->isMageEnterprise()) {
51
+ if (version_compare ( $version, '1.11.0', '>=' ))
52
+ return '1.6.0';
53
+ if (version_compare ( $version, '1.9.1', '>=' ))
54
+ return '1.5.0';
55
+ if (version_compare ( $version, '1.9.0', '>=' ))
56
+ return '1.4.2';
57
+ if (version_compare ( $version, '1.8.0', '>=' ))
58
+ return '1.3.1';
59
+ return '1.3.1';
60
+ }
61
+
62
+ /* Professional -
63
+ * If Entprise_Enterprise module is installed but it didn't pass Enterprise_Enterprise tests
64
+ * then the installation must be Magento Pro edition.
65
+ * 1.7 | 1.8
66
+ */
67
+ if ($this->isMageProfessional()) {
68
+ if (version_compare ( $version, '1.8.0', '>=' ))
69
+ return '1.4.1';
70
+ if (version_compare ( $version, '1.7.0', '>=' ))
71
+ return '1.3.1';
72
+ return '1.3.1';
73
+ }
74
+
75
+ /* Community -
76
+ * 1.5rc2 - December 29, 2010
77
+ * 1.4.2 - December 8, 2010
78
+ * 1.4.1 - June 10, 2010
79
+ * 1.3.3.0 - (April 23, 2010) *** does this release work like to 1.4.0.1?
80
+ * 1.4.0.1 - (February 19, 2010)
81
+ * 1.4.0.0 - (February 12, 2010)
82
+ * 1.3.0 - March 30, 2009
83
+ * 1.2.1.1 - February 23, 2009
84
+ * 1.1 - July 24, 2008
85
+ * 0.6.1316 - October 18, 2007
86
+ */
87
+ return $version;
88
+ }
89
+
90
+
91
+ /**
92
+ * Returns true if the base Magento version is what has been specified
93
+ * @param string $version
94
+ * @param unknown_type $task
95
+ * @return boolean
96
+ */
97
+ public function isBaseMageVersion($version, $task = null)
98
+ {
99
+ // convert Magento Enterprise, Professional, Community to a base version
100
+ $mage_base_version = $this->convertVersionToCommunityVersion ( Mage::getVersion (), $task );
101
+
102
+ if (version_compare ( $mage_base_version, $version, '=' )) {
103
+ return true;
104
+ }
105
+ return false;
106
+ }
107
+ }
app/code/community/Uecommerce/Mundipagg/Model/.DS_Store ADDED
Binary file
app/code/community/Uecommerce/Mundipagg/Model/Api.php ADDED
@@ -0,0 +1,1809 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ class Uecommerce_Mundipagg_Model_Api extends Uecommerce_Mundipagg_Model_Standard {
31
+
32
+ private $helperUtil;
33
+ private $modelStandard;
34
+ private $debugEnabled;
35
+ private $moduleVersion;
36
+
37
+ public function __construct() {
38
+ $this->helperUtil = new Uecommerce_Mundipagg_Helper_Util();
39
+ $this->modelStandard = new Uecommerce_Mundipagg_Model_Standard();
40
+ $this->moduleVersion = Mage::helper('mundipagg')->getExtensionVersion();
41
+ $this->debugEnabled = $this->modelStandard->getDebug();
42
+ parent::_construct();
43
+ }
44
+
45
+ /**
46
+ * Credit Card Transaction
47
+ */
48
+ public function creditCardTransaction($order, $data, Uecommerce_Mundipagg_Model_Standard $standard) {
49
+ $_logRequest = array();
50
+
51
+ try {
52
+ // Installments configuration
53
+ $installment = $standard->getParcelamento();
54
+ $qtdParcelasMax = $standard->getParcelamentoMax();
55
+
56
+ // Get Webservice URL
57
+ $url = $standard->getURL();
58
+
59
+ // Set Data
60
+ $_request = array();
61
+ $_request["Order"] = array();
62
+ $_request["Order"]["OrderReference"] = $order->getIncrementId();
63
+
64
+ // if ($standard->getEnvironment() != 'production') {
65
+ // $_request["Order"]["OrderReference"] = md5(date('Y-m-d H:i:s')); // Identificação do pedido na loja
66
+ // }
67
+
68
+ /*
69
+ * Append transaction (multi credit card payments)
70
+ * When one of Credit Cards has not been authorized and we try with a new one)
71
+ */
72
+ if ($orderReference = $order->getPayment()->getAdditionalInformation('OrderReference')) {
73
+ $_request["Order"]["OrderReference"] = $orderReference;
74
+ }
75
+
76
+ // Collection
77
+ $_request["CreditCardTransactionCollection"] = array();
78
+
79
+ /* @var $recurrencyModel Uecommerce_Mundipagg_Model_Recurrency */
80
+ $recurrencyModel = Mage::getModel('mundipagg/recurrency');
81
+
82
+ $creditcardTransactionCollection = array();
83
+
84
+ // Partial Payment (we use this reference in order to authorize the rest of the amount)
85
+ if ($order->getPayment()->getAdditionalInformation('OrderReference')) {
86
+ $_request["CreditCardTransactionCollection"]["OrderReference"] = $order->getPayment()->getAdditionalInformation('OrderReference');
87
+ }
88
+
89
+ $baseGrandTotal = str_replace(',', '.', $order->getBaseGrandTotal());
90
+ $amountInCentsVar = intval(strval(($baseGrandTotal * 100)));
91
+
92
+ // CreditCardOperationEnum : if more than one payment method we use AuthOnly and then capture if all are ok
93
+ $helper = Mage::helper('mundipagg');
94
+
95
+ $num = $helper->getCreditCardsNumber($data['payment_method']);
96
+
97
+ $installmentCount = 1;
98
+
99
+ if ($num > 1) {
100
+ $creditCardOperationEnum = 'AuthOnly';
101
+ } else {
102
+ $creditCardOperationEnum = $standard->getCreditCardOperationEnum();
103
+ }
104
+
105
+ foreach ($data['payment'] as $i => $paymentData) {
106
+ $creditcardTransactionData = new stdclass();
107
+ $creditcardTransactionData->CreditCard = new stdclass();
108
+ $creditcardTransactionData->Options = new stdclass();
109
+
110
+ // InstantBuyKey payment
111
+ if (isset($paymentData['card_on_file_id'])) {
112
+ $token = Mage::getModel('mundipagg/cardonfile')->load($paymentData['card_on_file_id']);
113
+
114
+ if ($token->getId() && $token->getEntityId() == $order->getCustomerId()) {
115
+ $creditcardTransactionData->CreditCard->InstantBuyKey = $token->getToken();
116
+ $creditcardTransactionData->CreditCard->CreditCardBrand = $token->getCcType();
117
+ $creditcardTransactionData->CreditCardOperation = $creditCardOperationEnum;
118
+ /** Tipo de operação: AuthOnly | AuthAndCapture | AuthAndCaptureWithDelay */
119
+ $creditcardTransactionData->AmountInCents = intval(strval(($paymentData['AmountInCents']))); // Valor da transação
120
+ $creditcardTransactionData->InstallmentCount = $paymentData['InstallmentCount']; // Nº de parcelas
121
+ $creditcardTransactionData->Options->CurrencyIso = "BRL"; //Moeda do pedido
122
+ }
123
+
124
+ } else { // Credit Card
125
+ $creditcardTransactionData->CreditCard->CreditCardNumber = $paymentData['CreditCardNumber']; // Número do cartão
126
+ $creditcardTransactionData->CreditCard->HolderName = $paymentData['HolderName']; // Nome do cartão
127
+ $creditcardTransactionData->CreditCard->SecurityCode = $paymentData['SecurityCode']; // Código de segurança
128
+ $creditcardTransactionData->CreditCard->ExpMonth = $paymentData['ExpMonth']; // Mês Exp
129
+ $creditcardTransactionData->CreditCard->ExpYear = $paymentData['ExpYear']; // Ano Exp
130
+ $creditcardTransactionData->CreditCard->CreditCardBrand = $paymentData['CreditCardBrandEnum']; // Bandeira do cartão : Visa ,MasterCard ,Hipercard ,Amex */
131
+ $creditcardTransactionData->CreditCardOperation = $creditCardOperationEnum;
132
+ /** Tipo de operação: AuthOnly | AuthAndCapture | AuthAndCaptureWithDelay */
133
+ $creditcardTransactionData->AmountInCents = intval(strval(($paymentData['AmountInCents']))); // Valor da transação
134
+ $creditcardTransactionData->InstallmentCount = $paymentData['InstallmentCount']; // Nº de parcelas
135
+ $creditcardTransactionData->Options->CurrencyIso = "BRL"; //Moeda do pedido
136
+ }
137
+
138
+ $installmentCount = $paymentData['InstallmentCount'];
139
+
140
+ // BillingAddress
141
+ if ($standard->getAntiFraud() == 1) {
142
+ $addy = $this->buyerBillingData($order, $data, $_request, $standard);
143
+
144
+ $creditcardTransactionData->CreditCard->BillingAddress = $addy['AddressCollection'][0];
145
+ }
146
+
147
+ if ($standard->getEnvironment() != 'production') {
148
+ $creditcardTransactionData->Options->PaymentMethodCode = $standard->getPaymentMethodCode(); // Código do meio de pagamento
149
+ }
150
+
151
+ // Verificamos se tem o produto de teste da Cielo no carrinho
152
+ foreach ($order->getItemsCollection() as $item) {
153
+ if ($item->getSku() == $standard->getCieloSku() && $standard->getEnvironment() == 'production') {
154
+ $creditcardTransactionData->Options->PaymentMethodCode = 5; // Código do meio de pagamento Cielo
155
+ }
156
+
157
+ // Adicionamos o produto a lógica de recorrência.
158
+ $qty = $item->getQtyOrdered();
159
+
160
+ for ($qt = 1; $qt <= $qty; $qt++) {
161
+ $recurrencyModel->setItem($item);
162
+ }
163
+ }
164
+
165
+ $creditcardTransactionCollection[] = $creditcardTransactionData;
166
+ }
167
+
168
+ $_request["CreditCardTransactionCollection"] = $this->ConvertCreditcardTransactionCollectionFromRequest($creditcardTransactionCollection, $standard);
169
+
170
+ $_request = $recurrencyModel->generateRecurrences($_request, $installmentCount);
171
+
172
+ // Buyer data
173
+ $_request["Buyer"] = array();
174
+ $_request["Buyer"] = $this->buyerBillingData($order, $data, $_request, $standard);
175
+
176
+ // Cart data
177
+ $_request["ShoppingCartCollection"] = array();
178
+ $_request["ShoppingCartCollection"] = $this->cartData($order, $data, $_request, $standard);
179
+
180
+ //verify anti-fraud config and mount the node 'RequestData'
181
+ $nodeRequestData = $this->getRequestDataNode();
182
+
183
+ if (is_array($nodeRequestData)) {
184
+ $_request['RequestData'] = $nodeRequestData;
185
+ }
186
+
187
+ if ($standard->getDebug() == 1) {
188
+ $_logRequest = $_request;
189
+
190
+ foreach ($_request["CreditCardTransactionCollection"] as $key => $paymentData) {
191
+ if (isset($_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["CreditCardNumber"])) {
192
+ $_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["CreditCardNumber"] = 'xxxxxxxxxxxxxxxx';
193
+ }
194
+
195
+ if (isset($_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["SecurityCode"])) {
196
+ $_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["SecurityCode"] = 'xxx';
197
+ }
198
+
199
+ if (isset($_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["ExpMonth"])) {
200
+ $_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["ExpMonth"] = 'xx';
201
+ }
202
+
203
+ if (isset($_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["ExpYear"])) {
204
+ $_logRequest["CreditCardTransactionCollection"][$key]["CreditCard"]["ExpYear"] = 'xx';
205
+ }
206
+ }
207
+ }
208
+
209
+ // Data
210
+ $_response = $this->sendRequest($_request, $url, $_logRequest);
211
+ $xml = $_response['xmlData'];
212
+ $dataR = $_response['arrayData'];
213
+
214
+ // if some error ocurred ex.: http 500 internal server error
215
+ if (isset($dataR['ErrorReport']) && !empty($dataR['ErrorReport'])) {
216
+ $_errorItemCollection = $dataR['ErrorReport']['ErrorItemCollection'];
217
+
218
+ // Return errors
219
+ return array(
220
+ 'error' => 1,
221
+ 'ErrorCode' => '',
222
+ 'ErrorDescription' => '',
223
+ 'OrderKey' => isset($dataR['OrderResult']['OrderKey']) ? $dataR['OrderResult']['OrderKey'] : null,
224
+ 'OrderReference' => isset($dataR['OrderResult']['OrderReference']) ? $dataR['OrderResult']['OrderReference'] : null,
225
+ 'ErrorItemCollection' => $_errorItemCollection,
226
+ 'result' => $dataR,
227
+ );
228
+ }
229
+
230
+ // Transactions colllection
231
+ $creditCardTransactionResultCollection = $dataR['CreditCardTransactionResultCollection'];
232
+
233
+ // Only 1 transaction
234
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
235
+ //and transaction success is true
236
+ if ((string)$creditCardTransactionResultCollection['CreditCardTransactionResult']['Success'] == 'true') {
237
+ $trans = $creditCardTransactionResultCollection['CreditCardTransactionResult'];
238
+
239
+ // We save Card On File
240
+ if ($data['customer_id'] != 0 && isset($data['payment'][1]['token']) && $data['payment'][1]['token'] == 'new') {
241
+ $cardonfile = Mage::getModel('mundipagg/cardonfile');
242
+
243
+ $cardonfile->setEntityId($data['customer_id']);
244
+ $cardonfile->setAddressId($data['address_id']);
245
+ $cardonfile->setCcType($data['payment'][1]['CreditCardBrandEnum']);
246
+ $cardonfile->setCreditCardMask($trans['CreditCard']['MaskedCreditCardNumber']);
247
+ $cardonfile->setExpiresAt(date("Y-m-t", mktime(0, 0, 0, $data['payment'][1]['ExpMonth'], 1, $data['payment'][1]['ExpYear'])));
248
+ $cardonfile->setToken($trans['CreditCard']['InstantBuyKey']);
249
+ $cardonfile->setActive(1);
250
+
251
+ $cardonfile->save();
252
+ }
253
+
254
+ $result = array(
255
+ 'success' => true,
256
+ 'message' => 1,
257
+ 'returnMessage' => urldecode($creditCardTransactionResultCollection['CreditCardTransactionResult']['AcquirerMessage']),
258
+ 'OrderKey' => $dataR['OrderResult']['OrderKey'],
259
+ 'OrderReference' => $dataR['OrderResult']['OrderReference'],
260
+ 'isRecurrency' => $recurrencyModel->recurrencyExists(),
261
+ 'result' => $xml
262
+ );
263
+
264
+ if (isset($dataR['OrderResult']['CreateDate'])) {
265
+ $result['CreateDate'] = $dataR['OrderResult']['CreateDate'];
266
+ }
267
+
268
+ return $result;
269
+
270
+ } else {
271
+ // CreditCardTransactionResult success == false, not authorized
272
+ $result = array(
273
+ 'error' => 1,
274
+ 'ErrorCode' => $creditCardTransactionResultCollection['CreditCardTransactionResult']['AcquirerReturnCode'],
275
+ 'ErrorDescription' => urldecode($creditCardTransactionResultCollection['CreditCardTransactionResult']['AcquirerMessage']),
276
+ 'OrderKey' => $dataR['OrderResult']['OrderKey'],
277
+ 'OrderReference' => $dataR['OrderResult']['OrderReference'],
278
+ 'result' => $xml
279
+ );
280
+
281
+ if (isset($dataR['OrderResult']['CreateDate'])) {
282
+ $result['CreateDate'] = $dataR['OrderResult']['CreateDate'];
283
+ }
284
+
285
+ /**
286
+ * @TODO precisa refatorar isto, pois deste jeito esta gravando offlineretry pra que qualquer pedido
287
+ * com mais de 1 cartao
288
+ */
289
+ // save offline retry statements if this feature is enabled
290
+ $orderResult = $dataR['OrderResult'];
291
+ $this->saveOfflineRetryStatements($orderResult['OrderReference'], new DateTime($orderResult['CreateDate']));
292
+
293
+ return $result;
294
+ }
295
+ } else { // More than 1 transaction
296
+ $allTransactions = $creditCardTransactionResultCollection['CreditCardTransactionResult'];
297
+
298
+ // We remove other transactions made before
299
+ $actualTransactions = count($data['payment']);
300
+ $totalTransactions = count($creditCardTransactionResultCollection['CreditCardTransactionResult']);
301
+ $transactionsToDelete = $totalTransactions - $actualTransactions;
302
+
303
+ if ($totalTransactions > $actualTransactions) {
304
+ for ($i = 0; $i <= ($transactionsToDelete - 1); $i++) {
305
+ unset($allTransactions[$i]);
306
+ }
307
+
308
+ // Reorganize array indexes from 0
309
+ $allTransactions = array_values($allTransactions);
310
+ }
311
+
312
+ $needSaveOfflineRetry = true;
313
+
314
+ foreach ($allTransactions as $key => $trans) {
315
+
316
+ // We save Cards On File for current transaction(s)
317
+ if ($data['customer_id'] != 0 && isset($data['payment'][$key + 1]['token']) && $data['payment'][$key + 1]['token'] == 'new') {
318
+ $cardonfile = Mage::getModel('mundipagg/cardonfile');
319
+
320
+ $cardonfile->setEntityId($data['customer_id']);
321
+ $cardonfile->setAddressId($data['address_id']);
322
+ $cardonfile->setCcType($data['payment'][$key + 1]['CreditCardBrandEnum']);
323
+ $cardonfile->setCreditCardMask($trans['CreditCard']['MaskedCreditCardNumber']);
324
+ $cardonfile->setExpiresAt(date("Y-m-t", mktime(0, 0, 0, $data['payment'][$key + 1]['ExpMonth'], 1, $data['payment'][$key + 1]['ExpYear'])));
325
+ $cardonfile->setToken($trans['CreditCard']['InstantBuyKey']);
326
+ $cardonfile->setActive(1);
327
+
328
+ $cardonfile->save();
329
+ }
330
+
331
+ // //some transaction not authorized, save offline retry if necessary
332
+ // if (isset($trans['Success']) && $trans['Success'] == 'false' && $needSaveOfflineRetry) {
333
+ // $needSaveOfflineRetry = false;
334
+ // $orderResult = $dataR['OrderResult'];
335
+ //
336
+ // $this->saveOfflineRetryStatements($orderResult['OrderReference'], new DateTime($orderResult['CreateDate']));
337
+ // }
338
+
339
+ }
340
+
341
+ // Result
342
+ $result = array(
343
+ 'success' => true,
344
+ 'message' => 1,
345
+ 'OrderKey' => $dataR['OrderResult']['OrderKey'],
346
+ 'OrderReference' => $dataR['OrderResult']['OrderReference'],
347
+ 'isRecurrency' => $recurrencyModel->recurrencyExists(),
348
+ 'result' => $xml,
349
+ );
350
+
351
+ if (isset($dataR['OrderResult']['CreateDate'])) {
352
+ $result['CreateDate'] = $dataR['OrderResult']['CreateDate'];
353
+ }
354
+
355
+ return $result;
356
+ }
357
+ } catch (Exception $e) {
358
+ //Redirect to Cancel page
359
+
360
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
361
+
362
+ //Log error
363
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
364
+ $helperLog->error($e, true);
365
+
366
+ //Mail error
367
+ $this->mailError(print_r($e->getMessage(), 1));
368
+
369
+ // Return error
370
+ $approvalRequest['error'] = 'Error WS';
371
+ $approvalRequest['ErrorCode'] = 'ErrorCode WS';
372
+ $approvalRequest['ErrorDescription'] = 'ErrorDescription WS';
373
+ $approvalRequest['OrderKey'] = '';
374
+ $approvalRequest['OrderReference'] = '';
375
+
376
+ return $approvalRequest;
377
+ }
378
+ }
379
+
380
+ /**
381
+ * Convert CreditcardTransaction Collection From Request
382
+ */
383
+ public function ConvertCreditcardTransactionCollectionFromRequest($creditcardTransactionCollectionRequest, $standard) {
384
+ $newCreditcardTransCollection = array();
385
+ $counter = 0;
386
+
387
+ foreach ($creditcardTransactionCollectionRequest as $creditcardTransItem) {
388
+ $creditcardTrans = array();
389
+ $creditcardTrans["AmountInCents"] = $creditcardTransItem->AmountInCents;
390
+
391
+ if (isset($creditcardTransItem->CreditCard->CreditCardNumber)) {
392
+ $creditcardTrans['CreditCard']["CreditCardNumber"] = $creditcardTransItem->CreditCard->CreditCardNumber;
393
+ }
394
+
395
+ if (isset($creditcardTransItem->CreditCard->HolderName)) {
396
+ $creditcardTrans['CreditCard']["HolderName"] = $creditcardTransItem->CreditCard->HolderName;
397
+ }
398
+
399
+ if (isset($creditcardTransItem->CreditCard->SecurityCode)) {
400
+ $creditcardTrans['CreditCard']["SecurityCode"] = $creditcardTransItem->CreditCard->SecurityCode;
401
+ }
402
+
403
+ if (isset($creditcardTransItem->CreditCard->ExpMonth)) {
404
+ $creditcardTrans['CreditCard']["ExpMonth"] = $creditcardTransItem->CreditCard->ExpMonth;
405
+ }
406
+
407
+ if (isset($creditcardTransItem->CreditCard->ExpYear)) {
408
+ $creditcardTrans['CreditCard']["ExpYear"] = $creditcardTransItem->CreditCard->ExpYear;
409
+ }
410
+
411
+ if (isset($creditcardTransItem->CreditCard->InstantBuyKey)) {
412
+ $creditcardTrans['CreditCard']["InstantBuyKey"] = $creditcardTransItem->CreditCard->InstantBuyKey;
413
+ }
414
+
415
+ $creditcardTrans['CreditCard']["CreditCardBrand"] = $creditcardTransItem->CreditCard->CreditCardBrand;
416
+ $creditcardTrans["CreditCardOperation"] = $creditcardTransItem->CreditCardOperation;
417
+ $creditcardTrans["InstallmentCount"] = $creditcardTransItem->InstallmentCount;
418
+ $creditcardTrans['Options']["CurrencyIso"] = $creditcardTransItem->Options->CurrencyIso;
419
+
420
+ if ($standard->getEnvironment() != 'production') {
421
+ $creditcardTrans['Options']["PaymentMethodCode"] = $creditcardTransItem->Options->PaymentMethodCode;
422
+ }
423
+
424
+ if ($standard->getAntiFraud() == 1) {
425
+ $creditcardTrans['CreditCard']['BillingAddress'] = $creditcardTransItem->CreditCard->BillingAddress;
426
+
427
+ unset($creditcardTrans['CreditCard']['BillingAddress']['AddressType']);
428
+ }
429
+
430
+ $newCreditcardTransCollection[$counter] = $creditcardTrans;
431
+ $counter += 1;
432
+ }
433
+
434
+ return $newCreditcardTransCollection;
435
+ }
436
+
437
+ /**
438
+ * Boleto transaction
439
+ **/
440
+ public function boletoTransaction($order, $data, Uecommerce_Mundipagg_Model_Standard $standard) {
441
+ try {
442
+ // Get Webservice URL
443
+ $url = $standard->getURL();
444
+
445
+ // Set Data
446
+ $_request = array();
447
+ $_request["Order"] = array();
448
+ $_request["Order"]["OrderReference"] = $order->getIncrementId();
449
+
450
+ if ($standard->getEnvironment() != 'production') {
451
+ $_request["Order"]["OrderReference"] = md5(date('Y-m-d H:i:s')); // Identificação do pedido na loja
452
+ }
453
+
454
+ $_request["BoletoTransactionCollection"] = array();
455
+
456
+ $boletoTransactionCollection = new stdclass();
457
+
458
+ for ($i = 1; $i <= $data['boleto_parcelamento']; $i++) {
459
+ $boletoTransactionData = new stdclass();
460
+
461
+ if (!empty($data['boleto_dates'])) {
462
+ $datePagamentoBoleto = $data['boleto_dates'][$i - 1];
463
+ $now = strtotime(date('Y-m-d'));
464
+ $yourDate = strtotime($datePagamentoBoleto);
465
+ $datediff = $yourDate - $now;
466
+ $daysToAddInBoletoExpirationDate = floor($datediff / (60 * 60 * 24));
467
+ } else {
468
+ $daysToAddInBoletoExpirationDate = $standard->getDiasValidadeBoleto();
469
+ }
470
+
471
+ $baseGrandTotal = str_replace(',', '.', $order->getBaseGrandTotal());
472
+ $amountInCentsVar = intval(strval((($baseGrandTotal / $data['boleto_parcelamento']) * 100)));
473
+
474
+ $boletoTransactionData->AmountInCents = $amountInCentsVar;
475
+ $boletoTransactionData->Instructions = $standard->getInstrucoesCaixa();
476
+
477
+ if ($standard->getEnvironment() != 'production') {
478
+ $boletoTransactionData->BankNumber = $standard->getBankNumber();
479
+ }
480
+
481
+ $boletoTransactionData->DocumentNumber = '';
482
+
483
+ $boletoTransactionData->Options = new stdclass();
484
+ $boletoTransactionData->Options->CurrencyIso = 'BRL';
485
+ $boletoTransactionData->Options->DaysToAddInBoletoExpirationDate = $daysToAddInBoletoExpirationDate;
486
+
487
+ $addy = $this->buyerBillingData($order, $data, $_request, $standard);
488
+
489
+ $boletoTransactionData->BillingAddress = $addy['AddressCollection'][0];
490
+
491
+ $boletoTransactionCollection = array($boletoTransactionData);
492
+ }
493
+
494
+ $_request["BoletoTransactionCollection"] = $this->ConvertBoletoTransactionCollectionFromRequest($boletoTransactionCollection);
495
+
496
+ // Buyer data
497
+ $_request["Buyer"] = array();
498
+ $_request["Buyer"] = $this->buyerBillingData($order, $data, $_request, $standard);
499
+
500
+ // Cart data
501
+ $_request["ShoppingCartCollection"] = array();
502
+ $_request["ShoppingCartCollection"] = $this->cartData($order, $data, $_request, $standard);
503
+
504
+ //verify anti-fraud config and mount the node 'RequestData'
505
+ $nodeRequestData = $this->getRequestDataNode();
506
+
507
+ if (is_array($nodeRequestData)) {
508
+ $_request['RequestData'] = $nodeRequestData;
509
+ }
510
+
511
+ // Data
512
+ $_response = $this->sendRequest($_request, $url);
513
+
514
+ $xml = $_response['xmlData'];
515
+ $data = $_response['arrayData'];
516
+
517
+ // Error
518
+ if (isset($data['ErrorReport']) && !empty($data['ErrorReport'])) {
519
+ $_errorItemCollection = $data['ErrorReport']['ErrorItemCollection'];
520
+
521
+ foreach ($_errorItemCollection as $errorItem) {
522
+ $errorCode = $errorItem['ErrorCode'];
523
+ $ErrorDescription = $errorItem['Description'];
524
+ }
525
+
526
+ return array(
527
+ 'error' => 1,
528
+ 'ErrorCode' => $errorCode,
529
+ 'ErrorDescription' => Mage::helper('mundipagg')->__($ErrorDescription),
530
+ 'result' => $data
531
+ );
532
+ }
533
+
534
+ // False
535
+ if (isset($data['Success']) && (string)$data['Success'] == 'false') {
536
+ return array(
537
+ 'error' => 1,
538
+ 'ErrorCode' => 'WithError',
539
+ 'ErrorDescription' => 'WithError',
540
+ 'result' => $data
541
+ );
542
+ } else {
543
+ // Success
544
+ $result = array(
545
+ 'success' => true,
546
+ 'message' => 0,
547
+ 'OrderKey' => $data['OrderResult']['OrderKey'],
548
+ 'OrderReference' => $data['OrderResult']['OrderReference'],
549
+ 'result' => $data
550
+ );
551
+
552
+ if (isset($data['OrderResult']['CreateDate'])) {
553
+ $result['CreateDate'] = $data['OrderResult']['CreateDate'];
554
+ }
555
+
556
+ return $result;
557
+ }
558
+ } catch (Exception $e) {
559
+ //Redirect to Cancel page
560
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
561
+
562
+ //Log error
563
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
564
+ $helperLog->error($e, true);
565
+
566
+ //Mail error
567
+ $this->mailError(print_r($e->getMessage(), 1));
568
+
569
+ // Return error
570
+ $approvalRequest['error'] = 'Error WS';
571
+ $approvalRequest['ErrorCode'] = 'ErrorCode WS';
572
+ $approvalRequest['ErrorDescription'] = 'ErrorDescription WS';
573
+ $approvalRequest['OrderKey'] = '';
574
+ $approvalRequest['OrderReference'] = '';
575
+
576
+ return $approvalRequest;
577
+ }
578
+ }
579
+
580
+ /**
581
+ * Convert BoletoTransaction Collection From Request
582
+ */
583
+ public function ConvertBoletoTransactionCollectionFromRequest($boletoTransactionCollectionRequest) {
584
+ $newBoletoTransCollection = array();
585
+ $counter = 0;
586
+
587
+ foreach ($boletoTransactionCollectionRequest as $boletoTransItem) {
588
+ $boletoTrans = array();
589
+
590
+ $boletoTrans["AmountInCents"] = $boletoTransItem->AmountInCents;
591
+ $boletoTrans["BankNumber"] = isset($boletoTransItem->BankNumber) ? $boletoTransItem->BankNumber : '';
592
+ $boletoTrans["Instructions"] = $boletoTransItem->Instructions;
593
+ $boletoTrans["DocumentNumber"] = $boletoTransItem->DocumentNumber;
594
+ $boletoTrans["Options"]["CurrencyIso"] = $boletoTransItem->Options->CurrencyIso;
595
+ $boletoTrans["Options"]["DaysToAddInBoletoExpirationDate"] = $boletoTransItem->Options->DaysToAddInBoletoExpirationDate;
596
+ $boletoTrans['BillingAddress'] = $boletoTransItem->BillingAddress;
597
+
598
+ $newBoletoTransCollection[$counter] = $boletoTrans;
599
+ $counter += 1;
600
+ }
601
+
602
+ return $newBoletoTransCollection;
603
+ }
604
+
605
+ /**
606
+ * Debit transaction
607
+ **/
608
+ public function debitTransaction($order, $data, Uecommerce_Mundipagg_Model_Standard $standard) {
609
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
610
+
611
+ try {
612
+ // Get Webservice URL
613
+ $url = $standard->getURL();
614
+
615
+ $baseGrandTotal = str_replace(',', '.', $order->getBaseGrandTotal());
616
+ $amountInCentsVar = intval(strval(($baseGrandTotal * 100)));
617
+
618
+ // Set Data
619
+ $_request = array();
620
+
621
+ $_request["RequestKey"] = '00000000-0000-0000-0000-000000000000';
622
+ $_request["AmountInCents"] = $amountInCentsVar;
623
+ $_request['Bank'] = $data['Bank'];
624
+ $_request['MerchantKey'] = $standard->getMerchantKey();
625
+
626
+ // Buyer data
627
+ $_request["Buyer"] = array();
628
+ $_request["Buyer"] = $this->buyerDebitBillingData($order, $data, $_request, $standard);
629
+
630
+ // Order data
631
+ $_request['InstallmentCount'] = '0';
632
+ $_request["OrderKey"] = '00000000-0000-0000-0000-000000000000';
633
+ $_request["OrderRequest"]['AmountInCents'] = $amountInCentsVar;
634
+ $_request["OrderRequest"]['OrderReference'] = $order->getIncrementId();
635
+
636
+ if ($standard->getEnvironment() != 'production') {
637
+ $_request["OrderRequest"]["OrderReference"] = md5(date('Y-m-d H:i:s')); // Identificação do pedido na loja
638
+ }
639
+
640
+ if ($standard->getEnvironment() != 'production') {
641
+ $_request['PaymentMethod'] = 'CieloSimulator';
642
+ }
643
+
644
+ $_request['PaymentType'] = null;
645
+
646
+ // Cart data
647
+ $shoppingCart = $this->cartData($order, $data, $_request, $standard);
648
+ if (!is_array($shoppingCart)) {
649
+ $shoppingCart = array();
650
+ }
651
+ $_request["ShoppingCart"] = $shoppingCart[0];
652
+ $deliveryAddress = $_request['ShoppingCart']['DeliveryAddress'];
653
+ unset($_request['ShoppingCart']['DeliveryAddress']);
654
+ $_request['DeliveryAddress'] = $deliveryAddress;
655
+ $_request['ShoppingCart']['ShoppingCartItemCollection'][0]['DiscountAmountInCents'] = 0;
656
+
657
+ // Data
658
+ $dataToPost = json_encode($_request);
659
+
660
+ if ($standard->getDebug() == 1) {
661
+ // Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion(), null, 'Uecommerce_Mundipagg.log');
662
+ // Mage::log(print_r($_request, 1), null, 'Uecommerce_Mundipagg.log');
663
+ $helperLog->debug(print_r($_request, true));
664
+ }
665
+
666
+ // Send payment data to MundiPagg
667
+ $ch = curl_init();
668
+
669
+ if (Mage::getStoreConfig('mundipagg_tests_cpf_cnpj') != '') {
670
+ // If tests runinig
671
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
672
+ }
673
+
674
+ // Header
675
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'MerchantKey: ' . $standard->getMerchantKey() . ''));
676
+
677
+ // Set the url, number of POST vars, POST data
678
+ curl_setopt($ch, CURLOPT_URL, $url);
679
+
680
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToPost);
681
+
682
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
683
+
684
+ // Execute post
685
+ $_response = curl_exec($ch);
686
+
687
+ if (curl_errno($ch)) {
688
+ $helperLog->info(curl_error($ch));
689
+ // Mage::log(curl_error($ch), null, 'Uecommerce_Mundipagg.log');
690
+ }
691
+
692
+ // Close connection
693
+ curl_close($ch);
694
+
695
+ if ($standard->getDebug() == 1) {
696
+ // Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion(), null, 'Uecommerce_Mundipagg.log');
697
+ // Mage::log(print_r($_response, 1), null, 'Uecommerce_Mundipagg.log');
698
+ $helperLog->debug(print_r($_response, true));
699
+ }
700
+
701
+ // Is there an error?
702
+ $xml = simplexml_load_string($_response);
703
+ $json = json_encode($xml);
704
+ $data = array();
705
+ $data = json_decode($json, true);
706
+
707
+ if ($standard->getDebug() == 1) {
708
+ // Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion(), null, 'Uecommerce_Mundipagg.log');
709
+ // Mage::log(print_r($data, 1), null, 'Uecommerce_Mundipagg.log');
710
+ $helperLog->debug(print_r($data, true));
711
+ }
712
+
713
+ // Error
714
+ if (isset($data['ErrorReport']) && !empty($data['ErrorReport'])) {
715
+ $_errorItemCollection = $data['ErrorReport']['ErrorItemCollection'];
716
+
717
+ foreach ($_errorItemCollection as $errorItem) {
718
+ $errorCode = $errorItem['ErrorCode'];
719
+ $ErrorDescription = $errorItem['Description'];
720
+ }
721
+
722
+ return array(
723
+ 'error' => 1,
724
+ 'ErrorCode' => $errorCode,
725
+ 'ErrorDescription' => Mage::helper('mundipagg')->__($ErrorDescription),
726
+ 'result' => $data
727
+ );
728
+ }
729
+
730
+ // False
731
+ if (isset($data['Success']) && (string)$data['Success'] == 'false') {
732
+ return array(
733
+ 'error' => 1,
734
+ 'ErrorCode' => 'WithError',
735
+ 'ErrorDescription' => 'WithError',
736
+ 'result' => $data
737
+ );
738
+ } else {
739
+ // Success
740
+ $result = array(
741
+ 'success' => true,
742
+ 'message' => 4,
743
+ 'OrderKey' => $data['OrderKey'],
744
+ 'TransactionKey' => $data['TransactionKey'],
745
+ 'TransactionKeyToBank' => $data['TransactionKeyToBank'],
746
+ 'TransactionReference' => $data['TransactionReference'],
747
+ 'result' => $data
748
+ );
749
+
750
+ if (isset($data['CreateDate'])) {
751
+ $result['CreateDate'] = $data['CreateDate'];
752
+ }
753
+
754
+ return $result;
755
+ }
756
+ } catch (Exception $e) {
757
+ //Redirect to Cancel page
758
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
759
+
760
+ //Log error
761
+ $helperLog->error($e, true);
762
+
763
+ //Mail error
764
+ $this->mailError(print_r($e->getMessage(), 1));
765
+
766
+ // Return error
767
+ $approvalRequest['error'] = 'Error WS';
768
+ $approvalRequest['ErrorCode'] = 'ErrorCode WS';
769
+ $approvalRequest['ErrorDescription'] = 'ErrorDescription WS';
770
+ $approvalRequest['OrderKey'] = '';
771
+ $approvalRequest['OrderReference'] = '';
772
+
773
+ return $approvalRequest;
774
+ }
775
+ }
776
+
777
+ /**
778
+ * Set buyer data
779
+ */
780
+ public function buyerBillingData($order, $data, $_request, $standard) {
781
+ if ($order->getData()) {
782
+ $gender = null;
783
+
784
+ if ($order->getCustomerGender()) {
785
+ $gender = $order->getCustomerGender();
786
+ }
787
+
788
+ if ($order->getCustomerIsGuest() == 0) {
789
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
790
+
791
+ $gender = $customer->getGender();
792
+
793
+ $createdAt = explode(' ', $customer->getCreatedAt());
794
+ $updatedAt = explode(' ', $customer->getUpdatedAt());
795
+ $currentDateTime = Mage::getModel('core/date')->date('Y-m-d H:i:s');
796
+ if (!array_key_exists(1, $createdAt)) {
797
+ $createdAt = explode(' ', $currentDateTime);
798
+ }
799
+
800
+ if (!array_key_exists(1, $updatedAt)) {
801
+ $updatedAt = explode(' ', $currentDateTime);
802
+ }
803
+
804
+ $createDateInMerchant = substr($createdAt[0] . 'T' . $createdAt[1], 0, 19);
805
+ $lastBuyerUpdateInMerchant = substr($updatedAt[0] . 'T' . $updatedAt[1], 0, 19);
806
+ } else {
807
+ $createDateInMerchant = $lastBuyerUpdateInMerchant = date('Y-m-d') . 'T' . date('H:i:s');
808
+ }
809
+
810
+ switch ($gender) {
811
+ case '1':
812
+ $gender = 'M';
813
+ break;
814
+
815
+ case '2':
816
+ $gender = 'F';
817
+ break;
818
+ }
819
+ }
820
+
821
+ $billingAddress = $order->getBillingAddress();
822
+ $street = $billingAddress->getStreet();
823
+ $regionCode = $billingAddress->getRegionCode();
824
+
825
+ if ($billingAddress->getRegionCode() == '') {
826
+ $regionCode = 'RJ';
827
+ }
828
+
829
+ $telephone = Mage::helper('mundipagg')->applyTelephoneMask($billingAddress->getTelephone());
830
+
831
+ if ($billingAddress->getTelephone() == '') {
832
+ $telephone = '55(21)88888888';
833
+ }
834
+
835
+ // In case we doesn't have CPF or CNPJ informed we set default value for MundiPagg (required field)
836
+ $data['DocumentNumber'] = isset($data['TaxDocumentNumber']) ? $data['TaxDocumentNumber'] : $order->getCustomerTaxvat();
837
+
838
+ $invalid = 0;
839
+
840
+ if (Mage::helper('mundipagg')->validateCPF($data['DocumentNumber'])) {
841
+ $data['PersonType'] = 'Person';
842
+ $data['DocumentType'] = 'CPF';
843
+ $data['DocumentNumber'] = $data['DocumentNumber'];
844
+ } else {
845
+ $invalid++;
846
+ }
847
+
848
+ // We verify if a CNPJ is informed
849
+ if (Mage::helper('mundipagg')->validateCNPJ($data['DocumentNumber'])) {
850
+ $data['PersonType'] = 'Company';
851
+ $data['DocumentType'] = 'CNPJ';
852
+ $data['DocumentNumber'] = $data['DocumentNumber'];
853
+ } else {
854
+ $invalid++;
855
+ }
856
+
857
+ if ($invalid == 2) {
858
+ $data['DocumentNumber'] = '00000000000';
859
+ $data['DocumentType'] = 'CPF';
860
+ $data['PersonType'] = 'Person';
861
+ }
862
+
863
+ // Request
864
+ if ($gender == 'M' || $gender == 'F') {
865
+ $_request["Buyer"]["Gender"] = $gender;
866
+ }
867
+
868
+ $_request["Buyer"]["DocumentNumber"] = preg_replace('[\D]', '', $data['DocumentNumber']);
869
+ $_request["Buyer"]["DocumentType"] = $data['DocumentType'];
870
+ $_request["Buyer"]["Email"] = $order->getCustomerEmail();
871
+ $_request["Buyer"]["EmailType"] = 'Personal';
872
+ $_request["Buyer"]["Name"] = $order->getCustomerName();
873
+ $_request["Buyer"]["PersonType"] = $data['PersonType'];
874
+ $_request["Buyer"]["MobilePhone"] = $telephone;
875
+ $_request["Buyer"]['BuyerCategory'] = 'Normal';
876
+ $_request["Buyer"]['FacebookId'] = '';
877
+ $_request["Buyer"]['TwitterId'] = '';
878
+ $_request["Buyer"]['BuyerReference'] = '';
879
+ $_request["Buyer"]['CreateDateInMerchant'] = $createDateInMerchant;
880
+ $_request["Buyer"]['LastBuyerUpdateInMerchant'] = $lastBuyerUpdateInMerchant;
881
+
882
+ // Address
883
+ $address = array();
884
+ $address['AddressType'] = 'Residential';
885
+ $address['City'] = $billingAddress->getCity();
886
+ $address['District'] = isset($street[3]) ? $street[3] : 'xxx';
887
+ $address['Complement'] = isset($street[2]) ? $street[2] : '';
888
+ $address['Number'] = isset($street[1]) ? $street[1] : '0';
889
+ $address['State'] = $regionCode;
890
+ $address['Street'] = isset($street[0]) ? $street[0] : 'xxx';
891
+ $address['ZipCode'] = preg_replace('[\D]', '', $billingAddress->getPostcode());
892
+ $address['Country'] = 'Brazil';
893
+
894
+ $_request["Buyer"]["AddressCollection"] = array();
895
+ $_request["Buyer"]["AddressCollection"] = array($address);
896
+
897
+ return $_request["Buyer"];
898
+ }
899
+
900
+ /**
901
+ * Set buyer data
902
+ */
903
+ public function buyerDebitBillingData($order, $data, $_request, $standard) {
904
+ if ($order->getData()) {
905
+ if ($order->getCustomerGender()) {
906
+ $gender = $order->getCustomerGender();
907
+ } else {
908
+ $customerId = $order->getCustomerId();
909
+
910
+ $customer = Mage::getModel('customer/customer')->load($customerId);
911
+
912
+ $gender = $customer->getGender();
913
+ }
914
+
915
+ switch ($gender) {
916
+ case '1':
917
+ $gender = 'M';
918
+ break;
919
+
920
+ case '2':
921
+ $gender = 'F';
922
+ break;
923
+ }
924
+ }
925
+
926
+ $billingAddress = $order->getBillingAddress();
927
+ $street = $billingAddress->getStreet();
928
+ $regionCode = $billingAddress->getRegionCode();
929
+
930
+ if ($billingAddress->getRegionCode() == '') {
931
+ $regionCode = 'RJ';
932
+ }
933
+
934
+ $telephone = Mage::helper('mundipagg')->applyTelephoneMask($billingAddress->getTelephone());
935
+
936
+ if ($billingAddress->getTelephone() == '') {
937
+ $telephone = '55(21)88888888';
938
+ }
939
+
940
+ $testCpfCnpj = Mage::getStoreConfig('mundipagg_tests_cpf_cnpj');
941
+ if ($testCpfCnpj != '') {
942
+ $data['TaxDocumentNumber'] = $testCpfCnpj;
943
+ }
944
+
945
+ // In case we doesn't have CPF or CNPJ informed we set default value for MundiPagg (required field)
946
+ $data['DocumentNumber'] = isset($data['TaxDocumentNumber']) ? $data['TaxDocumentNumber'] : $order->getCustomerTaxvat();
947
+
948
+ $invalid = 0;
949
+
950
+ if (Mage::helper('mundipagg')->validateCPF($data['DocumentNumber'])) {
951
+ $data['PersonType'] = 'Person';
952
+ $data['DocumentType'] = 'CPF';
953
+ $data['DocumentNumber'] = $data['DocumentNumber'];
954
+ } else {
955
+ $invalid++;
956
+ }
957
+
958
+ // We verify if a CNPJ is informed
959
+ if (Mage::helper('mundipagg')->validateCNPJ($data['DocumentNumber'])) {
960
+ $data['PersonType'] = 'Company';
961
+ $data['DocumentType'] = 'CNPJ';
962
+ $data['DocumentNumber'] = $data['DocumentNumber'];
963
+ } else {
964
+ $invalid++;
965
+ }
966
+
967
+ if ($invalid == 2) {
968
+ $data['DocumentNumber'] = '00000000000';
969
+ $data['DocumentType'] = 'CPF';
970
+ $data['PersonType'] = 'Person';
971
+ }
972
+
973
+ // Request
974
+ if ($gender == 'M' || $gender == 'F') {
975
+ $_request["Buyer"]["Gender"] = $gender;
976
+ $_request["Buyer"]["GenderEnum"] = $gender;
977
+ }
978
+
979
+ $_request["Buyer"]["TaxDocumentNumber"] = preg_replace('[\D]', '', $data['DocumentNumber']);
980
+ $_request["Buyer"]["TaxDocumentTypeEnum"] = $data['DocumentType'];
981
+ $_request["Buyer"]["Email"] = $order->getCustomerEmail();
982
+ $_request["Buyer"]["EmailType"] = 'Personal';
983
+ $_request["Buyer"]["Name"] = $order->getCustomerName();
984
+ $_request["Buyer"]["PersonType"] = $data['PersonType'];
985
+ $_request['Buyer']['PhoneRequestCollection'] = Mage::helper('mundipagg')->getPhoneRequestCollection($order);
986
+ //$_request["Buyer"]["MobilePhone"] = $telephone;
987
+ $_request["Buyer"]['BuyerCategory'] = 'Normal';
988
+ $_request["Buyer"]['FacebookId'] = '';
989
+ $_request["Buyer"]['TwitterId'] = '';
990
+ $_request["Buyer"]['BuyerReference'] = '';
991
+
992
+ // Address
993
+ $address = array();
994
+ $address['AddressTypeEnum'] = 'Residential';
995
+ $address['City'] = $billingAddress->getCity();
996
+ $address['District'] = isset($street[3]) ? $street[3] : 'xxx';
997
+ $address['Complement'] = isset($street[2]) ? $street[2] : '';
998
+ $address['Number'] = isset($street[1]) ? $street[1] : '0';
999
+ $address['State'] = $regionCode;
1000
+ $address['Street'] = isset($street[0]) ? $street[0] : 'xxx';
1001
+ $address['ZipCode'] = preg_replace('[\D]', '', $billingAddress->getPostcode());
1002
+
1003
+ $_request["Buyer"]["BuyerAddressCollection"] = array();
1004
+ $_request["Buyer"]["BuyerAddressCollection"] = array($address);
1005
+
1006
+ return $_request["Buyer"];
1007
+ }
1008
+
1009
+ /**
1010
+ * Set cart data
1011
+ */
1012
+ public function cartData($order, $data, $_request, $standard) {
1013
+ $baseGrandTotal = round($order->getBaseGrandTotal(), 2);
1014
+ $baseDiscountAmount = round($order->getBaseDiscountAmount(), 2);
1015
+
1016
+ if (abs($order->getBaseDiscountAmount()) > 0) {
1017
+ $totalWithoutDiscount = $baseGrandTotal + abs($baseDiscountAmount);
1018
+
1019
+ $discount = round(($baseGrandTotal / $totalWithoutDiscount), 4);
1020
+ } else {
1021
+ $discount = 1;
1022
+ }
1023
+
1024
+ $shippingDiscountAmount = round($order->getShippingDiscountAmount(), 2);
1025
+
1026
+ if (abs($shippingDiscountAmount) > 0) {
1027
+ $totalShippingWithoutDiscount = round($order->getBaseShippingInclTax(), 2);
1028
+ $totalShippingWithDiscount = $totalShippingWithoutDiscount - abs($shippingDiscountAmount);
1029
+
1030
+ $shippingDiscount = round(($totalShippingWithDiscount / $totalShippingWithoutDiscount), 4);
1031
+ } else {
1032
+ $shippingDiscount = 1;
1033
+ }
1034
+
1035
+ $items = array();
1036
+
1037
+ foreach ($order->getItemsCollection() as $item) {
1038
+ if ($item->getParentItemId() == '') {
1039
+ $items[$item->getItemId()]['sku'] = $item->getProductId();
1040
+ $items[$item->getItemId()]['name'] = $item->getName();
1041
+
1042
+ $items[$item->getItemId()]['description'] = Mage::getModel('catalog/product')->load($item->getProductId())->getShortDescription();
1043
+
1044
+ $items[$item->getItemId()]['qty'] = round($item->getQtyOrdered(), 0);
1045
+ $items[$item->getItemId()]['price'] = $item->getBasePrice();
1046
+ }
1047
+ }
1048
+
1049
+ $i = 0;
1050
+
1051
+ $shipping = intval(strval(($order->getBaseShippingInclTax() * $shippingDiscount * 100)));
1052
+
1053
+ $deadlineConfig = Mage::getStoreConfig('payment/mundipagg_standard/delivery_deadline');
1054
+ if ($deadlineConfig != '') {
1055
+ $date = new Zend_Date($order->getCreatedAtStoreDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT), Zend_Date::DATETIME);
1056
+ $date->addDay((int)$deadlineConfig);
1057
+ $deliveryDeadline = $date->toString('yyyy-MM-ddTHH:mm:ss');
1058
+
1059
+ $_request["ShoppingCartCollection"]['DeliveryDeadline'] = $deliveryDeadline;
1060
+ $_request["ShoppingCartCollection"]['EstimatedDeliveryDate'] = $deliveryDeadline;
1061
+ }
1062
+
1063
+ $_request["ShoppingCartCollection"]["FreightCostInCents"] = $shipping;
1064
+
1065
+ $_request['ShoppingCartCollection']['ShippingCompany'] = Mage::getStoreConfig('payment/mundipagg_standard/shipping_company');
1066
+
1067
+ foreach ($items as $itemId) {
1068
+ $unitCostInCents = intval(strval(($itemId['price'] * $discount * 100)));
1069
+
1070
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["Description"] = empty($itemId['description']) || ($itemId['description'] == '') ? $itemId['name'] : $itemId['description'];
1071
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["ItemReference"] = $itemId['sku'];
1072
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["Name"] = $itemId['name'];
1073
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["Quantity"] = $itemId['qty'];
1074
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["UnitCostInCents"] = $unitCostInCents;
1075
+ //}
1076
+
1077
+ $totalInCents = intval(strval(($itemId['qty'] * $itemId['price'] * $discount * 100)));
1078
+
1079
+ $_request["ShoppingCartCollection"]["ShoppingCartItemCollection"][$i]["TotalCostInCents"] = $totalInCents;
1080
+
1081
+ $i++;
1082
+ }
1083
+
1084
+ // Delivery address
1085
+ if ($order->getIsVirtual()) {
1086
+ $addy = $order->getBillingAddress();
1087
+ } else {
1088
+ $addy = $order->getShippingAddress();
1089
+ }
1090
+
1091
+ $street = $addy->getStreet();
1092
+ $regionCode = $addy->getRegionCode();
1093
+
1094
+ if ($addy->getRegionCode() == '') {
1095
+ $regionCode = 'RJ';
1096
+ }
1097
+
1098
+ $address = array();
1099
+ $address['City'] = $addy->getCity();
1100
+ $address['District'] = isset($street[3]) ? $street[3] : 'xxx';
1101
+ $address['Complement'] = isset($street[2]) ? $street[2] : '';
1102
+ $address['Number'] = isset($street[1]) ? $street[1] : '0';
1103
+ $address['State'] = $regionCode;
1104
+ $address['Street'] = isset($street[0]) ? $street[0] : 'xxx';
1105
+ $address['ZipCode'] = preg_replace('[\D]', '', $addy->getPostcode());
1106
+ $address['Country'] = 'Brazil';
1107
+ $address['AddressType'] = "Shipping";
1108
+
1109
+ $_request["ShoppingCartCollection"]["DeliveryAddress"] = array();
1110
+
1111
+ $_request["ShoppingCartCollection"]["DeliveryAddress"] = $address;
1112
+
1113
+ return array($_request["ShoppingCartCollection"]);
1114
+ }
1115
+
1116
+ /**
1117
+ * Manage Order Request: capture / void / refund
1118
+ **/
1119
+ public function manageOrderRequest($data, Uecommerce_Mundipagg_Model_Standard $standard) {
1120
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1121
+
1122
+ try {
1123
+ // Get Webservice URL
1124
+ $url = $standard->getURL() . '/' . $data['ManageOrderOperationEnum'];
1125
+
1126
+ unset($data['ManageOrderOperationEnum']);
1127
+
1128
+ // Get store key
1129
+ $key = $standard->getMerchantKey();
1130
+
1131
+ $dataToPost = json_encode($data);
1132
+
1133
+ if ($standard->getDebug() == 1) {
1134
+ $helperUtil = new Uecommerce_Mundipagg_Helper_Util();
1135
+
1136
+ $helperLog->debug("Request:\n{$helperUtil->jsonEncodePretty($data)}\n");
1137
+ }
1138
+
1139
+ // Send payment data to MundiPagg
1140
+ $ch = curl_init();
1141
+
1142
+ // Header
1143
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'MerchantKey: ' . $key . ''));
1144
+
1145
+ // Set the url, number of POST vars, POST data
1146
+ curl_setopt($ch, CURLOPT_URL, $url);
1147
+
1148
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToPost);
1149
+
1150
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1151
+
1152
+ // Execute post
1153
+ $_response = curl_exec($ch);
1154
+
1155
+ // Close connection
1156
+ curl_close($ch);
1157
+
1158
+ if ($standard->getDebug() == 1) {
1159
+ $xml = simplexml_load_string($_response);
1160
+ $domXml = new DOMDocument('1.0');
1161
+
1162
+ $domXml->formatOutput = true;
1163
+ $domXml->loadXML($xml->asXML());
1164
+
1165
+ $xml = $domXml->saveXML();
1166
+
1167
+ $helperLog->debug("Response:\n{$xml}\n");
1168
+ }
1169
+
1170
+ // Return
1171
+ return array('result' => simplexml_load_string($_response));
1172
+
1173
+ } catch (Exception $e) {
1174
+ //Redirect to Cancel page
1175
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess(false);
1176
+
1177
+ //Log error
1178
+ $helperLog->error($e, true);
1179
+
1180
+ //Mail error
1181
+ $this->mailError(print_r($e->getMessage(), true));
1182
+
1183
+ // Throw Exception
1184
+ Mage::throwException(Mage::helper('mundipagg')->__('Payment Error'));
1185
+ }
1186
+ }
1187
+
1188
+ /**
1189
+ * Process order
1190
+ * @param $order
1191
+ * @param $data
1192
+ */
1193
+ public function processOrder($postData) {
1194
+ $standard = Mage::getModel('mundipagg/standard');
1195
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1196
+
1197
+ try {
1198
+ if (isset($postData['xmlStatusNotification'])) {
1199
+ $xmlStatusNotificationString = htmlspecialchars_decode($postData['xmlStatusNotification']);
1200
+ $xml = simplexml_load_string($xmlStatusNotificationString);
1201
+ $json = json_encode($xml);
1202
+ $data = json_decode($json, true);
1203
+
1204
+ if ($standard->getConfigData('debug') == 1) {
1205
+ if (isset($postData['xmlStatusNotification'])) {
1206
+ $orderReference = isset($xml->OrderReference) ? $xml->OrderReference : null;
1207
+
1208
+ if (is_null($orderReference)) {
1209
+ $logMessage = "Notification post:\n{$xmlStatusNotificationString}\n";
1210
+
1211
+ } else {
1212
+ $logMessage = "Notification post for order #{$orderReference}:\n{$xmlStatusNotificationString}";
1213
+ }
1214
+
1215
+ $helperLog->debug($logMessage);
1216
+ }
1217
+ }
1218
+
1219
+ $orderReference = $data['OrderReference'];
1220
+
1221
+ if (!empty($data['BoletoTransaction'])) {
1222
+ $status = $data['BoletoTransaction']['BoletoTransactionStatus'];
1223
+ $transactionKey = $data['BoletoTransaction']['TransactionKey'];
1224
+ $capturedAmountInCents = $data['BoletoTransaction']['AmountPaidInCents'];
1225
+ }
1226
+
1227
+ if (!empty($data['CreditCardTransaction'])) {
1228
+ $status = $data['CreditCardTransaction']['CreditCardTransactionStatus'];
1229
+ $transactionKey = $data['CreditCardTransaction']['TransactionKey'];
1230
+ $capturedAmountInCents = $data['CreditCardTransaction']['CapturedAmountInCents'];
1231
+ }
1232
+
1233
+ if (!empty($data['OnlineDebitTransaction'])) {
1234
+ $status = $data['OnlineDebitTransaction']['OnlineDebitTransactionStatus'];
1235
+ $transactionKey = $data['OnlineDebitTransaction']['TransactionKey'];
1236
+ $capturedAmountInCents = $data['OnlineDebitTransaction']['AmountPaidInCents'];
1237
+ }
1238
+
1239
+ $order = Mage::getModel('sales/order');
1240
+ $order->loadByIncrementId($orderReference);
1241
+
1242
+ if (!$order->getId()) {
1243
+ return 'KO';
1244
+ }
1245
+
1246
+ // We check if transactionKey exists in database
1247
+ $t = 0;
1248
+
1249
+ $transactions = Mage::getModel('sales/order_payment_transaction')
1250
+ ->getCollection()
1251
+ ->addAttributeToFilter('order_id', array('eq' => $order->getEntityId()));
1252
+
1253
+ foreach ($transactions as $key => $transaction) {
1254
+ $orderTransactionKey = $transaction->getAdditionalInformation('TransactionKey');
1255
+
1256
+ // transactionKey found
1257
+ if ($orderTransactionKey == $transactionKey) {
1258
+ $t++;
1259
+ continue;
1260
+ }
1261
+ }
1262
+
1263
+ // transactionKey has been found so we can proceed
1264
+ if ($t > 0) {
1265
+ /**
1266
+ * @var $recurrence Uecommerce_Mundiapgg_Model_Recurrency
1267
+ */
1268
+ $recurrence = Mage::getModel('mundipagg/recurrency');
1269
+ $recurrence->checkRecurrencesByOrder($order);
1270
+
1271
+ switch ($status) {
1272
+ case 'Captured':
1273
+ case 'Paid':
1274
+ case 'OverPaid':
1275
+ case 'Overpaid':
1276
+
1277
+ if ($order->canUnhold()) {
1278
+ $order->unhold();
1279
+ }
1280
+
1281
+ if (!$order->canInvoice()) {
1282
+ return 'OK';
1283
+ }
1284
+
1285
+ // Partial invoice
1286
+ $epsilon = 0.00001;
1287
+
1288
+ if ($order->canInvoice() && abs($order->getGrandTotal() - $capturedAmountInCents * 0.01) > $epsilon) {
1289
+ $baseTotalPaid = $order->getTotalPaid();
1290
+
1291
+ // If there is already a positive baseTotalPaid value it's not the first transaction
1292
+ if ($baseTotalPaid > 0) {
1293
+ $baseTotalPaid += $capturedAmountInCents * 0.01;
1294
+
1295
+ $order->setTotalPaid(0);
1296
+ } else {
1297
+ $baseTotalPaid = $capturedAmountInCents * 0.01;
1298
+
1299
+ $order->setTotalPaid($baseTotalPaid);
1300
+ }
1301
+
1302
+ // Can invoice only if total captured amount is equal to GrandTotal
1303
+ if (abs($order->getGrandTotal() - $baseTotalPaid) < $epsilon) {
1304
+ $result = $this->createInvoice($order, $data, $baseTotalPaid, $status);
1305
+
1306
+ return $result;
1307
+ } else {
1308
+ $order->save();
1309
+
1310
+ return 'OK';
1311
+ }
1312
+ }
1313
+
1314
+ // Create invoice
1315
+ if ($order->canInvoice() && abs($capturedAmountInCents * 0.01 - $order->getGrandTotal()) < $epsilon) {
1316
+ $result = $this->createInvoice($order, $data, $order->getGrandTotal(), $status);
1317
+
1318
+ return $result;
1319
+ }
1320
+
1321
+ return 'KO';
1322
+
1323
+ break;
1324
+
1325
+ case 'UnderPaid':
1326
+ case 'Underpaid':
1327
+ if ($order->canUnhold()) {
1328
+ $order->unhold();
1329
+ }
1330
+
1331
+ $order->addStatusHistoryComment('Captured offline amount of R$' . $capturedAmountInCents * 0.01, false);
1332
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'underpaid');
1333
+ $order->setBaseTotalPaid($capturedAmountInCents * 0.01);
1334
+ $order->setTotalPaid($capturedAmountInCents * 0.01);
1335
+ $order->save();
1336
+
1337
+ return 'OK';
1338
+ break;
1339
+
1340
+ case 'NotAuthorized':
1341
+ return 'OK';
1342
+ break;
1343
+
1344
+ case 'Canceled':
1345
+ case 'Refunded':
1346
+ case 'Voided':
1347
+ if ($order->canUnhold()) {
1348
+ $order->unhold();
1349
+ }
1350
+
1351
+ $ok = 0;
1352
+ $invoices = array();
1353
+ $canceledInvoices = array();
1354
+
1355
+ foreach ($order->getInvoiceCollection() as $invoice) {
1356
+ // We check if invoice can be refunded
1357
+ if ($invoice->canRefund()) {
1358
+ $invoices[] = $invoice;
1359
+ }
1360
+
1361
+ // We check if invoice has already been canceled
1362
+ if ($invoice->isCanceled()) {
1363
+ $canceledInvoices[] = $invoice;
1364
+ }
1365
+ }
1366
+
1367
+ // Refund invoices and Credit Memo
1368
+ if (!empty($invoices)) {
1369
+ $service = Mage::getModel('sales/service_order', $order);
1370
+
1371
+ foreach ($invoices as $invoice) {
1372
+ $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_CANCELED);
1373
+ $invoice->save();
1374
+
1375
+ $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
1376
+ $creditmemo->setOfflineRequested(true);
1377
+ $creditmemo->register()->save();
1378
+ }
1379
+
1380
+ // Close order
1381
+ $order->setData('state', 'closed');
1382
+ $order->setStatus('closed');
1383
+ $order->save();
1384
+
1385
+ // Return
1386
+ $ok++;
1387
+ }
1388
+
1389
+ // Credit Memo
1390
+ if (!empty($canceledInvoices)) {
1391
+ $service = Mage::getModel('sales/service_order', $order);
1392
+
1393
+ foreach ($invoices as $invoice) {
1394
+ $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
1395
+ $creditmemo->setOfflineRequested(true);
1396
+ $creditmemo->register()->save();
1397
+ }
1398
+
1399
+ // Close order
1400
+ $order->setData('state', Mage_Sales_Model_Order::STATE_CLOSED);
1401
+ $order->setStatus(Mage_Sales_Model_Order::STATE_CLOSED);
1402
+ $order->save();
1403
+
1404
+ // Return
1405
+ $ok++;
1406
+ }
1407
+
1408
+ if (empty($invoices) && empty($canceledInvoices)) {
1409
+ // Cancel order
1410
+ $order->cancel()->save();
1411
+
1412
+ // Return
1413
+ $ok++;
1414
+ }
1415
+
1416
+ if ($ok > 0) {
1417
+ return 'OK';
1418
+ } else {
1419
+ return 'KO';
1420
+ }
1421
+ break;
1422
+
1423
+ // For other status we add comment to history
1424
+ default:
1425
+ $order->addStatusHistoryComment($status, false);
1426
+ $order->save();
1427
+
1428
+ return 'KO';
1429
+ }
1430
+ } else {
1431
+ return 'KO';
1432
+ }
1433
+ } else {
1434
+ return 'KO';
1435
+ }
1436
+ } catch (Exception $e) {
1437
+ //Log error
1438
+ $helperLog->error($e, true);
1439
+
1440
+ //Mail error
1441
+ $this->mailError(print_r($e->getMessage(), 1));
1442
+
1443
+ return 'KO';
1444
+ }
1445
+ }
1446
+
1447
+ /**
1448
+ * Create invoice
1449
+ */
1450
+ private function createInvoice($order, $data, $totalPaid, $status) {
1451
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
1452
+
1453
+ if (!$invoice->getTotalQty()) {
1454
+ $order->addStatusHistoryComment('Cannot create an invoice without products.', false);
1455
+ $order->save();
1456
+
1457
+ return 'KO';
1458
+ }
1459
+
1460
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
1461
+ $invoice->register();
1462
+ $invoice->getOrder()->setCustomerNoteNotify(true);
1463
+ $invoice->getOrder()->setIsInProcess(true);
1464
+ $invoice->setCanVoidFlag(true);
1465
+
1466
+ $transactionSave = Mage::getModel('core/resource_transaction')
1467
+ ->addObject($invoice)
1468
+ ->addObject($invoice->getOrder());
1469
+ $transactionSave->save();
1470
+
1471
+ // Send invoice email if enabled
1472
+ if (Mage::helper('sales')->canSendNewInvoiceEmail($order->getStoreId())) {
1473
+ $invoice->sendEmail(true);
1474
+ $invoice->setEmailSent(true);
1475
+ }
1476
+
1477
+ $order->setBaseTotalPaid($totalPaid);
1478
+ $order->addStatusHistoryComment('Captured offline', false);
1479
+
1480
+ $payment = $order->getPayment();
1481
+
1482
+ $payment->setAdditionalInformation('OrderStatusEnum', $data['OrderStatus']);
1483
+
1484
+ if ($payment->getAdditionalInformation('PaymentMethod') == 'mundipagg_creditcard') {
1485
+ $payment->setAdditionalInformation('CreditCardTransactionStatusEnum', $data['CreditCardTransaction']['CreditCardTransactionStatus']);
1486
+ }
1487
+
1488
+ if ($payment->getAdditionalInformation('PaymentMethod') == 'mundipagg_boleto') {
1489
+ $payment->setAdditionalInformation('BoletoTransactionStatusEnum', $data['BoletoTransaction']['BoletoTransactionStatus']);
1490
+ }
1491
+
1492
+ if (isset($data['OnlineDebitTransaction']['BankPaymentDate'])) {
1493
+ $payment->setAdditionalInformation('BankPaymentDate', $data['OnlineDebitTransaction']['BankPaymentDate']);
1494
+ }
1495
+
1496
+ if (isset($data['OnlineDebitTransaction']['BankName'])) {
1497
+ $payment->setAdditionalInformation('BankName', $data['OnlineDebitTransaction']['BankName']);
1498
+ }
1499
+
1500
+ if (isset($data['OnlineDebitTransaction']['Signature'])) {
1501
+ $payment->setAdditionalInformation('Signature', $data['OnlineDebitTransaction']['Signature']);
1502
+ }
1503
+
1504
+ if (isset($data['OnlineDebitTransaction']['TransactionIdentifier'])) {
1505
+ $payment->setAdditionalInformation('TransactionIdentifier', $data['OnlineDebitTransaction']['TransactionIdentifier']);
1506
+ }
1507
+
1508
+ $payment->save();
1509
+
1510
+ if ($status == 'OverPaid' || $status == 'Overpaid') {
1511
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, 'overpaid');
1512
+ } else {
1513
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
1514
+ }
1515
+
1516
+ $order->save();
1517
+
1518
+ return 'OK';
1519
+ }
1520
+
1521
+ /**
1522
+ * Search by orderkey
1523
+ * @param string $orderKey
1524
+ * @return array
1525
+ */
1526
+ public function getTransactionHistory($orderKey) {
1527
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1528
+
1529
+ // @var $standard Uecommerce_Mundipagg_Model_Standard
1530
+ $standard = Mage::getModel('mundipagg/standard');
1531
+
1532
+ // Get store key
1533
+ $key = $standard->getMerchantKey();
1534
+
1535
+ // Get Webservice URL
1536
+ $url = $standard->getURL() . '/Query/' . http_build_query(array('OrderKey' => $orderKey));
1537
+
1538
+ // get transactions from MundiPagg
1539
+ $ch = curl_init();
1540
+
1541
+ // Header
1542
+ curl_setopt($ch, CURLOPT_HEADER, false);
1543
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'MerchantKey: ' . $key . ''));
1544
+ curl_setopt($ch, CURLOPT_URL, $url);
1545
+
1546
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1547
+
1548
+ // Execute get
1549
+ $_response = curl_exec($ch);
1550
+
1551
+ // Close connection
1552
+ curl_close($ch);
1553
+
1554
+ if ($standard->getDebug() == 1) {
1555
+ // Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion() . ' Notification (return url)', null, 'Uecommerce_Mundipagg.log');
1556
+ // Mage::log(print_r($_response, 1), null, 'Uecommerce_Mundipagg.log');
1557
+ $helperLog->debug(print_r($_response, true));
1558
+ }
1559
+
1560
+ // Return
1561
+ return array('result' => simplexml_load_string($_response));
1562
+ }
1563
+
1564
+ /**
1565
+ * Mail error to Mage::getStoreConfig('trans_email/ident_custom1/email')
1566
+ *
1567
+ * @author Ruan Azevedo <razevedo@mundipagg.com>
1568
+ * @since 31-05-2016
1569
+ * @param string $message
1570
+ */
1571
+ public function mailError($message = '') {
1572
+ $mail = new Zend_Mail();
1573
+ $fromName = Mage::getStoreConfig('trans_email/ident_sales/name');
1574
+ $fromEmail = Mage::getStoreConfig('trans_email/ident_sales/email');
1575
+ $toEmail = Mage::getStoreConfig('trans_email/ident_custom1/email');
1576
+ $toName = Mage::getStoreConfig('trans_email/ident_custom1/name');
1577
+ $bcc = array('ruan.azevedo@gmail.com', 'razevedo@mundipagg.com');
1578
+ $subject = 'Error Report - MundiPagg Magento Integration';
1579
+ $body = "Error Report from: {$_SERVER['HTTP_HOST']}<br><br>{$message}";
1580
+
1581
+ $mail->setFrom($fromEmail, $fromName)
1582
+ ->addTo($toEmail, $toName)
1583
+ ->addBcc($bcc)
1584
+ ->setSubject($subject)
1585
+ ->setBodyHtml($body);
1586
+
1587
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1588
+
1589
+ try {
1590
+ $mail->send();
1591
+ $helperLog->info("Error Report Sent: {$message}");
1592
+
1593
+ } catch (Exception $e) {
1594
+ $helperLog->error($e);
1595
+ }
1596
+
1597
+ }
1598
+
1599
+ /**
1600
+ * Get 'RequestData' node for the One v2 request if antifraud is enabled
1601
+ *
1602
+ * @author Ruan Azevedo <razvedo@mundipagg.com>
1603
+ * @since 06-01-2016
1604
+ * @throws Mage_Core_Exception
1605
+ * @return array $requestData
1606
+ */
1607
+ private function getRequestDataNode() {
1608
+ $antifraud = Mage::getStoreConfig('payment/mundipagg_standard/antifraud');
1609
+ $antifraudProvider = Mage::getStoreConfig('payment/mundipagg_standard/antifraud_provider');
1610
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1611
+ $helperHttpCore = new Mage_Core_Helper_Http();
1612
+ $customerIp = $helperHttpCore->getRemoteAddr();
1613
+ $outputMsg = "";
1614
+ $sessionId = '';
1615
+ $error = false;
1616
+
1617
+ $requestData = array(
1618
+ 'IpAddress' => $customerIp,
1619
+ 'SessionId' => ''
1620
+ );
1621
+
1622
+ if ($this->debugEnabled) {
1623
+ $helperLog->debug("Checking antifraud config...");
1624
+ }
1625
+
1626
+ if ($antifraud == false) {
1627
+ if ($this->debugEnabled) {
1628
+ $helperLog->debug("Antifraud disabled.");
1629
+ }
1630
+
1631
+ return false;
1632
+ }
1633
+
1634
+ if ($this->debugEnabled) {
1635
+ $helperLog->debug("Antifraud enabled...");
1636
+ }
1637
+
1638
+ switch ($antifraudProvider) {
1639
+ case Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_NONE:
1640
+ $outputMsg = "Antifraud enabled and none antifraud provider selected at module configuration.";
1641
+ $error = true;
1642
+ break;
1643
+
1644
+ case Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_CLEARSALE:
1645
+ $outputMsg = "Antifraud provider: Clearsale";
1646
+ $sessionId = Uecommerce_Mundipagg_Model_Customer_Session::getSessionId();
1647
+ break;
1648
+
1649
+ case Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_FCONTROL:
1650
+ $outputMsg = "Antifraud provider: FControl";
1651
+ $sessionId = Uecommerce_Mundipagg_Model_Customer_Session::getSessionId();
1652
+ break;
1653
+ }
1654
+
1655
+ if ($error) {
1656
+ $helperLog->error($outputMsg, true);
1657
+ // Mage::throwException($outputMsg);
1658
+ }
1659
+
1660
+ if (is_null($sessionId)) {
1661
+ $sessionId = '';
1662
+ }
1663
+
1664
+ $requestData['SessionId'] = $sessionId;
1665
+
1666
+ $helperLog->info($outputMsg);
1667
+
1668
+ return $requestData;
1669
+ }
1670
+
1671
+ private function clearAntifraudDataFromSession() {
1672
+ $customerSession = Mage::getSingleton('customer/session');
1673
+ $customerSession->unsetData(Uecommerce_Mundipagg_Model_Customer_Session::SESSION_ID);
1674
+ }
1675
+
1676
+ /**
1677
+ * Method to unify the transactions requests and his logs
1678
+ *
1679
+ * @author Ruan Azevedo <razvedo@mundipagg.com>
1680
+ * @since 05-24-2016
1681
+ * @param array $dataToPost
1682
+ * @param string $url
1683
+ * @param array $_logRequest
1684
+ * @return array $_response
1685
+ */
1686
+ private function sendRequest($dataToPost, $url, $_logRequest = array()) {
1687
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1688
+
1689
+ if (empty($dataToPost) || empty($url)) {
1690
+ $errMsg = __METHOD__ . "Exception: one or more arguments not informed to request";
1691
+
1692
+ $helperLog->error($errMsg);
1693
+ throw new InvalidArgumentException($errMsg);
1694
+ }
1695
+
1696
+ $debug = $this->modelStandard->getDebug();
1697
+
1698
+ if ($debug) {
1699
+
1700
+ if (empty($_logRequest)) {
1701
+ $_logRequest = $dataToPost;
1702
+ }
1703
+
1704
+ $requestRawJson = json_encode($dataToPost);
1705
+ $requestJSON = $this->helperUtil->jsonEncodePretty($_logRequest);
1706
+
1707
+ $helperLog->debug("Request: {$requestJSON}\n");
1708
+ }
1709
+
1710
+ $ch = curl_init();
1711
+
1712
+ // Header
1713
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'MerchantKey: ' . $this->modelStandard->getMerchantKey() . ''));
1714
+ // Set the url, number of POST vars, POST data
1715
+ curl_setopt($ch, CURLOPT_URL, $url);
1716
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $requestRawJson);
1717
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1718
+
1719
+ // Execute post
1720
+ $_response = curl_exec($ch);
1721
+
1722
+ // Close connection
1723
+ curl_close($ch);
1724
+
1725
+ // Is there an error?
1726
+ $xml = simplexml_load_string($_response);
1727
+ $responseJSON = $this->helperUtil->jsonEncodePretty($xml);
1728
+ $responseArray = json_decode($responseJSON, true);
1729
+
1730
+ if ($debug) {
1731
+ $helperLog->debug("Response: {$responseJSON} \n");
1732
+ }
1733
+
1734
+ $responseData = array(
1735
+ 'xmlData' => $xml,
1736
+ 'arrayData' => $responseArray
1737
+ );
1738
+
1739
+ $this->clearAntifraudDataFromSession();
1740
+
1741
+ return $responseData;
1742
+ }
1743
+
1744
+ /**
1745
+ * Check if order is in offline retry time
1746
+ *
1747
+ * @author Ruan Azevedo <razevedo@mundipagg.com>
1748
+ * @since 2016-06-20
1749
+ * @param string $orderIncrementId
1750
+ * @return boolean
1751
+ */
1752
+ public function orderIsInOfflineRetry($orderIncrementId) {
1753
+ $model = Mage::getModel('mundipagg/offlineretry');
1754
+ $offlineRetry = $model->loadByIncrementId($orderIncrementId);
1755
+ $deadline = $offlineRetry->getDeadline();
1756
+ $now = new DateTime();
1757
+ $deadline = new DateTime($deadline);
1758
+
1759
+ if ($now < $deadline) {
1760
+ // in offline retry yet
1761
+ return true;
1762
+
1763
+ } else {
1764
+ // offline retry time is over
1765
+ return false;
1766
+ }
1767
+ }
1768
+
1769
+ /**
1770
+ * If the Offline Retry feature is enabled, save order offline retry statements
1771
+ *
1772
+ * @author Ruan Azevedo <razevedo@mundipagg.com>
1773
+ * @since 2016-06-23
1774
+ * @param string $orderIncrementId
1775
+ * @param DateTime $createDate
1776
+ */
1777
+ private function saveOfflineRetryStatements($orderIncrementId, DateTime $createDate) {
1778
+ // is offline retry is enabled, save statements
1779
+ if (Uecommerce_Mundipagg_Model_Offlineretry::offlineRetryIsEnabled()) {
1780
+ $offlineRetryTime = Mage::getStoreConfig('payment/mundipagg_standard/delayed_retry_max_time');
1781
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1782
+ $offlineRetryLogLabel = "Order #{$orderIncrementId} | offline retry statements";
1783
+
1784
+ $model = new Uecommerce_Mundipagg_Model_Offlineretry();
1785
+ $offlineRetry = $model->loadByIncrementId($orderIncrementId);
1786
+
1787
+ try {
1788
+ $offlineRetry->setOrderIncrementId($orderIncrementId);
1789
+ $offlineRetry->setCreateDate($createDate->getTimestamp());
1790
+
1791
+ $deadline = new DateTime();
1792
+ $interval = new DateInterval('PT' . $offlineRetryTime . 'M');
1793
+
1794
+ $deadline->setTimestamp($createDate->getTimestamp());
1795
+ $deadline->add($interval);
1796
+
1797
+ $offlineRetry->setDeadline($deadline->getTimestamp());
1798
+ $offlineRetry->save();
1799
+
1800
+ $helperLog->info("{$offlineRetryLogLabel} saved successfully.");
1801
+
1802
+ } catch (Exception $e) {
1803
+ $helperLog->error("{$offlineRetryLogLabel} cannot be saved: {$e}");
1804
+ }
1805
+
1806
+ }
1807
+ }
1808
+
1809
+ }
app/code/community/Uecommerce/Mundipagg/Model/Boleto.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Boleto extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_boleto';
37
+ protected $_formBlockType = 'mundipagg/standard_boleto';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ $validadeBoleto = $this->getConfigData('dias_validade_boleto');
60
+
61
+ if(empty($validadeBoleto) || $validadeBoleto == ' ' || is_null($validadeBoleto) || $validadeBoleto == ''){
62
+ $validadeBoleto = '3';
63
+ }
64
+
65
+ switch ($standard->getEnvironment())
66
+ {
67
+ case 'localhost':
68
+ case 'development':
69
+ case 'staging':
70
+ default:
71
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
72
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
73
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
74
+ $this->setPaymentMethodCode(1);
75
+ $this->setBankNumber(341);
76
+ $this->setDebug($standard->getConfigData('debug'));
77
+ $this->setDiasValidadeBoleto(trim($validadeBoleto));
78
+ $this->setInstrucoesCaixa(trim($this->getConfigData('instrucoes_caixa')));
79
+ $this->setEnvironment($standard->getConfigData('environment'));
80
+ break;
81
+
82
+ case 'production':
83
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
84
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
85
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
86
+ $this->setDebug($standard->getConfigData('debug'));
87
+ $this->setDiasValidadeBoleto(trim($validadeBoleto));
88
+ $this->setInstrucoesCaixa(trim($this->getConfigData('instrucoes_caixa')));
89
+ $this->setEnvironment($standard->getConfigData('environment'));
90
+ break;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Armazena as informações passadas via formulário no frontend
96
+ * @access public
97
+ * @param array $data
98
+ * @return Uecommerce_Mundipagg_Model_Standard
99
+ */
100
+ public function assignData($data)
101
+ {
102
+ parent::assignData($data);
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Prepare info instance for save
109
+ *
110
+ * @return Mage_Payment_Model_Abstract
111
+ */
112
+ public function prepareSave()
113
+ {
114
+ parent::prepareSave();
115
+ }
116
+
117
+ /**
118
+ * Instantiate state and set it to state object
119
+ *
120
+ * @param string $paymentAction
121
+ * @param Varien_Object
122
+ */
123
+ public function initialize($paymentAction, $stateObject)
124
+ {
125
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
126
+
127
+ if (version_compare($mageVersion, '1.5.0', '<')) {
128
+ $orderAction = 'order';
129
+ } else {
130
+ $orderAction = Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
131
+ }
132
+
133
+ $payment = $this->getInfoInstance();
134
+ $order = $payment->getOrder();
135
+
136
+ parent::order($payment, $order->getBaseTotalDue());
137
+ }
138
+ }
app/code/community/Uecommerce/Mundipagg/Model/Cardonfile.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Cardonfile extends Mage_Core_Model_Abstract
32
+ {
33
+ public function _construct()
34
+ {
35
+ parent::_construct();
36
+ //Ressource Model
37
+ $this->_init('mundipagg/cardonfile');
38
+ }
39
+
40
+ public function loadByToken($token)
41
+ {
42
+ return $this->load($token, 'token');
43
+ }
44
+ }
app/code/community/Uecommerce/Mundipagg/Model/Creditcard.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Creditcard extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_creditcard';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
67
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
68
+ $this->setPaymentMethodCode(1);
69
+ $this->setBankNumber(341);
70
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
71
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
72
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
73
+ $this->setDebug($standard->getConfigData('debug'));
74
+ $this->setEnvironment($standard->getConfigData('environment'));
75
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
76
+ break;
77
+
78
+ case 'production':
79
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
80
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
81
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
82
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
83
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
84
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
85
+ $this->setDebug($standard->getConfigData('debug'));
86
+ $this->setEnvironment($standard->getConfigData('environment'));
87
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
88
+ break;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Armazena as informações passadas via formulário no frontend
94
+ * @access public
95
+ * @param array $data
96
+ * @return Uecommerce_Mundipagg_Model_Standard
97
+ */
98
+ public function assignData($data)
99
+ {
100
+ $info = $this->getInfoInstance();
101
+
102
+ // Reset interests first
103
+ $this->resetInterest($info);
104
+
105
+ $cctype = $data[$this->_code.'_1_1_cc_type'];
106
+
107
+ if (isset($data[$this->_code.'_token_1_1']) && $data[$this->_code.'_token_1_1'] != 'new') {
108
+ $parcelsNumber = $data[$this->_code.'_credito_parcelamento_1_1'];
109
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_1_1']);
110
+ $cctype = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
111
+ } else {
112
+ $parcelsNumber = $data[$this->_code.'_new_credito_parcelamento_1_1'];
113
+
114
+ }
115
+
116
+ /**
117
+ * @var $interest Uecommerce_Mundipagg_Helper_Installments
118
+ */
119
+ $interest = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber , $cctype);
120
+ $interestInformation = array();
121
+ $interestInformation[$this->_code.'_1_1'] = new Varien_Object();
122
+ $interestInformation[$this->_code.'_1_1']->setInterest(str_replace(',','.',$interest));
123
+
124
+ if ($interest > 0) {
125
+ $info->setAdditionalInformation('mundipagg_interest_information', array());
126
+ $info->setAdditionalInformation('mundipagg_interest_information',$interestInformation);
127
+ $this->applyInterest($info, $interest);
128
+
129
+ } else {
130
+ // If none of Cc parcels doens't have interest we reset interest
131
+ $this->resetInterest($info);
132
+ }
133
+
134
+ parent::assignData($data);
135
+ }
136
+
137
+ /**
138
+ * Prepare info instance for save
139
+ *
140
+ * @return Mage_Payment_Model_Abstract
141
+ */
142
+ public function prepareSave()
143
+ {
144
+ parent::prepareSave();
145
+ }
146
+
147
+ /**
148
+ * Instantiate state and set it to state object
149
+ *
150
+ * @param string $paymentAction
151
+ * @param Varien_Object
152
+ */
153
+ public function initialize($paymentAction, $stateObject)
154
+ {
155
+ $standard = Mage::getModel('mundipagg/standard');
156
+
157
+ switch($standard->getConfigData('payment_action')) {
158
+ case 'order':
159
+ $this->setCreditCardOperationEnum('AuthAndCapture');
160
+
161
+ $paymentAction = $orderAction = 'order';
162
+ break;
163
+
164
+ case 'authorize':
165
+ $this->setCreditCardOperationEnum('AuthOnly');
166
+
167
+ $paymentAction = $orderAction = 'authorize';
168
+ break;
169
+
170
+ case 'authorize_capture':
171
+ $this->setCreditCardOperationEnum('AuthAndCaptureWithDelay');
172
+
173
+ $paymentAction = $orderAction = 'authorize_capture';
174
+ break;
175
+ }
176
+
177
+ $payment = $this->getInfoInstance();
178
+ $order = $payment->getOrder();
179
+
180
+ switch ($paymentAction) {
181
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
182
+ parent::authorize($payment, $order->getBaseTotalDue());
183
+ break;
184
+
185
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
186
+ parent::authorize($payment, $order->getBaseTotalDue());
187
+ break;
188
+
189
+ case $orderAction:
190
+ parent::order($payment, $order->getBaseTotalDue());
191
+ break;
192
+
193
+ default:
194
+ parent::order($payment, $order->getBaseTotalDue());
195
+ break;
196
+ }
197
+ }
198
+ }
app/code/community/Uecommerce/Mundipagg/Model/Creditcardoneinstallment.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Creditcardoneinstallment extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_creditcardoneinstallment';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canRefundInvoicePartial = true;
46
+ protected $_canVoid = true;
47
+ protected $_canUseInternal = true;
48
+ protected $_canUseCheckout = true;
49
+ protected $_canUseForMultishipping = true;
50
+ protected $_canSaveCc = false;
51
+ protected $_canFetchTransactionInfo = false;
52
+ protected $_canManageRecurringProfiles = false;
53
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
54
+ protected $_isInitializeNeeded = true;
55
+
56
+ public function __construct()
57
+ {
58
+ $standard = Mage::getModel('mundipagg/standard');
59
+
60
+ switch ($standard->getEnvironment())
61
+ {
62
+ case 'localhost':
63
+ case 'development':
64
+ case 'staging':
65
+ default:
66
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
67
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
68
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
69
+ $this->setPaymentMethodCode(1);
70
+ $this->setBankNumber(341);
71
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
72
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
73
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
74
+ $this->setDebug($standard->getConfigData('debug'));
75
+ $this->setEnvironment($standard->getConfigData('environment'));
76
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
77
+ break;
78
+
79
+ case 'production':
80
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
81
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
82
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
83
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
84
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
85
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
86
+ $this->setDebug($standard->getConfigData('debug'));
87
+ $this->setEnvironment($standard->getConfigData('environment'));
88
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
89
+ break;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Armazena as informações passadas via formulário no frontend
95
+ * @access public
96
+ * @param array $data
97
+ * @return Uecommerce_Mundipagg_Model_Standard
98
+ */
99
+ public function assignData($data)
100
+ {
101
+ if (!($data instanceof Varien_Object)) {
102
+ $data = new Varien_Object($data);
103
+ }
104
+
105
+ $info = $this->getInfoInstance();
106
+
107
+ // Reset interests from old methods first
108
+ $this->resetInterest($info);
109
+
110
+ parent::assignData($data);
111
+ }
112
+
113
+ /**
114
+ * Prepare info instance for save
115
+ *
116
+ * @return Mage_Payment_Model_Abstract
117
+ */
118
+ public function prepareSave()
119
+ {
120
+ parent::prepareSave();
121
+ }
122
+
123
+ /**
124
+ * Instantiate state and set it to state object
125
+ *
126
+ * @param string $paymentAction
127
+ * @param Varien_Object
128
+ */
129
+ public function initialize($paymentAction, $stateObject)
130
+ {
131
+ $standard = Mage::getModel('mundipagg/standard');
132
+
133
+ switch($standard->getConfigData('payment_action')) {
134
+ case 'order':
135
+ $this->setCreditCardOperationEnum('AuthAndCapture');
136
+
137
+ $paymentAction = $orderAction = 'order';
138
+ break;
139
+
140
+ case 'authorize':
141
+ $this->setCreditCardOperationEnum('AuthOnly');
142
+
143
+ $paymentAction = $orderAction = 'authorize';
144
+ break;
145
+
146
+ case 'authorize_capture':
147
+ $this->setCreditCardOperationEnum('AuthAndCaptureWithDelay');
148
+
149
+ $paymentAction = $orderAction = 'authorize_capture';
150
+ break;
151
+ }
152
+
153
+ $payment = $this->getInfoInstance();
154
+ $order = $payment->getOrder();
155
+
156
+ switch ($paymentAction) {
157
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
158
+ parent::authorize($payment, $order->getBaseTotalDue());
159
+ break;
160
+
161
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
162
+ parent::authorize($payment, $order->getBaseTotalDue());
163
+ break;
164
+
165
+ case $orderAction:
166
+ parent::order($payment, $order->getBaseTotalDue());
167
+ break;
168
+
169
+ default:
170
+ parent::order($payment, $order->getBaseTotalDue());
171
+ break;
172
+ }
173
+ }
174
+ }
app/code/community/Uecommerce/Mundipagg/Model/Customer/Session.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Customer_Session {
4
+
5
+ const SESSION_ID = 'session_id';
6
+
7
+ public static function getSessionId() {
8
+ $session = Mage::getSingleton('customer/session');
9
+ return $session->getData(self::SESSION_ID);
10
+ }
11
+
12
+ public static function setSessionId($sessionId) {
13
+ $session = Mage::getSingleton('customer/session');
14
+ $session->setData(self::SESSION_ID, $sessionId);
15
+ }
16
+
17
+ }
app/code/community/Uecommerce/Mundipagg/Model/Customers.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Customers extends Mage_Core_Model_Abstract
32
+ {
33
+ public function _construct()
34
+ {
35
+ parent::_construct();
36
+ //Ressource Model
37
+ $this->_init('mundipagg/customers');
38
+ }
39
+ }
app/code/community/Uecommerce/Mundipagg/Model/Debit.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2015 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Debit extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_debit';
37
+ protected $_formBlockType = 'mundipagg/standard_debit';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = false;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($this->getConfigData('apiDebitStagingUrl')));
67
+ $this->setPaymentMethodCode(1);
68
+ $this->setDebug($standard->getConfigData('debug'));
69
+ $this->setEnvironment($standard->getConfigData('environment'));
70
+ $this->setDebitTypes($this->getConfigData('debit_types'));
71
+ break;
72
+
73
+ case 'production':
74
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
75
+ $this->setUrl(trim($this->getConfigData('apiDebitUrl')));
76
+ $this->setDebug($standard->getConfigData('debug'));
77
+ $this->setEnvironment($standard->getConfigData('environment'));
78
+ $this->setDebitTypes($this->getConfigData('debit_types'));
79
+ break;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Armazena as informações passadas via formulário no frontend
85
+ * @access public
86
+ * @param array $data
87
+ * @return Uecommerce_Mundipagg_Model_Standard
88
+ */
89
+ public function assignData($data)
90
+ {
91
+ parent::assignData($data);
92
+ }
93
+
94
+ /**
95
+ * Prepare info instance for save
96
+ *
97
+ * @return Mage_Payment_Model_Abstract
98
+ */
99
+ public function prepareSave()
100
+ {
101
+ parent::prepareSave();
102
+ }
103
+
104
+ /**
105
+ * Instantiate state and set it to state object
106
+ *
107
+ * @param string $paymentAction
108
+ * @param Varien_Object
109
+ */
110
+ public function initialize($paymentAction, $stateObject)
111
+ {
112
+ $payment = $this->getInfoInstance();
113
+ $order = $payment->getOrder();
114
+
115
+ parent::order($payment, $order->getBaseTotalDue());
116
+ }
117
+
118
+ public function getConfigData($key, $storeId = null)
119
+ {
120
+ return Mage::getStoreConfig('payment/mundipagg_debit/' . $key, $storeId);
121
+ }
122
+ }
app/code/community/Uecommerce/Mundipagg/Model/Fivecreditcards.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Fivecreditcards extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_fivecreditcards';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
67
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
68
+ $this->setPaymentMethodCode(1);
69
+ $this->setBankNumber(341);
70
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
71
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
72
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
73
+ $this->setDebug($standard->getConfigData('debug'));
74
+ $this->setEnvironment($standard->getConfigData('environment'));
75
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
76
+ break;
77
+
78
+ case 'production':
79
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
80
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
81
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
82
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
83
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
84
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
85
+ $this->setDebug($standard->getConfigData('debug'));
86
+ $this->setEnvironment($standard->getConfigData('environment'));
87
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
88
+ break;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Armazena as informações passadas via formulário no frontend
94
+ * @access public
95
+ * @param array $data
96
+ * @return Uecommerce_Mundipagg_Model_Standard
97
+ */
98
+ public function assignData($data)
99
+ {
100
+ $info = $this->getInfoInstance();
101
+ $this->resetInterest($info);
102
+
103
+ parent::assignData($data);
104
+
105
+ $cctype1 = $data[$this->_code.'_5_1_cc_type'];
106
+
107
+ if (isset($data[$this->_code.'_token_5_1']) && $data[$this->_code.'_token_5_1'] != 'new') {
108
+ $parcelsNumber1 = $data[$this->_code.'_credito_parcelamento_5_1'];
109
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_5_1']);
110
+ $cctype1 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
111
+ $value1 = $data[$this->_code.'_value_5_1'];
112
+ } else {
113
+ $parcelsNumber1 = $data[$this->_code.'_new_credito_parcelamento_5_1'];
114
+ $value1 = $data[$this->_code.'_new_value_5_1'];
115
+ }
116
+
117
+ $cctype2 = $data[$this->_code.'_5_2_cc_type'];
118
+
119
+ if (isset($data[$this->_code.'_token_5_2']) && $data[$this->_code.'_token_5_2'] != 'new') {
120
+ $parcelsNumber2 = $data[$this->_code.'_credito_parcelamento_5_2'];
121
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_5_2']);
122
+ $cctype2 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
123
+ $value2 = $data[$this->_code.'_value_5_2'];
124
+ } else {
125
+ $parcelsNumber2 = $data[$this->_code.'_new_credito_parcelamento_5_2'];
126
+ $value2 = $data[$this->_code.'_new_value_5_2'];
127
+ }
128
+
129
+ $cctype3 = $data[$this->_code.'_5_3_cc_type'];
130
+
131
+ if (isset($data[$this->_code.'_token_5_3']) && $data[$this->_code.'_token_5_3'] != 'new') {
132
+ $parcelsNumber3 = $data[$this->_code.'_credito_parcelamento_5_3'];
133
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_5_3']);
134
+ $cctype3 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
135
+ $value3 = $data[$this->_code.'_value_5_3'];
136
+ } else {
137
+ $parcelsNumber3 = $data[$this->_code.'_new_credito_parcelamento_5_3'];
138
+ $value3 = $data[$this->_code.'_new_value_5_3'];
139
+ }
140
+
141
+ $cctype4 = $data[$this->_code.'_5_4_cc_type'];
142
+
143
+ if (isset($data[$this->_code.'_token_5_4']) && $data[$this->_code.'_token_5_4'] != 'new') {
144
+ $parcelsNumber4 = $data[$this->_code.'_credito_parcelamento_5_4'];
145
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_5_4']);
146
+ $cctype4 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
147
+ $value4 = $data[$this->_code.'_value_5_4'];
148
+ } else {
149
+ $parcelsNumber4 = $data[$this->_code.'_new_credito_parcelamento_5_4'];
150
+ $value4 = $data[$this->_code.'_new_value_5_4'];
151
+ }
152
+
153
+ $cctype5 = $data[$this->_code.'_5_5_cc_type'];
154
+
155
+ if (isset($data[$this->_code.'_token_5_5']) && $data[$this->_code.'_token_5_5'] != 'new') {
156
+ $parcelsNumber5 = $data[$this->_code.'_credito_parcelamento_5_5'];
157
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_5_5']);
158
+ $cctype5 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
159
+ $value5 = $data[$this->_code.'_value_5_5'];
160
+ } else {
161
+ $parcelsNumber5 = $data[$this->_code.'_new_credito_parcelamento_5_5'];
162
+ $value5 = $data[$this->_code.'_new_value_5_5'];
163
+ }
164
+
165
+ $interest1 = 0;
166
+ $interest2 = 0;
167
+ $interest3 = 0;
168
+ $interest4 = 0;
169
+ $interest5 = 0;
170
+ $interestInformation = array();
171
+
172
+ if(Mage::app()->getRequest()->getActionName() == 'partialPost'){
173
+ $keyCode = $this->_code.'_partial';
174
+ $interestInformation = $info->getAdditionalInformation('mundipagg_interest_information');
175
+ }else{
176
+ $keyCode = $this->_code;
177
+ }
178
+
179
+ if($cctype1) {
180
+ $interest1 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber1 , $cctype1, $value1);
181
+ $interestInformation[$keyCode.'_5_1'] = new Varien_Object();
182
+ $interestInformation[$keyCode.'_5_1']->setInterest(str_replace(',','.',$interest1))->setValue(str_replace(',','.',$value1));
183
+ }
184
+
185
+ if($cctype2) {
186
+ $interest2 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber2 , $cctype2, $value2);
187
+ $interestInformation[$keyCode.'_5_2'] = new Varien_Object();
188
+ $interestInformation[$keyCode.'_5_2']->setInterest(str_replace(',','.',$interest2))->setValue(str_replace(',','.',$value2));
189
+ }
190
+
191
+ if($cctype3) {
192
+ $interest3 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber3 , $cctype3, $value3);
193
+ $interestInformation[$keyCode.'_5_3'] = new Varien_Object();
194
+ $interestInformation[$keyCode.'_5_3']->setInterest(str_replace(',','.',$interest3))->setValue(str_replace(',','.',$value3));
195
+ }
196
+
197
+ if($cctype4) {
198
+ $interest4 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber4 , $cctype4, $value4);
199
+ $interestInformation[$keyCode.'_5_4'] = new Varien_Object();
200
+ $interestInformation[$keyCode.'_5_4']->setInterest(str_replace(',','.',$interest4))->setValue(str_replace(',','.',$value4));
201
+ }
202
+
203
+ if($cctype5) {
204
+ $interest5 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber5 , $cctype5, $value5);
205
+ $interestInformation[$keyCode.'_5_5'] = new Varien_Object();
206
+ $interestInformation[$keyCode.'_5_5']->setInterest(str_replace(',','.',$interest5))->setValue(str_replace(',','.',$value5));
207
+ }
208
+
209
+ $interest = $interest1+$interest2+$interest3+$interest4+$interest5;
210
+
211
+ if ($interest > 0) {
212
+ $info->setAdditionalInformation('mundipagg_interest_information', array());
213
+ $info->setAdditionalInformation('mundipagg_interest_information',$interestInformation);
214
+ $this->applyInterest($info, $interest);
215
+
216
+ } else {
217
+ // If none of Cc parcels doens't have interest we reset interest
218
+ $this->resetInterest($info);
219
+ }
220
+
221
+ return $this;
222
+ }
223
+
224
+ /**
225
+ * Prepare info instance for save
226
+ *
227
+ * @return Mage_Payment_Model_Abstract
228
+ */
229
+ public function prepareSave()
230
+ {
231
+ parent::prepareSave();
232
+ }
233
+
234
+ /**
235
+ * Instantiate state and set it to state object
236
+ *
237
+ * @param string $paymentAction
238
+ * @param Varien_Object
239
+ */
240
+ public function initialize($paymentAction, $stateObject)
241
+ {
242
+ $this->setCreditCardOperationEnum('AuthAndCapture');
243
+
244
+ $payment = $this->getInfoInstance();
245
+ $order = $payment->getOrder();
246
+
247
+ parent::authorize($payment, $order->getBaseTotalDue());
248
+ }
249
+ }
app/code/community/Uecommerce/Mundipagg/Model/Fourcreditcards.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Fourcreditcards extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_fourcreditcards';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
67
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
68
+ $this->setPaymentMethodCode(1);
69
+ $this->setBankNumber(341);
70
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
71
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
72
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
73
+ $this->setDebug($standard->getConfigData('debug'));
74
+ $this->setEnvironment($standard->getConfigData('environment'));
75
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
76
+ break;
77
+
78
+ case 'production':
79
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
80
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
81
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
82
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
83
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
84
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
85
+ $this->setDebug($standard->getConfigData('debug'));
86
+ $this->setEnvironment($standard->getConfigData('environment'));
87
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
88
+ break;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Armazena as informações passadas via formulário no frontend
94
+ * @access public
95
+ * @param array $data
96
+ * @return Uecommerce_Mundipagg_Model_Standard
97
+ */
98
+ public function assignData($data)
99
+ {
100
+ $info = $this->getInfoInstance();
101
+ $this->resetInterest($info);
102
+
103
+ parent::assignData($data);
104
+
105
+ $cctype1 = $data[$this->_code.'_4_1_cc_type'];
106
+
107
+ if (isset($data[$this->_code.'_token_4_1']) && $data[$this->_code.'_token_4_1'] != 'new') {
108
+ $parcelsNumber1 = $data[$this->_code.'_credito_parcelamento_4_1'];
109
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_4_1']);
110
+ $cctype1 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
111
+ $value1 = $data[$this->_code.'_value_4_1'];
112
+ } else {
113
+ $parcelsNumber1 = $data[$this->_code.'_new_credito_parcelamento_4_1'];
114
+ $value1 = $data[$this->_code.'_new_value_4_1'];
115
+ }
116
+
117
+ $cctype2 = $data[$this->_code.'_4_2_cc_type'];
118
+
119
+ if (isset($data[$this->_code.'_token_4_2']) && $data[$this->_code.'_token_4_2'] != 'new') {
120
+ $parcelsNumber2 = $data[$this->_code.'_credito_parcelamento_4_2'];
121
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_4_2']);
122
+ $cctype2 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
123
+ $value2 = $data[$this->_code.'_value_4_2'];
124
+ } else {
125
+ $parcelsNumber2 = $data[$this->_code.'_new_credito_parcelamento_4_2'];
126
+ $value2 = $data[$this->_code.'_new_value_4_2'];
127
+ }
128
+
129
+ $cctype3 = $data[$this->_code.'_4_3_cc_type'];
130
+
131
+ if (isset($data[$this->_code.'_token_4_3']) && $data[$this->_code.'_token_4_3'] != 'new') {
132
+ $parcelsNumber3 = $data[$this->_code.'_credito_parcelamento_4_3'];
133
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_4_3']);
134
+ $cctype3 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
135
+ $value3 = $data[$this->_code.'_value_4_3'];
136
+ } else {
137
+ $parcelsNumber3 = $data[$this->_code.'_new_credito_parcelamento_4_3'];
138
+ $value3 = $data[$this->_code.'_new_value_4_3'];
139
+ }
140
+
141
+ $cctype4 = $data[$this->_code.'_4_4_cc_type'];
142
+
143
+ if (isset($data[$this->_code.'_token_4_4']) && $data[$this->_code.'_token_4_4'] != 'new') {
144
+ $parcelsNumber4 = $data[$this->_code.'_credito_parcelamento_4_4'];
145
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_4_4']);
146
+ $cctype4 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
147
+ $value4 = $data[$this->_code.'_value_4_4'];
148
+ } else {
149
+ $parcelsNumber4 = $data[$this->_code.'_new_credito_parcelamento_4_4'];
150
+ $value4 = $data[$this->_code.'_new_value_4_4'];
151
+ }
152
+
153
+ $interest1 = 0;
154
+ $interest2 = 0;
155
+ $interest3 = 0;
156
+ $interest4 = 0;
157
+ $interestInformation = array();
158
+ if(Mage::app()->getRequest()->getActionName() == 'partialPost'){
159
+ $keyCode = $this->_code.'_partial';
160
+ $interestInformation = $info->getAdditionalInformation('mundipagg_interest_information');
161
+ }else{
162
+ $keyCode = $this->_code;
163
+ }
164
+
165
+ if($cctype1) {
166
+ $interest1 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber1 , $cctype1, $value1);
167
+ $interestInformation[$keyCode.'_4_1'] = new Varien_Object();
168
+ $interestInformation[$keyCode.'_4_1']->setInterest(str_replace(',','.',$interest1))->setValue(str_replace(',','.',$value1));
169
+ }
170
+
171
+ if($cctype2) {
172
+ $interest2 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber2 , $cctype2, $value2);
173
+ $interestInformation[$keyCode.'_4_2'] = new Varien_Object();
174
+ $interestInformation[$keyCode.'_4_2']->setInterest(str_replace(',','.',$interest2))->setValue(str_replace(',','.',$value2));
175
+ }
176
+
177
+ if($cctype3) {
178
+ $interest3 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber3 , $cctype3, $value3);
179
+ $interestInformation[$keyCode.'_4_3'] = new Varien_Object();
180
+ $interestInformation[$keyCode.'_4_3']->setInterest(str_replace(',','.',$interest3))->setValue(str_replace(',','.',$value3));
181
+ }
182
+
183
+ if($cctype4) {
184
+ $interest4 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber4 , $cctype4, $value4);
185
+ $interestInformation[$keyCode.'_4_4'] = new Varien_Object();
186
+ $interestInformation[$keyCode.'_4_4']->setInterest(str_replace(',','.',$interest4))->setValue(str_replace(',','.',$value4));
187
+ }
188
+
189
+ $interest = $interest1+$interest2+$interest3+$interest4;
190
+
191
+ if ($interest > 0) {
192
+ $info->setAdditionalInformation('mundipagg_interest_information', array());
193
+ $info->setAdditionalInformation('mundipagg_interest_information',$interestInformation);
194
+ $this->applyInterest($info, $interest);
195
+
196
+ } else {
197
+ // If none of Cc parcels doens't have interest we reset interest
198
+ $this->resetInterest($info);
199
+ }
200
+
201
+ return $this;
202
+ }
203
+
204
+ /**
205
+ * Prepare info instance for save
206
+ *
207
+ * @return Mage_Payment_Model_Abstract
208
+ */
209
+ public function prepareSave()
210
+ {
211
+ parent::prepareSave();
212
+ }
213
+
214
+ /**
215
+ * Instantiate state and set it to state object
216
+ *
217
+ * @param string $paymentAction
218
+ * @param Varien_Object
219
+ */
220
+ public function initialize($paymentAction, $stateObject)
221
+ {
222
+ $this->setCreditCardOperationEnum('AuthAndCapture');
223
+
224
+ $payment = $this->getInfoInstance();
225
+ $order = $payment->getOrder();
226
+
227
+ parent::authorize($payment, $order->getBaseTotalDue());
228
+ }
229
+ }
app/code/community/Uecommerce/Mundipagg/Model/Observer.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ class Uecommerce_Mundipagg_Model_Observer extends Uecommerce_Mundipagg_Model_Standard {
32
+ /*
33
+ * Update status and notify customer or not
34
+ */
35
+ private function _updateStatus($order, $state, $status, $comment, $notified) {
36
+
37
+ try {
38
+ $order->setState($state, $status, $comment, $notified);
39
+ $order->save();
40
+
41
+ return $this;
42
+
43
+ } catch (Exception $e) {
44
+ //Api
45
+ $api = Mage::getModel('mundipagg/api');
46
+
47
+ //Log error
48
+ Mage::logException($e);
49
+
50
+ //Mail error
51
+ $api->mailError(print_r($e->getMessage(), 1));
52
+ }
53
+ }
54
+
55
+ public function canceledOrder($event){
56
+ $order = $event->getOrder();
57
+ $state = $order->getState();
58
+
59
+ // if a order is canceled successfuly, offline retry data must be deleted if exists
60
+ if ($state == Mage_Sales_Model_Order::STATE_CANCELED) {
61
+
62
+ if (Uecommerce_Mundipagg_Model_Offlineretry::offlineRetryIsEnabled()) {
63
+ $model = Mage::getModel('mundipagg/offlineretry');
64
+ $incrementId = $order->getIncrementId();
65
+ $offlineRetry = $model->loadByIncrementId($incrementId);
66
+
67
+ if(empty($offlineRetry->getData())){
68
+ return;
69
+ }
70
+
71
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
72
+ $helperLog->setLogLabel("Order #{$incrementId} canceled");
73
+
74
+ try {
75
+ $offlineRetry->delete();
76
+ $helperLog->info("Offline retry data deleted successfully.");
77
+
78
+ } catch (Exception $e) {
79
+ $helperLog->info("Offline retry data cannot be deleted: {$e}");
80
+ }
81
+ }
82
+
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Update status
88
+ * */
89
+ public function updateStatus($event) {
90
+ $standard = Mage::getModel('mundipagg/standard');
91
+
92
+ $paymentAction = $standard->getConfigData('payment_action');
93
+
94
+ $method = $event->getOrder()->getPayment()->getAdditionalInformation('PaymentMethod');
95
+
96
+ // If it's a multi-payment types we force to ACTION_AUTHORIZE
97
+ $num = substr($method, 0, 1);
98
+
99
+ if ($num > 1) {
100
+ $paymentAction = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
101
+ }
102
+
103
+ $approvalRequestSuccess = Mage::getSingleton('checkout/session')->getApprovalRequestSuccess();
104
+
105
+ if ($method == 'mundipagg_boleto' && $approvalRequestSuccess != 'cancel') {
106
+ $comment = Mage::helper('mundipagg')->__('Waiting for Boleto Bancário payment');
107
+
108
+ $this->_updateStatus($event->getOrder(), Mage_Sales_Model_Order::STATE_HOLDED, true, $comment, false);
109
+ }
110
+
111
+ if ($method != 'mundipagg_boleto' && $paymentAction == 'authorize' && $approvalRequestSuccess == 'partial') {
112
+ $this->_updateStatus($event->getOrder(), Mage_Sales_Model_Order::STATE_NEW, 'pending', '', false);
113
+ }
114
+
115
+ if ($method != 'mundipagg_boleto' && $paymentAction == 'authorize' && $approvalRequestSuccess == 'success') {
116
+ $comment = Mage::helper('mundipagg')->__('Authorized');
117
+
118
+ $this->_updateStatus($event->getOrder(), Mage_Sales_Model_Order::STATE_NEW, 'pending', $comment, false);
119
+ }
120
+ }
121
+
122
+ /**
123
+ * If were are not in a Mundipagg controller methods listed above we unset parcial
124
+ */
125
+ public function sessionUpdate($observer) {
126
+ $action = $observer['controller_action']->getFullActionName();
127
+
128
+ if (
129
+ $action != 'mundipagg_standard_redirect'
130
+ && $action != 'mundipagg_standard_installments'
131
+ && $action != 'mundipagg_standard_installmentsandinterest'
132
+ && $action != 'mundipagg_standard_partial'
133
+ && $action != 'mundipagg_standard_partialPost'
134
+ && $action != 'mundipagg_standard_success'
135
+ ) {
136
+ Mage::getSingleton('checkout/session')->unsetData('approval_request_success');
137
+ Mage::getSingleton('checkout/session')->unsetData('authorized_amount');
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Remove all non MundiPagg payment methods and MundiPagg Boleto from partial payment page
143
+ */
144
+ public function removePaymentMethods($observer) {
145
+ $event = $observer->getEvent();
146
+ $method = $event->getMethodInstance();
147
+ $result = $event->getResult();
148
+ $isPartial = Mage::getSingleton('checkout/session')->getApprovalRequestSuccess();
149
+
150
+ if ($isPartial == 'partial') {
151
+ switch ($method->getCode()) {
152
+ case 'mundipagg_creditcardoneinstallment':
153
+ case 'mundipagg_creditcard':
154
+ case 'mundipagg_twocreditcards':
155
+ case 'mundipagg_threecreditcards':
156
+ case 'mundipagg_fourcreditcards':
157
+ case 'mundipagg_fivecreditcards':
158
+ $active = Mage::getStoreConfig('payment/' . $method->getCode() . '/active');
159
+
160
+ if ($active == '1') {
161
+ $result->isAvailable = true;
162
+ } else {
163
+ $result->isAvailable = false;
164
+ }
165
+ break;
166
+ case 'mundipagg_boleto':
167
+ $result->isAvailable = false;
168
+ break;
169
+ default:
170
+ $result->isAvailable = false;
171
+ break;
172
+ }
173
+ }
174
+ }
175
+
176
+ public function removeInterest($observer) {
177
+ $session = Mage::getSingleton('admin/session');
178
+
179
+ if ($session->isLoggedIn()) {
180
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
181
+ } else {
182
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
183
+ }
184
+
185
+ $quote->setMundipaggInterest(0.0);
186
+ $quote->setMundipaggBaseInterest(0.0);
187
+ $quote->setTotalsCollectedFlag(false)->collectTotals();
188
+ $quote->save();
189
+ }
190
+
191
+ /**
192
+ * Check if recurrency product is in cart in order to show only Mundipagg Credit Card payment
193
+ */
194
+ public function checkForRecurrency($observer) {
195
+ $recurrent = 0;
196
+
197
+ $session = Mage::getSingleton('admin/session');
198
+
199
+ if ($session->isLoggedIn()) {
200
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
201
+ } else {
202
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
203
+ }
204
+
205
+ $cartItems = $quote->getAllVisibleItems();
206
+
207
+ foreach ($cartItems as $item) {
208
+ $productId = $item->getProductId();
209
+
210
+ $product = Mage::getModel('catalog/product')->load($productId);
211
+
212
+ if ($product->getMundipaggRecurrent()) {
213
+ $recurrent++;
214
+ }
215
+ }
216
+
217
+ if ($recurrent > 0) {
218
+ $instance = $observer->getMethodInstance();
219
+ $result = $observer->getResult();
220
+
221
+ switch ($instance->getCode()) {
222
+ case 'mundipagg_boleto':
223
+ case 'mundipagg_debit':
224
+ case 'mundipagg_creditcardoneinstallment':
225
+ case 'mundipagg_twocreditcards':
226
+ case 'mundipagg_threecreditcards':
227
+ case 'mundipagg_fourcreditcards':
228
+ case 'mundipagg_fivecreditcards':
229
+ $result->isAvailable = false;
230
+ break;
231
+ case 'mundipagg_creditcard':
232
+ $result->isAvailable = true;
233
+ break;
234
+ default:
235
+ $result->isAvailable = false;
236
+ break;
237
+ }
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Add discount amount in the quote when partial payment
243
+ *
244
+ * @param type $observer
245
+ */
246
+ public function addDiscountWhenPartial($observer) {
247
+ $session = Mage::getSingleton('checkout/session');
248
+ if (!$session->getApprovalRequestSuccess() == 'partial') {
249
+ $request = Mage::app()->getRequest();
250
+ if (Mage::app()->getRequest()->getActionName() != 'partialPost' && $request->getModuleName() != 'mundipagg' && $request->getControllerName() != 'standard') {
251
+ return $this;
252
+ }
253
+ }
254
+ $quote = $observer->getEvent()->getQuote();
255
+ $quoteid = $quote->getId();
256
+
257
+ $reservedOrderId = $quote->getReservedOrderId();
258
+
259
+ if (!$reservedOrderId) {
260
+ return $this;
261
+ }
262
+
263
+ $order = Mage::getModel('sales/order')->loadByIncrementId($reservedOrderId);
264
+
265
+ if (!$order->getId()) {
266
+ return $this;
267
+ }
268
+
269
+ $payment = $order->getPayment();
270
+
271
+ $interestInformation = $payment->getAdditionalInformation('mundipagg_interest_information');
272
+ $discountAmount = 0;
273
+
274
+ if (isset($interestInformation)) {
275
+ foreach ($interestInformation as $ii) {
276
+ $discountAmount += (float)$ii->getValue();
277
+ }
278
+ }
279
+
280
+ if ($quoteid) {
281
+ $total = $quote->getBaseSubtotal();
282
+ $quote->setSubtotal(0);
283
+ $quote->setBaseSubtotal(0);
284
+
285
+ $quote->setSubtotalWithDiscount(0);
286
+ $quote->setBaseSubtotalWithDiscount(0);
287
+
288
+ $quote->setGrandTotal(0);
289
+ $quote->setBaseGrandTotal(0);
290
+
291
+
292
+ $canAddItems = $quote->isVirtual() ? ('billing') : ('shipping');
293
+ foreach ($quote->getAllAddresses() as $address) {
294
+
295
+ $discountAmount -= $address->getShippingAmount();
296
+
297
+ $address->setSubtotal(0);
298
+ $address->setBaseSubtotal(0);
299
+
300
+ $address->setGrandTotal(0);
301
+ $address->setBaseGrandTotal(0);
302
+
303
+ $address->collectTotals();
304
+
305
+ $quote->setSubtotal((float)$quote->getSubtotal() + $address->getSubtotal());
306
+ $quote->setBaseSubtotal((float)$quote->getBaseSubtotal() + $address->getBaseSubtotal());
307
+
308
+ $quote->setSubtotalWithDiscount(
309
+ (float)$quote->getSubtotalWithDiscount() + $address->getSubtotalWithDiscount()
310
+ );
311
+ $quote->setBaseSubtotalWithDiscount(
312
+ (float)$quote->getBaseSubtotalWithDiscount() + $address->getBaseSubtotalWithDiscount()
313
+ );
314
+
315
+ $quote->setGrandTotal((float)$quote->getGrandTotal() + $address->getGrandTotal());
316
+ $quote->setBaseGrandTotal((float)$quote->getBaseGrandTotal() + $address->getBaseGrandTotal());
317
+
318
+ $quote->save();
319
+
320
+ $quote->setGrandTotal($quote->getBaseSubtotal() - $discountAmount)
321
+ ->setBaseGrandTotal($quote->getBaseSubtotal() - $discountAmount)
322
+ ->setSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)
323
+ ->setBaseSubtotalWithDiscount($quote->getBaseSubtotal() - $discountAmount)
324
+ ->save();
325
+
326
+
327
+ if ($address->getAddressType() == $canAddItems) {
328
+ //echo $address->setDiscountAmount; exit;
329
+ $address->setSubtotalWithDiscount((float)$address->getSubtotalWithDiscount() - $discountAmount);
330
+ $address->setGrandTotal((float)$address->getGrandTotal() - $discountAmount);
331
+ $address->setBaseSubtotalWithDiscount((float)$address->getBaseSubtotalWithDiscount() - $discountAmount);
332
+ $address->setBaseGrandTotal((float)$address->getBaseGrandTotal() - $discountAmount);
333
+ if ($address->getDiscountDescription()) {
334
+ $address->setDiscountAmount(-($address->getDiscountAmount() - $discountAmount));
335
+ $address->setDiscountDescription($address->getDiscountDescription() . ', Discount to Partial Payment');
336
+ $address->setBaseDiscountAmount(-($address->getBaseDiscountAmount() - $discountAmount));
337
+ } else {
338
+ $address->setDiscountAmount(-($discountAmount));
339
+ $address->setDiscountDescription('Discount to Partial Payment');
340
+ $address->setBaseDiscountAmount(-($discountAmount));
341
+ }
342
+ $address->save();
343
+ }
344
+ }
345
+ //echo $quote->getGrandTotal();
346
+
347
+ foreach ($quote->getAllItems() as $item) {
348
+ //We apply discount amount based on the ratio between the GrandTotal and the RowTotal
349
+ $rat = $item->getPriceInclTax() / $total;
350
+ $ratdisc = $discountAmount * $rat;
351
+ $item->setDiscountAmount(($item->getDiscountAmount() + $ratdisc) * $item->getQty());
352
+ $item->setBaseDiscountAmount(($item->getBaseDiscountAmount() + $ratdisc) * $item->getQty())->save();
353
+ }
354
+ }
355
+ }
356
+ }
app/code/community/Uecommerce/Mundipagg/Model/Offlineretry.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Offlineretry extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('mundipagg/offlineretry');
8
+ }
9
+
10
+ public static function offlineRetryIsEnabled() {
11
+ return Mage::getStoreConfig('payment/mundipagg_standard/offline_retry_enabled');
12
+ }
13
+
14
+ public function loadByIncrementId($incrementId) {
15
+ return $this->load($incrementId, 'order_increment_id');
16
+ }
17
+ }
app/code/community/Uecommerce/Mundipagg/Model/Order/Invoice/Interest.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Order_Invoice_Interest extends Mage_Sales_Model_Order_Invoice_Total_Abstract
32
+ {
33
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
34
+ {
35
+ $order = $invoice->getOrder();
36
+
37
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $order->getMundipaggInterest());
38
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $order->getMundipaggBaseInterest());
39
+
40
+ return $this;
41
+ }
42
+ }
app/code/community/Uecommerce/Mundipagg/Model/Providervalidation.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Providervalidation extends Mage_Core_Model_Config_Data {
4
+
5
+ public function save() {
6
+ $antifraudProvider = $this->getValue();
7
+
8
+ if($antifraudProvider == Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_NONE){
9
+ Mage::throwException("Erro ao tentar salvar: fornecedor de anti-fraude não informado.");
10
+ }
11
+
12
+ return parent::save();
13
+ }
14
+
15
+ }
app/code/community/Uecommerce/Mundipagg/Model/Quote/Address/Interest.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Quote_Address_Interest extends Mage_Sales_Model_Quote_Address_Total_Abstract
32
+ {
33
+ /**
34
+ * Constructor that should initiaze
35
+ */
36
+ public function __construct()
37
+ {
38
+ $this->setCode('mundipagg_interest');
39
+ }
40
+
41
+ public function collect(Mage_Sales_Model_Quote_Address $address)
42
+ {
43
+ if($address->getQuote()->isVirtual()){
44
+ if ($address->getData('address_type') == 'shipping') return $this;
45
+ }else{
46
+ if ($address->getData('address_type') == 'billing') return $this;
47
+ }
48
+
49
+ $this->_setAddress($address);
50
+
51
+ parent::collect($address);
52
+
53
+ $quote = $address->getQuote();
54
+ $amount = $quote->getMundipaggInterest();
55
+
56
+ if($amount > 0) {
57
+ $this->_setBaseAmount(0.00);
58
+ $this->_setAmount(0.00);
59
+
60
+ $quote->getPayment()->setPaymentInterest($amount);
61
+ $address->setMundipaggInterest($amount);
62
+
63
+ $this->_setBaseAmount($amount);
64
+ $this->_setAmount($amount);
65
+ } else {
66
+ $this->_setBaseAmount(0.00);
67
+ $this->_setAmount(0.00);
68
+
69
+ $quote->getPayment()->setPaymentInterest(0.00);
70
+ $address->setMundipaggInterest(0.00);
71
+ }
72
+
73
+ return $this;
74
+ }
75
+
76
+
77
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
78
+ {
79
+ if ($address->getMundipaggInterest() != 0)
80
+ {
81
+ $address->addTotal(array
82
+ (
83
+ 'code' => $this->getCode(),
84
+ 'title' => Mage::helper('mundipagg')->__('Interest'),
85
+ 'value' => $address->getMundipaggInterest()
86
+ ));
87
+ }
88
+ }
89
+ }
app/code/community/Uecommerce/Mundipagg/Model/Recurrency.php ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ class Uecommerce_Mundipagg_Model_Recurrency extends Varien_Object {
32
+
33
+ /**
34
+ * Loaded Product
35
+ *
36
+ * @var Mage_Catalog_Model_Product
37
+ */
38
+ protected $_product;
39
+
40
+ /**
41
+ * Recurrency for this Product
42
+ *
43
+ * @var array
44
+ */
45
+ protected $_recurrency;
46
+
47
+ /**
48
+ * Recurrences for all Products
49
+ *
50
+ * @var array
51
+ */
52
+ protected $_recurrencesData;
53
+
54
+ /**
55
+ * Get item from quote
56
+ *
57
+ * @var Mage_Sales_Model_Order_Item
58
+ */
59
+ protected $_item;
60
+
61
+ /**
62
+ * Varien_Object
63
+ */
64
+ public function _construct() {
65
+ parent::_construct();
66
+
67
+ $this->_recurrences = array();
68
+ $this->_product = null;
69
+ $this->_recurrency = null;
70
+ $this->_recurrencesData = array();
71
+ }
72
+
73
+ /**
74
+ * Set item
75
+ *
76
+ * @param Mage_Sales_Model_Order_Item $item
77
+ * @return Uecommerce_Mundipagg_Model_Recurrency
78
+ */
79
+ public function setItem(Mage_Sales_Model_Order_Item $item) {
80
+ $this->_item = $item;
81
+
82
+ $this->_product = Mage::getModel('catalog/product')->load($item->getProductId());
83
+
84
+
85
+ if ($this->_product->getMundipaggRecurrent() && $this->isRecurrent()) {
86
+ $this->_setRecurrencyByProduct($this->_product);
87
+ }
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Set Product
94
+ *
95
+ * @param Mage_Catalog_Model_Product $product
96
+ * @return Uecommerce_Mundipagg_Model_Recurrency
97
+ */
98
+ public function setProduct(Mage_Catalog_Model_Product $product) {
99
+ if ($product->HasMundipaggRecurrent()) {
100
+ $this->_product = $product;
101
+ } else {
102
+ $this->_product = Mage::getModel('catalog/product')->load($product->getId());
103
+ }
104
+
105
+ if ($this->_product->getMundipaggRecurrent() && $this->isRecurrent()) {
106
+ $this->_setRecurrencyByProduct($this->_product);
107
+ }
108
+
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Set Product by id
114
+ *
115
+ * @param int $id
116
+ * @return Uecommerce_Mundipagg_Model_Recurrency
117
+ */
118
+ public function setProductById($id) {
119
+ $this->_product = Mage::getModel('catalog/product')->load($id);
120
+
121
+ if ($this->_product->getMundipaggRecurrent() && $this->isRecurrent()) {
122
+ $this->_setRecurrencyByProduct($this->_product);
123
+ }
124
+
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Check if this product is recurrent
130
+ *
131
+ * @return boolean
132
+ */
133
+ public function isRecurrent() {
134
+ return $this->getProduct()->getMundipaggRecurrent() ? true : false;
135
+ }
136
+
137
+ /**
138
+ * Get product
139
+ *
140
+ * @return Mage_Catalog_Model_Product
141
+ */
142
+ public function getProduct() {
143
+ return $this->_product;
144
+ }
145
+
146
+ /**
147
+ * Set Recurrency for this product
148
+ *
149
+ * @param Mage_Catalog_Model_Product $_product
150
+ * @return boolean
151
+ */
152
+ protected function _setRecurrencyByProduct(Mage_Catalog_Model_Product $_product) {
153
+ if (!$_product->getMundipaggRecurrent()) {
154
+ return false;
155
+ }
156
+
157
+ switch ($_product->getMundipaggFrequencyEnum()) {
158
+ case 'Quarterly':
159
+ $frequency = 'Monthly';
160
+ $interval = '3';
161
+ break;
162
+ case 'Biannual':
163
+ $frequency = 'Monthly';
164
+ $interval = '6';
165
+ break;
166
+ default:
167
+ $frequency = $_product->getMundipaggFrequencyEnum();
168
+ $interval = '1';
169
+ }
170
+
171
+ $this->_recurrency = array(
172
+ 'DateToStartBilling' => $this->getFormattedDateToStartBilling($frequency, $interval),
173
+ 'Frequency' => $frequency,
174
+ 'Interval' => $interval,
175
+ 'Recurrences' => ($_product->getMundipaggRecurrences() - 1)
176
+ );
177
+
178
+ $this->setData('recurrency', $this->_recurrency);
179
+
180
+ $this->addRecurrencyData();
181
+
182
+ return true;
183
+ }
184
+
185
+ /**
186
+ * Get Formatted Date to Start Billing
187
+ *
188
+ * @param string $frequency
189
+ * @param int $interval
190
+ * @return string
191
+ */
192
+ public function getFormattedDateToStartBilling($frequency, $interval) {
193
+ $date = new Zend_Date(Mage::getModel('core/date')->timestamp(), Zend_Date::TIMESTAMP);
194
+
195
+ switch ($frequency) {
196
+ case 'Daily':
197
+ $frequency = 'Day';
198
+ break;
199
+ case 'Weekly':
200
+ $frequency = 'Week';
201
+ break;
202
+ case 'Monthly':
203
+ $frequency = 'Month';
204
+ break;
205
+ case 'Yearly':
206
+ $frequency = 'Year';
207
+ break;
208
+ }
209
+
210
+ $function = 'add' . $frequency;
211
+
212
+ $date->{$function}($interval);
213
+
214
+ return $date->toString('yyyy-MM-ddTHH:mm:ss');
215
+ }
216
+
217
+ /**
218
+ * Get item from Order
219
+ *
220
+ * @return Mage_Sales_Model_Order_Item
221
+ */
222
+ public function getItem() {
223
+ return $this->_item;
224
+ }
225
+
226
+ /**
227
+ * Get the item price with the discount and tax applied
228
+ *
229
+ * @return float
230
+ */
231
+ public function getItemFinalPrice() {
232
+ $item = $this->getItem();
233
+
234
+ $amount = $item->getPrice();
235
+ if ($item->getDiscountAmount()) {
236
+ $amount = ($amount - $item->getDiscountAmount());
237
+ }
238
+
239
+ if ($item->getTaxAmount()) {
240
+ $amount = ($amount + $item->getTaxAmount());
241
+ }
242
+
243
+ return $amount;
244
+ }
245
+
246
+ /**
247
+ * Add current recorrency in array data.
248
+ */
249
+ protected function addRecurrencyData() {
250
+ if (!empty($this->_recurrency)) {
251
+ $recurrency = new Varien_Object();
252
+ $recurrency->setData('product', $this->getProduct());
253
+ $recurrency->setData('recurrency', $this->getRecurrency());
254
+ $recurrency->setData('item', $this->getItem());
255
+ $recurrency->getItem()->setItemFinalPrice($this->getItemFinalPrice());
256
+
257
+ $this->_recurrencesData[] = $recurrency;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Get all recurrences Data
263
+ *
264
+ * @return array
265
+ */
266
+ public function getRecurrencesData() {
267
+ return $this->_recurrencesData;
268
+ }
269
+
270
+ /**
271
+ * Check if there is any recurrency
272
+ *
273
+ * @return boolean
274
+ */
275
+ public function recurrencyExists() {
276
+ $recurrencesData = $this->getRecurrencesData();
277
+
278
+ if (!empty($recurrencesData)) {
279
+ return true;
280
+ } else {
281
+ return false;
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Generate all recurrences in request if exists
287
+ *
288
+ * @param array $_request
289
+ * @param int $installmentCount
290
+ * @return array Parameter $_request
291
+ */
292
+ public function generateRecurrences($_request, $installmentCount) {
293
+ if (!$this->recurrencyExists()) {
294
+ return $_request;
295
+ }
296
+
297
+ foreach ($this->getRecurrencesData() as $recurrency) {
298
+ $newCreditCardTransactionCollection = $_request['CreditCardTransactionCollection'][0];
299
+
300
+ if ($recurrency->hasItem()) {
301
+ $amountItem = $recurrency->getItem()->getItemFinalPrice();
302
+
303
+ $amount = str_replace('.', '', number_format($amountItem, 2, '.', ''));
304
+ } else {
305
+ $amount = str_replace('.', '', number_format($recurrency->getProduct()->getFinalPrice(), 2, '.', ''));
306
+ }
307
+
308
+ $itemRecurrency = $recurrency->getRecurrency();
309
+ $newCreditCardTransactionCollection['AmountInCents'] = $amount;
310
+ $newCreditCardTransactionCollection['InstallmentCount'] = $installmentCount;
311
+ $newCreditCardTransactionCollection['Recurrency'] = $itemRecurrency;
312
+ $newCreditCardTransactionCollection['CreditCardOperation'] = 'AuthOnly';
313
+ $_request['CreditCardTransactionCollection'][] = $newCreditCardTransactionCollection;
314
+ }
315
+
316
+ return $_request;
317
+ }
318
+
319
+ /**
320
+ *
321
+ * @param Mage_Sales_Model_Order $order
322
+ * @return boolean
323
+ */
324
+ public function checkRecurrencesByOrder(Mage_Sales_Model_Order $order){
325
+ $payment = $order->getPayment();
326
+ if($payment->getAdditionalInformation('isRecurrency') != '1'){
327
+ return false;
328
+ }
329
+
330
+ // @var $transactions Mage_Sales_Model_Order_Payment_Transaction
331
+ $transactions = Mage::getModel('sales/order_payment_transaction')->getCollection()
332
+ ->addAttributeToFilter('order_id', array('eq' => $order->getEntityId()));
333
+ $transactionsKeys = array();
334
+ if($transactions->getSize()){
335
+ foreach($transactions as $transaction){
336
+ $transactionsKeys[] = $transaction->getAdditionalInformation('TransactionKey');
337
+ }
338
+ }
339
+
340
+ // @var $api Uecommerce_Mundipagg_Model_Api
341
+ $api = Mage::getModel('mundipagg/api');
342
+
343
+ $apiTransactions = $api->getTransactionHistory($payment->getAdditionalInformation('OrderKey'));
344
+
345
+ $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
346
+
347
+ if(count($apiTransactions['result'])){
348
+ foreach($apiTransactions['result']->SaleDataCollection->Sale->CreditCardTransactionDataCollection->CreditCardTransactionData as $transaction){
349
+ if(!in_array($transaction->TransactionKey, $transactionsKeys)){
350
+ // Check if ONEDOLLARAUTH transaction
351
+ if($transaction->AmountInCents == '100'
352
+ && $transaction->AuthorizedAmountInCents == '100'
353
+ && $transaction->InstallmentCount == '0'
354
+ && $transaction->IsReccurency == 'true'){
355
+ continue;
356
+ }
357
+ $this->_addTransaction($payment, $transaction->TransactionKey, $transactionType, $transaction);
358
+ }
359
+ }
360
+ }
361
+
362
+ }
363
+
364
+ /**
365
+ * Add payment transaction
366
+ *
367
+ * @param Mage_Sales_Model_Order_Payment $payment
368
+ * @param string $transactionId
369
+ * @param string $transactionType
370
+ * @param array $transactionAdditionalInfo
371
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
372
+ */
373
+ public function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, $transactionAdditionalInfo)
374
+ {
375
+ $transaction = Mage::getModel('sales/order_payment_transaction');
376
+ $transaction->setOrderPaymentObject($payment);
377
+
378
+ $transaction = $transaction->loadByTxnId($transactionId.'-'.$transactionType);
379
+
380
+ $transaction->setTxnType($transactionType);
381
+ $transaction->setTxnId($transactionId.'-'.$transactionType);
382
+
383
+ if($transactionType == 'authorization') {
384
+ if ($transactionAdditionalInfo['CreditCardTransactionStatus'] == 'AuthorizedPendingCapture') {
385
+ $transaction->setIsClosed(0);
386
+ }
387
+
388
+ if ($transactionAdditionalInfo['CreditCardTransactionStatus'] == 'NotAuthorized') {
389
+ $transaction->setIsClosed(1);
390
+ }
391
+ }
392
+
393
+ /*
394
+ if ($transactionAdditionalInfo['Success'] == true && ($transactionType == 'order' || $transactionType == 'payment')) {
395
+ $transaction->setIsClosed(1);
396
+ }
397
+ */
398
+
399
+ foreach ($transactionAdditionalInfo as $transKey => $value) {
400
+ if (!is_array($value)){
401
+ $transaction->setAdditionalInformation($transKey, htmlspecialchars_decode($value));
402
+ } else {
403
+ foreach ($value as $key2 => $value2) {
404
+ $transaction->setAdditionalInformation($key2, htmlspecialchars_decode($value2));
405
+ }
406
+ }
407
+ }
408
+
409
+ return $transaction->save();
410
+ }
411
+
412
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Cardonfile.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Resource_Cardonfile extends Mage_Core_Model_Mysql4_Abstract
32
+ {
33
+ public function _construct()
34
+ {
35
+ //1st argument : modulename/tablename
36
+ //2nd argument : refers to the key field in your database table
37
+ $this->_init('mundipagg/mundipagg_card_on_file', 'id');
38
+ }
39
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Cardonfile/Collection.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Resource_Cardonfile_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
32
+ {
33
+ protected function _construct()
34
+ {
35
+ $this->_init('mundipagg/cardonfile');
36
+ }
37
+
38
+ public function addEntityIdFilter($entityId)
39
+ {
40
+ $this->addFieldToFilter('entity_id', $entityId);
41
+ return $this;
42
+ }
43
+
44
+ public function addExpiresAtFilter()
45
+ {
46
+ $this->addFieldToFilter('expires_at', array( 'gteq' => date('Y-m-t') ) );
47
+ return $this;
48
+ }
49
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Customers.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Resource_Customers extends Mage_Core_Model_Mysql4_Abstract
32
+ {
33
+ public function _construct()
34
+ {
35
+ //1st argument : modulename/tablename
36
+ //2nd argument : refers to the key field in your database table
37
+ $this->_init('mundipagg/mundipagg_customers', 'id');
38
+ }
39
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Customers/Collection.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Resource_Customers_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
32
+ {
33
+ protected function _construct()
34
+ {
35
+ $this->_init('mundipagg/customers');
36
+ }
37
+
38
+ public function addEntityIdFilter($entityId)
39
+ {
40
+ $this->addFieldToFilter('entity_id', $entityId);
41
+ return $this;
42
+ }
43
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Offlineretry.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Resource_Offlineretry extends Mage_Core_Model_Mysql4_Abstract {
4
+ public function _construct() {
5
+ $this->_init('mundipagg/mundipagg_offline_retry', 'id');
6
+ }
7
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Offlineretry/Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Resource_Offlineretry_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init('mundipagg/offlineretry');
7
+ }
8
+
9
+ // public function addEntityIdFilter($entityId) {
10
+ // $this->addFieldToFilter('entity_id', $entityId);
11
+ //
12
+ // return $this;
13
+ // }
14
+ //
15
+ // public function addExpiresAtFilter() {
16
+ // $this->addFieldToFilter('expires_at', array('gteq' => date('Y-m-t')));
17
+ //
18
+ // return $this;
19
+ // }
20
+ }
app/code/community/Uecommerce/Mundipagg/Model/Resource/Setup.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
32
+ {
33
+
34
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Antifraud.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Model_Source_Antifraud {
4
+
5
+ const ANTIFRAUD_NONE = 0;
6
+ const ANTIFRAUD_CLEARSALE = 1;
7
+ const ANTIFRAUD_FCONTROL = 2;
8
+ const ANTIFRAUD_STONE = 3;
9
+
10
+ public function toOptionArray() {
11
+ return array(
12
+ array('value' => self::ANTIFRAUD_NONE, 'label' => 'Selecione...'),
13
+ array('value' => self::ANTIFRAUD_STONE, 'label' => 'Stone'),
14
+ array('value' => self::ANTIFRAUD_CLEARSALE, 'label' => 'Clearsale'),
15
+ array('value' => self::ANTIFRAUD_FCONTROL, 'label' => 'FControl'),
16
+ );
17
+ }
18
+
19
+
20
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Banks.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Banks
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => '234', 'label' => 'Bradesco'),
37
+ array('value' => '341', 'label' => 'Itaú'),
38
+ array('value' => '033', 'label' => 'Santander'),
39
+ );
40
+ }
41
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/CctypeProductInstallments.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_CctypeProductInstallments
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => '', 'label' => 'Padrões'),
37
+ array('value' => 'VI', 'label' => 'Visa'),
38
+ array('value' => 'MC', 'label' => 'Mastercard'),
39
+ array('value' => 'AE', 'label' => 'Amex'),
40
+ array('value' => 'DI', 'label' => 'Diners'),
41
+ array('value' => 'EL', 'label' => 'Elo'),
42
+ array('value' => 'HI', 'label' => 'Hipercard'),
43
+ );
44
+ }
45
+
46
+
47
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Cctypes.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Cctypes
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => 'VI', 'label' => 'Visa'),
37
+ array('value' => 'MC', 'label' => 'Mastercard'),
38
+ array('value' => 'AE', 'label' => 'Amex'),
39
+ array('value' => 'DI', 'label' => 'Diners'),
40
+ array('value' => 'EL', 'label' => 'Elo'),
41
+ array('value' => 'HI', 'label' => 'Hipercard'),
42
+ );
43
+ }
44
+
45
+ public function getCcTypeForLabel($label){
46
+ $ccTypes = $this->toOptionArray();
47
+ foreach($ccTypes as $cc){
48
+ if($cc['label'] == $label){
49
+ return $cc['value'];
50
+ }
51
+ }
52
+ }
53
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Debit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2015 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Debit
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => '001', 'label' => 'Banco Do Brasil'),
37
+ array('value' => '237', 'label' => 'Bradesco'),
38
+ array('value' => '341', 'label' => 'Itaú'),
39
+ array('value' => 'VBV', 'label' => 'VBV'),
40
+ array('value' => 'cielo_mastercard', 'label' => 'Mastercard'),
41
+ array('value' => 'cielo_visa', 'label' => 'Visa'),
42
+ );
43
+ }
44
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Environment.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Environment
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return
36
+ array(
37
+ 'development' => Mage::helper('mundipagg')->__('Development'),
38
+ 'production' => Mage::helper('mundipagg')->__('Production'),
39
+ );
40
+ }
41
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/FControlEnvironment.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author Ruan Azevedo <razevedo@mundipagg.com>
5
+ * @since 2016-06-14
6
+ * Class Uecommerce_Mundipagg_Model_Source_Environment
7
+ */
8
+ class Uecommerce_Mundipagg_Model_Source_FControlEnvironment {
9
+
10
+ const SANDBOX = 1;
11
+ const PRODUCTION = 2;
12
+
13
+ const CONFIG_STRING = 'payment/mundipagg_standard/environment_fcontrol';
14
+
15
+ public function toOptionArray() {
16
+ return
17
+ array(
18
+ array('value' => self::SANDBOX, 'label' => Mage::helper('mundipagg')->__('Sandbox')),
19
+ array('value' => self::PRODUCTION, 'label' => Mage::helper('mundipagg')->__('Production')),
20
+ );
21
+ }
22
+
23
+ public static function getEnvironment(){
24
+ return Mage::getStoreConfig(self::CONFIG_STRING);
25
+ }
26
+
27
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Frequency.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Frequency extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
32
+ {
33
+ public function getAllOptions()
34
+ {
35
+ return array(
36
+ array('value' => '0', 'label' => 'Nenhuma'),
37
+ array('value' => 'Daily', 'label' => Mage::helper('mundipagg')->__('Daily')),
38
+ array('value' => 'Weekly', 'label' => Mage::helper('mundipagg')->__('Weekly')),
39
+ array('value' => 'Monthly', 'label' => Mage::helper('mundipagg')->__('Monthly')),
40
+ array('value' => 'Quarterly', 'label' => Mage::helper('mundipagg')->__('Quarterly')),
41
+ array('value' => 'Biannual', 'label' => Mage::helper('mundipagg')->__('Biannual')),
42
+ array('value' => 'Yearly', 'label' => Mage::helper('mundipagg')->__('Yearly'))
43
+ );
44
+ }
45
+
46
+ public function toOptionArray()
47
+ {
48
+ return $this->getAllOptions();
49
+ }
50
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/Installments.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_Installments
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array('value' => '2', 'label' => '2'),
37
+ array('value' => '3', 'label' => '3'),
38
+ array('value' => '4', 'label' => '4'),
39
+ array('value' => '5', 'label' => '5'),
40
+ array('value' => '6', 'label' => '6'),
41
+ array('value' => '7', 'label' => '7'),
42
+ array('value' => '8', 'label' => '8'),
43
+ array('value' => '9', 'label' => '9'),
44
+ array('value' => '10', 'label' => '10'),
45
+ array('value' => '11', 'label' => '11'),
46
+ array('value' => '12', 'label' => '12'),
47
+ );
48
+ }
49
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_PaymentAction
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array(
37
+ 'value' => 'order',
38
+ 'label' => Mage::helper('mundipagg')->__('AuthAndCapture')
39
+ ),
40
+ array(
41
+ 'value' => 'authorize',
42
+ 'label' => Mage::helper('mundipagg')->__('AuthOnly')
43
+ ),
44
+ /*
45
+ array(
46
+ 'value' => 'authorize_capture',
47
+ 'label' => Mage::helper('mundipagg')->__('AuthAndCaptureWithDelay')
48
+ ),
49
+ */
50
+ );
51
+ }
52
+ }
app/code/community/Uecommerce/Mundipagg/Model/Source/PaymentMethods.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Source_PaymentMethods
32
+ {
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array(
37
+ 'value' => 'BoletoBancario',
38
+ 'label' => Mage::helper('mundipagg')->__('Boleto Bancário')
39
+ ),
40
+ array(
41
+ 'value' => '1CreditCards',
42
+ 'label' => Mage::helper('mundipagg')->__('1 Credit Card')
43
+ ),
44
+ array(
45
+ 'value' => '2CreditCards',
46
+ 'label' => Mage::helper('mundipagg')->__('2 Credit Cards')
47
+ ),
48
+ array(
49
+ 'value' => '3CreditCards',
50
+ 'label' => Mage::helper('mundipagg')->__('3 Credit Cards')
51
+ ),
52
+ array(
53
+ 'value' => '4CreditCards',
54
+ 'label' => Mage::helper('mundipagg')->__('4 Credit Cards')
55
+ ),
56
+ array(
57
+ 'value' => '5CreditCards',
58
+ 'label' => Mage::helper('mundipagg')->__('5 Credit Cards')
59
+ ),
60
+ );
61
+ }
62
+ }
app/code/community/Uecommerce/Mundipagg/Model/Standard.php ADDED
@@ -0,0 +1,1869 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ class Uecommerce_Mundipagg_Model_Standard extends Mage_Payment_Model_Method_Abstract {
31
+ /**
32
+ * Availability options
33
+ */
34
+ protected $_code = 'mundipagg_standard';
35
+ protected $_formBlockType = 'mundipagg/standard_form';
36
+ protected $_infoBlockType = 'mundipagg/info';
37
+ protected $_isGateway = true;
38
+ protected $_canOrder = true;
39
+ protected $_canAuthorize = true;
40
+ protected $_canCapture = true;
41
+ protected $_canCapturePartial = false;
42
+ protected $_canRefund = true;
43
+ protected $_canVoid = true;
44
+ protected $_canUseInternal = false;
45
+ protected $_canUseCheckout = false;
46
+ protected $_canUseForMultishipping = true;
47
+ protected $_canSaveCc = false;
48
+ protected $_canFetchTransactionInfo = false;
49
+ protected $_canManageRecurringProfiles = false;
50
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
51
+ protected $_isInitializeNeeded = true;
52
+
53
+ /**
54
+ * Transaction ID
55
+ **/
56
+ protected $_transactionId = null;
57
+
58
+ /**
59
+ * CreditCardOperationEnum na gateway
60
+ * @var $CreditCardOperationEnum varchar
61
+ */
62
+ private $_creditCardOperationEnum;
63
+
64
+ public function getUrl() {
65
+ return $this->url;
66
+ }
67
+
68
+ public function setUrl($url) {
69
+ $this->url = $url;
70
+ }
71
+
72
+ public function setmerchantKey($merchantKey) {
73
+ $this->merchantKey = $merchantKey;
74
+ }
75
+
76
+ public function getmerchantKey() {
77
+ return $this->merchantKey;
78
+ }
79
+
80
+ public function setEnvironment($environment) {
81
+ $this->environment = $environment;
82
+ }
83
+
84
+ public function getEnvironment() {
85
+ return $this->environment;
86
+ }
87
+
88
+ public function setPaymentMethodCode($paymentMethodCode) {
89
+ $this->paymentMethodCode = $paymentMethodCode;
90
+ }
91
+
92
+ public function getPaymentMethodCode() {
93
+ return $this->paymentMethodCode;
94
+ }
95
+
96
+ public function setAntiFraud($antiFraud) {
97
+ $this->antiFraud = $antiFraud;
98
+ }
99
+
100
+ public function getAntiFraud() {
101
+ return $this->antiFraud;
102
+ }
103
+
104
+ public function setBankNumber($bankNumber) {
105
+ $this->bankNumber = $bankNumber;
106
+ }
107
+
108
+ public function getBankNumber() {
109
+ return $this->bankNumber;
110
+ }
111
+
112
+ public function setDebug($debug) {
113
+ $this->_debug = $debug;
114
+ }
115
+
116
+ public function getDebug() {
117
+ return $this->_debug;
118
+ }
119
+
120
+ public function setDiasValidadeBoleto($diasValidadeBoleto) {
121
+ $this->_diasValidadeBoleto = $diasValidadeBoleto;
122
+ }
123
+
124
+ public function getDiasValidadeBoleto() {
125
+ return $this->_diasValidadeBoleto;
126
+ }
127
+
128
+ public function setInstrucoesCaixa($instrucoesCaixa) {
129
+ $this->_instrucoesCaixa = $instrucoesCaixa;
130
+ }
131
+
132
+ public function getInstrucoesCaixa() {
133
+ return $this->_instrucoesCaixa;
134
+ }
135
+
136
+ public function setCreditCardOperationEnum($creditCardOperationEnum) {
137
+ $this->_creditCardOperationEnum = $creditCardOperationEnum;
138
+ }
139
+
140
+ public function getCreditCardOperationEnum() {
141
+ return $this->_creditCardOperationEnum;
142
+ }
143
+
144
+ public function setParcelamento($parcelamento) {
145
+ $this->parcelamento = $parcelamento;
146
+ }
147
+
148
+ public function getParcelamento() {
149
+ return $this->parcelamento;
150
+ }
151
+
152
+ public function setParcelamentoMax($parcelamentoMax) {
153
+ $this->parcelamentoMax = $parcelamentoMax;
154
+ }
155
+
156
+ public function getParcelamentoMax() {
157
+ return $this->parcelamentoMax;
158
+ }
159
+
160
+ public function setPaymentAction($paymentAction) {
161
+ $this->paymentAction = $paymentAction;
162
+ }
163
+
164
+ public function getPaymentAction() {
165
+ return $this->paymentAction;
166
+ }
167
+
168
+ public function setCieloSku($cieloSku) {
169
+ $this->cieloSku = $cieloSku;
170
+ }
171
+
172
+ public function getCieloSku() {
173
+ return $this->cieloSku;
174
+ }
175
+
176
+ public function __construct() {
177
+ $this->setEnvironment($this->getConfigData('environment'));
178
+ $this->setPaymentAction($this->getConfigData('payment_action'));
179
+
180
+ switch ($this->getConfigData('environment')) {
181
+ case 'localhost':
182
+ case 'development':
183
+ case 'staging':
184
+ default:
185
+ $this->setmerchantKey(trim($this->getConfigData('merchantKeyStaging')));
186
+ $this->setUrl(trim($this->getConfigData('apiUrlStaging')));
187
+ $this->setAntiFraud($this->getConfigData('antifraud'));
188
+ $this->setPaymentMethodCode(1);
189
+ $this->setBankNumber(341);
190
+ $this->setParcelamento($this->getConfigData('parcelamento'));
191
+ $this->setParcelamentoMax($this->getConfigData('parcelamento_max'));
192
+ $this->setDebug($this->getConfigData('debug'));
193
+ $this->setEnvironment($this->getConfigData('environment'));
194
+ $this->setCieloSku($this->getConfigData('cielo_sku'));
195
+ break;
196
+
197
+ case 'production':
198
+ $this->setmerchantKey(trim($this->getConfigData('merchantKeyProduction')));
199
+ $this->setUrl(trim($this->getConfigData('apiUrlProduction')));
200
+ $this->setAntiFraud($this->getConfigData('antifraud'));
201
+ $this->setParcelamento($this->getConfigData('parcelamento'));
202
+ $this->setParcelamentoMax($this->getConfigData('parcelamento_max'));
203
+ $this->setDebug($this->getConfigData('debug'));
204
+ $this->setEnvironment($this->getConfigData('environment'));
205
+ $this->setCieloSku($this->getConfigData('cielo_sku'));
206
+ break;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Armazena as informações passadas via formulário no frontend
212
+ * @access public
213
+ * @param array $data
214
+ * @return Uecommerce_Mundipagg_Model_Standard
215
+ */
216
+ public function assignData($data) {
217
+ if (!($data instanceof Varien_Object)) {
218
+ $data = new Varien_Object($data);
219
+ }
220
+
221
+ $info = $this->getInfoInstance();
222
+
223
+ $mundipagg = array();
224
+ $helper = Mage::helper('mundipagg');
225
+
226
+ foreach ($data->getData() as $id => $value) {
227
+ $mundipagg[$id] = $value;
228
+
229
+ //Mage::log($id.' '.$value, null, 'Uecommerce_Mundipagg.log');
230
+
231
+ // We verify if a CPF OR CNPJ is valid
232
+ $posTaxvat = strpos($id, 'taxvat');
233
+
234
+ if ($posTaxvat !== false && $value != '') {
235
+ if (!$helper->validateCPF($value) && !$helper->validateCNPJ($value)) {
236
+ $error = $helper->__('CPF or CNPJ is invalid');
237
+
238
+ Mage::throwException($error);
239
+ }
240
+ }
241
+ }
242
+
243
+ if (!empty($mundipagg)) {
244
+ $helperInstallments = Mage::helper('mundipagg/Installments');
245
+
246
+ //Set Mundipagg Data in Session
247
+ $session = Mage::getSingleton('checkout/session');
248
+ $session->setMundipaggData($mundipagg);
249
+
250
+ $info = $this->getInfoInstance();
251
+
252
+ if (isset($mundipagg['mundipagg_type'])) {
253
+ $info->setAdditionalInformation('PaymentMethod', $mundipagg['method']);
254
+
255
+ switch ($mundipagg['method']) {
256
+ case 'mundipagg_creditcard':
257
+ if (isset($mundipagg['mundipagg_creditcard_1_1_cc_type'])) {
258
+ if (array_key_exists('mundipagg_creditcard_credito_parcelamento_1_1', $mundipagg)) {
259
+ if ($mundipagg['mundipagg_creditcard_credito_parcelamento_1_1'] > $helperInstallments->getMaxInstallments($mundipagg['mundipagg_creditcard_1_1_cc_type'])) {
260
+ Mage::throwException($helper->__('it is not possible to divide by %s times', $mundipagg['mundipagg_creditcard_credito_parcelamento_1_1']));
261
+ }
262
+ }
263
+ $info->setCcType($mundipagg['mundipagg_creditcard_1_1_cc_type'])
264
+ ->setCcOwner($mundipagg['mundipagg_creditcard_cc_holder_name_1_1'])
265
+ ->setCcLast4(substr($mundipagg['mundipagg_creditcard_1_1_cc_number'], -4))
266
+ ->setCcNumber($mundipagg['mundipagg_creditcard_1_1_cc_number'])
267
+ ->setCcCid($mundipagg['mundipagg_creditcard_cc_cid_1_1'])
268
+ ->setCcExpMonth($mundipagg['mundipagg_creditcard_expirationMonth_1_1'])
269
+ ->setCcExpYear($mundipagg['mundipagg_creditcard_expirationYear_1_1']);
270
+ } else {
271
+ $info->setAdditionalInformation('mundipagg_creditcard_token_1_1', $mundipagg['mundipagg_creditcard_token_1_1']);
272
+ }
273
+
274
+ break;
275
+
276
+ default:
277
+
278
+ $info->setCcType(null)
279
+ ->setCcOwner(null)
280
+ ->setCcLast4(null)
281
+ ->setCcNumber(null)
282
+ ->setCcCid(null)
283
+ ->setCcExpMonth(null)
284
+ ->setCcExpYear(null);
285
+
286
+ break;
287
+ }
288
+
289
+ foreach ($mundipagg as $key => $value) {
290
+ // We don't save CcNumber
291
+ $posCcNumber = strpos($key, 'number');
292
+
293
+ // We don't save Security Code
294
+ $posCid = strpos($key, 'cid');
295
+
296
+ // We don't save Cc Holder name
297
+ $posHolderName = strpos($key, 'holder_name');
298
+
299
+ if ($value != '' &&
300
+ $posCcNumber === false &&
301
+ $posCid === false &&
302
+ $posHolderName === false
303
+ ) {
304
+ if (strpos($key, 'cc_type')) {
305
+ $value = $helper->issuer($value);
306
+ }
307
+
308
+ $info->setAdditionalInformation($key, $value);
309
+ }
310
+ }
311
+
312
+ // We check if quote grand total is equal to installments sum
313
+ if ($mundipagg['method'] != 'mundipagg_boleto'
314
+ && $mundipagg['method'] != 'mundipagg_creditcardoneinstallment'
315
+ && $mundipagg['method'] != 'mundipagg_creditcard'
316
+ ) {
317
+ $num = $helper->getCreditCardsNumber($mundipagg['method']);
318
+ $method = $helper->getPaymentMethod($num);
319
+
320
+ (float)$grandTotal = $info->getQuote()->getGrandTotal();
321
+ (float)$totalInstallmentsToken = 0;
322
+ (float)$totalInstallmentsNew = 0;
323
+ (float)$totalInstallments = 0;
324
+
325
+ for ($i = 1; $i <= $num; $i++) {
326
+
327
+ if (isset($mundipagg[$method . '_token_' . $num . '_' . $i]) && $mundipagg[$method . '_token_' . $num . '_' . $i] != 'new') {
328
+ (float)$value = str_replace(',', '.', $mundipagg[$method . '_value_' . $num . '_' . $i]);
329
+
330
+ if (array_key_exists($method . '_credito_parcelamento_' . $num . '_' . $i, $mundipagg)) {
331
+ if (!array_key_exists($method . '_' . $num . '_' . $i . '_cc_type', $mundipagg)) {
332
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($mundipagg[$method . '_token_' . $num . '_' . $i]);
333
+
334
+ $mundipagg[$method . '_' . $num . '_' . $i . '_cc_type'] = Mage::helper('mundipagg')->getCardTypeByIssuer($cardonFile->getCcType());
335
+ }
336
+
337
+ if ($mundipagg[$method . '_credito_parcelamento_' . $num . '_' . $i] > $helperInstallments->getMaxInstallments($mundipagg[$method . '_' . $num . '_' . $i . '_cc_type'], $value)) {
338
+ Mage::throwException($helper->__('it is not possible to divide by %s times', $mundipagg[$method . '_credito_parcelamento_' . $num . '_' . $i]));
339
+ }
340
+ }
341
+
342
+ (float)$totalInstallmentsToken += $value;
343
+ } else {
344
+ (float)$value = str_replace(',', '.', $mundipagg[$method . '_new_value_' . $num . '_' . $i]);
345
+
346
+ if (array_key_exists($method . '_new_credito_parcelamento_' . $num . '_' . $i, $mundipagg)) {
347
+ if ($mundipagg[$method . '_new_credito_parcelamento_' . $num . '_' . $i] > $helperInstallments->getMaxInstallments($mundipagg[$method . '_' . $num . '_' . $i . '_cc_type'], $value)) {
348
+ Mage::throwException($helper->__('it is not possible to divide by %s times', $mundipagg[$method . '_new_credito_parcelamento_' . $num . '_' . $i]));
349
+ }
350
+ }
351
+
352
+ (float)$totalInstallmentsNew += $value;
353
+ }
354
+ }
355
+
356
+ // Total Installments from token and Credit Card
357
+ (float)$totalInstallments = $totalInstallmentsToken + $totalInstallmentsNew;
358
+
359
+ //Mage::log('totalInstallmentsToken: '. $totalInstallmentsToken, null, 'Uecommerce_Mundipagg.log');
360
+ //Mage::log('totalInstallmentsNew: '. $totalInstallmentsNew, null, 'Uecommerce_Mundipagg.log');
361
+
362
+ // If an amount has already been authorized
363
+ if (isset($mundipagg['multi']) && Mage::getSingleton('checkout/session')->getAuthorizedAmount()) {
364
+ //Mage::log('multi already authorized', null, 'Uecommerce_Mundipagg.log');
365
+
366
+ (float)$totalInstallments += (float)Mage::getSingleton('checkout/session')->getAuthorizedAmount();
367
+
368
+ // Unset session
369
+ Mage::getSingleton('checkout/session')->setAuthorizedAmount();
370
+ }
371
+
372
+ // Mage::log('grandTotal: '.$grandTotal, null, 'Uecommerce_Mundipagg.log');
373
+ // Mage::log('totalInstallments: '.$totalInstallments, null, 'Uecommerce_Mundipagg.log');
374
+ // Mage::log('getPaymentInterest: '. $info->getPaymentInterest());
375
+ // Mage::log('cal: '. abs($grandTotal-$totalInstallments-$info->getPaymentInterest()), null, 'Uecommerce_Mundipagg.log');
376
+
377
+
378
+ $epsilon = 0.00001;
379
+
380
+ if ($totalInstallments > 0 && ($grandTotal - $totalInstallments - $info->getPaymentInterest()) > $epsilon) {
381
+ Mage::throwException(Mage::helper('payment')->__('Installments does not match with quote.'));
382
+ }
383
+ }
384
+ } else {
385
+ if (isset($mundipagg['method'])) {
386
+ $info->setAdditionalInformation('PaymentMethod', $mundipagg['method']);
387
+ }
388
+ }
389
+ }
390
+
391
+ // Get customer_id from Quote (payment made on site) or from POST (payment made from API)
392
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
393
+ if ($this->getQuote()->getCustomer()->getEntityId()) {
394
+ $customerId = $this->getQuote()->getCustomer()->getEntityId();
395
+ }
396
+ } elseif (isset($mundipagg['entity_id'])) {
397
+ $customerId = $mundipagg['entity_id'];
398
+ }
399
+
400
+ // We verifiy if token is from customer
401
+ if (isset($customerId) && isset($mundipagg['method'])) {
402
+ $num = $helper->getCreditCardsNumber($mundipagg['method']);
403
+
404
+ if ($num == 0) {
405
+ $num = 1;
406
+ }
407
+
408
+ foreach ($mundipagg as $key => $value) {
409
+ $pos = strpos($key, 'token_' . $num);
410
+
411
+ if ($pos !== false && $value != '' && $value != 'new') {
412
+ $token = Mage::getModel('mundipagg/cardonfile')->load($value);
413
+
414
+ if ($token->getId() && $token->getEntityId() == $customerId) {
415
+ // Ok
416
+ $info->setAdditionalInformation('CreditCardBrandEnum_' . $key, $token->getCcType());
417
+ } else {
418
+ $error = $helper->__('Token not found');
419
+
420
+ //Log error
421
+ Mage::log($error, null, 'Uecommerce_Mundipagg.log');
422
+
423
+ Mage::throwException($error);
424
+ }
425
+ }
426
+ }
427
+ }
428
+
429
+ return $this;
430
+ }
431
+
432
+ /**
433
+ * Prepare info instance for save
434
+ *
435
+ * @return Mage_Payment_Model_Abstract
436
+ */
437
+ public function prepareSave() {
438
+ $info = $this->getInfoInstance();
439
+ if ($this->_canSaveCc) {
440
+ $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
441
+ }
442
+
443
+ $info->setCcNumber(null);
444
+
445
+ return $this;
446
+ }
447
+
448
+ /**
449
+ * Get payment quote
450
+ */
451
+ public function getPayment() {
452
+ return $this->getQuote()->getPayment();
453
+ }
454
+
455
+ /**
456
+ * Get Modulo session namespace
457
+ *
458
+ * @return Uecommerce_Mundipagg_Model_Session
459
+ */
460
+ public function getSession() {
461
+ return Mage::getSingleton('mundipagg/session');
462
+ }
463
+
464
+ /**
465
+ * Get checkout session namespace
466
+ *
467
+ * @return Mage_Checkout_Model_Session
468
+ */
469
+ public function getCheckout() {
470
+ return Mage::getSingleton('checkout/session');
471
+ }
472
+
473
+ /**
474
+ * Get current quote
475
+ *
476
+ * @return Mage_Sales_Model_Quote
477
+ */
478
+ public function getQuote() {
479
+ return $this->getCheckout()->getQuote();
480
+ }
481
+
482
+ /**
483
+ * Check order availability
484
+ *
485
+ * @return bool
486
+ */
487
+ public function canOrder() {
488
+ return $this->_canOrder;
489
+ }
490
+
491
+ /**
492
+ * Check authorize availability
493
+ *
494
+ * @return bool
495
+ */
496
+ public function canAuthorize() {
497
+ return $this->_canAuthorize;
498
+ }
499
+
500
+ /**
501
+ * Check capture availability
502
+ *
503
+ * @return bool
504
+ */
505
+ public function canCapture() {
506
+ return $this->_canCapture;
507
+ }
508
+
509
+ /**
510
+ * Instantiate state and set it to state object
511
+ *
512
+ * @param string $paymentAction
513
+ * @param Varien_Object
514
+ */
515
+ public function initialize($paymentAction, $stateObject) {
516
+ // TODO move initialize method to appropriate model (Boleto, Creditcard ...)
517
+ $paymentAction = $this->getPaymentAction();
518
+
519
+ switch ($paymentAction) {
520
+ case 'order':
521
+ $this->setCreditCardOperationEnum('AuthAndCapture');
522
+ break;
523
+
524
+ case 'authorize':
525
+ $this->setCreditCardOperationEnum('AuthOnly');
526
+ break;
527
+
528
+ case 'authorize_capture':
529
+ $this->setCreditCardOperationEnum('AuthAndCaptureWithDelay');
530
+ break;
531
+ }
532
+
533
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
534
+
535
+ if (version_compare($mageVersion, '1.5.0', '<')) {
536
+ $orderAction = 'order';
537
+ } else {
538
+ $orderAction = Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
539
+ }
540
+
541
+ $payment = $this->getInfoInstance();
542
+ $order = $payment->getOrder();
543
+
544
+ // If payment method is Boleto Bancário we call "order" method
545
+ if ($payment->getAdditionalInformation('PaymentMethod') == 'mundipagg_boleto') {
546
+ $this->order($payment, $order->getBaseTotalDue());
547
+
548
+ return $this;
549
+ }
550
+
551
+ // If it's a multi-payment types we force to ACTION_AUTHORIZE
552
+ $num = Mage::helper('mundipagg')->getCreditCardsNumber($payment->getAdditionalInformation('PaymentMethod'));
553
+
554
+ if ($num > 1) {
555
+ $paymentAction = Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
556
+ }
557
+
558
+ switch ($paymentAction) {
559
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
560
+ $payment->authorize($payment, $order->getBaseTotalDue());
561
+ break;
562
+
563
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
564
+ $payment->authorize($payment, $order->getBaseTotalDue());
565
+ break;
566
+
567
+ case $orderAction:
568
+ $this->order($payment, $order->getBaseTotalDue());
569
+ break;
570
+
571
+ default:
572
+ $this->order($payment, $order->getBaseTotalDue());
573
+ break;
574
+ }
575
+ }
576
+
577
+ /**
578
+ * Authorize payment abstract method
579
+ *
580
+ * @param Varien_Object $payment
581
+ * @param float $amount
582
+ *
583
+ * @return Mage_Payment_Model_Abstract
584
+ */
585
+ public function authorize(Varien_Object $payment, $amount) {
586
+ try {
587
+ if (!$this->canAuthorize()) {
588
+ Mage::throwException(Mage::helper('payment')->__('Authorize action is not available.'));
589
+ }
590
+
591
+ // Load order
592
+ $order = $payment->getOrder();
593
+
594
+ // Proceed to authorization on Gateway
595
+ $resultPayment = $this->doPayment($payment, $order);
596
+
597
+ // We record transaction(s)
598
+ if (isset($resultPayment['result'])) {
599
+ $xml = $resultPayment['result'];
600
+ $json = json_encode($xml);
601
+
602
+ $resultPayment['result'] = array();
603
+ $resultPayment['result'] = json_decode($json, true);
604
+
605
+ if (isset($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult)) {
606
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
607
+ $trans = $resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
608
+
609
+ $transaction = $this->_addTransaction($payment, $trans['TransactionKey'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, $trans);
610
+ } else {
611
+ foreach ($resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
612
+ $transaction = $this->_addTransaction($payment, $trans['TransactionKey'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, $trans, $key);
613
+ }
614
+ }
615
+ }
616
+ }
617
+
618
+ // Return
619
+ if (isset($resultPayment['error'])) {
620
+ try {
621
+ $payment->setSkipOrderProcessing(true)->save();
622
+
623
+ Mage::throwException(Mage::helper('mundipagg')->__($resultPayment['ErrorDescription']));
624
+ } catch (Exception $e) {
625
+ Mage::logException($e);
626
+
627
+ return $this;
628
+ }
629
+ } else {
630
+ // Send new order email when not in admin
631
+ if (Mage::app()->getStore()->getCode() != 'admin') {
632
+ $order->sendNewOrderEmail();
633
+ }
634
+
635
+ if (isset($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult)) {
636
+ $creditCardTransactionResultCollection = $xml->CreditCardTransactionResultCollection->CreditCardTransactionResult;
637
+
638
+ // We can capture only if:
639
+ // 1. Multiple Credit Cards Payment
640
+ // 2. Anti fraud is disabled
641
+ // 3. Payment action is "AuthorizeAndCapture"
642
+ if (
643
+ count($creditCardTransactionResultCollection) > 1 &&
644
+ $this->getAntiFraud() == 0 &&
645
+ $this->getPaymentAction() == 'order'
646
+ ) {
647
+ $this->captureAndcreateInvoice($payment);
648
+ }
649
+ }
650
+ }
651
+
652
+ return $this;
653
+ } catch (Exception $e) {
654
+ Mage::logException($e);
655
+ }
656
+ }
657
+
658
+ /**
659
+ * Capture payment abstract method
660
+ *
661
+ * @param Varien_Object $payment
662
+ * @param float $amount
663
+ *
664
+ * @return Mage_Payment_Model_Abstract
665
+ */
666
+ public function capture(Varien_Object $payment, $amount) {
667
+ $helper = Mage::helper('payment');
668
+
669
+ if (!$this->canCapture()) {
670
+ Mage::throwException($helper->__('Capture action is not available.'));
671
+ }
672
+
673
+ if ($payment->getAdditionalInformation('PaymentMethod') == 'mundipagg_boleto') {
674
+ Mage::throwException($helper->__('You cannot capture Boleto Bancário.'));
675
+ }
676
+
677
+ if ($this->getAntiFraud() == 1) {
678
+ Mage::throwException($helper->__('You cannot capture having anti fraud activated.'));
679
+ }
680
+
681
+ // Already captured
682
+ if ($payment->getAdditionalInformation('CreditCardTransactionStatusEnum') == 'Captured' || $payment->getAdditionalInformation('CreditCardTransactionStatus') == 'Captured') {
683
+ return $this;
684
+ }
685
+
686
+ // Prepare data in order to capture
687
+ if ($payment->getAdditionalInformation('OrderKey')) {
688
+ $transactions = Mage::getModel('sales/order_payment_transaction')
689
+ ->getCollection()
690
+ ->addAttributeToFilter('order_id', array('eq' => $payment->getOrder()->getEntityId()))
691
+ ->addAttributeToFilter('txn_type', array('eq' => 'authorization'));
692
+
693
+ foreach ($transactions as $key => $transaction) {
694
+ $TransactionKey = $transaction->getAdditionalInformation('TransactionKey');
695
+ $TransactionReference = $transaction->getAdditionalInformation('TransactionReference');
696
+ }
697
+
698
+ $data['CreditCardTransactionCollection']['AmountInCents'] = $payment->getOrder()->getBaseGrandTotal() * 100;
699
+ $data['CreditCardTransactionCollection']['TransactionKey'] = $TransactionKey;
700
+ $data['CreditCardTransactionCollection']['TransactionReference'] = $TransactionReference;
701
+ $data['OrderKey'] = $payment->getAdditionalInformation('OrderKey');
702
+ $data['ManageOrderOperationEnum'] = 'Capture';
703
+
704
+ //Call Gateway Api
705
+ $api = Mage::getModel('mundipagg/api');
706
+
707
+ $capture = $api->manageOrderRequest($data, $this);
708
+
709
+ // Xml
710
+ $xml = $capture['result'];
711
+ $json = json_encode($xml);
712
+
713
+ $capture['result'] = array();
714
+ $capture['result'] = json_decode($json, true);
715
+
716
+ // Save transactions
717
+ if (isset($capture['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'])) {
718
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
719
+ $trans = $capture['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
720
+
721
+ $this->_addTransaction($payment, $trans['TransactionKey'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $trans);
722
+ } else {
723
+ $CapturedAmountInCents = 0;
724
+
725
+ foreach ($capture['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
726
+ $TransactionKey = $trans['TransactionKey'];
727
+ $CapturedAmountInCents += $trans['CapturedAmountInCents'];
728
+ }
729
+
730
+ $trans = array();
731
+ $trans['CapturedAmountInCents'] = $CapturedAmountInCents;
732
+ $trans['Success'] = true;
733
+
734
+ $this->_addTransaction($payment, $TransactionKey, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $trans);
735
+ }
736
+ } else {
737
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
738
+
739
+ return false;
740
+ }
741
+ } else {
742
+ Mage::throwException(Mage::helper('mundipagg')->__('No OrderKey found.'));
743
+
744
+ return false;
745
+ }
746
+ }
747
+
748
+ /**
749
+ * Capture payment abstract method
750
+ *
751
+ * @param Varien_Object $payment
752
+ * @param float $amount
753
+ *
754
+ * @return Mage_Payment_Model_Abstract
755
+ */
756
+ public function captureAndcreateInvoice(Varien_Object $payment) {
757
+ $order = $payment->getOrder();
758
+
759
+ // Capture
760
+ $capture = $this->capture($payment, $order->getGrandTotal());
761
+
762
+ // Error
763
+ if (!$capture) {
764
+ return $this;
765
+ }
766
+
767
+ // Create invoice
768
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice(array());
769
+ $invoice->register();
770
+
771
+ $invoice->setCanVoidFlag(true);
772
+ $invoice->getOrder()->setIsInProcess(true);
773
+ $invoice->setState(2);
774
+
775
+ if (Mage::helper('sales')->canSendNewInvoiceEmail($order->getStoreId())) {
776
+ $invoice->setEmailSent(true);
777
+ $invoice->sendEmail();
778
+ }
779
+
780
+ $invoice->save();
781
+
782
+ $order->setBaseTotalPaid($order->getBaseGrandTotal());
783
+ $order->setTotalPaid($order->getBaseGrandTotal());
784
+ $order->addStatusHistoryComment('Captured online amount of R$' . $order->getBaseGrandTotal(), false);
785
+ $order->save();
786
+
787
+ return $this;
788
+ }
789
+
790
+ /**
791
+ * Order payment abstract method
792
+ *
793
+ * @param Varien_Object $payment
794
+ * @param float $amount
795
+ *
796
+ * @return Mage_Payment_Model_Abstract
797
+ */
798
+ public function order(Varien_Object $payment, $amount) {
799
+ if (!$this->canOrder()) {
800
+ Mage::throwException(Mage::helper('payment')->__('Order action is not available.'));
801
+ }
802
+
803
+ // Load order
804
+ $order = $payment->getOrder();
805
+
806
+ $order = Mage::getModel('sales/order')->loadByIncrementId($order->getRealOrderId());
807
+
808
+ // Proceed to payment on Gateway
809
+ $resultPayment = $this->doPayment($payment, $order);
810
+
811
+ // Return error
812
+ if (isset($resultPayment['error'])) {
813
+ try {
814
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
815
+
816
+ if (version_compare($mageVersion, '1.5.0', '<')) {
817
+ $transactionType = 'payment';
818
+ } else {
819
+ $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER;
820
+ }
821
+
822
+ // Xml
823
+ $xml = $resultPayment['result'];
824
+ $json = json_encode($xml);
825
+
826
+ $resultPayment['result'] = array();
827
+ $resultPayment['result'] = json_decode($json, true);
828
+
829
+ // We record transaction(s)
830
+ if (isset($resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'])) {
831
+ if (count($resultPayment['result']['CreditCardTransactionResultCollection']) == 1) {
832
+ $trans = $resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
833
+
834
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans);
835
+ } else {
836
+ foreach ($resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
837
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans, $key);
838
+ }
839
+ }
840
+ }
841
+
842
+ if (isset($resultPayment['ErrorItemCollection'])) {
843
+ if (count($resultPayment['ErrorItemCollection']) == 1) {
844
+ foreach ($resultPayment['ErrorItemCollection']['ErrorItem'] as $key => $value) {
845
+ $payment->setAdditionalInformation($key, $value)->save();
846
+ }
847
+ } else {
848
+ foreach ($resultPayment['ErrorItemCollection'] as $key1 => $error) {
849
+ foreach ($error as $key2 => $value) {
850
+ $payment->setAdditionalInformation($key1 . '_' . $key2, $value)->save();
851
+ }
852
+ }
853
+ }
854
+ }
855
+
856
+ $payment->setSkipOrderProcessing(true)->save();
857
+
858
+ if (isset($resultPayment['ErrorDescription'])) {
859
+ $order->addStatusHistoryComment(Mage::helper('mundipagg')->__(htmlspecialchars_decode($resultPayment['ErrorDescription'])));
860
+ $order->save();
861
+
862
+ Mage::throwException(Mage::helper('mundipagg')->__($resultPayment['ErrorDescription']));
863
+ } else {
864
+ Mage::throwException(Mage::helper('mundipagg')->__('Erro'));
865
+ }
866
+ } catch (Exception $e) {
867
+ return $this;
868
+ }
869
+ } else {
870
+ if (isset($resultPayment['message'])) {
871
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
872
+
873
+ if (version_compare($mageVersion, '1.5.0', '<')) {
874
+ $transactionType = 'payment';
875
+ } else {
876
+ $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER;
877
+ }
878
+
879
+ // Xml
880
+ $xml = $resultPayment['result'];
881
+ $json = json_encode($xml);
882
+
883
+ $resultPayment['result'] = array();
884
+ $resultPayment['result'] = json_decode($json, true);
885
+
886
+ switch ($resultPayment['message']) {
887
+ // Boleto
888
+ case 0:
889
+ $payment->setAdditionalInformation('BoletoUrl', $resultPayment['result']['BoletoTransactionResultCollection']['BoletoTransactionResult']['BoletoUrl']);
890
+
891
+ // In order to show "Print Boleto" link in order email
892
+ $order->getPayment()->setAdditionalInformation('BoletoUrl', $resultPayment['result']['BoletoTransactionResultCollection']['BoletoTransactionResult']['BoletoUrl']);
893
+
894
+ // We record transaction(s)
895
+ if (count($resultPayment['result']['BoletoTransactionResultCollection']) == 1) {
896
+ $trans = $resultPayment['result']['BoletoTransactionResultCollection']['BoletoTransactionResult'];
897
+
898
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans);
899
+ } else {
900
+ foreach ($resultPayment['result']['BoletoTransactionResultCollection']['BoletoTransactionResult'] as $key => $trans) {
901
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans, $key);
902
+ }
903
+ }
904
+
905
+ $payment->setTransactionId($this->_transactionId);
906
+
907
+ $payment->save();
908
+
909
+ // Send new order email when not in admin
910
+ if (Mage::app()->getStore()->getCode() != 'admin') {
911
+ $order->sendNewOrderEmail();
912
+ }
913
+
914
+ break;
915
+
916
+ // Credit Card
917
+ case 1:
918
+ // We record transaction(s)
919
+ if (count($resultPayment['result']['CreditCardTransactionResultCollection']) == 1) {
920
+ $trans = $resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
921
+ if (array_key_exists('TransactionKey', $trans)) {
922
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans);
923
+ }
924
+ } else {
925
+ foreach ($resultPayment['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
926
+ if (array_key_exists('TransactionKey', $trans)) {
927
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans, $key);
928
+ }
929
+ }
930
+ }
931
+
932
+ // Send new order email when not in admin
933
+ if (Mage::app()->getStore()->getCode() != 'admin') {
934
+ $order->sendNewOrderEmail();
935
+ }
936
+
937
+ // Invoice
938
+ $order = $payment->getOrder();
939
+
940
+ if (!$order->canInvoice()) {
941
+ // Log error
942
+ Mage::logException(Mage::helper('core')->__('Cannot create an invoice.'));
943
+
944
+ Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
945
+ }
946
+
947
+ // Create invoice
948
+ $invoice = Mage::getModel('sales/service_order', $payment->getOrder())->prepareInvoice(array());
949
+ $invoice->register();
950
+
951
+ // Set capture case to offline and register the invoice.
952
+ $invoice->setTransactionId($this->_transactionId);
953
+ $invoice->setCanVoidFlag(true);
954
+ $invoice->getOrder()->setIsInProcess(true);
955
+ $invoice->setState(2);
956
+
957
+ // Send invoice if enabled
958
+ if (Mage::helper('sales')->canSendNewInvoiceEmail($order->getStoreId())) {
959
+ $invoice->setEmailSent(true);
960
+ $invoice->sendEmail();
961
+ }
962
+
963
+ $invoice->save();
964
+
965
+ $order->setBaseTotalPaid($order->getBaseGrandTotal());
966
+ $order->setTotalPaid($order->getBaseGrandTotal());
967
+ $order->addStatusHistoryComment('Captured online amount of R$' . $order->getBaseGrandTotal(), false);
968
+ $order->save();
969
+
970
+ $payment->setLastTransId($this->_transactionId);
971
+ $payment->save();
972
+
973
+ break;
974
+
975
+ // Debit
976
+ case 4:
977
+ // We record transaction
978
+ $trans = $resultPayment['result'];
979
+
980
+ $this->_addTransaction($payment, $trans['TransactionKey'], $transactionType, $trans);
981
+ break;
982
+ }
983
+ }
984
+
985
+ return $this;
986
+ }
987
+ }
988
+
989
+ /**
990
+ * Proceed to payment
991
+ * @param object $order
992
+ */
993
+ public function doPayment($payment, $order) {
994
+ try {
995
+ $session = Mage::getSingleton('checkout/session');
996
+ $mundipaggData = $session->getMundipaggData();
997
+
998
+ //Post data
999
+ $postData = Mage::app()->getRequest()->getPost();
1000
+
1001
+ // Get customer taxvat
1002
+ $taxvat = '';
1003
+
1004
+ if ($order->getCustomerTaxvat() == '') {
1005
+ $customerId = $order->getCustomerId();
1006
+
1007
+ if ($customerId) {
1008
+ $customer = Mage::getModel('customer/customer')->load($customerId);
1009
+
1010
+ $taxvat = $customer->getTaxvat();
1011
+ }
1012
+
1013
+ if ($taxvat != '') {
1014
+ $order->setCustomerTaxvat($taxvat)->save();
1015
+ }
1016
+ } else {
1017
+ $taxvat = $order->getCustomerTaxvat();
1018
+ }
1019
+
1020
+ // Data to pass to api
1021
+ $data['customer_id'] = $order->getCustomerId();
1022
+ $data['address_id'] = $order->getBillingAddress()->getCustomerAddressId();
1023
+ $data['payment_method'] = isset($postData['payment']['method']) ? $postData['payment']['method'] : $mundipaggData['method'];
1024
+
1025
+ $type = $data['payment_method'];
1026
+
1027
+ // 1 or more Credit Cards Payment
1028
+ if ($data['payment_method'] != 'mundipagg_boleto' && $data['payment_method'] != 'mundipagg_debit') {
1029
+ $helper = Mage::helper('mundipagg');
1030
+
1031
+ $num = $helper->getCreditCardsNumber($type);
1032
+
1033
+ $method = $helper->getPaymentMethod($num);
1034
+
1035
+ if ($num == 0) {
1036
+ $num = 1;
1037
+ }
1038
+
1039
+ for ($i = 1; $i <= $num; $i++) {
1040
+ // New Credit Card
1041
+ if (
1042
+ !isset($postData['payment'][$method . '_token_' . $num . '_' . $i]) ||
1043
+ (isset($postData['payment'][$method . '_token_' . $num . '_' . $i]) && $postData['payment'][$method . '_token_' . $num . '_' . $i] == 'new')
1044
+ ) {
1045
+ $data['payment'][$i]['HolderName'] = isset($postData['payment'][$method . '_cc_holder_name_' . $num . '_' . $i]) ? $postData['payment'][$method . '_cc_holder_name_' . $num . '_' . $i] : $mundipaggData[$method . '_cc_holder_name_' . $num . '_' . $i];
1046
+ $data['payment'][$i]['CreditCardNumber'] = isset($postData['payment'][$method . '_' . $num . '_' . $i . '_cc_number']) ? $postData['payment'][$method . '_' . $num . '_' . $i . '_cc_number'] : $mundipaggData[$method . '_' . $num . '_' . $i . '_cc_number'];
1047
+ $data['payment'][$i]['ExpMonth'] = isset($postData['payment'][$method . '_expirationMonth_' . $num . '_' . $i]) ? $postData['payment'][$method . '_expirationMonth_' . $num . '_' . $i] : $mundipaggData[$method . '_expirationMonth_' . $num . '_' . $i];
1048
+ $data['payment'][$i]['ExpYear'] = isset($postData['payment'][$method . '_expirationYear_' . $num . '_' . $i]) ? $postData['payment'][$method . '_expirationYear_' . $num . '_' . $i] : $mundipaggData[$method . '_expirationYear_' . $num . '_' . $i];
1049
+ $data['payment'][$i]['SecurityCode'] = isset($postData['payment'][$method . '_cc_cid_' . $num . '_' . $i]) ? $postData['payment'][$method . '_cc_cid_' . $num . '_' . $i] : $mundipaggData[$method . '_cc_cid_' . $num . '_' . $i];
1050
+ $data['payment'][$i]['CreditCardBrandEnum'] = Mage::helper('mundipagg')->issuer(isset($postData['payment'][$method . '_' . $num . '_' . $i . '_cc_type']) ? $postData['payment'][$method . '_' . $num . '_' . $i . '_cc_type'] : $mundipaggData[$method . '_' . $num . '_' . $i . '_cc_type']);
1051
+ $data['payment'][$i]['InstallmentCount'] = isset($postData['payment'][$method . '_new_credito_parcelamento_' . $num . '_' . $i]) ? $postData['payment'][$method . '_new_credito_parcelamento_' . $num . '_' . $i] : 1;
1052
+ $data['payment'][$i]['token'] = isset($postData['payment'][$method . '_save_token_' . $num . '_' . $i]) ? $postData['payment'][$method . '_save_token_' . $num . '_' . $i] : null;
1053
+
1054
+ if (isset($postData['payment'][$method . '_new_value_' . $num . '_' . $i]) && $postData['payment'][$method . '_new_value_' . $num . '_' . $i] != '') {
1055
+ $data['payment'][$i]['AmountInCents'] = str_replace(',', '.', $postData['payment'][$method . '_new_value_' . $num . '_' . $i]);
1056
+ $data['payment'][$i]['AmountInCents'] = $data['payment'][$i]['AmountInCents'] + Mage::helper('mundipagg/installments')->getInterestForCard($data['payment'][$i]['InstallmentCount'], isset($postData['payment'][$method . '_' . $num . '_' . $i . '_cc_type']) ? $postData['payment'][$method . '_' . $num . '_' . $i . '_cc_type'] : $mundipaggData[$method . '_' . $num . '_' . $i . '_cc_type'], $data['payment'][$i]['AmountInCents']);
1057
+
1058
+ $data['payment'][$i]['AmountInCents'] = $data['payment'][$i]['AmountInCents'] * 100;
1059
+ } else {
1060
+ if (!isset($postData['partial'])) {
1061
+ $data['payment'][$i]['AmountInCents'] = $order->getGrandTotal() * 100;
1062
+ } else { // If partial payment we deduct authorized amount already processed
1063
+ if (Mage::getSingleton('checkout/session')->getAuthorizedAmount()) {
1064
+ $data['payment'][$i]['AmountInCents'] = ($order->getGrandTotal()) * 100 - Mage::getSingleton('checkout/session')->getAuthorizedAmount() * 100;
1065
+ } else {
1066
+ $data['payment'][$i]['AmountInCents'] = ($order->getGrandTotal()) * 100;
1067
+ }
1068
+ }
1069
+ }
1070
+
1071
+ $data['payment'][$i]['TaxDocumentNumber'] = isset($postData['payment'][$method . '_cc_taxvat_' . $num . '_' . $i]) ? $postData['payment'][$method . '_cc_taxvat_' . $num . '_' . $i] : $taxvat;
1072
+ } else { // Token
1073
+ $data['payment'][$i]['card_on_file_id'] = isset($postData['payment'][$method . '_token_' . $num . '_' . $i]) ? $postData['payment'][$method . '_token_' . $num . '_' . $i] : $mundipaggData[$method . '_token_' . $num . '_' . $i];
1074
+ $data['payment'][$i]['InstallmentCount'] = isset($postData['payment'][$method . '_credito_parcelamento_' . $num . '_' . $i]) ? $postData['payment'][$method . '_credito_parcelamento_' . $num . '_' . $i] : 1;
1075
+
1076
+ if (isset($postData['payment'][$method . '_value_' . $num . '_' . $i]) && $postData['payment'][$method . '_value_' . $num . '_' . $i] != '') {
1077
+ $data['payment'][$i]['AmountInCents'] = str_replace(',', '.', $postData['payment'][$method . '_value_' . $num . '_' . $i]);
1078
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($postData['payment'][$method . '_token_' . $num . '_' . $i]);
1079
+ $tokenCctype = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
1080
+ $data['payment'][$i]['AmountInCents'] = $data['payment'][$i]['AmountInCents'] + Mage::helper('mundipagg/installments')->getInterestForCard($data['payment'][$i]['InstallmentCount'], $tokenCctype, $data['payment'][$i]['AmountInCents']);
1081
+ $data['payment'][$i]['AmountInCents'] = $data['payment'][$i]['AmountInCents'] * 100;
1082
+
1083
+ } else {
1084
+ if (!isset($postData['partial'])) {
1085
+ $data['payment'][$i]['AmountInCents'] = $order->getGrandTotal() * 100;
1086
+ } else { // If partial payment we deduct authorized amount already processed
1087
+ if (Mage::getSingleton('checkout/session')->getAuthorizedAmount()) {
1088
+ $data['payment'][$i]['AmountInCents'] = ($order->getGrandTotal()) * 100 - Mage::getSingleton('checkout/session')->getAuthorizedAmount() * 100;
1089
+ } else {
1090
+ $data['payment'][$i]['AmountInCents'] = $order->getGrandTotal() * 100;
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ $data['payment'][$i]['TaxDocumentNumber'] = isset($postData['payment'][$method . '_cc_taxvat_' . $num . '_' . $i]) ? $postData['payment'][$method . '_cc_taxvat_' . $num . '_' . $i] : $taxvat;
1096
+ }
1097
+
1098
+ if (Mage::helper('mundipagg')->validateCPF($data['payment'][$i]['TaxDocumentNumber'])) {
1099
+ $data['PersonTypeEnum'] = 'Person';
1100
+ $data['TaxDocumentTypeEnum'] = 'CPF';
1101
+ $data['TaxDocumentNumber'] = $data['payment'][$i]['TaxDocumentNumber'];
1102
+ }
1103
+
1104
+ // We verify if a CNPJ is informed
1105
+ if (Mage::helper('mundipagg')->validateCNPJ($data['payment'][$i]['TaxDocumentNumber'])) {
1106
+ $data['PersonTypeEnum'] = 'Company';
1107
+ $data['TaxDocumentTypeEnum'] = 'CNPJ';
1108
+ $data['TaxDocumentNumber'] = $data['payment'][$i]['TaxDocumentNumber'];
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ // Boleto Payment
1114
+ if ($data['payment_method'] == 'mundipagg_boleto') {
1115
+ $data['TaxDocumentNumber'] = isset($postData['payment']['boleto_taxvat']) ? $postData['payment']['boleto_taxvat'] : $taxvat;
1116
+ $data['boleto_parcelamento'] = isset($postData['payment']['boleto_parcelamento']) ? $postData['payment']['boleto_parcelamento'] : 1;
1117
+ $data['boleto_dates'] = isset($postData['payment']['boleto_dates']) ? $postData['payment']['boleto_dates'] : null;
1118
+
1119
+ // We verify if a CPF is informed
1120
+ if (Mage::helper('mundipagg')->validateCPF($data['TaxDocumentNumber'])) {
1121
+ $data['PersonTypeEnum'] = 'Person';
1122
+ $data['TaxDocumentTypeEnum'] = 'CPF';
1123
+ }
1124
+
1125
+ // We verify if a CNPJ is informed
1126
+ if (Mage::helper('mundipagg')->validateCNPJ($data['TaxDocumentNumber'])) {
1127
+ $data['PersonTypeEnum'] = 'Company';
1128
+ $data['TaxDocumentTypeEnum'] = 'CNPJ';
1129
+ }
1130
+ }
1131
+
1132
+ // Debit Payment
1133
+ if ($data['payment_method'] == 'mundipagg_debit') {
1134
+ $data['TaxDocumentNumber'] = isset($postData['payment']['taxvat']) ? $postData['payment']['taxvat'] : $taxvat;
1135
+ $data['Bank'] = isset($postData['payment']['mundipagg_debit']) ? $postData['payment']['mundipagg_debit'] : $mundipaggData['mundipagg_debit'];
1136
+
1137
+ // We verify if a CPF is informed
1138
+ if (Mage::helper('mundipagg')->validateCPF($data['TaxDocumentNumber'])) {
1139
+ $data['PersonTypeEnum'] = 'Person';
1140
+ $data['TaxDocumentTypeEnum'] = 'CPF';
1141
+ }
1142
+
1143
+ // We verify if a CNPJ is informed
1144
+ if (Mage::helper('mundipagg')->validateCNPJ($data['TaxDocumentNumber'])) {
1145
+ $data['PersonTypeEnum'] = 'Company';
1146
+ $data['TaxDocumentTypeEnum'] = 'CNPJ';
1147
+ }
1148
+ }
1149
+
1150
+ // Unset MundipaggData data
1151
+ $session->setMundipaggData();
1152
+
1153
+ // Api
1154
+ $api = Mage::getModel('mundipagg/api');
1155
+
1156
+ // Get approval request from gateway
1157
+ switch ($type) {
1158
+ case 'mundipagg_boleto':
1159
+ $approvalRequest = $api->boletoTransaction($order, $data, $this);
1160
+ break;
1161
+
1162
+ case 'mundipagg_debit':
1163
+ $approvalRequest = $api->debitTransaction($order, $data, $this);
1164
+ break;
1165
+
1166
+ case $type:
1167
+ $approvalRequest = $api->creditCardTransaction($order, $data, $this);
1168
+ break;
1169
+ }
1170
+
1171
+ // Set some data from Mundipagg
1172
+ $payment = $this->setPaymentAdditionalInformation($approvalRequest, $payment);
1173
+
1174
+ // Payment gateway error
1175
+ if (isset($approvalRequest['error'])) {
1176
+ // Partial payment
1177
+ if (isset($approvalRequest['ErrorCode']) && $approvalRequest['ErrorCode'] == 'multi') {
1178
+ // We set authorized amount in session
1179
+ $orderGrandTotal = $order->getGrandTotal();
1180
+ $authorizedAmount = 0;
1181
+
1182
+ foreach ($approvalRequest['result']->CreditCardTransactionResultCollection->CreditCardTransactionResult as $key => $result) {
1183
+ if ($result->Success == true) {
1184
+ $authorizedAmount += $result->AuthorizedAmountInCents * 0.01;
1185
+ }
1186
+ }
1187
+
1188
+ // If authorized amount is the same as order grand total we can show success page
1189
+ $epsilon = 0.1;
1190
+
1191
+ if ($authorizedAmount != 0) {
1192
+ if (($orderGrandTotal - $authorizedAmount) <= $epsilon) {
1193
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('success');
1194
+ Mage::getSingleton('checkout/session')->setAuthorizedAmount();
1195
+
1196
+ } else {
1197
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('partial');
1198
+ Mage::getSingleton('checkout/session')->setAuthorizedAmount($authorizedAmount);
1199
+ }
1200
+ } else {
1201
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
1202
+ }
1203
+ } else {
1204
+ $this->offlineRetryCancelOrSuccessOrder($order->getIncrementId());
1205
+ }
1206
+ } else {
1207
+ switch ($approvalRequest['message']) {
1208
+ // BoletoBancario
1209
+ case 0:
1210
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('success');
1211
+ break;
1212
+
1213
+ // 1CreditCards
1214
+ case 1: // AuthAndCapture
1215
+ case 2: // AuthOnly
1216
+ case 3: // AuthAndCaptureWithDelay
1217
+ // We set authorized amount in session
1218
+ $orderGrandTotal = $order->getGrandTotal();
1219
+ $authorizedAmount = 0;
1220
+
1221
+ $xml = $approvalRequest['result'];
1222
+
1223
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
1224
+ $result = $xml->CreditCardTransactionResultCollection->CreditCardTransactionResult;
1225
+
1226
+ if ($result->Success == true) {
1227
+ $authorizedAmount += $result->AuthorizedAmountInCents * 0.01;
1228
+ }
1229
+ } else {
1230
+ foreach ($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult as $key => $result) {
1231
+ if ($result->Success == true) {
1232
+ $authorizedAmount += $result->AuthorizedAmountInCents * 0.01;
1233
+ }
1234
+ }
1235
+ }
1236
+
1237
+ // If authorized amount is the same as order grand total we can show success page
1238
+ $epsilon = 0.1;
1239
+
1240
+ if (($orderGrandTotal - $authorizedAmount) <= $epsilon) {
1241
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('success');
1242
+ Mage::getSingleton('checkout/session')->setAuthorizedAmount();
1243
+
1244
+ if ($orderGrandTotal < $authorizedAmount) {
1245
+ $interestInformation = $payment->getAdditionalInformation('mundipagg_interest_information');
1246
+ $newInterestInformation = array();
1247
+ if (count($interestInformation)) {
1248
+ $newInterest = 0;
1249
+ foreach ($interestInformation as $key => $ii) {
1250
+ if (strpos($key, 'partial') !== false) {
1251
+ if ($ii->hasValue()) {
1252
+ $newInterest += (float)($ii->getInterest());
1253
+ }
1254
+ }
1255
+
1256
+ }
1257
+ // Mage::log('newInterest: '.$newInterest);
1258
+ // Mage::log('grandTodal: '.$orderGrandTotal);
1259
+ // Mage::log('authorizeAmount: '.$authorizedAmount);
1260
+ }
1261
+ $this->addInterestToOrder($order, $newInterest);
1262
+ }
1263
+ } else {
1264
+ if ($authorizedAmount != 0) {
1265
+ if (($orderGrandTotal - $authorizedAmount) >= $epsilon) {
1266
+
1267
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('partial');
1268
+ Mage::getSingleton('checkout/session')->setAuthorizedAmount($authorizedAmount);
1269
+ $interestInformation = $payment->getAdditionalInformation('mundipagg_interest_information');
1270
+ $unauthorizedAmount = (float)($orderGrandTotal - $authorizedAmount);
1271
+ $newInterestInformation = array();
1272
+ if (count($interestInformation)) {
1273
+ foreach ($interestInformation as $key => $ii) {
1274
+
1275
+ if ($ii->hasValue()) {
1276
+ if ((float)($ii->getValue() + $ii->getInterest()) == (float)trim($unauthorizedAmount)) {
1277
+ $this->removeInterestToOrder($order, $ii->getInterest());
1278
+ } else {
1279
+ $newInterestInformation[$key] = $ii;
1280
+ }
1281
+ } else {
1282
+ if (($order->getGrandTotal() + $order->getMundipaggInterest()) == $unauthorizedAmount) {
1283
+ $this->removeInterestToOrder($order, $ii->getInterest());
1284
+ } else {
1285
+ $newInterestInformation[$key] = $ii;
1286
+ }
1287
+ }
1288
+ }
1289
+
1290
+ $payment->setAdditionalInformation('mundipagg_interest_information', $newInterestInformation);
1291
+ }
1292
+ }
1293
+ } else {
1294
+ $this->offlineRetryCancelOrSuccessOrder($order->getIncrementId());
1295
+ }
1296
+ }
1297
+
1298
+ // Session
1299
+ $xml = simplexml_load_string($approvalRequest['result']);
1300
+ $json = json_encode($xml);
1301
+ $dataR = array();
1302
+ $dataR = json_decode($json, true);
1303
+
1304
+ // Transaction
1305
+ $transactionKey = isset($dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult']['TransactionKey']) ? $dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult']['TransactionKey'] : null;
1306
+ $creditCardTransactionStatusEnum = isset($dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult']['CreditCardTransactionStatus']) ? $dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult']['CreditCardTransactionStatus'] : null;
1307
+
1308
+ try {
1309
+ if ($transactionKey != null) {
1310
+ $this->_transactionId = $transactionKey;
1311
+
1312
+ $payment->setTransactionId($this->_transactionId);
1313
+
1314
+ $payment->save();
1315
+ }
1316
+ } catch (Exception $e) {
1317
+ continue;
1318
+ }
1319
+ break;
1320
+
1321
+ // Debit
1322
+ case 4:
1323
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('debit');
1324
+ Mage::getSingleton('checkout/session')->setBankRedirectUrl($approvalRequest['result']['BankRedirectUrl']);
1325
+ break;
1326
+ }
1327
+ }
1328
+
1329
+ return $approvalRequest;
1330
+ } catch (Exception $e) {
1331
+ //Api
1332
+ $api = Mage::getModel('mundipagg/api');
1333
+
1334
+ //Log error
1335
+ Mage::logException($e);
1336
+
1337
+ //Mail error
1338
+ $api->mailError(print_r($e->getMessage(), 1));
1339
+ }
1340
+ }
1341
+
1342
+ private function setPaymentAdditionalInformation($approvalRequest, $payment) {
1343
+ if (isset($approvalRequest['ErrorCode'])) {
1344
+ $payment->setAdditionalInformation('ErrorCode', $approvalRequest['ErrorCode']);
1345
+ }
1346
+
1347
+ if (isset($approvalRequest['ErrorDescription'])) {
1348
+ $payment->setAdditionalInformation('ErrorDescription', $approvalRequest['ErrorDescription']);
1349
+ }
1350
+
1351
+ if (isset($approvalRequest['OrderKey'])) {
1352
+ $payment->setAdditionalInformation('OrderKey', $approvalRequest['OrderKey']);
1353
+ }
1354
+
1355
+ if (isset($approvalRequest['OrderReference'])) {
1356
+ $payment->setAdditionalInformation('OrderReference', $approvalRequest['OrderReference']);
1357
+ }
1358
+
1359
+ if (isset($approvalRequest['CreateDate'])) {
1360
+ $payment->setAdditionalInformation('CreateDate', $approvalRequest['CreateDate']);
1361
+ }
1362
+
1363
+ if (isset($approvalRequest['OrderStatusEnum'])) {
1364
+ $payment->setAdditionalInformation('OrderStatusEnum', $approvalRequest['OrderStatusEnum']);
1365
+ }
1366
+
1367
+ if (isset($approvalRequest['TransactionKey'])) {
1368
+ $payment->setAdditionalInformation('TransactionKey', $approvalRequest['TransactionKey']);
1369
+ }
1370
+
1371
+ if (isset($approvalRequest['OnlineDebitStatus'])) {
1372
+ $payment->setAdditionalInformation('OnlineDebitStatus', $approvalRequest['OnlineDebitStatus']);
1373
+ }
1374
+
1375
+ if (isset($approvalRequest['TransactionKeyToBank'])) {
1376
+ $payment->setAdditionalInformation('TransactionKeyToBank', $approvalRequest['TransactionKeyToBank']);
1377
+ }
1378
+
1379
+ if (isset($approvalRequest['TransactionReference'])) {
1380
+ $payment->setAdditionalInformation('TransactionReference', $approvalRequest['TransactionReference']);
1381
+ }
1382
+
1383
+ if (array_key_exists('isRecurrency', $approvalRequest)) {
1384
+ $payment->setAdditionalInformation('isRecurrency', $approvalRequest['isRecurrency']);
1385
+ }
1386
+
1387
+ return $payment;
1388
+ }
1389
+
1390
+ /**
1391
+ * Set capture transaction ID and enable Void to invoice for informational purposes
1392
+ * @param Mage_Sales_Model_Order_Invoice $invoice
1393
+ * @param Mage_Sales_Model_Order_Payment $payment
1394
+ * @return Mage_Payment_Model_Method_Abstract
1395
+ */
1396
+ public function processInvoice($invoice, $payment) {
1397
+ if ($payment->getLastTransId()) {
1398
+ $invoice->setTransactionId($payment->getLastTransId());
1399
+ $invoice->setCanVoidFlag(true);
1400
+
1401
+ if (Mage::helper('sales')->canSendNewInvoiceEmail($payment->getOrder()->getStoreId())) {
1402
+ $invoice->setEmailSent(true);
1403
+ $invoice->sendEmail();
1404
+ }
1405
+
1406
+ return $this;
1407
+ }
1408
+
1409
+ return false;
1410
+ }
1411
+
1412
+ /**
1413
+ * Check void availability
1414
+ *
1415
+ * @return bool
1416
+ */
1417
+ public function canVoid(Varien_Object $payment) {
1418
+ if ($payment instanceof Mage_Sales_Model_Order_Creditmemo) {
1419
+ return false;
1420
+ }
1421
+
1422
+ return $this->_canVoid;
1423
+ }
1424
+
1425
+ public function void(Varien_Object $payment) {
1426
+ if (!$this->canVoid($payment)) {
1427
+ Mage::throwException(Mage::helper('payment')->__('Void action is not available.'));
1428
+ }
1429
+
1430
+ //Prepare data in order to void
1431
+ if ($payment->getAdditionalInformation('OrderKey')) {
1432
+ $transactions = Mage::getModel('sales/order_payment_transaction')
1433
+ ->getCollection()
1434
+ ->addAttributeToFilter('order_id', array('eq' => $payment->getOrder()->getEntityId()));
1435
+
1436
+ foreach ($transactions as $key => $transaction) {
1437
+ $TransactionKey = $transaction->getAdditionalInformation('TransactionKey');
1438
+ $TransactionReference = $transaction->getAdditionalInformation('TransactionReference');
1439
+ }
1440
+
1441
+ $data['CreditCardTransactionCollection']['AmountInCents'] = $payment->getOrder()->getBaseGrandTotal() * 100;
1442
+ $data['CreditCardTransactionCollection']['TransactionKey'] = $TransactionKey;
1443
+ $data['CreditCardTransactionCollection']['TransactionReference'] = $TransactionReference;
1444
+ $data['OrderKey'] = $payment->getAdditionalInformation('OrderKey');
1445
+ $data['ManageOrderOperationEnum'] = 'Cancel';
1446
+
1447
+ //Call Gateway Api
1448
+ $api = Mage::getModel('mundipagg/api');
1449
+
1450
+ $void = $api->manageOrderRequest($data, $this);
1451
+
1452
+ // Xml
1453
+ $xml = $void['result'];
1454
+ $json = json_encode($xml);
1455
+
1456
+ $void['result'] = array();
1457
+ $void['result'] = json_decode($json, true);
1458
+
1459
+ // We record transaction(s)
1460
+ if (count($void['result']['CreditCardTransactionResultCollection']) > 0) {
1461
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
1462
+ $trans = $void['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
1463
+
1464
+ $this->_addTransaction($payment, $trans['TransactionKey'], 'void', $trans);
1465
+ } else {
1466
+ foreach ($void['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
1467
+ $this->_addTransaction($payment, $trans['TransactionKey'], 'void', $trans, $key);
1468
+ }
1469
+ }
1470
+ }
1471
+
1472
+ if (isset($void['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'])) {
1473
+ $order = $payment->getOrder();
1474
+ $order->setBaseDiscountRefunded($order->getBaseDiscountInvoiced());
1475
+ $order->setBaseShippingRefunded($order->getBaseShippingAmount());
1476
+ $order->setBaseShippingTaxRefunded($order->getBaseShippingTaxInvoiced());
1477
+ $order->setBaseSubtotalRefunded($order->getBaseSubtotalInvoiced());
1478
+ $order->setBaseTaxRefunded($order->getBaseTaxInvoiced());
1479
+ $order->setBaseTotalOnlineRefunded($order->getBaseGrandTotal());
1480
+ $order->setDiscountRefunded($order->getDiscountInvoiced());
1481
+ $order->setShippinRefunded($order->getShippingInvoiced());
1482
+ $order->setShippinTaxRefunded($order->getShippingTaxAmount());
1483
+ $order->setSubtotalRefunded($order->getSubtotalInvoiced());
1484
+ $order->setTaxRefunded($order->getTaxInvoiced());
1485
+ $order->setTotalOnlineRefunded($order->getBaseGrandTotal());
1486
+ $order->setTotalRefunded($order->getBaseGrandTotal());
1487
+ $order->save();
1488
+
1489
+ return $this;
1490
+ } else {
1491
+ $error = Mage::helper('mundipagg')->__('Unable to void order.');
1492
+
1493
+ //Log error
1494
+ Mage::log($error, null, 'Uecommerce_Mundipagg.log');
1495
+
1496
+ Mage::throwException($error);
1497
+ }
1498
+ } else {
1499
+ Mage::throwException(Mage::helper('mundipagg')->__('No OrderKey found.'));
1500
+ }
1501
+ }
1502
+
1503
+ /**
1504
+ * Check refund availability
1505
+ *
1506
+ * @return bool
1507
+ */
1508
+ public function canRefund() {
1509
+ return $this->_canRefund;
1510
+ }
1511
+
1512
+ /**
1513
+ * Set refund transaction id to payment object for informational purposes
1514
+ * Candidate to be deprecated:
1515
+ * there can be multiple refunds per payment, thus payment.refund_transactionId doesn't make big sense
1516
+ *
1517
+ * @param Mage_Sales_Model_Order_Invoice $invoice
1518
+ * @param Mage_Sales_Model_Order_Payment $payment
1519
+ * @return Mage_Payment_Model_Method_Abstract
1520
+ */
1521
+ public function processBeforeRefund($invoice, $payment) {
1522
+ $payment->setRefundTransactionId($invoice->getTransactionId());
1523
+
1524
+ return $this;
1525
+ }
1526
+
1527
+ /**
1528
+ * Refund specified amount for payment
1529
+ *
1530
+ * @param Varien_Object $payment
1531
+ * @param float $amount
1532
+ *
1533
+ * @return Mage_Payment_Model_Abstract
1534
+ */
1535
+ public function refund(Varien_Object $payment, $amount) {
1536
+ if (!$this->canRefund()) {
1537
+ Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
1538
+ }
1539
+
1540
+ //Prepare data in order to refund
1541
+ if ($payment->getAdditionalInformation('OrderKey')) {
1542
+ $data['OrderKey'] = $payment->getAdditionalInformation('OrderKey');
1543
+ $data['ManageOrderOperationEnum'] = 'Void';
1544
+
1545
+ //Call Gateway Api
1546
+ $api = Mage::getModel('mundipagg/api');
1547
+
1548
+ $refund = $api->manageOrderRequest($data, $this);
1549
+
1550
+ // Xml
1551
+ $xml = $refund['result'];
1552
+ $json = json_encode($xml);
1553
+
1554
+ $refund['result'] = array();
1555
+ $refund['result'] = json_decode($json, true);
1556
+
1557
+ // We record transaction(s)
1558
+ if (count($refund['result']['CreditCardTransactionResultCollection']) > 0) {
1559
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
1560
+ $trans = $refund['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
1561
+
1562
+ $this->_addTransaction($payment, $trans['TransactionKey'], 'void', $trans);
1563
+ } else {
1564
+ foreach ($refund['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
1565
+ $this->_addTransaction($payment, $trans['TransactionKey'], 'void', $trans, $key);
1566
+ }
1567
+ }
1568
+ }
1569
+
1570
+ if (isset($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult)) {
1571
+ if (count($xml->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
1572
+ $capturedAmountInCents = $manageOrderResult->CreditCardTransactionResultCollection->CreditCardTransactionResult->CapturedAmountInCents;
1573
+ } else {
1574
+ $capturedAmountInCents = 0;
1575
+
1576
+ foreach ($refund['result']['CreditCardTransactionResultCollection']['CreditCardTransactionResult'] as $key => $trans) {
1577
+ $capturedAmountInCents += $trans['CapturedAmountInCents'];
1578
+ }
1579
+ }
1580
+
1581
+ $order = $payment->getOrder();
1582
+ $order->setBaseDiscountRefunded($order->getBaseDiscountInvoiced());
1583
+ $order->setBaseShippingRefunded($order->getBaseShippingAmount());
1584
+ $order->setBaseShippingTaxRefunded($order->getBaseShippingTaxInvoiced());
1585
+ $order->setBaseSubtotalRefunded($order->getBaseSubtotalInvoiced());
1586
+ $order->setBaseTaxRefunded($order->getBaseTaxInvoiced());
1587
+ $order->setBaseTotalOnlineRefunded($capturedAmountInCents * 0.01);
1588
+ $order->setDiscountRefunded($order->getDiscountInvoiced());
1589
+ $order->setShippinRefunded($order->getShippingInvoiced());
1590
+ $order->setShippinTaxRefunded($order->getShippingTaxAmount());
1591
+ $order->setSubtotalRefunded($order->getSubtotalInvoiced());
1592
+ $order->setTaxRefunded($order->getTaxInvoiced());
1593
+ $order->setTotalOnlineRefunded($capturedAmountInCents * 0.01);
1594
+ $order->setTotalRefunded($capturedAmountInCents * 0.01);
1595
+ $order->save();
1596
+
1597
+ return $this;
1598
+ } else {
1599
+ $error = Mage::helper('mundipagg')->__('Unable to refund order.');
1600
+
1601
+ //Log error
1602
+ Mage::log($error, null, 'Uecommerce_Mundipagg.log');
1603
+
1604
+ Mage::throwException($error);
1605
+ }
1606
+ } else {
1607
+ Mage::throwException(Mage::helper('mundipagg')->__('No OrderKey found.'));
1608
+ }
1609
+ }
1610
+
1611
+ /**
1612
+ * Validate
1613
+ */
1614
+ public function validate() {
1615
+ parent::validate();
1616
+
1617
+ $currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
1618
+
1619
+ if (!in_array($currencyCode, $this->_allowCurrencyCode)) {
1620
+ Mage::throwException(Mage::helper('payment')->__('Selected currency code (' . $currencyCode . ') is not compatabile with Mundipagg'));
1621
+ }
1622
+
1623
+ $info = $this->getInfoInstance();
1624
+
1625
+ $errorMsg = false;
1626
+
1627
+ // Check if we are dealing with a new Credit Card
1628
+ $isToken = $info->getAdditionalInformation('mundipagg_creditcard_token_1_1');
1629
+
1630
+ if ($info->getAdditionalInformation('PaymentMethod') == 'mundipagg_creditcard' && ($isToken == '' || $isToken == 'new')) {
1631
+ $availableTypes = $this->getCcTypes();
1632
+
1633
+ $ccNumber = $info->getCcNumber();
1634
+
1635
+ // remove credit card number delimiters such as "-" and space
1636
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
1637
+ $info->setCcNumber($ccNumber);
1638
+
1639
+ if (in_array($info->getCcType(), $availableTypes)) {
1640
+ if (!Mage::helper('mundipagg')->validateCcNum($ccNumber) && $info->getCcType() != 'HI') {
1641
+ $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
1642
+ }
1643
+ } else {
1644
+ $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
1645
+ }
1646
+
1647
+ if (!$info->getCcType()) {
1648
+ $errorMsg = Mage::helper('payment')->__('Please select your credit card type.');
1649
+ }
1650
+
1651
+ if (!$info->getCcOwner()) {
1652
+ $errorMsg = Mage::helper('payment')->__('Please enter your credit card holder name.');
1653
+ }
1654
+
1655
+ if ($info->getCcType() && $info->getCcType() != 'SS' && !Mage::helper('mundipagg')->validateExpDate('20' . $info->getCcExpYear(), $info->getCcExpMonth())) {
1656
+ $errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
1657
+ }
1658
+ }
1659
+
1660
+ if ($errorMsg) {
1661
+ Mage::throwException($errorMsg);
1662
+ }
1663
+
1664
+ return $this;
1665
+ }
1666
+
1667
+ /**
1668
+ * Redirect Url
1669
+ *
1670
+ * @return void
1671
+ */
1672
+ public function getOrderPlaceRedirectUrl() {
1673
+ switch (Mage::getSingleton('checkout/session')->getApprovalRequestSuccess()) {
1674
+ case 'debit':
1675
+ $redirectUrl = Mage::getSingleton('checkout/session')->getBankRedirectUrl();
1676
+ break;
1677
+
1678
+ case 'success':
1679
+ $redirectUrl = Mage::getUrl('mundipagg/standard/success', array('_secure' => true));
1680
+ break;
1681
+
1682
+ case 'partial':
1683
+ $redirectUrl = Mage::getUrl('mundipagg/standard/partial', array('_secure' => true));
1684
+ break;
1685
+
1686
+ case 'cancel':
1687
+ $redirectUrl = Mage::getUrl('mundipagg/standard/cancel', array('_secure' => true));
1688
+ break;
1689
+
1690
+ default:
1691
+ $redirectUrl = Mage::getUrl('mundipagg/standard/cancel', array('_secure' => true));
1692
+ break;
1693
+ }
1694
+
1695
+ return $redirectUrl;
1696
+ }
1697
+
1698
+ public function prepare() {
1699
+
1700
+ }
1701
+
1702
+ /**
1703
+ * Get payment methods
1704
+ */
1705
+ public function getPaymentMethods() {
1706
+ $payment_methods = $this->getConfigData('payment_methods');
1707
+
1708
+ if ($payment_methods != '') {
1709
+ $payment_methods = explode(",", $payment_methods);
1710
+ } else {
1711
+ $payment_methods = array();
1712
+ }
1713
+
1714
+ return $payment_methods;
1715
+ }
1716
+
1717
+ /**
1718
+ * CCards
1719
+ */
1720
+ public function getCcTypes() {
1721
+ $ccTypes = Mage::getStoreConfig('payment/mundipagg_standard/cc_types');
1722
+
1723
+ if ($ccTypes != '') {
1724
+ $ccTypes = explode(",", $ccTypes);
1725
+ } else {
1726
+ $ccTypes = array();
1727
+ }
1728
+
1729
+ return $ccTypes;
1730
+ }
1731
+
1732
+ /**
1733
+ * Reset interest
1734
+ */
1735
+ public function resetInterest($info) {
1736
+ if ($info->getQuote()->getMundipaggInterest() > 0 || $info->getQuote()->getMundipaggBaseInterest() > 0) {
1737
+ $info->getQuote()->setMundipaggInterest(0.0);
1738
+ $info->getQuote()->setMundipaggBaseInterest(0.0);
1739
+ $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals();
1740
+ $info->getQuote()->save();
1741
+ }
1742
+
1743
+ return $info;
1744
+ }
1745
+
1746
+ /**
1747
+ * Apply interest
1748
+ */
1749
+ public function applyInterest($info, $interest) {
1750
+ $info->getQuote()->setMundipaggInterest($info->getQuote()->getStore()->convertPrice($interest, false));
1751
+ $info->getQuote()->setMundipaggBaseInterest($interest);
1752
+ $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals();
1753
+ $info->getQuote()->save();
1754
+ }
1755
+
1756
+ /**
1757
+ * Remove interest to order when the total is not allowed.
1758
+ *
1759
+ * @param Mage_Sales_Model_Order $order
1760
+ * @param float $interest
1761
+ */
1762
+ protected function removeInterestToOrder(Mage_Sales_Model_Order $order, $interest) {
1763
+ $mundipaggInterest = $order->getMundipaggInterest();
1764
+ $setInterest = (float)($mundipaggInterest - $interest);
1765
+ $order->setMundipaggInterest(($setInterest) ? $setInterest : 0);
1766
+ $order->setMundipaggBaseInterest(($setInterest) ? $setInterest : 0);
1767
+ $order->setGrandTotal(($order->getGrandTotal() - $interest));
1768
+ $order->setBaseGrandTotal(($order->getBaseGrandTotal() - $interest));
1769
+ $order->save();
1770
+ $info = $this->getInfoInstance();
1771
+ $info->setPaymentInterest(($info->getPaymentInterest() - $setInterest));
1772
+ $info->save();
1773
+
1774
+ }
1775
+
1776
+ /**
1777
+ * Add interest to order
1778
+ */
1779
+ protected function addInterestToOrder(Mage_Sales_Model_Order $order, $interest) {
1780
+ $mundipaggInterest = $order->getMundipaggInterest();
1781
+ $setInterest = (float)($mundipaggInterest + $interest);
1782
+ $order->setMundipaggInterest(($setInterest) ? $setInterest : 0);
1783
+ $order->setMundipaggBaseInterest(($setInterest) ? $setInterest : 0);
1784
+ $order->setGrandTotal(($order->getGrandTotal() + $interest));
1785
+ $order->setBaseGrandTotal(($order->getBaseGrandTotal() + $interest));
1786
+ $order->save();
1787
+ }
1788
+
1789
+ /**
1790
+ * Add payment transaction
1791
+ *
1792
+ * @param Mage_Sales_Model_Order_Payment $payment
1793
+ * @param string $transactionId
1794
+ * @param string $transactionType
1795
+ * @param array $transactionAdditionalInfo
1796
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
1797
+ */
1798
+ public function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, $transactionAdditionalInfo, $num = 0) {
1799
+ // Num
1800
+ $num = $num + 1;
1801
+
1802
+ // Transaction
1803
+ $transaction = Mage::getModel('sales/order_payment_transaction');
1804
+ $transaction->setOrderPaymentObject($payment);
1805
+
1806
+ $transaction = $transaction->loadByTxnId($transactionId . '-' . $transactionType);
1807
+
1808
+ $transaction->setTxnType($transactionType);
1809
+ $transaction->setTxnId($transactionId . '-' . $transactionType);
1810
+
1811
+ if ($transactionType == 'authorization') {
1812
+ if ($transactionAdditionalInfo['CreditCardTransactionStatus'] == 'AuthorizedPendingCapture') {
1813
+ $transaction->setIsClosed(0);
1814
+ }
1815
+
1816
+ if ($transactionAdditionalInfo['CreditCardTransactionStatus'] == 'NotAuthorized') {
1817
+ $transaction->setIsClosed(1);
1818
+ }
1819
+ }
1820
+
1821
+ foreach ($transactionAdditionalInfo as $transKey => $value) {
1822
+ if (!is_array($value)) {
1823
+ $transaction->setAdditionalInformation($transKey, htmlspecialchars_decode($value));
1824
+
1825
+ $payment->setAdditionalInformation($num . '_' . $transKey, htmlspecialchars_decode($value));
1826
+ } else {
1827
+ foreach ($value as $key2 => $value2) {
1828
+ $transaction->setAdditionalInformation($key2, htmlspecialchars_decode($value2));
1829
+
1830
+ $payment->setAdditionalInformation($num . '_' . $key2, htmlspecialchars_decode($value2));
1831
+ }
1832
+ }
1833
+ }
1834
+
1835
+ return $transaction->save();
1836
+ }
1837
+
1838
+ /**
1839
+ * Cancel order or not if is in offline retry time
1840
+ *
1841
+ * @author Ruan Azevedo <razevedo@mundipagg.com>
1842
+ * @since 2016-06-21
1843
+ * @param string $orderIncrementId
1844
+ */
1845
+ private function offlineRetryCancelOrSuccessOrder($orderIncrementId) {
1846
+ $offlineRetryIsEnabled = Uecommerce_Mundipagg_Model_Offlineretry::offlineRetryIsEnabled();
1847
+
1848
+ if($offlineRetryIsEnabled == false){
1849
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
1850
+ return;
1851
+ }
1852
+
1853
+ $api = new Uecommerce_Mundipagg_Model_Api();
1854
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
1855
+ $logLabel = "Order #{$orderIncrementId}";
1856
+
1857
+ if ($api->orderIsInOfflineRetry($orderIncrementId)) {
1858
+ $message = "{$logLabel} | payment not authorized but order is in offline retry yet, not cancel.";
1859
+
1860
+ $helperLog->info($message);
1861
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('success');
1862
+
1863
+ } else {
1864
+ $helperLog->info("{$logLabel} | Payment not authorized and store don't have offline retry, order will be canceled.");
1865
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('cancel');
1866
+ }
1867
+ }
1868
+
1869
+ }
app/code/community/Uecommerce/Mundipagg/Model/System/Config/Backend/Installments.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_System_Config_Backend_Installments extends Mage_Core_Model_Config_Data
32
+ {
33
+ /**
34
+ * Process data after load
35
+ */
36
+ protected function _afterLoad()
37
+ {
38
+ $value = $this->getValue();
39
+ $value = Mage::helper('mundipagg/installments')->makeArrayFieldValue($value);
40
+ $this->setValue($value);
41
+ }
42
+
43
+ /**
44
+ * Prepare data before save
45
+ */
46
+ protected function _beforeSave()
47
+ {
48
+ $value = $this->getValue();
49
+ $value = Mage::helper('mundipagg/installments')->makeStorableArrayFieldValue($value);
50
+ $this->setValue($value);
51
+ }
52
+ }
app/code/community/Uecommerce/Mundipagg/Model/Threecreditcards.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Threecreditcards extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_threecreditcards';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
67
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
68
+ $this->setPaymentMethodCode(1);
69
+ $this->setBankNumber(341);
70
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
71
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
72
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
73
+ $this->setDebug($standard->getConfigData('debug'));
74
+ $this->setEnvironment($standard->getConfigData('environment'));
75
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
76
+ break;
77
+
78
+ case 'production':
79
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
80
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
81
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
82
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
83
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
84
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
85
+ $this->setDebug($standard->getConfigData('debug'));
86
+ $this->setEnvironment($standard->getConfigData('environment'));
87
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
88
+ break;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Armazena as informações passadas via formulário no frontend
94
+ * @access public
95
+ * @param array $data
96
+ * @return Uecommerce_Mundipagg_Model_Standard
97
+ */
98
+ public function assignData($data)
99
+ {
100
+ $info = $this->getInfoInstance();
101
+ $this->resetInterest($info);
102
+
103
+ parent::assignData($data);
104
+
105
+
106
+
107
+ $cctype1 = $data[$this->_code.'_3_1_cc_type'];
108
+
109
+ if (isset($data[$this->_code.'_token_3_1']) && $data[$this->_code.'_token_3_1'] != 'new') {
110
+ $parcelsNumber1 = $data[$this->_code.'_credito_parcelamento_3_1'];
111
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_3_1']);
112
+ $cctype1 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
113
+ $value1 = $data[$this->_code.'_value_3_1'];
114
+ } else {
115
+ $parcelsNumber1 = $data[$this->_code.'_new_credito_parcelamento_3_1'];
116
+ $value1 = $data[$this->_code.'_new_value_3_1'];
117
+ }
118
+
119
+ $cctype2 = $data[$this->_code.'_3_2_cc_type'];
120
+
121
+ if (isset($data[$this->_code.'_token_3_2']) && $data[$this->_code.'_token_3_2'] != 'new') {
122
+ $parcelsNumber2 = $data[$this->_code.'_credito_parcelamento_3_2'];
123
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_3_2']);
124
+ $cctype2 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
125
+ $value2 = $data[$this->_code.'_value_3_2'];
126
+ } else {
127
+ $parcelsNumber2 = $data[$this->_code.'_new_credito_parcelamento_3_2'];
128
+ $value2 = $data[$this->_code.'_new_value_3_2'];
129
+ }
130
+
131
+ $cctype3 = $data[$this->_code.'_3_3_cc_type'];
132
+
133
+ if (isset($data[$this->_code.'_token_3_3']) && $data[$this->_code.'_token_3_3'] != 'new') {
134
+ $parcelsNumber3 = $data[$this->_code.'_credito_parcelamento_3_3'];
135
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_3_3']);
136
+ $cctype3 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
137
+ $value3 = $data[$this->_code.'_value_3_3'];
138
+ } else {
139
+ $parcelsNumber3 = $data[$this->_code.'_new_credito_parcelamento_3_3'];
140
+ $value3 = $data[$this->_code.'_new_value_3_3'];
141
+ }
142
+
143
+ $interest1 = 0;
144
+ $interest2 = 0;
145
+ $interest3 = 0;
146
+ $interestInformation = array();
147
+ if(Mage::app()->getRequest()->getActionName() == 'partialPost'){
148
+ $keyCode = $this->_code.'_partial';
149
+ $interestInformation = $info->getAdditionalInformation('mundipagg_interest_information');
150
+ }else{
151
+ $keyCode = $this->_code;
152
+ }
153
+
154
+ if($cctype1) {
155
+ $interest1 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber1 , $cctype1, $value1);
156
+ $interestInformation[$keyCode.'_3_1'] = new Varien_Object();
157
+ $interestInformation[$keyCode.'_3_1']->setInterest(str_replace(',','.',$interest1))->setValue(str_replace(',','.',$value1));
158
+ }
159
+
160
+ if($cctype2) {
161
+ $interest2 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber2 , $cctype2, $value2);
162
+ $interestInformation[$keyCode.'_3_2'] = new Varien_Object();
163
+ $interestInformation[$keyCode.'_3_2']->setInterest(str_replace(',','.',$interest2))->setValue(str_replace(',','.',$value2));
164
+ }
165
+
166
+ if($cctype3) {
167
+ $interest3 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber3 , $cctype3, $value3);
168
+ $interestInformation[$keyCode.'_3_3'] = new Varien_Object();
169
+ $interestInformation[$keyCode.'_3_3']->setInterest(str_replace(',','.',$interest3))->setValue(str_replace(',','.',$value3));
170
+ }
171
+
172
+ $interest = $interest1+$interest2+$interest3;
173
+
174
+ if ($interest > 0) {
175
+ $info->setAdditionalInformation('mundipagg_interest_information', array());
176
+ $info->setAdditionalInformation('mundipagg_interest_information',$interestInformation);
177
+ $this->applyInterest($info, $interest);
178
+
179
+ } else {
180
+ // If none of Cc parcels doens't have interest we reset interest
181
+ $this->resetInterest($info);
182
+ }
183
+
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * Prepare info instance for save
189
+ *
190
+ * @return Mage_Payment_Model_Abstract
191
+ */
192
+ public function prepareSave()
193
+ {
194
+ parent::prepareSave();
195
+ }
196
+
197
+ /**
198
+ * Instantiate state and set it to state object
199
+ *
200
+ * @param string $paymentAction
201
+ * @param Varien_Object
202
+ */
203
+ public function initialize($paymentAction, $stateObject)
204
+ {
205
+ $this->setCreditCardOperationEnum('AuthAndCapture');
206
+
207
+ $payment = $this->getInfoInstance();
208
+ $order = $payment->getOrder();
209
+
210
+ parent::authorize($payment, $order->getBaseTotalDue());
211
+ }
212
+ }
app/code/community/Uecommerce/Mundipagg/Model/Twocreditcards.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Model_Twocreditcards extends Uecommerce_Mundipagg_Model_Standard
32
+ {
33
+ /**
34
+ * Availability options
35
+ */
36
+ protected $_code = 'mundipagg_twocreditcards';
37
+ protected $_formBlockType = 'mundipagg/standard_form';
38
+ protected $_infoBlockType = 'mundipagg/info';
39
+ protected $_isGateway = true;
40
+ protected $_canOrder = true;
41
+ protected $_canAuthorize = true;
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = true;
45
+ protected $_canVoid = true;
46
+ protected $_canUseInternal = true;
47
+ protected $_canUseCheckout = true;
48
+ protected $_canUseForMultishipping = true;
49
+ protected $_canSaveCc = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canManageRecurringProfiles = false;
52
+ protected $_allowCurrencyCode = array('BRL', 'USD', 'EUR');
53
+ protected $_isInitializeNeeded = true;
54
+
55
+ public function __construct()
56
+ {
57
+ $standard = Mage::getModel('mundipagg/standard');
58
+
59
+ switch ($standard->getEnvironment())
60
+ {
61
+ case 'localhost':
62
+ case 'development':
63
+ case 'staging':
64
+ default:
65
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyStaging')));
66
+ $this->setUrl(trim($standard->getConfigData('apiUrlStaging')));
67
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
68
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
69
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
70
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
71
+ $this->setPaymentMethodCode(1);
72
+ $this->setBankNumber(341);
73
+ $this->setDebug($standard->getConfigData('debug'));
74
+ $this->setEnvironment($standard->getConfigData('environment'));
75
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
76
+ break;
77
+
78
+ case 'production':
79
+ $this->setmerchantKey(trim($standard->getConfigData('merchantKeyProduction')));
80
+ $this->setUrl(trim($standard->getConfigData('apiUrlProduction')));
81
+ $this->setAntiFraud($standard->getConfigData('antifraud'));
82
+ $this->setParcelamento($standard->getConfigData('parcelamento'));
83
+ $this->setParcelamentoMax($standard->getConfigData('parcelamento_max'));
84
+ $this->setPaymentAction($standard->getConfigData('payment_action'));
85
+ $this->setDebug($standard->getConfigData('debug'));
86
+ $this->setEnvironment($standard->getConfigData('environment'));
87
+ $this->setCieloSku($standard->getConfigData('cielo_sku'));
88
+ break;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Armazena as informações passadas via formulário no frontend
94
+ * @access public
95
+ * @param array $data
96
+ * @return Uecommerce_Mundipagg_Model_Standard
97
+ */
98
+ public function assignData($data)
99
+ {
100
+ $info = $this->getInfoInstance();
101
+ $this->resetInterest($info);
102
+
103
+ parent::assignData($data);
104
+
105
+ $cctype1 = $data[$this->_code.'_2_1_cc_type'];
106
+
107
+ if (isset($data[$this->_code.'_token_2_1']) && $data[$this->_code.'_token_2_1'] != 'new') {
108
+ $parcelsNumber1 = $data[$this->_code.'_credito_parcelamento_2_1'];
109
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_2_1']);
110
+ $cctype1 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
111
+ $value1 = $data[$this->_code.'_value_2_1'];
112
+ } else {
113
+ $parcelsNumber1 = $data[$this->_code.'_new_credito_parcelamento_2_1'];
114
+ $value1 = $data[$this->_code.'_new_value_2_1'];
115
+ }
116
+
117
+ $cctype2 = $data[$this->_code.'_2_2_cc_type'];
118
+
119
+ if (isset($data[$this->_code.'_token_2_2']) && $data[$this->_code.'_token_2_2'] != 'new') {
120
+ $parcelsNumber2 = $data[$this->_code.'_credito_parcelamento_2_2'];
121
+ $cardonFile = Mage::getModel('mundipagg/cardonfile')->load($data[$this->_code.'_token_2_2']);
122
+ $cctype2 = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cardonFile->getCcType());
123
+ $value2 = $data[$this->_code.'_value_2_2'];
124
+ } else {
125
+ $parcelsNumber2 = $data[$this->_code.'_new_credito_parcelamento_2_2'];
126
+ $value2 = $data[$this->_code.'_new_value_2_2'];
127
+ }
128
+
129
+ $interest1 = 0;
130
+ $interest2 = 0;
131
+ $interestInformation = array();
132
+
133
+ if(Mage::app()->getRequest()->getActionName() == 'partialPost'){
134
+ $keyCode = $this->_code.'_partial';
135
+ $interestInformation = $info->getAdditionalInformation('mundipagg_interest_information');
136
+ }else{
137
+ $keyCode = $this->_code;
138
+ }
139
+ if($cctype1) {
140
+ $interest1 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber1 , $cctype1, $value1);
141
+
142
+
143
+ $interestInformation[$keyCode.'_2_1'] = new Varien_Object();
144
+ $interestInformation[$keyCode.'_2_1']->setInterest(str_replace(',','.',$interest1))->setValue(str_replace(',','.',$value1));
145
+ }
146
+
147
+ if($cctype2){
148
+ $interest2 = Mage::helper('mundipagg/installments')->getInterestForCard($parcelsNumber2 , $cctype2, str_replace(',','.',$value2));
149
+ $interestInformation[$keyCode.'_2_2'] = new Varien_Object();
150
+ $interestInformation[$keyCode.'_2_2']->setInterest(str_replace(',','.',$interest2))->setValue(str_replace(',','.',$value2));
151
+ }
152
+
153
+ $interest = $interest1+$interest2;
154
+
155
+ if ($interest > 0) {
156
+ $info->setAdditionalInformation('mundipagg_interest_information', array());
157
+ $info->setAdditionalInformation('mundipagg_interest_information',$interestInformation);
158
+ $this->applyInterest($info, $interest);
159
+
160
+ } else {
161
+ // If none of Cc parcels doens't have interest we reset interest
162
+ $info = $this->resetInterest($info);
163
+ }
164
+
165
+ return $this;
166
+ }
167
+
168
+ /**
169
+ * Prepare info instance for save
170
+ *
171
+ * @return Mage_Payment_Model_Abstract
172
+ */
173
+ public function prepareSave()
174
+ {
175
+ parent::prepareSave();
176
+
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Instantiate state and set it to state object
182
+ *
183
+ * @param string $paymentAction
184
+ * @param Varien_Object
185
+ */
186
+ public function initialize($paymentAction, $stateObject)
187
+ {
188
+ $this->setCreditCardOperationEnum('AuthAndCapture');
189
+
190
+ $payment = $this->getInfoInstance();
191
+ $order = $payment->getOrder();
192
+
193
+ parent::authorize($payment, $order->getBaseTotalDue());
194
+ }
195
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/Abstract.php ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Uecommerce_Mundipagg_Test_Selenium_Abstract extends PHPUnit_Extensions_Selenium2TestCase {
5
+
6
+ public $_installmentActive;
7
+ public $_Recurrency;
8
+ public $_paymentType;
9
+ public $_isLogged;
10
+ public $_isPj;
11
+ protected $_additionalSaveSettings = array();
12
+ protected static $_custmerTest = array(
13
+ 'firstname' => 'Test',
14
+ 'lastname' => 'Test',
15
+ 'email' => 'test@testmundipagg.com.br',
16
+ 'street1' => 'Rua da Quitanda',
17
+ 'city' => 'Rio de Janeiro',
18
+ 'country_id' => 'BR',
19
+ 'postcode' => '20091005',
20
+ 'telephone' => '2135542800',
21
+ 'customer_password' => 'mundipagg123',
22
+ 'confirm_password' => 'mundipagg123',
23
+ 'taxvat' => '54201288102',
24
+ 'region' => 'RJ'
25
+ );
26
+
27
+ protected static $_customerPjTest = array(
28
+ 'firstname' => 'Test',
29
+ 'lastname' => 'Test',
30
+ 'email' => 'test@testmundipagg.com.br',
31
+ 'street1' => 'Rua da Quitanda',
32
+ 'city' => 'Rio de Janeiro',
33
+ 'country_id' => 'BR',
34
+ 'postcode' => '20091005',
35
+ 'telephone' => '2135542800',
36
+ 'customer_password' => 'mundipagg123',
37
+ 'confirm_password' => 'mundipagg123',
38
+ 'taxvat' => '61181731000175',
39
+ 'company' => 'Test',
40
+ 'region' => 'RJ'
41
+ );
42
+
43
+ protected static $_disableCaches;
44
+ protected static $_setConfigMagento;
45
+ protected static $_createProduct;
46
+ protected static $_productSku = 'test';
47
+ protected static $_defaultSleep = 10;
48
+ protected $_envCI = 'MAGE';
49
+
50
+
51
+
52
+ public function setUp(){
53
+ parent::setUp();
54
+
55
+ $this->setBrowser('firefox');
56
+ $this->setBrowserUrl(Mage::getBaseUrl());
57
+ $this->setUpSessionStrategy(null);
58
+
59
+ // Default Browser-Size
60
+ $this->prepareSession()->currentWindow()->size(array('width' => 1280, 'height' => 1024));
61
+
62
+
63
+ self::initFrontend(1);
64
+
65
+ if(Mage::getIsDeveloperMode()){
66
+ self::$_defaultSleep = 4;
67
+ }
68
+
69
+ $this->disableCaches();
70
+ $this->setConfigMagento();
71
+ $this->setMundipaggConfig();
72
+ $this->createSimpleProduct();
73
+ shell_exec('echo "" > ../var/log/Uecommerce_Mundipagg.log');
74
+
75
+ }
76
+
77
+ /**
78
+ * Set default settings Mundipagg
79
+ */
80
+ public function setMundipaggConfig() {
81
+ $config = $this->getConfig();
82
+
83
+ $config->saveConfig('payment/mundipagg_standard/merchantKeyStaging', '5efae21a-3ce0-4a63-884a-b8b6fb6ad1e3');
84
+ $config->saveConfig('payment/mundipagg_standard/payment_action', 'authorize');
85
+ $config->saveConfig('payment/mundipagg_standard/cc_types', 'VI,MC,AE,DI,EL,HI');
86
+ if ($this->_installmentActive) {
87
+ $config->saveConfig('payment/mundipagg_standard/enable_installments', '1');
88
+ $config->saveConfig('payment/mundipagg_standard/display_total', '1');
89
+ $config->saveConfig('payment/mundipagg_standard/installments', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
90
+ $config->saveConfig('payment/mundipagg_standard/installments_VI', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
91
+ $config->saveConfig('payment/mundipagg_standard/installments_MC', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
92
+ $config->saveConfig('payment/mundipagg_standard/installments_AE', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
93
+ $config->saveConfig('payment/mundipagg_standard/installments_DI', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
94
+ $config->saveConfig('payment/mundipagg_standard/installments_EL', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
95
+ $config->saveConfig('payment/mundipagg_standard/installments_HI', 'a:4:{i:0;a:3:{i:0;s:0:"";i:1;s:1:"1";i:2;s:0:"";}i:1;a:3:{i:0;s:0:"";i:1;s:1:"2";i:2;s:0:"";}i:2;a:3:{i:0;s:0:"";i:1;s:1:"3";i:2;s:1:"5";}i:3;a:3:{i:0;s:0:"";i:1;s:1:"5";i:2;s:2:"10";}}');
96
+ } else {
97
+ $config->saveConfig('payment/mundipagg_standard/enable_installments', '0');
98
+ }
99
+
100
+ if(is_array($this->_additionalSaveSettings) && count($this->_additionalSaveSettings)){
101
+ foreach($this->_additionalSaveSettings as $path => $value){
102
+ $config->saveConfig($path, $value);
103
+ }
104
+ }
105
+
106
+ $config->reinit();
107
+ $config->cleanCache();
108
+ Mage::app()->reinitStores();
109
+ Mage::app()->getCacheInstance()->cleanType('config');
110
+ }
111
+
112
+ /**
113
+ * Set default settings Magento
114
+ */
115
+ public function setConfigMagento() {
116
+ if(self::$_setConfigMagento){
117
+ return false;
118
+ }
119
+ $config = $this->getConfig();
120
+ $config->saveConfig('dev/template/allow_symlink', '1');
121
+ $config->saveConfig('dev/log/active', '1');
122
+ $config->saveConfig('customer/address/taxvat_show', 'opt');
123
+ $config->reinit();
124
+ $config->cleanCache();
125
+ Mage::app()->reinitStores();
126
+ self::$_setConfigMagento = true;
127
+ }
128
+
129
+
130
+
131
+ /**
132
+ * Create a simple product to test
133
+ */
134
+ public function createSimpleProduct() {
135
+ if(self::$_createProduct){
136
+ return false;
137
+ }
138
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
139
+
140
+ /** @var $product Mage_Catalog_Model_Product */
141
+ $product = Mage::getModel('catalog/product');
142
+ $product->load('sku', 'test');
143
+ if ($product->getId()) {
144
+ return false;
145
+ }
146
+
147
+ try {
148
+ $product
149
+ ->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array
150
+ ->setAttributeSetId(Mage::getModel('catalog/product')->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
151
+ ->setTypeId('simple') //product type
152
+ ->setCreatedAt(strtotime('now')) //product creation time
153
+ ->setSku(self::$_productSku) //SKU
154
+ ->setName('Test') //product name
155
+ ->setWeight(1.0000)
156
+ ->setStatus(1) //product status (1 - enabled, 2 - disabled)
157
+ ->setTaxClassId(0) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
158
+ ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) //catalog and search visibility
159
+ //->setNewsFromDate('06/26/2014') //product set as new from
160
+ //->setNewsToDate('06/30/2014') //product set as new to
161
+ ->setPrice(11.22) //price in form 11.22
162
+ ->setCost(11.22) //price in form 11.22
163
+ //->setSpecialPrice(00.44) //special price in form 11.22
164
+ // ->setSpecialFromDate('06/1/2014') //special price from (MM-DD-YYYY)
165
+ //->setSpecialToDate('06/30/2014') //special price to (MM-DD-YYYY)
166
+ ->setDescription('This is a long description')
167
+ ->setShortDescription('This is a short description')
168
+ ->setStockData(array(
169
+ 'use_config_manage_stock' => 0, //'Use config settings' checkbox
170
+ 'manage_stock' => 0, //manage stock
171
+ // 'min_sale_qty' => 1, //Minimum Qty Allowed in Shopping Cart
172
+ // 'max_sale_qty' => 2, //Maximum Qty Allowed in Shopping Cart
173
+ // 'is_in_stock' => 1, //Stock Availability
174
+ // 'qty' => 999 //qty
175
+ )
176
+ );
177
+ //->setCategoryIds(array(3, 10)); //assign product to categories
178
+ $product->save();
179
+ self::$_createProduct = true;
180
+ //endif;
181
+ } catch (Exception $e) {
182
+ self::$_createProduct = false;
183
+ Mage::log($e->getMessage());
184
+ }
185
+ }
186
+
187
+
188
+ /**
189
+ * Disable all Magento caches
190
+ *
191
+ * @return boolean
192
+ */
193
+ public function disableCaches(){
194
+ if(self::$_disableCaches){
195
+ return false;
196
+ }
197
+ /** @var $model Mage_Core_Model_Cache */
198
+ $model = Mage::getModel('core/cache');
199
+ $options = $model->canUse();
200
+ foreach($options as $option => $value){
201
+ $options[$option] = 0;
202
+ }
203
+ $model->saveOptions($option);
204
+ self::$_disableCaches = true;
205
+ }
206
+
207
+
208
+
209
+ public function runMundipagg(){
210
+ //Mage::log(Mage::app()->getResponse());
211
+ if(!$this->_isLogged){
212
+ $this->deleteCustomerIfExists();
213
+ }
214
+
215
+ $customer = $this->getCustomer();
216
+ Mage::getConfig()->saveConfig('mundipagg_tests_cpf_cnpj', $customer['taxvat']);
217
+ Mage::getConfig()->reinit();
218
+ Mage::getConfig()->cleanCache();
219
+ Mage::app()->reinitStores();
220
+
221
+ // Access homePage
222
+ $this->url(Mage::getBaseUrl());
223
+ $customer = $this->getCustomer();
224
+
225
+ $this->assertEquals(200, $this->getHttpCode());
226
+ sleep(self::$_defaultSleep);
227
+
228
+ // Search product
229
+ $element = $this->byId('search');
230
+ $element->value(self::$_productSku);
231
+ $this->clickButtonByContainer('search_mini_form');
232
+ $this->assertContains('?q=' . self::$_productSku, $this->url());
233
+ // Add product to cart
234
+ $productsByList = $this->findElementsByCssSelector('.btn-cart');
235
+ foreach ($productsByList as $btn) {
236
+ if ($btn->displayed()) {
237
+ $btn->click();
238
+ }
239
+ }
240
+ $this->assertContains('checkout/cart',$this->url());
241
+ // Go to checkout
242
+ $this->byCssSelector('.btn-proceed-checkout')->click();
243
+ $this->assertContains('checkout/onepage/', $this->url());
244
+ //Customer onepage
245
+ if(!$this->_isLogged){
246
+ $this->registerCustomer();
247
+ }else{
248
+ $this->loginCustomer();
249
+ }
250
+
251
+
252
+ }
253
+
254
+ /**
255
+ * Selenium register Customer
256
+ */
257
+ public function registerCustomer(){
258
+ $customer = $this->getCustomer();
259
+ $this->byId('login:register')->click();
260
+ $this->byId('onepage-guest-register-button')->click();
261
+ sleep(self::$_defaultSleep);
262
+ $this->byId('billing:firstname')->value($customer['firstname']);
263
+ $this->byId('billing:lastname')->value($customer['lastname']);
264
+ $this->byId('billing:email')->value($customer['email']);
265
+ $this->byId('billing:street1')->value($customer['street1']);
266
+ $this->byId('billing:city')->value($customer['city']);
267
+ $this->byId('billing:country_id')->value($customer['country_id']);
268
+ if($this->byName('billing[region]')->displayed()) {
269
+ $this->byId('billing:region')->value($customer['region']);
270
+ }
271
+ $this->byId('billing:postcode')->value($customer['postcode']);
272
+ $this->byId('billing:telephone')->value($customer['telephone']);
273
+ $this->byId('billing:customer_password')->value($customer['customer_password']);
274
+ $this->byId('billing:confirm_password')->value($customer['confirm_password']);
275
+ /*if($this->byName('billing[taxvat]')->displayed()) {
276
+ $this->byId('billing:taxvat')->value($customer['taxvat']);
277
+ }*/
278
+ $this->clickButtonByContainer('billing-buttons-container');
279
+
280
+ sleep(self::$_defaultSleep);
281
+ //$this->assertElementHasClass('active', $this->byId('opc-shipping_method'));
282
+ sleep(self::$_defaultSleep);
283
+ }
284
+
285
+ /**
286
+ * Login Customer
287
+ */
288
+ public function loginCustomer(){
289
+ $this->byId('login-email')->value(self::$_custmerTest['email']);
290
+ $this->byId('login-password')->value(self::$_custmerTest['customer_password']);
291
+ $this->byId('login-form')->submit();
292
+ sleep(self::$_defaultSleep);
293
+ $this->assertElementHasClass('active', $this->byId('opc-billing'));
294
+ $this->clickButtonByContainer('billing-buttons-container');
295
+ sleep(self::$_defaultSleep);
296
+ $this->assertElementHasClass('active', $this->byId('opc-shipping_method'));
297
+
298
+ sleep(self::$_defaultSleep);
299
+
300
+ }
301
+
302
+ /**
303
+ * Delete Test customer
304
+ *
305
+ * @return boolean
306
+ */
307
+ public function deleteCustomerIfExists(){
308
+ $website = Mage::app()->getWebsite()->getId();
309
+
310
+ /** @var $customer Mage_Customer_Model_Customer */
311
+ $customer = Mage::getModel('customer/customer');
312
+ $customer->setWebsiteId(($website?$website:1));
313
+ $customer->loadByEmail(self::$_custmerTest['email']);
314
+
315
+ if ($customer->getId()) {
316
+ $customer->setIsDeleteable(true);
317
+ $customer->delete();
318
+ return true;
319
+ }else{
320
+ return false;
321
+ }
322
+ }
323
+
324
+ /**
325
+ * @return PHPUnit_Extensions_Selenium2TestCase_Element
326
+ */
327
+ public function findElementsByCssSelector($selector, \PHPUnit_Extensions_Selenium2TestCase_Element $root_element = null) {
328
+ if (!$root_element) {
329
+ $root_element = $this;
330
+ }
331
+ return $root_element->elements($this->using('css selector')->value($selector));
332
+ }
333
+
334
+ /**
335
+ * Performs a click on the child element the id of the last container as a parameter
336
+ *
337
+ * @param string $container
338
+ */
339
+ public function clickButtonByContainer($container) {
340
+ $buttons = $this->findElementsByCssSelector('.button', $this->byId($container));
341
+ foreach ($buttons as $b) {
342
+ if ($b->displayed()) {
343
+ $b->click();
344
+ }
345
+ }
346
+ }
347
+
348
+ /**
349
+ * Get Http Response Code
350
+ *
351
+ * @return int
352
+ */
353
+ public function getHttpCode(){
354
+ return Mage::app()->getResponse()->getHttpResponseCode();
355
+ }
356
+
357
+ /**
358
+ * @param $class
359
+ * @param PHPUnit_Extensions_Selenium2TestCase_Element $element
360
+ */
361
+ public function assertElementHasClass( $class, \PHPUnit_Extensions_Selenium2TestCase_Element $element )
362
+ {
363
+ $classes = explode(' ', $element->attribute('class') );
364
+ $this->assertContains($class, $classes);
365
+ }
366
+
367
+ protected function tearDown(){
368
+ //$this->deleteCustomerIfExists();
369
+ print shell_exec('cat ../var/log/Uecommerce_Mundipagg.log');
370
+
371
+ }
372
+ public static function initFrontend($code = null)
373
+ {
374
+ if ($code === null) {
375
+ $code = self::getArg('store_code', '');
376
+ }
377
+ self::init($code);
378
+
379
+ Mage::register('isSecureArea', true, true);
380
+
381
+
382
+ Mage::app()->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
383
+
384
+ Mage::getSingleton('core/translate')->setLocale(Mage::app()->getLocale()->getLocaleCode())->init(
385
+ Mage_Core_Model_App_Area::AREA_FRONTEND,
386
+ true
387
+ );
388
+ }
389
+
390
+ protected static function init($code)
391
+ {
392
+ Mage::$headersSentThrowsException = false;
393
+
394
+ // $options = array();
395
+ // $options['config_model'] = 'Codex_Xtest_Model_Core_Config';
396
+ // $options['cache_dir'] = Mage::getBaseDir('var').DS.'cache'.DS.'xtest';
397
+
398
+ Mage::reset();
399
+ Mage::app($code, 'store');
400
+
401
+ // if ($disableDouble = (bool)self::getArg('disable_double', false)) {
402
+ // self::getConfig()->setDisableDoubles($disableDouble);
403
+ // }
404
+ }
405
+
406
+ /**
407
+ * @return Mage_Core_Model_Config
408
+ */
409
+ public static function getConfig()
410
+ {
411
+ return Mage::getConfig();
412
+ }
413
+
414
+ public function selectOptionByValue(PHPUnit_Extensions_Selenium2TestCase_Element $element, $value){
415
+ PHPUnit_Extensions_Selenium2TestCase_Element_Select::fromElement($element)->selectOptionByValue($value);
416
+ }
417
+
418
+ public function getCustomer()
419
+ {
420
+ if($this->_isPj) {
421
+ $customer = self::$_customerPjTest;
422
+ } else {
423
+ $customer = self::$_custmerTest;
424
+ }
425
+
426
+ return $customer;
427
+ }
428
+
429
+ public function execSuccessTest($url = false)
430
+ {
431
+ if(!$url) {
432
+ $url = 'mundipagg/standard/success';
433
+ }
434
+ if(!getenv($this->_envCI)) {
435
+ sleep(self::$_defaultSleep+20);
436
+ $this->assertContains($url,$this->url());
437
+ }
438
+ }
439
+
440
+
441
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/BoletoTest.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Uecommerce_Mundipagg_Test_Selenium_BoletoTest extends Uecommerce_Mundipagg_Test_Selenium_Abstract {
5
+
6
+ public function setUp() {
7
+ $this->_installmentActive=false;
8
+ $this->_additionalSaveSettings['payment/mundipagg_boleto/active'] = '1';
9
+ parent::setUp();
10
+
11
+ }
12
+
13
+ /**
14
+ * Test boleto registering a new customer.
15
+ */
16
+ public function testBoletoRegistered(){
17
+ $this->_isLogged = false;
18
+ $this->runMundipagg();
19
+ $this->setBoleto();
20
+ }
21
+
22
+ /**
23
+ * Test boleto registering a new company customer
24
+ * @depends testBoletoLogged
25
+ */
26
+ public function testBoletoRegisteredPJ()
27
+ {
28
+ $this->_isLogged = false;
29
+ $this->_isPj = true;
30
+ $this->setBoleto();
31
+ }
32
+
33
+ /**
34
+ * Test boleto with the logged customer.
35
+ *
36
+ * @depends testBoletoRegistered
37
+ */
38
+ public function testBoletoLogged(){
39
+ $this->_isLogged = true;
40
+ $this->runMundipagg();
41
+ $this->setBoleto();
42
+ }
43
+
44
+ /**
45
+ * Test boleto with the logged company customer.
46
+ *
47
+ * @depends testBoletoRegisteredPJ
48
+ */
49
+ public function testBoletoLoggedPj()
50
+ {
51
+ $this->_isLogged = true;
52
+ $this->_isPj = true;
53
+ $this->runMundipagg();
54
+ $this->setBoleto();
55
+ }
56
+
57
+ /**
58
+ * Set all values to boleto and test.
59
+ */
60
+ protected function setBoleto(){
61
+ $customer = $this->getCustomer();
62
+ $this->clickButtonByContainer('shipping-method-buttons-container');
63
+ sleep(self::$_defaultSleep);
64
+ $this->byId('p_method_mundipagg_boleto')->click();
65
+ $this->byId('mundipagg_boleto_boleto_taxvat')->value($customer['taxvat']);
66
+ $this->clickButtonByContainer('payment-buttons-container');
67
+ sleep(self::$_defaultSleep);
68
+ $this->clickButtonByContainer('review-buttons-container');
69
+ sleep(self::$_defaultSleep);
70
+
71
+ if(!getenv($this->_envCI)) {
72
+ $elements = $this->byCssSelector('.pagSucess')->elements($this->using('css selector')->value('a'));
73
+ foreach($elements as $element){
74
+ $element->click();
75
+ }
76
+ sleep(self::$_defaultSleep+20);
77
+ $this->assertContains('mundipagg/standard/success',$this->url());
78
+ }
79
+ }
80
+
81
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes extends Uecommerce_Mundipagg_Test_Selenium_Abstract {
4
+
5
+ /**
6
+ * Fake credit cards informations to test
7
+ *
8
+ * @var array
9
+ */
10
+ public $_ccCards;
11
+ public $_isCardonfile;
12
+ public $_paymentType;
13
+ public $_ccLength;
14
+ public $_values;
15
+
16
+ public function setUp() {
17
+ $this->_installmentActive = false;
18
+ $this->_additionalSaveSettings = array(
19
+ 'payment/mundipagg_creditcardoneinstallment/active' => 1,
20
+ 'payment/mundipagg_creditcard/active' => 1,
21
+ 'payment/mundipagg_twocreditcards/active' => 1,
22
+ 'payment/mundipagg_threecreditcards/active' => 1,
23
+ 'payment/mundipagg_fourcreditcards/active' => 1,
24
+ 'payment/mundipagg_fivecreditcards/active' => 1,
25
+ );
26
+
27
+ $this->setAllFakeCc();
28
+
29
+ parent::setUp();
30
+ }
31
+
32
+ /**
33
+ * Test all ccTypes validations
34
+ */
35
+ public function runAllCcFlagsValidations() {
36
+ $this->runMundipagg();
37
+ $this->clickButtonByContainer('shipping-method-buttons-container');
38
+ sleep(self::$_defaultSleep);
39
+ $this->byId('p_method_mundipagg_' . $this->_paymentType)->click();
40
+
41
+ if (empty($this->_ccLength)) {
42
+ $this->_ccLength = 1;
43
+ }
44
+
45
+ for ($i = 1; $i <= $this->_ccLength; $i++) {
46
+ $flags = $this->findElementsByCssSelector('.cc_brand_types', $this->byId('mundipagg_' . $this->_paymentType . '_new_credit_card_' . $this->_ccLength . '_' . $i));
47
+ foreach ($this->_ccCards as $flag => $card) {
48
+ foreach ($card as $key => $number) {
49
+ $this->byId('mundipagg_' . $this->_paymentType . '_' . $this->_ccLength . '_' . $i . '_cc_number')->value($this->_ccCards[$flag][$key][0]);
50
+ foreach ($flags as $element) {
51
+ if (strpos($element->attribute('class'), strtolower($flag)) !== false) {
52
+ sleep(1);
53
+ $this->assertContains('active', $element->attribute('class'));
54
+ $this->byId('mundipagg_' . $this->_paymentType . '_' . $this->_ccLength . '_' . $i . '_cc_number')->clear();
55
+ }
56
+ }
57
+ }
58
+ }
59
+ $this->byId('mundipagg_' . $this->_paymentType . '_' . $this->_ccLength . '_' . $i . '_cc_number')->clear();
60
+ $ccRand = $this->getCcRand();
61
+ $this->byId('mundipagg_' . $this->_paymentType . '_' . $this->_ccLength . '_' . $i . '_cc_number')->value($ccRand[0]);
62
+ $this->byId('mundipagg_' . $this->_paymentType . '_cc_holder_name_' . $this->_ccLength . '_' . $i)->value(self::$_custmerTest['firstname']);
63
+ $this->selectOptionByValue($this->byId('mundipagg_' . $this->_paymentType . '_expirationMonth_' . $this->_ccLength . '_' . $i), 06);
64
+ $this->selectOptionByValue($this->byId('mundipagg_' . $this->_paymentType . '_expirationYear_' . $this->_ccLength . '_' . $i), 25);
65
+ $this->byId('mundipagg_' . $this->_paymentType . '_cc_cid_' . $this->_ccLength . '_' . $i)->value($ccRand[1]);
66
+
67
+ //TODO Implement Tests for card on file.
68
+ //$this->byId('mundipagg_' . $this->_paymentType . '_save_token_' . $this->_ccLength . '_' . $i)->click();
69
+ }
70
+ $this->setValues();
71
+ }
72
+
73
+ public function runCardonfile() {
74
+ $this->runMundipagg();
75
+ if ($this->_isCardonfile) {
76
+ for ($i = 1; $i < $this->_ccLength; $i++) {
77
+ $cardonFiles = $this->byCssSelector('select#mundipagg_twocreditcards_token_' . $this->_ccLength . '_' . $i . ' > option');
78
+
79
+ $this->selectOptionByValue($this->byId('mundipagg_twocreditcards_token_' . $this->_ccLength . '_' . $i), $cardonFiles[1]->value());
80
+ }
81
+ }
82
+ $this->clickButtonByContainer('shipping-method-buttons-container');
83
+ sleep(self::$_defaultSleep);
84
+ $this->byId('p_method_mundipagg_' . $this->_paymentType)->click();
85
+ $this->setValues();
86
+ }
87
+
88
+ public function continueBuy() {
89
+ $this->clickButtonByContainer('payment-buttons-container');
90
+ sleep(self::$_defaultSleep);
91
+ $this->clickButtonByContainer('review-buttons-container');
92
+ $this->execSuccessTest();
93
+ }
94
+
95
+ public function setValues() {
96
+ if (is_array($this->_values) && count($this->_values)) {
97
+ foreach ($this->_values as $input => $value) {
98
+ $this->byId('mundipagg_' . $this->_paymentType . '_new_value_' . $this->_ccLength . '_' . $input)->value($value);
99
+ }
100
+ } else {
101
+ return false;
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Set all fake Cc
107
+ */
108
+ public function setAllFakeCc() {
109
+ $this->_ccCards = array(
110
+ 'VI' => array(
111
+ // Credit card number // Verification Number
112
+ array('4539237284301694', '123'),
113
+ // array('4485024757890740', '123'),
114
+ // array('4970582526036384', '123'),
115
+ // array('4716815682675549', '123'),
116
+ // array('4218703979907168', '123'),
117
+ ),
118
+ 'MC' => array(
119
+ array('5208217933877887', '123'),
120
+ // array('5575900683301001', '123'),
121
+ // array('5303567141573171', '123'),
122
+ // array('5368614439596803', '123'),
123
+ // array('5208793547521723', '123'),
124
+ ),
125
+ 'DI' => array(
126
+ array('30151661373832', '123'),
127
+ // array('36551150116846', '123'),
128
+ // array('30008112964538', '123'),
129
+ // array('30110260186607', '123'),
130
+ ),
131
+ 'AE' => array(
132
+ array('377422011608347', '1234'),
133
+ // array('370935808314404', '1234'),
134
+ // array('349750622252286', '1234'),
135
+ // array('375588571162990', '1234'),
136
+ ),
137
+ 'HI' => array(
138
+ array('6062828614827141', '123'),
139
+ // array('6062829471639405', '123'),
140
+ // array('6062828961022288', '123'),
141
+ // array('6062825624254001', '123'),
142
+ // array('3841001111222233334', '123')
143
+ ),
144
+ 'EL' => array(
145
+ array('6362974242267115', '123'),
146
+ array('4011783039660247', '123'),
147
+ array('6363683924722462', '123'),
148
+ array('4011798939333205', '123'),
149
+ )
150
+ );
151
+ }
152
+
153
+ /**
154
+ * Get
155
+ *
156
+ * @return array
157
+ */
158
+ public function getCcRand() {
159
+ $total = (count($this->_ccCards) - 1);
160
+ $nrand = rand(0, $total);
161
+ if ($nrand == $total) {
162
+ $nrand = 1;
163
+ }
164
+ $currentRand = reset(array_slice($this->_ccCards, $nrand, -($total - $nrand)));
165
+ return $currentRand[0];
166
+ }
167
+
168
+ protected function deleteAllCardonfiles() {
169
+ $customer = Mage::getModel("customer/customer");
170
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
171
+ if ($customer->loadByEmail(parent::$_custmerTest['email'])->getId()) {
172
+ $ccsCollection = Mage::getResourceModel('mundipagg/cardonfile_collection')
173
+ ->addEntityIdFilter($customer->getId());
174
+ foreach ($ccsCollection as $cardonfile) {
175
+ $cardonfile->delete();
176
+ }
177
+ }
178
+ }
179
+
180
+ protected function tearDown() {
181
+ // if ($this->_isLogged) {
182
+ // $this->deleteAllCardonfiles();
183
+ // }
184
+ parent::tearDown();
185
+ }
186
+
187
+ protected function runProcess()
188
+ {
189
+ $this->runAllCcFlagsValidations();
190
+ $this->continueBuy();
191
+ }
192
+
193
+ /**
194
+ * To set values to split cards.
195
+ *
196
+ * @param int $n
197
+ */
198
+ protected function setCCValues($n = 2)
199
+ {
200
+ switch ($n) {
201
+ case 2:
202
+ $this->_values = array(
203
+ 1 => '5',
204
+ // 2 => '6,22'
205
+ );
206
+ break;
207
+ case 3:
208
+ $this->_values = array(
209
+ 1 => '5,61',
210
+ 2 => '5,61',
211
+ 3 => '5,00'
212
+ );
213
+ break;
214
+ case 4:
215
+ $this->_values = array(
216
+ 1 => '3,74',
217
+ 2 => '3,74',
218
+ 3 => '3,74',
219
+ 4 => '5,00'
220
+ );
221
+ break;
222
+ case 5:
223
+ $this->_values = array(
224
+ 1 => '2,22',
225
+ 2 => '3,00',
226
+ 3 => '3,00',
227
+ 4 => '3,00',
228
+ 5 => '5,00'
229
+ );
230
+ break;
231
+ }
232
+ }
233
+
234
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/CreditcardTest.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_CreditcardTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'creditcard';
7
+ parent::setUp();
8
+
9
+ }
10
+
11
+ public function testCreditcardRegistered() {
12
+ $this->_isLogged = false;
13
+ $this->runProcess();
14
+ }
15
+
16
+ /**
17
+ * @depends testCreditcardRegistered
18
+ */
19
+ public function testCreditcardLogged(){
20
+ $this->_isLogged = true;
21
+ //$this->runCardonfile();
22
+ $this->runProcess();
23
+ }
24
+
25
+ /**
26
+ * @depends testCreditcardLogged
27
+ */
28
+ public function testCreditcardRegisteredPj()
29
+ {
30
+ $this->_isLogged = false;
31
+ $this->_isPj = true;
32
+ $this->runProcess();
33
+ }
34
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/CreditcardoneinstallmentTest.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_CreditcardoneinstallmentTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'creditcardoneinstallment';
7
+ parent::setUp();
8
+
9
+ }
10
+
11
+
12
+
13
+ public function testCreditcardoneinstallmentRegistered() {
14
+ $this->_isLogged = false;
15
+ $this->runProcess();
16
+ }
17
+
18
+ /**
19
+ * @depends testCreditcardoneinstallmentRegistered
20
+ */
21
+ public function testCreditcardoneinstallmentLogged(){
22
+ $this->_isLogged = true;
23
+ //$this->runCardonfile();
24
+ $this->runProcess();
25
+ }
26
+
27
+ /**
28
+ * @depends testCreditcardoneinstallmentLogged
29
+ */
30
+ public function testCreditcardoneinstallmentRegisteredPj()
31
+ {
32
+ $this->_isLogged = false;
33
+ $this->_isPj = true;
34
+ $this->runProcess();
35
+ }
36
+
37
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/FivecreditcardsTest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_FivecreditcardisTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'fivecreditcards';
7
+ $this->_ccLength = 5;
8
+ parent::setUp();
9
+ $this->setCCValues($this->_ccLength);
10
+
11
+ }
12
+
13
+ public function testFiveCreditcardsRegistered() {
14
+ $this->_isLogged = false;
15
+ $this->runProcess();
16
+ }
17
+
18
+ /**
19
+ * @depends testFiveCreditcardsRegistered
20
+ */
21
+ public function testFiveCreditcardsLogged(){
22
+ $this->_isLogged = true;
23
+ $this->runProcess();
24
+ }
25
+
26
+ public function testFiveCreditcardsRegisteredPj()
27
+ {
28
+ $this->_isLogged = false;
29
+ $this->_isPj = true;
30
+ $this->runProcess();
31
+ }
32
+
33
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/FourcheditcardsTest.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_FourcreditcardisTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'fourcreditcards';
7
+ $this->_ccLength = 4;
8
+ parent::setUp();
9
+ $this->setCCValues($this->_ccLength);
10
+
11
+ }
12
+
13
+ public function testFourCreditcardsRegistered() {
14
+ $this->_isLogged = false;
15
+ $this->runProcess();
16
+ }
17
+
18
+ /**
19
+ * @depends testFourCreditcardsRegistered
20
+ */
21
+ public function testFourCreditcardsLogged(){
22
+ $this->_isLogged = true;
23
+ $this->runProcess();
24
+ }
25
+
26
+ /**
27
+ * @depends testFourCreditcardsLogged
28
+ */
29
+ public function testFourCreditcardsRegisteredPj()
30
+ {
31
+ $this->_isLogged = false;
32
+ $this->_isPj = true;
33
+ $this->runProcess();
34
+ }
35
+
36
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/ThreecreditcardsTest.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_ThreecreditcardisTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'threecreditcards';
7
+ $this->_ccLength = 3;
8
+ parent::setUp();
9
+ $this->setCCValues($this->_ccLength);
10
+
11
+ }
12
+
13
+ public function testThreeCreditcardsRegistered() {
14
+ $this->_isLogged = false;
15
+ $this->runProcess();
16
+ }
17
+
18
+ /**
19
+ * @depends testThreeCreditcardsRegistered
20
+ */
21
+ public function testThreeCreditcardsLogged(){
22
+ $this->_isLogged = true;
23
+ //$this->runCardonfile();
24
+ $this->runProcess();
25
+ }
26
+
27
+ /**
28
+ * @depends testThreeCreditcardsLogged
29
+ */
30
+ public function testThreeCreditcardsRegisteredPJ()
31
+ {
32
+ $this->_isLogged = false;
33
+ $this->_isPj = true;
34
+ $this->runProcess();
35
+ }
36
+
37
+
38
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/CcTypes/TwocreditcardsTest.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_Test_Selenium_CcTypes_TwocreditcardsTest extends Uecommerce_Mundipagg_Test_Selenium_CcTypes {
4
+
5
+ public function setUp() {
6
+ $this->_paymentType = 'twocreditcards';
7
+ $this->_ccLength = 2;
8
+ parent::setUp();
9
+ $this->setCCValues($this->_ccLength);
10
+ }
11
+
12
+ public function testTwoCreditcardsRegistered() {
13
+ $this->_isLogged = false;
14
+ $this->runProcess();
15
+ }
16
+
17
+ /**
18
+ * @depends testTwoCreditcardsRegistered
19
+ */
20
+ public function testTwoCreditcardsLogged(){
21
+ $this->_isLogged = true;
22
+ //$this->runCardonfile();
23
+ $this->runProcess();
24
+ }
25
+
26
+ /**
27
+ * @depends testTwoCreditcardsLogged
28
+ */
29
+ public function testTwoCreditcardsRegisteredPj()
30
+ {
31
+ $this->_isLogged = false;
32
+ $this->_isPj = true;
33
+ $this->runProcess();
34
+ }
35
+
36
+
37
+
38
+ }
app/code/community/Uecommerce/Mundipagg/Test/Selenium/DebitTest.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Uecommerce_Mundipagg_Test_Selenium_DebitTest extends Uecommerce_Mundipagg_Test_Selenium_Abstract
5
+ {
6
+ //001,237,341,VBV,cielo_mastercard,cielo_visa
7
+ protected $_debitTypes = array(
8
+ '001',
9
+ //'237', // @todo O banco especificado não está configurado para a loja Uecommerce
10
+ '341',
11
+ //'VBV', // @todo O banco especificado não está configurado para a loja Uecommerce
12
+ 'cielo_mastercard',
13
+ 'cielo_visa'
14
+ );
15
+
16
+ protected $_randonBanck = false;
17
+
18
+ public function setUp()
19
+ {
20
+ $this->_installmentActive = false;
21
+ $this->_additionalSaveSettings['payment/mundipagg_debit/active'] = '1';
22
+ $this->_additionalSaveSettings['payment/mundipagg_debit/debit_types'] = implode(',',$this->_debitTypes);
23
+ $this->_additionalSaveSettings['payment/mundipagg_debit/apiDebitStagingUrl'] = 'https://32616eb84cb7487a81b748ab2eeeeac5.cloudapp.net/Order/OnlineDebit/';
24
+ $this->_additionalSaveSettings['payment/mundipagg_standard/merchantKeyStaging'] = '41CAA365-1A75-4FB7-BF1B-2EAA089264DB';
25
+
26
+ parent::setUp();
27
+ }
28
+
29
+ /**
30
+ * Test debit registering a new customer.
31
+ */
32
+ public function testDebitRegistered(){
33
+ $this->_isLogged = false;
34
+ $this->runMundipagg();
35
+ $this->setDebit();
36
+ }
37
+
38
+ /**
39
+ * @depends testDebitRegistered
40
+ */
41
+ public function testDebitLogged()
42
+ {
43
+ $this->_isLogged = true;
44
+ $this->runMundipagg();
45
+ $this->setDebit();
46
+ }
47
+
48
+ /**
49
+ * @depends testDebitLogged
50
+ */
51
+ public function testDebitRegisteredPj()
52
+ {
53
+ $this->_isPj = true;
54
+ $this->_isLogged = false;
55
+ $this->runMundipagg();
56
+ $this->setDebit();
57
+ }
58
+
59
+ /**
60
+ * Set all values to debit and test.
61
+ */
62
+ protected function setDebit(){
63
+ $customer = $this->getCustomer();
64
+ $this->clickButtonByContainer('shipping-method-buttons-container');
65
+ sleep(self::$_defaultSleep);
66
+ $this->byId('p_method_mundipagg_debit')->click();
67
+ $this->byId('mundipagg_debit_taxvat')->value($customer['taxvat']);
68
+ sleep(1);
69
+ $this->byId('mundipagg_debit_'.$this->getRandonBanck())->click();
70
+ $this->clickButtonByContainer('payment-buttons-container');
71
+ sleep(self::$_defaultSleep);
72
+ $this->clickButtonByContainer('review-buttons-container');
73
+ sleep(self::$_defaultSleep);
74
+ switch ($this->getRandonBanck()) {
75
+ case 'cielo_visa':
76
+ case 'cielo_mastercard':
77
+ $url = 'cieloecommerce.cielo.com.br';
78
+ break;
79
+ case '341':
80
+ $url = 'onlinedebitstaging.mundipaggone.com';
81
+ break;
82
+ case '001':
83
+ $url = 'www16.bancodobrasil.com.br';
84
+ break;
85
+ }
86
+ $this->execSuccessTest($url);
87
+ }
88
+
89
+ protected function getRandonBanck()
90
+ {
91
+ if(!$this->_randonBanck) {
92
+ $this->_randonBanck = $this->_debitTypes[array_rand($this->_debitTypes)];
93
+ }
94
+
95
+ return $this->_randonBanck;
96
+ }
97
+
98
+ }
app/code/community/Uecommerce/Mundipagg/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ class Uecommerce_Mundipagg_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
32
+ {
33
+ /**
34
+ * Constructor
35
+ */
36
+ protected function _construct()
37
+ {
38
+ $this->setUsedModuleName('mundipagg');
39
+ }
40
+
41
+ public function installmentsandinterestAction()
42
+ {
43
+ $post = $this->getRequest()->getPost();
44
+ $result = array();
45
+ $installmentsHelper = Mage::helper('mundipagg/installments');
46
+
47
+ if(isset($post['cctype'])){
48
+ $total = $post['total'];
49
+ $cctype = $post['cctype'];
50
+
51
+ if(!$total || $total == 0) {
52
+ $total = null;
53
+ }
54
+
55
+ $installments = $installmentsHelper->getInstallmentForCreditCardType($cctype,$total);
56
+
57
+ $result['installments'] = $installments;
58
+ $result['brand'] = $cctype;
59
+ } else {
60
+ $installments = $installmentsHelper->getInstallmentForCreditCardType();
61
+ $result['installments'] = $installments;
62
+ }
63
+
64
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
65
+ }
66
+
67
+ public function setoldsettingsAction()
68
+ {
69
+ $path = 'payment/mundipagg_standard/';
70
+
71
+ if(!Mage::getStoreConfig($path.'parcelamento_de2')) {
72
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => $this->__('Probably you had not installed the old version.'))));
73
+ return;
74
+ }
75
+
76
+ $settings = array();
77
+
78
+ $settings[0] = array(Mage::getStoreConfig($path.'parcelamento_de2'),'1','');
79
+
80
+ for($i=2;$i<=12;$i++) {
81
+ $settings[] = array(Mage::getStoreConfig($path.'parcelamento_ate'.$i),$i, '');
82
+ }
83
+
84
+ Mage::getConfig()->saveConfig($path.'installments', serialize($settings));
85
+ Mage::getConfig()->reinit();
86
+ Mage::app()->reinitStores();
87
+ Mage::getConfig()->cleanCache();
88
+
89
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
90
+ 'success' => $this->__('The old settings have been successfully restored! Please check and make tests in your store.'))));
91
+ }
92
+ }
app/code/community/Uecommerce/Mundipagg/controllers/ClearsaleController.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_ClearsaleController extends Uecommerce_Mundipagg_Controller_Abstract {
4
+
5
+ public function getConfigAction() {
6
+
7
+ if ($this->requestIsValid() == false) {
8
+ echo $this->getResponseForInvalidRequest();
9
+ return false;
10
+ }
11
+
12
+ $entityCode = Mage::getStoreConfig('payment/mundipagg_standard/clearsale_entitycode');
13
+ $app = Mage::getStoreConfig('payment/mundipagg_standard/clearsale_app');
14
+ $response = array(
15
+ 'entityCode' => $entityCode,
16
+ 'app' => $app,
17
+ 'sessionId' => $this->getSessionId()
18
+ );
19
+
20
+ try {
21
+ return $this->jsonResponse($response);
22
+
23
+ } catch (Exception $e) {
24
+
25
+ }
26
+ }
27
+
28
+ }
app/code/community/Uecommerce/Mundipagg/controllers/FcontrolController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_FcontrolController extends Uecommerce_Mundipagg_Controller_Abstract {
4
+
5
+ /*
6
+ public function getOrderIdAction() {
7
+
8
+ if ($this->requestIsValid() == false) {
9
+ echo $this->getResponseForInvalidRequest();
10
+
11
+ return false;
12
+ }
13
+
14
+ $quoteId = Mage::getSingleton('checkout/session')->getQuoteId();
15
+ $quote = Mage::getModel("sales/quote")->load($quoteId);
16
+
17
+ $quote->reserveOrderId();
18
+
19
+ $incrementId = $quote->getReservedOrderId();
20
+ $response['orderId'] = $incrementId;
21
+
22
+ return $this->jsonResponse($response);
23
+ }
24
+ */
25
+
26
+ const FINGERPRINT_URL_SANDBOX = 'https://static.fcontrol.com.br/fingerprint/hmlg-fcontrol-ed.min.js';
27
+ const FINGERPRINT_URL_PRODUCTION = 'https://static.fcontrol.com.br/fingerprint/fcontrol.min-ed.js';
28
+
29
+ public function getConfigAction() {
30
+ $environment = Uecommerce_Mundipagg_Model_Source_FControlEnvironment::getEnvironment();
31
+ $configStrPrefix = 'payment/mundipagg_standard';
32
+
33
+ if ($environment == Uecommerce_Mundipagg_Model_Source_FControlEnvironment::SANDBOX) {
34
+ $configStrKey = "{$configStrPrefix}/fcontrol_key_sandbox";
35
+
36
+ } else {
37
+ $configStrKey = "{$configStrPrefix}/fcontrol_key_production";
38
+ }
39
+
40
+ if ($environment == Uecommerce_Mundipagg_Model_Source_FControlEnvironment::SANDBOX) {
41
+ $url = self::FINGERPRINT_URL_SANDBOX;
42
+
43
+ } else {
44
+ $url = self::FINGERPRINT_URL_PRODUCTION;
45
+ }
46
+
47
+ $response = array();
48
+ $response['sessionId'] = $this->getSessionId();
49
+ $response['key'] = Mage::getStoreConfig($configStrKey);
50
+ $response['scriptUrl'] = $url;
51
+
52
+ try {
53
+ return $this->jsonResponse($response);
54
+
55
+ } catch (Exception $e) {
56
+ }
57
+
58
+ }
59
+
60
+ public function reportErrorAction() {
61
+ if ($this->requestIsValid() == false) {
62
+ echo $this->getResponseForInvalidRequest();
63
+
64
+ return false;
65
+ }
66
+
67
+ $api = new Uecommerce_Mundipagg_Model_Api();
68
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
69
+ $message = $this->getRequest()->getPost('message');
70
+
71
+ try {
72
+ $helperLog->error($message, true);
73
+ $api->mailError($message);
74
+
75
+ } catch (Exception $e) {
76
+
77
+ }
78
+ }
79
+
80
+ public function logFpAction() {
81
+ $helperLog = new Uecommerce_Mundipagg_Helper_Log(__METHOD__);
82
+ $helperUtil = new Uecommerce_Mundipagg_Helper_Util();
83
+ $event = $this->getRequest()->getPost('event');
84
+ $data = $this->getRequest()->getPost('data');
85
+ $data = json_decode($data);
86
+ $data = $helperUtil->jsonEncodePretty($data);
87
+ $data = stripslashes($data);
88
+ $message = "Fingerprint {$event}:\n{$data}\n";
89
+
90
+ try {
91
+ $helperLog->info($message);
92
+
93
+ } catch (Exception $e) {
94
+ }
95
+
96
+ }
97
+
98
+ }
app/code/community/Uecommerce/Mundipagg/controllers/StandardController.php ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ class Uecommerce_Mundipagg_StandardController extends Mage_Core_Controller_Front_Action {
31
+
32
+ /**
33
+ * Order instance
34
+ */
35
+ protected $_order;
36
+
37
+ function indexAction() {
38
+ $request = $this->getRequest();
39
+ $post = $request->getPost();
40
+
41
+ echo 'ok!';
42
+ }
43
+
44
+ public function getOrder() {
45
+ if ($this->_order == null) {
46
+
47
+ }
48
+
49
+ return $this->_order;
50
+ }
51
+
52
+ /**
53
+ * Get block instance
54
+ *
55
+ * @return
56
+ */
57
+ protected function _getRedirectBlock() {
58
+ return $this->getLayout()->createBlock('standard/redirect');
59
+ }
60
+
61
+ public function getStandard() {
62
+ return Mage::getSingleton('mundipagg/standard');
63
+ }
64
+
65
+ protected function _expireAjax() {
66
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
67
+ $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired');
68
+ exit;
69
+ }
70
+ }
71
+
72
+ public function getOnepage() {
73
+ return Mage::getSingleton('checkout/type_onepage');
74
+ }
75
+
76
+ /**
77
+ * Partial payment
78
+ */
79
+ public function partialAction() {
80
+ $paymentMethod = Mage::helper('payment')->getMethodInstance('mundipagg_creditcard');
81
+
82
+ $session = Mage::getSingleton('checkout/session');
83
+
84
+ $approvalRequestSuccess = $session->getApprovalRequestSuccess();
85
+
86
+ if (!$session->getLastSuccessQuoteId() && $approvalRequestSuccess != 'partial') {
87
+ $this->_redirect('checkout/cart');
88
+
89
+ return;
90
+ }
91
+
92
+ $lastQuoteId = $session->getLastSuccessQuoteId();
93
+
94
+ $session->setQuoteId($lastQuoteId);
95
+
96
+ $quote = Mage::getModel('sales/quote')->load($lastQuoteId);
97
+
98
+ $this->getOnepage()->setQuote($quote);
99
+ $this->getOnepage()->getQuote()->setIsActive(true);
100
+ $this->getOnepage()->getQuote()->save();
101
+
102
+ if ($session->getLastRealOrderId()) {
103
+ Mage::getSingleton('checkout/session')->setApprovalRequestSuccess('partial');
104
+
105
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
106
+
107
+ if ($order->getId()) {
108
+ //Render
109
+ $this->loadLayout();
110
+ $this->getLayout()->getBlock('content')->append($this->getLayout()->createBlock('mundipagg/standard_partial'));
111
+ $this->renderLayout();
112
+ } else {
113
+ $this->_redirect();
114
+ }
115
+ } else {
116
+ $this->_redirect();
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Partial payment Post
122
+ */
123
+ public function partialPostAction() {
124
+ $session = Mage::getSingleton('checkout/session');
125
+
126
+ // Post
127
+ if ($data = $this->getRequest()->getPost('payment', array())) {
128
+ try {
129
+ $lastQuoteId = $session->getLastSuccessQuoteId();
130
+
131
+ $session->setQuoteId($lastQuoteId);
132
+
133
+ $quote = Mage::getModel('sales/quote')->load($lastQuoteId);
134
+
135
+ $this->getOnepage()->setQuote($quote);
136
+ $this->getOnepage()->getQuote()->setIsActive(true);
137
+
138
+ // Get Reserved Order Id
139
+ if ($reservedOrderId = $this->getOnepage()->getQuote()->getReservedOrderId()) {
140
+ $session->setApprovalRequestSuccess('partial');
141
+
142
+ $order = Mage::getModel('sales/order')->loadByIncrementId($reservedOrderId);
143
+
144
+ if ($order->getStatus() == 'pending' OR $order->getStatus() == 'payment_review') {
145
+ if (empty($data)) {
146
+ return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data'));
147
+ }
148
+
149
+ if ($this->getOnepage()->getQuote()->isVirtual()) {
150
+ $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
151
+ } else {
152
+ $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
153
+ }
154
+
155
+ $payment = $quote->getPayment();
156
+ $payment->importData($data);
157
+
158
+ $quote->save();
159
+
160
+ switch ($data['method']):
161
+ case 'mundipagg_creditcardoneinstallment':
162
+ $onepage = Mage::getModel('mundipagg/creditcardoneinstallment');
163
+ break;
164
+ case 'mundipagg_creditcard':
165
+ $onepage = Mage::getModel('mundipagg/creditcard');
166
+ break;
167
+
168
+ case 'mundipagg_twocreditcards':
169
+ $onepage = Mage::getModel('mundipagg/twocreditcards');
170
+ break;
171
+
172
+ case 'mundipagg_threecreditcards':
173
+ $onepage = Mage::getModel('mundipagg/threecreditcards');
174
+ break;
175
+
176
+ case 'mundipagg_fourcreditcards':
177
+ $onepage = Mage::getModel('mundipagg/fourcreditcards');
178
+ break;
179
+
180
+ case 'mundipagg_fivecreditcards':
181
+ $onepage = Mage::getModel('mundipagg/fivecreditcards');
182
+ break;
183
+
184
+ default:
185
+ $this->_redirect('mundipagg/standard/partial');
186
+ break;
187
+ endswitch;
188
+
189
+ $resultPayment = $onepage->doPayment($payment, $order);
190
+
191
+ // Send new order email when not in admin and payment is success
192
+ if (Mage::getSingleton('checkout/session')->getApprovalRequestSuccess() == 'success') {
193
+ if (Mage::app()->getStore()->getCode() != 'admin') {
194
+ $order->sendNewOrderEmail();
195
+ }
196
+ }
197
+
198
+ $info = $order->getPayment();
199
+
200
+ // We record transaction(s)
201
+ $json = json_encode($resultPayment['result']);
202
+ $dataR = array();
203
+ $dataR = json_decode($json, true);
204
+
205
+ if (count($resultPayment['result']->CreditCardTransactionResultCollection->CreditCardTransactionResult) == 1) {
206
+ $trans = $dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
207
+
208
+ $onepage->_addTransaction($order->getPayment(), $trans['TransactionKey'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, $trans);
209
+ } else {
210
+ $transactions = $dataR['CreditCardTransactionResultCollection']['CreditCardTransactionResult'];
211
+
212
+ foreach ($transactions as $key => $trans) {
213
+ $onepage->_addTransaction($order->getPayment(), $trans['TransactionKey'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, $trans);
214
+ }
215
+
216
+ // We can capture only if anti fraud is disabled and payment action is "AuthorizeAndCapture"
217
+ $creditCardTransactionResultCollection = $resultPayment['result']->CreditCardTransactionResultCollection;
218
+
219
+ if (
220
+ count($creditCardTransactionResultCollection->CreditCardTransactionResult) > 1 &&
221
+ $onepage->getAntiFraud() == 0 &&
222
+ $onepage->getPaymentAction() == 'order'
223
+ ) {
224
+ $resultCapture = $onepage->captureAndcreateInvoice($info);
225
+ }
226
+ }
227
+
228
+ // Redirect
229
+ if (Mage::getSingleton('checkout/session')->getApprovalRequestSuccess() == 'success') {
230
+ $this->_redirect('mundipagg/standard/success');
231
+ } else {
232
+ $this->_redirect('mundipagg/standard/partial');
233
+ }
234
+ }
235
+ }
236
+ } catch (Exception $e) {
237
+ //Log error
238
+ Mage::logException($e);
239
+ }
240
+ } else {
241
+ $this->_redirect();
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Cancel page
247
+ */
248
+ public function cancelAction() {
249
+ $this->cancelOrder();
250
+
251
+ //Render
252
+ $this->loadLayout();
253
+ $this->getLayout()->getBlock('content')->append($this->getLayout()->createBlock('mundipagg/standard_cancel'));
254
+ $this->renderLayout();
255
+ }
256
+
257
+ /**
258
+ * Force Cancel page
259
+ */
260
+ public function fcancelAction() {
261
+ $this->cancelOrder();
262
+
263
+ //Render
264
+ $this->loadLayout();
265
+ $this->getLayout()->getBlock('content')->append($this->getLayout()->createBlock('mundipagg/standard_fcancel'));
266
+ $this->renderLayout();
267
+ }
268
+
269
+ /*
270
+ * Cancel order and set quote as inactive
271
+ */
272
+ private function cancelOrder() {
273
+ $session = Mage::getSingleton('checkout/session');
274
+
275
+ if (!$session->getLastSuccessQuoteId()) {
276
+ $this->_redirect('checkout/cart');
277
+
278
+ return;
279
+ }
280
+
281
+ // Set quote as inactive
282
+ Mage::getSingleton('checkout/session')
283
+ ->getQuote()
284
+ ->setIsActive(false)
285
+ ->setTotalsCollectedFlag(false)
286
+ ->setAuthorizedAmount()
287
+ ->save()
288
+ ->collectTotals();
289
+
290
+ if ($session->getLastRealOrderId()) {
291
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
292
+
293
+ if ($order->getId() && $order->canCancel()) {
294
+ $order->cancel()->save();
295
+ }
296
+ }
297
+
298
+ $session->clear();
299
+ }
300
+
301
+ /**
302
+ * Success page (also used for Mundipagg return page for payments like "debit" and "boleto")
303
+ */
304
+ public function successAction() {
305
+ $session = Mage::getSingleton('checkout/session');
306
+ $approvalRequestSuccess = $session->getApprovalRequestSuccess();
307
+
308
+ if (!$this->getRequest()->isPost() && ($approvalRequestSuccess == 'success' || $approvalRequestSuccess == 'debit')) {
309
+ if (!$session->getLastSuccessQuoteId()) {
310
+ $this->_redirect('checkout/cart');
311
+
312
+ return;
313
+ }
314
+
315
+ $session->setQuoteId($session->getMundipaggStandardQuoteId(true));
316
+
317
+ // Last Order Id
318
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
319
+
320
+ // Set quote as inactive
321
+ Mage::getSingleton('checkout/session')
322
+ ->getQuote()
323
+ ->setIsActive(false)
324
+ ->setTotalsCollectedFlag(false)
325
+ ->save()
326
+ ->collectTotals();
327
+
328
+ // Load order
329
+ $order = Mage::getModel('sales/order')->load($lastOrderId);
330
+
331
+ if ($order->getId()) {
332
+ Mage::register('current_order', Mage::getModel('sales/order')->load($lastOrderId));
333
+
334
+ // Render
335
+ $this->loadLayout();
336
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
337
+ $this->getLayout()->getBlock('content')->append($this->getLayout()->createBlock('mundipagg/standard_success'));
338
+ $this->renderLayout();
339
+
340
+ $session->clear();
341
+ } else {
342
+ // Redirect to homepage
343
+ $this->_redirect('');
344
+ }
345
+ } else {
346
+ // Get posted data
347
+ $postData = $this->getRequest()->getPost();
348
+
349
+ $api = Mage::getModel('mundipagg/api');
350
+
351
+ // Process order
352
+ $result = $api->processOrder($postData);
353
+
354
+ // If result is empty we redirect to homepage
355
+ if ($result === false) {
356
+ $this->_redirect('');
357
+ } else {
358
+ $this->getResponse()->setBody($result);
359
+ }
360
+ }
361
+ }
362
+
363
+ public function installmentsandinterestAction() {
364
+ $post = $this->getRequest()->getPost();
365
+ $result = array();
366
+ $installmentsHelper = Mage::helper('mundipagg/installments');
367
+
368
+ if (isset($post['cctype'])) {
369
+ $total = $post['total'];
370
+ $cctype = $post['cctype'];
371
+ if (!$total) {
372
+ $total = null;
373
+ }
374
+
375
+ $installments = $installmentsHelper->getInstallmentForCreditCardType($cctype, $total);
376
+
377
+ $result['installments'] = $installments;
378
+ $result['brand'] = $cctype;
379
+
380
+ } else {
381
+ $installments = $installmentsHelper->getInstallmentForCreditCardType();
382
+ $result['installments'] = $installments;
383
+ }
384
+
385
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
386
+ }
387
+
388
+ /**
389
+ * Get max number of installments for a value
390
+ */
391
+ public function installmentsAction() {
392
+ $val = $this->getRequest()->getParam('val');
393
+
394
+ if (is_numeric($val)) {
395
+ $standard = Mage::getSingleton('mundipagg/standard');
396
+
397
+ $valorMinParcelamento = $standard->getConfigData('parcelamento_min');
398
+
399
+ // Não ter valor mínimo para parcelar OU Parcelar a partir de um valor mínimo
400
+ if ($valorMinParcelamento == 0) {
401
+ $qtdParcelasMax = $standard->getConfigData('parcelamento_max');
402
+ }
403
+
404
+ // Parcelar a partir de um valor mínimo
405
+ if ($valorMinParcelamento > 0 && $val >= $valorMinParcelamento) {
406
+ $qtdParcelasMax = $standard->getConfigData('parcelamento_max');
407
+ }
408
+
409
+ // Por faixa de valores
410
+ if ($valorMinParcelamento == '') {
411
+ $qtdParcelasMax = $standard->getConfigData('parcelamento_max');
412
+
413
+ $p = 1;
414
+
415
+ for ($p = 1; $p <= $qtdParcelasMax; $p++) {
416
+ if ($p == 1) {
417
+ $de = 0;
418
+ $parcelaDe = 0;
419
+ } else {
420
+ $de = 'parcelamento_de' . $p;
421
+ $parcelaDe = $standard->getConfigData($de);
422
+ }
423
+
424
+ $ate = 'parcelamento_ate' . $p;
425
+ $parcelaAte = $standard->getConfigData($ate);
426
+
427
+ if ($parcelaDe >= 0 && $parcelaAte >= $parcelaDe) {
428
+ if ($val >= $parcelaDe AND $val <= $parcelaAte) {
429
+ $qtdParcelasMax = $p;
430
+ }
431
+ } else {
432
+ $qtdParcelasMax = $p - 1;
433
+ }
434
+ }
435
+ }
436
+
437
+ $result['qtdParcelasMax'] = $qtdParcelasMax;
438
+ $result['currencySymbol'] = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
439
+
440
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
441
+ }
442
+ }
443
+ }
app/code/community/Uecommerce/Mundipagg/controllers/StoneController.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Uecommerce_Mundipagg_StoneController extends Uecommerce_Mundipagg_Controller_Abstract {
4
+
5
+ public function getConfigAction() {
6
+
7
+ if ($this->requestIsValid() == false) {
8
+ echo $this->getResponseForInvalidRequest();
9
+ return false;
10
+ }
11
+
12
+ $entityCode = Mage::getStoreConfig('payment/mundipagg_standard/stone_entitycode');
13
+ $app = Mage::getStoreConfig('payment/mundipagg_standard/stone_app');
14
+ $response = array(
15
+ 'entityCode' => $entityCode,
16
+ 'app' => $app,
17
+ 'sessionId' => $this->getSessionId()
18
+ );
19
+
20
+ try {
21
+ return $this->jsonResponse($response);
22
+
23
+ } catch (Exception $e) {
24
+
25
+ }
26
+ }
27
+
28
+ }
app/code/community/Uecommerce/Mundipagg/etc/config.xml ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ -->
32
+ <config>
33
+ <modules>
34
+ <Uecommerce_Mundipagg>
35
+ <version>2.6.1</version>
36
+ </Uecommerce_Mundipagg>
37
+ </modules>
38
+
39
+ <global>
40
+ <models>
41
+ <mundipagg>
42
+ <class>Uecommerce_Mundipagg_Model</class>
43
+ <resourceModel>mundipagg_resource</resourceModel>
44
+ </mundipagg>
45
+ <mundipagg_resource>
46
+ <class>Uecommerce_Mundipagg_Model_Resource</class>
47
+ <entities>
48
+ <mundipagg_customers>
49
+ <table>mundipagg_customers</table>
50
+ </mundipagg_customers>
51
+ <mundipagg_card_on_file>
52
+ <table>mundipagg_card_on_file</table>
53
+ </mundipagg_card_on_file>
54
+ <mundipagg_offline_retry>
55
+ <table>mundipagg_offline_retry</table>
56
+ </mundipagg_offline_retry>
57
+ </entities>
58
+ </mundipagg_resource>
59
+ </models>
60
+
61
+ <events>
62
+ <controller_action_predispatch>
63
+ <observers>
64
+ <sessionUpdate>
65
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
66
+ <method>sessionUpdate</method>
67
+ </sessionUpdate>
68
+ </observers>
69
+ </controller_action_predispatch>
70
+ <payment_method_is_active>
71
+ <observers>
72
+ <removePaymentMethods>
73
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
74
+ <method>removePaymentMethods</method>
75
+ </removePaymentMethods>
76
+ </observers>
77
+ </payment_method_is_active>
78
+ <sales_order_place_after>
79
+ <observers>
80
+ <onhold_order>
81
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
82
+ <method>updateStatus</method>
83
+ </onhold_order>
84
+ </observers>
85
+ </sales_order_place_after>
86
+ <controller_action_postdispatch_checkout_onepage_savePayment>
87
+ <observers>
88
+ <removeInterest>
89
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
90
+ <method>removeInterest</method>
91
+ </removeInterest>
92
+ </observers>
93
+ </controller_action_postdispatch_checkout_onepage_savePayment>
94
+ <payment_method_is_active>
95
+ <observers>
96
+ <checkForRecurrency>
97
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
98
+ <method>checkForRecurrency</method>
99
+ </checkForRecurrency>
100
+ </observers>
101
+ </payment_method_is_active>
102
+ <sales_quote_collect_totals_after>
103
+ <observers>
104
+ <mundipagg_discount_partial>
105
+ <type>singleton</type>
106
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
107
+ <method>addDiscountWhenPartial</method>
108
+ </mundipagg_discount_partial>
109
+ </observers>
110
+ </sales_quote_collect_totals_after>
111
+ <order_cancel_after>
112
+ <observers>
113
+ <delete_offline_retry_data_from_canceled_order>
114
+ <type>singleton</type>
115
+ <class>Uecommerce_Mundipagg_Model_Observer</class>
116
+ <method>canceledOrder</method>
117
+ </delete_offline_retry_data_from_canceled_order>
118
+ </observers>
119
+ </order_cancel_after>
120
+ </events>
121
+
122
+ <resources>
123
+ <mundipagg_setup>
124
+ <setup>
125
+ <module>Uecommerce_Mundipagg</module>
126
+ <class>Uecommerce_Mundipagg_Model_Resource_Setup</class>
127
+ </setup>
128
+ <connection>
129
+ <use>core_setup</use>
130
+ </connection>
131
+ </mundipagg_setup>
132
+ <mundipagg_write>
133
+ <connection>
134
+ <use>core_write</use>
135
+ </connection>
136
+ </mundipagg_write>
137
+ <mundipagg_read>
138
+ <connection>
139
+ <use>core_read</use>
140
+ </connection>
141
+ </mundipagg_read>
142
+ </resources>
143
+
144
+ <blocks>
145
+ <mundipagg>
146
+ <class>Uecommerce_Mundipagg_Block</class>
147
+ </mundipagg>
148
+ <adminhtml>
149
+ <rewrite>
150
+ <sales_transactions_detail_grid>Uecommerce_Mundipagg_Block_Adminhtml_Sales_Transactions_Detail_Grid</sales_transactions_detail_grid>
151
+ <sales_order_totals>Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
152
+ <sales_order_invoice_totals>Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
153
+ <sales_order_creditmemo_totals>Uecommerce_Mundipagg_Block_Adminhtml_Sales_Order_Creditmemo_Totals</sales_order_creditmemo_totals>
154
+ </rewrite>
155
+ </adminhtml>
156
+ <sales>
157
+ <rewrite>
158
+ <order_totals>Uecommerce_Mundipagg_Block_Sales_Order_Totals</order_totals>
159
+ <order_invoice_totals>Uecommerce_Mundipagg_Block_Sales_Order_Invoice_Totals</order_invoice_totals>
160
+ <order_creditmemo_totals>Uecommerce_Mundipagg_Block_Sales_Order_Creditmemo_Totals</order_creditmemo_totals>
161
+ </rewrite>
162
+ </sales>
163
+ <checkout>
164
+ <rewrite>
165
+ <onepage_payment_methods>Uecommerce_Mundipagg_Block_Checkout_Onepage_Payment_Methods</onepage_payment_methods>
166
+ </rewrite>
167
+ </checkout>
168
+ </blocks>
169
+
170
+ <helpers>
171
+ <mundipagg>
172
+ <class>Uecommerce_Mundipagg_Helper</class>
173
+ </mundipagg>
174
+ </helpers>
175
+
176
+ <sales>
177
+ <quote>
178
+ <totals>
179
+ <mundipagg_interest>
180
+ <class>Uecommerce_Mundipagg_Model_Quote_Address_Interest</class>
181
+ <after>shipping</after>
182
+ <before>grand_total</before>
183
+ </mundipagg_interest>
184
+ </totals>
185
+ </quote>
186
+ <order>
187
+ <totals>
188
+ <mundipagg_interest>
189
+ <class>Uecommerce_Mundipagg_Model_Quote_Address_Interest</class>
190
+ <after>shipping</after>
191
+ <before>grand_total</before>
192
+ </mundipagg_interest>
193
+ </totals>
194
+ </order>
195
+ <order_invoice>
196
+ <totals>
197
+ <your_total>
198
+ <class>Uecommerce_Mundipagg_Model_Order_Invoice_Interest</class>
199
+ <after>shipping</after>
200
+ <before>grand_total</before>
201
+ </your_total>
202
+ </totals>
203
+ </order_invoice>
204
+ </sales>
205
+
206
+ <fieldsets>
207
+ <sales_convert_quote_address>
208
+ <mundipagg_interest>
209
+ <to_order>*</to_order>
210
+ </mundipagg_interest>
211
+ <mundipagg_base_interest>
212
+ <to_order>*</to_order>
213
+ </mundipagg_base_interest>
214
+ </sales_convert_quote_address>
215
+ <sales_convert_order>
216
+ <mundipagg_interest>
217
+ <to_invoice>*</to_invoice>
218
+ <to_shipment>*</to_shipment>
219
+ <to_cm>*</to_cm>
220
+ </mundipagg_interest>
221
+ <mundipagg_base_interest>
222
+ <to_invoice>*</to_invoice>
223
+ <to_shipment>*</to_shipment>
224
+ <to_cm>*</to_cm>
225
+ </mundipagg_base_interest>
226
+ </sales_convert_order>
227
+ </fieldsets>
228
+ </global>
229
+
230
+ <frontend>
231
+ <routers>
232
+ <mundipagg>
233
+ <use>standard</use>
234
+ <args>
235
+ <module>Uecommerce_Mundipagg</module>
236
+ <frontName>mundipagg</frontName>
237
+ </args>
238
+ </mundipagg>
239
+ </routers>
240
+ <translate>
241
+ <modules>
242
+ <mundipagg>
243
+ <files>
244
+ <default>Uecommerce_Mundipagg.csv</default>
245
+ </files>
246
+ </mundipagg>
247
+ </modules>
248
+ </translate>
249
+ <layout>
250
+ <updates>
251
+ <mundipagg module="Uecommerce_Mundipagg">
252
+ <file>mundipagg.xml</file>
253
+ </mundipagg>
254
+ </updates>
255
+ </layout>
256
+ </frontend>
257
+
258
+ <adminhtml>
259
+ <translate>
260
+ <modules>
261
+ <mundipagg>
262
+ <files>
263
+ <default>Uecommerce_Mundipagg.csv</default>
264
+ </files>
265
+ </mundipagg>
266
+ </modules>
267
+ </translate>
268
+ <layout>
269
+ <updates>
270
+ <mundipagg module="Uecommerce_Mundipagg">
271
+ <file>mundipagg.xml</file>
272
+ </mundipagg>
273
+ </updates>
274
+ </layout>
275
+ </adminhtml>
276
+ <admin>
277
+ <routers>
278
+ <adminhtml>
279
+ <args>
280
+ <modules>
281
+ <mundipagg after="Mage_Adminhtml">Uecommerce_Mundipagg_Adminhtml</mundipagg>
282
+ </modules>
283
+ </args>
284
+ </adminhtml>
285
+ </routers>
286
+ </admin>
287
+
288
+ <default>
289
+ <payment>
290
+ <mundipagg_standard>
291
+ <model>mundipagg/standard</model>
292
+ <apiUrlStaging>https://sandbox.mundipaggone.com/sale/</apiUrlStaging>
293
+ <apiUrlProduction>https://transactionv2.mundipaggone.com/Sale/</apiUrlProduction>
294
+ <antifraud>0</antifraud>
295
+ <debug>1</debug>
296
+ <payment_action>order</payment_action>
297
+ <save_cardonfile>1</save_cardonfile>
298
+ <delivery_deadline>5</delivery_deadline>
299
+ <shipping_company>Correios</shipping_company>
300
+ <environment_fcontrol>1</environment_fcontrol>
301
+ </mundipagg_standard>
302
+ <mundipagg_creditcardoneinstallment>
303
+ <model>mundipagg/creditcardoneinstallment</model>
304
+ <active>0</active>
305
+ <title><![CDATA[Cartão de Crédito à vista]]></title>
306
+ <allowspecific>0</allowspecific>
307
+ <payment_action>authorize</payment_action>
308
+ </mundipagg_creditcardoneinstallment>
309
+ <mundipagg_creditcard>
310
+ <model>mundipagg/creditcard</model>
311
+ <active>0</active>
312
+ <title><![CDATA[Cartão de Crédito]]></title>
313
+ <allowspecific>0</allowspecific>
314
+ <payment_action>authorize</payment_action>
315
+ </mundipagg_creditcard>
316
+ <mundipagg_twocreditcards>
317
+ <model>mundipagg/twocreditcards</model>
318
+ <active>0</active>
319
+ <title><![CDATA[2 Cartões de Crédito]]></title>
320
+ <allowspecific>0</allowspecific>
321
+ <payment_action>authorize</payment_action>
322
+ </mundipagg_twocreditcards>
323
+ <mundipagg_threecreditcards>
324
+ <model>mundipagg/threecreditcards</model>
325
+ <active>0</active>
326
+ <title><![CDATA[3 Cartões de Crédito]]></title>
327
+ <allowspecific>0</allowspecific>
328
+ <payment_action>authorize</payment_action>
329
+ </mundipagg_threecreditcards>
330
+ <mundipagg_fourcreditcards>
331
+ <model>mundipagg/fourcreditcards</model>
332
+ <active>0</active>
333
+ <title><![CDATA[4 Cartões de Crédito]]></title>
334
+ <allowspecific>0</allowspecific>
335
+ <payment_action>authorize</payment_action>
336
+ </mundipagg_fourcreditcards>
337
+ <mundipagg_fivecreditcards>
338
+ <model>mundipagg/fivecreditcards</model>
339
+ <active>0</active>
340
+ <title><![CDATA[5 Cartões de Crédito]]></title>
341
+ <allowspecific>0</allowspecific>
342
+ <payment_action>authorize</payment_action>
343
+ </mundipagg_fivecreditcards>
344
+ <mundipagg_boleto>
345
+ <model>mundipagg/boleto</model>
346
+ <active>0</active>
347
+ <title><![CDATA[Boleto]]></title>
348
+ <dias_validade_boleto>3</dias_validade_boleto>
349
+ <allowspecific>0</allowspecific>
350
+ <payment_action>authorize</payment_action>
351
+ </mundipagg_boleto>
352
+ <mundipagg_debit>
353
+ <model>mundipagg/debit</model>
354
+ <active>0</active>
355
+ <title><![CDATA[Débito]]></title>
356
+ <apiDebitUrl>https://api.mundipaggone.com/Order/OnlineDebit/</apiDebitUrl>
357
+ <apiDebitStagingUrl>https://apisandbox.mundipaggone.com/Order/OnlineDebit/</apiDebitStagingUrl>
358
+ <allowspecific>0</allowspecific>
359
+ <payment_action>authorize</payment_action>
360
+ </mundipagg_debit>
361
+ </payment>
362
+ </default>
363
+ </config>
app/code/community/Uecommerce/Mundipagg/etc/jstranslator.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <jstranslator>
3
+ <validar_cpf translate="message" module="mundipagg">
4
+ <message>The taxvat is invalid</message>
5
+ </validar_cpf>
6
+ <check_values translate="message" module="mundipagg">
7
+ <message>Check the values to pass on each card</message>
8
+ </check_values>
9
+ <validate-cc-exp-cus translate="message" module="mundipagg">
10
+ <message>Expiration date of the incorrect card</message>
11
+ </validate-cc-exp-cus>
12
+ <template_insterest translate="message" module="mundipagg">
13
+ <message>Total amount with interest: USD{%%%}</message>
14
+ </template_insterest>
15
+ </jstranslator>
app/code/community/Uecommerce/Mundipagg/etc/system.xml ADDED
@@ -0,0 +1,1144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ -->
32
+ <config>
33
+ <sections>
34
+ <payment translate="label" module="payment">
35
+ <groups>
36
+ <mundipagg_standard type="group" translate="label">
37
+ <label><![CDATA[MundiPagg]]></label>
38
+ <sort_order>420</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <comment>
43
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
44
+
45
+ <fields>
46
+ <version translate="label">
47
+ <label>Version</label>
48
+ <frontend_type>select</frontend_type>
49
+ <frontend_model>Uecommerce_Mundipagg_Block_Adminhtml_Version</frontend_model>
50
+ <sort_order>0</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </version>
55
+
56
+ <environment translate="label">
57
+ <label>Environment</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>Uecommerce_Mundipagg_Model_Source_Environment</source_model>
60
+ <sort_order>1</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ <comment>
65
+ <![CDATA[<b>Development</b> = ambiente de teste<br/><b>Production</b> = ambiente de produção]]></comment>
66
+ </environment>
67
+
68
+ <debug translate="label">
69
+ <label>Debug</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_yesno</source_model>
72
+ <sort_order>2</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ <comment>
77
+ <![CDATA[O Debug permite gravar o retorno da MundiPagg nos logs do Magento (/var/log/system.log), para tal é necessário ter os logs do Magento ativados (System -> Configuration -> Advanced -> Developer -> Log Settings -> Yes)]]></comment>
78
+ </debug>
79
+
80
+ <apiUrlStaging translate="label">
81
+ <label>Api URL Staging</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>3</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </apiUrlStaging>
88
+
89
+ <merchantKeyStaging translate="label">
90
+ <label>merchantKey Staging</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>4</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </merchantKeyStaging>
97
+
98
+ <apiUrlProduction translate="label">
99
+ <label>Api URL Production</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>5</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </apiUrlProduction>
106
+
107
+ <merchantKeyProduction translate="label">
108
+ <label>merchantKey Production</label>
109
+ <frontend_type>text</frontend_type>
110
+ <sort_order>6</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ </merchantKeyProduction>
115
+
116
+ <payment_action translate="label">
117
+ <label>Payment Action</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>Uecommerce_Mundipagg_Model_Source_PaymentAction</source_model>
120
+ <sort_order>7</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <comment>
125
+ <![CDATA[<b>AuthOnly</b> = Autorizar<br/><b>AuthAndCapture</b> = Autorizar e capturar]]></comment>
126
+ </payment_action>
127
+
128
+ <antifraud translate="label">
129
+ <label>Enviar para anti-fraude?</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_yesno</source_model>
132
+ <sort_order>8</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </antifraud>
137
+
138
+ <antifraud_provider translate="label">
139
+ <label>Fornecedor Anti-fraude</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>Uecommerce_Mundipagg_Model_Source_Antifraud</source_model>
142
+ <backend_model>mundipagg/providervalidation</backend_model>
143
+ <sort_order>9</sort_order>
144
+ <depends>
145
+ <antifraud>1</antifraud>
146
+ </depends>
147
+ <validates>required-entry</validates>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ </antifraud_provider>
152
+
153
+ <environment_fcontrol translate="label">
154
+ <label>Fingerprint environment</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>Uecommerce_Mundipagg_Model_Source_FControlEnvironment</source_model>
157
+ <depends>
158
+ <antifraud>1</antifraud>
159
+ <antifraud_provider>2</antifraud_provider>
160
+ </depends>
161
+ <sort_order>10</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ </environment_fcontrol>
166
+
167
+ <fcontrol_key_sandbox translate="label">
168
+ <label>FControl sandbox key</label>
169
+ <frontend_type>text</frontend_type>
170
+ <sort_order>11</sort_order>
171
+ <depends>
172
+ <antifraud>1</antifraud>
173
+ <antifraud_provider>2</antifraud_provider>
174
+ <environment_fcontrol>1</environment_fcontrol>
175
+ </depends>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ <comment>Chave informada pela FControl</comment>
180
+ </fcontrol_key_sandbox>
181
+
182
+ <fcontrol_key_production translate="label">
183
+ <label>FControl production key</label>
184
+ <frontend_type>text</frontend_type>
185
+ <sort_order>11</sort_order>
186
+ <depends>
187
+ <antifraud>1</antifraud>
188
+ <antifraud_provider>2</antifraud_provider>
189
+ <environment_fcontrol>2</environment_fcontrol>
190
+ </depends>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ <comment>Chave informada pela FControl</comment>
195
+ </fcontrol_key_production>
196
+
197
+ <clearsale_entitycode translate="label">
198
+ <label>EntityCode</label>
199
+ <frontend_type>text</frontend_type>
200
+ <sort_order>10</sort_order>
201
+ <depends>
202
+ <antifraud>1</antifraud>
203
+ <antifraud_provider>1</antifraud_provider>
204
+ </depends>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ <comment>Chave informada pela Clearsale</comment>
209
+ </clearsale_entitycode>
210
+
211
+ <clearsale_app translate="label">
212
+ <label>AppKey</label>
213
+ <frontend_type>text</frontend_type>
214
+ <sort_order>11</sort_order>
215
+ <depends>
216
+ <antifraud>1</antifraud>
217
+ <antifraud_provider>1</antifraud_provider>
218
+ </depends>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ <comment>codigo informado pela Clearsale</comment>
223
+ </clearsale_app>
224
+
225
+ <stone_entitycode translate="label">
226
+ <label>EntityCode</label>
227
+ <frontend_type>text</frontend_type>
228
+ <sort_order>10</sort_order>
229
+ <depends>
230
+ <antifraud>1</antifraud>
231
+ <antifraud_provider>3</antifraud_provider>
232
+ </depends>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ <comment>Chave informada pela Stone</comment>
237
+ </stone_entitycode>
238
+
239
+ <stone_app translate="label">
240
+ <label>AppKey</label>
241
+ <frontend_type>text</frontend_type>
242
+ <sort_order>11</sort_order>
243
+ <depends>
244
+ <antifraud>1</antifraud>
245
+ <antifraud_provider>3</antifraud_provider>
246
+ </depends>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <comment>codigo informado pela Stone</comment>
251
+ </stone_app>
252
+
253
+ <cc_types translate="label">
254
+ <label>Credit Card Issuers</label>
255
+ <frontend_type>multiselect</frontend_type>
256
+ <source_model>Uecommerce_Mundipagg_Model_Source_Cctypes</source_model>
257
+ <sort_order>12</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ <comment><![CDATA[Escolha as bandeiras que você aceita na sua loja]]></comment>
262
+ </cc_types>
263
+
264
+ <heading_installments translate="label">
265
+ <label>Installments and Interest</label>
266
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
267
+ <sort_order>13</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>0</show_in_store>
271
+ </heading_installments>
272
+
273
+ <enable_installments translate="label">
274
+ <label>Ativar parcelamento?</label>
275
+ <frontend_type>select</frontend_type>
276
+ <source_model>adminhtml/system_config_source_yesno</source_model>
277
+ <sort_order>14</sort_order>
278
+ <show_in_default>1</show_in_default>
279
+ <show_in_website>1</show_in_website>
280
+ <show_in_store>1</show_in_store>
281
+ </enable_installments>
282
+
283
+ <display_total>
284
+ <label>Exibir total com juros ao lado das parcelas?</label>
285
+ <frontend_type>select</frontend_type>
286
+ <source_model>adminhtml/system_config_source_yesno</source_model>
287
+ <sort_order>15</sort_order>
288
+ <show_in_default>1</show_in_default>
289
+ <show_in_website>1</show_in_website>
290
+ <show_in_store>1</show_in_store>
291
+ </display_total>
292
+
293
+ <product_pages_installment_default>
294
+ <label>Qual parcelamento exibir na página do produto?</label>
295
+ <frontend_type>select</frontend_type>
296
+ <source_model>Uecommerce_Mundipagg_Model_Source_CctypeProductInstallments</source_model>
297
+ <sort_order>16</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>1</show_in_store>
301
+ </product_pages_installment_default>
302
+
303
+ <setoldsettings translate="label comment tooltip">
304
+ <label>Set old settings</label>
305
+ <sort_order>17</sort_order>
306
+ <frontend_type>button</frontend_type>
307
+ <frontend_model>mundipagg/adminhtml_system_config_form_button</frontend_model>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ <comment>If you just update the module and its old version is below 2.0.0, you can click
312
+ this button to generate the installments as were set in the old version of the module.
313
+ </comment>
314
+ <tooltip>If you have already set manually, CAUTION! This function will reset all
315
+ installments.
316
+ </tooltip>
317
+ </setoldsettings>
318
+
319
+ <installments translate="label">
320
+ <label>Installments default</label>
321
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
322
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
323
+ <sort_order>18</sort_order>
324
+ <show_in_default>1</show_in_default>
325
+ <show_in_website>1</show_in_website>
326
+ <show_in_store>1</show_in_store>
327
+
328
+ </installments>
329
+
330
+ <installments_VI translate="label">
331
+ <label>Installments for Visa</label>
332
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
333
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
334
+ <sort_order>19</sort_order>
335
+ <show_in_default>1</show_in_default>
336
+ <show_in_website>1</show_in_website>
337
+ <show_in_store>1</show_in_store>
338
+
339
+ </installments_VI>
340
+
341
+ <installments_MC translate="label">
342
+ <label>Installments for Mastercard</label>
343
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
344
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
345
+ <sort_order>20</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>1</show_in_store>
349
+
350
+ </installments_MC>
351
+
352
+ <installments_AE translate="label">
353
+ <label>Installments for Amex</label>
354
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
355
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
356
+ <sort_order>21</sort_order>
357
+ <show_in_default>1</show_in_default>
358
+ <show_in_website>1</show_in_website>
359
+ <show_in_store>1</show_in_store>
360
+
361
+ </installments_AE>
362
+
363
+ <installments_DI translate="label">
364
+ <label>Installments for Diners</label>
365
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
366
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
367
+ <sort_order>22</sort_order>
368
+ <show_in_default>1</show_in_default>
369
+ <show_in_website>1</show_in_website>
370
+ <show_in_store>1</show_in_store>
371
+ <comments>This is the fallback if specific credit card type has no installments configured
372
+ </comments>
373
+ </installments_DI>
374
+
375
+ <installments_EL translate="label">
376
+ <label>Installments for Elo</label>
377
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
378
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
379
+ <sort_order>23</sort_order>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>1</show_in_website>
382
+ <show_in_store>1</show_in_store>
383
+
384
+ </installments_EL>
385
+
386
+ <installments_HI translate="label">
387
+ <label>Installments for Hipercard</label>
388
+ <frontend_model>mundipagg/adminhtml_form_field_installments</frontend_model>
389
+ <backend_model>mundipagg/system_config_backend_installments</backend_model>
390
+ <sort_order>24</sort_order>
391
+ <show_in_default>1</show_in_default>
392
+ <show_in_website>1</show_in_website>
393
+ <show_in_store>1</show_in_store>
394
+ </installments_HI>
395
+
396
+ <offline_retry_heading translate="label">
397
+ <label>Offline Retry</label>
398
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
399
+ <sort_order>25</sort_order>
400
+ <show_in_default>1</show_in_default>
401
+ <show_in_website>1</show_in_website>
402
+ <show_in_store>0</show_in_store>
403
+ </offline_retry_heading>
404
+
405
+ <offline_retry_enabled translate="label">
406
+ <label>Enabled</label>
407
+ <frontend_type>select</frontend_type>
408
+ <source_model>adminhtml/system_config_source_yesno</source_model>
409
+ <sort_order>26</sort_order>
410
+ <show_in_default>1</show_in_default>
411
+ <show_in_website>1</show_in_website>
412
+ <show_in_store>0</show_in_store>
413
+ </offline_retry_enabled>
414
+
415
+ <delayed_retry_max_time translate="label">
416
+ <label>Max time to retry in minutes</label>
417
+ <frontend_type>text</frontend_type>
418
+ <sort_order>27</sort_order>
419
+ <depends>
420
+ <offline_retry_enabled>1</offline_retry_enabled>
421
+ </depends>
422
+ <show_in_default>1</show_in_default>
423
+ <show_in_website>1</show_in_website>
424
+ <show_in_store>0</show_in_store>
425
+ <comment>Max time to wait for an authorization. After this, the order will be cancelled.</comment>
426
+ </delayed_retry_max_time>
427
+
428
+ <heading_extras translate="label">
429
+ <label>Extras</label>
430
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
431
+ <sort_order>30</sort_order>
432
+ <show_in_default>1</show_in_default>
433
+ <show_in_website>1</show_in_website>
434
+ <show_in_store>0</show_in_store>
435
+ </heading_extras>
436
+
437
+ <shipping_company>
438
+ <label>Frete Padrão</label>
439
+ <frontend_type>text</frontend_type>
440
+ <sort_order>31</sort_order>
441
+ <show_in_default>1</show_in_default>
442
+ <show_website>1</show_website>
443
+ <show_in_store>1</show_in_store>
444
+ <comment><![CDATA[Empresa que realiza as entregas]]></comment>
445
+ </shipping_company>
446
+
447
+ <delivery_deadline translate="label">
448
+ <label>Média de prazo de entrega</label>
449
+ <frontend_type>text</frontend_type>
450
+ <sort_order>32</sort_order>
451
+ <show_in_default>1</show_in_default>
452
+ <show_in_website>1</show_in_website>
453
+ <show_in_store>1</show_in_store>
454
+ <comment><![CDATA[Quantidade de dias em média para entrega de seus produtos.]]></comment>
455
+ </delivery_deadline>
456
+
457
+ <save_cardonfile translate="label">
458
+ <label>Enable feature (use the card for future purchases)</label>
459
+ <frontend_type>select</frontend_type>
460
+ <source_model>adminhtml/system_config_source_yesno</source_model>
461
+ <sort_order>33</sort_order>
462
+ <show_in_default>1</show_in_default>
463
+ <show_in_website>1</show_in_website>
464
+ <show_in_store>1</show_in_store>
465
+ </save_cardonfile>
466
+
467
+ <cielo_sku translate="label">
468
+ <label>SKU produto de teste de R$1,00 da Cielo</label>
469
+ <frontend_type>text</frontend_type>
470
+ <sort_order>34</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>1</show_in_store>
474
+ <comment>
475
+ <![CDATA[SKU do produto de teste da Cielo para forçar o pagamento pela Cielo durante a homologação]]></comment>
476
+ </cielo_sku>
477
+
478
+ </fields>
479
+
480
+ </mundipagg_standard>
481
+
482
+ <mundipagg_creditcardoneinstallment type="group" translate="label">
483
+ <label><![CDATA[MundiPagg - Cartão de Crédito à vista]]></label>
484
+ <sort_order>430</sort_order>
485
+ <show_in_default>1</show_in_default>
486
+ <show_in_website>1</show_in_website>
487
+ <show_in_store>1</show_in_store>
488
+ <comment>
489
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
490
+ <fields>
491
+ <active translate="label">
492
+ <label>Enabled</label>
493
+ <frontend_type>select</frontend_type>
494
+ <source_model>adminhtml/system_config_source_yesno</source_model>
495
+ <sort_order>1</sort_order>
496
+ <show_in_default>1</show_in_default>
497
+ <show_in_website>1</show_in_website>
498
+ <show_in_store>1</show_in_store>
499
+ </active>
500
+
501
+ <title translate="label">
502
+ <label>Title</label>
503
+ <frontend_type>text</frontend_type>
504
+ <sort_order>2</sort_order>
505
+ <show_in_default>1</show_in_default>
506
+ <show_in_website>1</show_in_website>
507
+ <show_in_store>1</show_in_store>
508
+ <comment>
509
+ <![CDATA[Texto que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
510
+ </title>
511
+
512
+ <allowspecific translate="label">
513
+ <label>Payment from Applicable Countries</label>
514
+ <frontend_type>allowspecific</frontend_type>
515
+ <sort_order>60</sort_order>
516
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
517
+ <show_in_default>1</show_in_default>
518
+ <show_in_website>1</show_in_website>
519
+ <show_in_store>1</show_in_store>
520
+ </allowspecific>
521
+
522
+ <specificcountry translate="label">
523
+ <label>Payment from Specific Countries</label>
524
+ <frontend_type>multiselect</frontend_type>
525
+ <sort_order>61</sort_order>
526
+ <source_model>adminhtml/system_config_source_country</source_model>
527
+ <show_in_default>1</show_in_default>
528
+ <show_in_website>1</show_in_website>
529
+ <show_in_store>1</show_in_store>
530
+ </specificcountry>
531
+
532
+ <min_order_total translate="label">
533
+ <label>Min Order Total</label>
534
+ <frontend_type>text</frontend_type>
535
+ <sort_order>70</sort_order>
536
+ <show_in_default>1</show_in_default>
537
+ <show_in_website>1</show_in_website>
538
+ <show_in_store>1</show_in_store>
539
+ <frontend_class>validate-number</frontend_class>
540
+ </min_order_total>
541
+
542
+ <max_order_total translate="label">
543
+ <label>Max Order Total</label>
544
+ <frontend_type>text</frontend_type>
545
+ <sort_order>80</sort_order>
546
+ <show_in_default>1</show_in_default>
547
+ <show_in_website>1</show_in_website>
548
+ <show_in_store>1</show_in_store>
549
+ <frontend_class>validate-number</frontend_class>
550
+ </max_order_total>
551
+
552
+ <sort_order translate="label">
553
+ <label>Sort Order</label>
554
+ <frontend_type>text</frontend_type>
555
+ <sort_order>100</sort_order>
556
+ <show_in_default>1</show_in_default>
557
+ <show_in_website>1</show_in_website>
558
+ <show_in_store>1</show_in_store>
559
+ <frontend_class>validate-number</frontend_class>
560
+ </sort_order>
561
+ </fields>
562
+ </mundipagg_creditcardoneinstallment>
563
+ <mundipagg_creditcard type="group" translate="label">
564
+ <label><![CDATA[MundiPagg - Cartão de Crédito]]></label>
565
+ <sort_order>430</sort_order>
566
+ <show_in_default>1</show_in_default>
567
+ <show_in_website>1</show_in_website>
568
+ <show_in_store>1</show_in_store>
569
+ <comment>
570
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
571
+ <fields>
572
+ <active translate="label">
573
+ <label>Enabled</label>
574
+ <frontend_type>select</frontend_type>
575
+ <source_model>adminhtml/system_config_source_yesno</source_model>
576
+ <sort_order>1</sort_order>
577
+ <show_in_default>1</show_in_default>
578
+ <show_in_website>1</show_in_website>
579
+ <show_in_store>1</show_in_store>
580
+ </active>
581
+
582
+ <title translate="label">
583
+ <label>Title</label>
584
+ <frontend_type>text</frontend_type>
585
+ <sort_order>2</sort_order>
586
+ <show_in_default>1</show_in_default>
587
+ <show_in_website>1</show_in_website>
588
+ <show_in_store>1</show_in_store>
589
+ <comment>
590
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
591
+ </title>
592
+
593
+ <allowspecific translate="label">
594
+ <label>Payment from Applicable Countries</label>
595
+ <frontend_type>allowspecific</frontend_type>
596
+ <sort_order>60</sort_order>
597
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
598
+ <show_in_default>1</show_in_default>
599
+ <show_in_website>1</show_in_website>
600
+ <show_in_store>1</show_in_store>
601
+ </allowspecific>
602
+
603
+ <specificcountry translate="label">
604
+ <label>Payment from Specific Countries</label>
605
+ <frontend_type>multiselect</frontend_type>
606
+ <sort_order>61</sort_order>
607
+ <source_model>adminhtml/system_config_source_country</source_model>
608
+ <show_in_default>1</show_in_default>
609
+ <show_in_website>1</show_in_website>
610
+ <show_in_store>1</show_in_store>
611
+ </specificcountry>
612
+
613
+ <min_order_total translate="label">
614
+ <label>Min Order Total</label>
615
+ <frontend_type>text</frontend_type>
616
+ <sort_order>70</sort_order>
617
+ <show_in_default>1</show_in_default>
618
+ <show_in_website>1</show_in_website>
619
+ <show_in_store>1</show_in_store>
620
+ <frontend_class>validate-number</frontend_class>
621
+ </min_order_total>
622
+
623
+ <max_order_total translate="label">
624
+ <label>Max Order Total</label>
625
+ <frontend_type>text</frontend_type>
626
+ <sort_order>80</sort_order>
627
+ <show_in_default>1</show_in_default>
628
+ <show_in_website>1</show_in_website>
629
+ <show_in_store>1</show_in_store>
630
+ <frontend_class>validate-number</frontend_class>
631
+ </max_order_total>
632
+
633
+ <sort_order translate="label">
634
+ <label>Sort Order</label>
635
+ <frontend_type>text</frontend_type>
636
+ <sort_order>100</sort_order>
637
+ <show_in_default>1</show_in_default>
638
+ <show_in_website>1</show_in_website>
639
+ <show_in_store>1</show_in_store>
640
+ <frontend_class>validate-number</frontend_class>
641
+ </sort_order>
642
+ </fields>
643
+ </mundipagg_creditcard>
644
+ <mundipagg_twocreditcards type="group" translate="label">
645
+ <label><![CDATA[MundiPagg - 2 Cartões de Crédito]]></label>
646
+ <sort_order>440</sort_order>
647
+ <show_in_default>1</show_in_default>
648
+ <show_in_website>1</show_in_website>
649
+ <show_in_store>1</show_in_store>
650
+ <comment>
651
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
652
+ <fields>
653
+ <active translate="label">
654
+ <label>Enabled</label>
655
+ <frontend_type>select</frontend_type>
656
+ <source_model>adminhtml/system_config_source_yesno</source_model>
657
+ <sort_order>1</sort_order>
658
+ <show_in_default>1</show_in_default>
659
+ <show_in_website>1</show_in_website>
660
+ <show_in_store>1</show_in_store>
661
+ </active>
662
+
663
+ <title translate="label">
664
+ <label>Title</label>
665
+ <frontend_type>text</frontend_type>
666
+ <sort_order>2</sort_order>
667
+ <show_in_default>1</show_in_default>
668
+ <show_in_website>1</show_in_website>
669
+ <show_in_store>1</show_in_store>
670
+ <comment>
671
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
672
+ </title>
673
+
674
+ <allowspecific translate="label">
675
+ <label>Payment from Applicable Countries</label>
676
+ <frontend_type>allowspecific</frontend_type>
677
+ <sort_order>60</sort_order>
678
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
679
+ <show_in_default>1</show_in_default>
680
+ <show_in_website>1</show_in_website>
681
+ <show_in_store>1</show_in_store>
682
+ </allowspecific>
683
+
684
+ <specificcountry translate="label">
685
+ <label>Payment from Specific Countries</label>
686
+ <frontend_type>multiselect</frontend_type>
687
+ <sort_order>61</sort_order>
688
+ <source_model>adminhtml/system_config_source_country</source_model>
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>1</show_in_website>
691
+ <show_in_store>1</show_in_store>
692
+ </specificcountry>
693
+
694
+ <min_order_total translate="label">
695
+ <label>Min Order Total</label>
696
+ <frontend_type>text</frontend_type>
697
+ <sort_order>70</sort_order>
698
+ <show_in_default>1</show_in_default>
699
+ <show_in_website>1</show_in_website>
700
+ <show_in_store>1</show_in_store>
701
+ <frontend_class>validate-number</frontend_class>
702
+ </min_order_total>
703
+
704
+ <max_order_total translate="label">
705
+ <label>Max Order Total</label>
706
+ <frontend_type>text</frontend_type>
707
+ <sort_order>80</sort_order>
708
+ <show_in_default>1</show_in_default>
709
+ <show_in_website>1</show_in_website>
710
+ <show_in_store>1</show_in_store>
711
+ <frontend_class>validate-number</frontend_class>
712
+ </max_order_total>
713
+
714
+ <sort_order translate="label">
715
+ <label>Sort Order</label>
716
+ <frontend_type>text</frontend_type>
717
+ <sort_order>100</sort_order>
718
+ <show_in_default>1</show_in_default>
719
+ <show_in_website>1</show_in_website>
720
+ <show_in_store>1</show_in_store>
721
+ <frontend_class>validate-number</frontend_class>
722
+ </sort_order>
723
+ </fields>
724
+ </mundipagg_twocreditcards>
725
+ <mundipagg_threecreditcards type="group" translate="label">
726
+ <label><![CDATA[MundiPagg - 3 Cartões de Crédito]]></label>
727
+ <sort_order>450</sort_order>
728
+ <show_in_default>1</show_in_default>
729
+ <show_in_website>1</show_in_website>
730
+ <show_in_store>1</show_in_store>
731
+ <comment>
732
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
733
+ <fields>
734
+ <active translate="label">
735
+ <label>Enabled</label>
736
+ <frontend_type>select</frontend_type>
737
+ <source_model>adminhtml/system_config_source_yesno</source_model>
738
+ <sort_order>1</sort_order>
739
+ <show_in_default>1</show_in_default>
740
+ <show_in_website>1</show_in_website>
741
+ <show_in_store>1</show_in_store>
742
+ </active>
743
+
744
+ <title translate="label">
745
+ <label>Title</label>
746
+ <frontend_type>text</frontend_type>
747
+ <sort_order>2</sort_order>
748
+ <show_in_default>1</show_in_default>
749
+ <show_in_website>1</show_in_website>
750
+ <show_in_store>1</show_in_store>
751
+ <comment>
752
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
753
+ </title>
754
+
755
+ <allowspecific translate="label">
756
+ <label>Payment from Applicable Countries</label>
757
+ <frontend_type>allowspecific</frontend_type>
758
+ <sort_order>60</sort_order>
759
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
760
+ <show_in_default>1</show_in_default>
761
+ <show_in_website>1</show_in_website>
762
+ <show_in_store>1</show_in_store>
763
+ </allowspecific>
764
+
765
+ <specificcountry translate="label">
766
+ <label>Payment from Specific Countries</label>
767
+ <frontend_type>multiselect</frontend_type>
768
+ <sort_order>61</sort_order>
769
+ <source_model>adminhtml/system_config_source_country</source_model>
770
+ <show_in_default>1</show_in_default>
771
+ <show_in_website>1</show_in_website>
772
+ <show_in_store>1</show_in_store>
773
+ </specificcountry>
774
+
775
+ <min_order_total translate="label">
776
+ <label>Min Order Total</label>
777
+ <frontend_type>text</frontend_type>
778
+ <sort_order>70</sort_order>
779
+ <show_in_default>1</show_in_default>
780
+ <show_in_website>1</show_in_website>
781
+ <show_in_store>1</show_in_store>
782
+ <frontend_class>validate-number</frontend_class>
783
+ </min_order_total>
784
+
785
+ <max_order_total translate="label">
786
+ <label>Max Order Total</label>
787
+ <frontend_type>text</frontend_type>
788
+ <sort_order>80</sort_order>
789
+ <show_in_default>1</show_in_default>
790
+ <show_in_website>1</show_in_website>
791
+ <show_in_store>1</show_in_store>
792
+ <frontend_class>validate-number</frontend_class>
793
+ </max_order_total>
794
+
795
+ <sort_order translate="label">
796
+ <label>Sort Order</label>
797
+ <frontend_type>text</frontend_type>
798
+ <sort_order>100</sort_order>
799
+ <show_in_default>1</show_in_default>
800
+ <show_in_website>1</show_in_website>
801
+ <show_in_store>1</show_in_store>
802
+ <frontend_class>validate-number</frontend_class>
803
+ </sort_order>
804
+ </fields>
805
+ </mundipagg_threecreditcards>
806
+ <mundipagg_fourcreditcards type="group" translate="label">
807
+ <label><![CDATA[MundiPagg - 4 Cartões de Crédito]]></label>
808
+ <sort_order>460</sort_order>
809
+ <show_in_default>1</show_in_default>
810
+ <show_in_website>1</show_in_website>
811
+ <show_in_store>1</show_in_store>
812
+ <comment>
813
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
814
+ <fields>
815
+ <active translate="label">
816
+ <label>Enabled</label>
817
+ <frontend_type>select</frontend_type>
818
+ <source_model>adminhtml/system_config_source_yesno</source_model>
819
+ <sort_order>1</sort_order>
820
+ <show_in_default>1</show_in_default>
821
+ <show_in_website>1</show_in_website>
822
+ <show_in_store>1</show_in_store>
823
+ </active>
824
+
825
+ <title translate="label">
826
+ <label>Title</label>
827
+ <frontend_type>text</frontend_type>
828
+ <sort_order>2</sort_order>
829
+ <show_in_default>1</show_in_default>
830
+ <show_in_website>1</show_in_website>
831
+ <show_in_store>1</show_in_store>
832
+ <comment>
833
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
834
+ </title>
835
+
836
+ <allowspecific translate="label">
837
+ <label>Payment from Applicable Countries</label>
838
+ <frontend_type>allowspecific</frontend_type>
839
+ <sort_order>60</sort_order>
840
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
841
+ <show_in_default>1</show_in_default>
842
+ <show_in_website>1</show_in_website>
843
+ <show_in_store>1</show_in_store>
844
+ </allowspecific>
845
+
846
+ <specificcountry translate="label">
847
+ <label>Payment from Specific Countries</label>
848
+ <frontend_type>multiselect</frontend_type>
849
+ <sort_order>61</sort_order>
850
+ <source_model>adminhtml/system_config_source_country</source_model>
851
+ <show_in_default>1</show_in_default>
852
+ <show_in_website>1</show_in_website>
853
+ <show_in_store>1</show_in_store>
854
+ </specificcountry>
855
+
856
+ <min_order_total translate="label">
857
+ <label>Min Order Total</label>
858
+ <frontend_type>text</frontend_type>
859
+ <sort_order>70</sort_order>
860
+ <show_in_default>1</show_in_default>
861
+ <show_in_website>1</show_in_website>
862
+ <show_in_store>1</show_in_store>
863
+ <frontend_class>validate-number</frontend_class>
864
+ </min_order_total>
865
+
866
+ <max_order_total translate="label">
867
+ <label>Max Order Total</label>
868
+ <frontend_type>text</frontend_type>
869
+ <sort_order>80</sort_order>
870
+ <show_in_default>1</show_in_default>
871
+ <show_in_website>1</show_in_website>
872
+ <show_in_store>1</show_in_store>
873
+ <frontend_class>validate-number</frontend_class>
874
+ </max_order_total>
875
+
876
+ <sort_order translate="label">
877
+ <label>Sort Order</label>
878
+ <frontend_type>text</frontend_type>
879
+ <sort_order>100</sort_order>
880
+ <show_in_default>1</show_in_default>
881
+ <show_in_website>1</show_in_website>
882
+ <show_in_store>1</show_in_store>
883
+ <frontend_class>validate-number</frontend_class>
884
+ </sort_order>
885
+ </fields>
886
+ </mundipagg_fourcreditcards>
887
+ <mundipagg_fivecreditcards type="group" translate="label">
888
+ <label><![CDATA[MundiPagg - 5 Cartões de Crédito]]></label>
889
+ <sort_order>470</sort_order>
890
+ <show_in_default>1</show_in_default>
891
+ <show_in_website>1</show_in_website>
892
+ <show_in_store>1</show_in_store>
893
+ <comment>
894
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
895
+ <fields>
896
+ <active translate="label">
897
+ <label>Enabled</label>
898
+ <frontend_type>select</frontend_type>
899
+ <source_model>adminhtml/system_config_source_yesno</source_model>
900
+ <sort_order>1</sort_order>
901
+ <show_in_default>1</show_in_default>
902
+ <show_in_website>1</show_in_website>
903
+ <show_in_store>1</show_in_store>
904
+ </active>
905
+
906
+ <title translate="label">
907
+ <label>Title</label>
908
+ <frontend_type>text</frontend_type>
909
+ <sort_order>2</sort_order>
910
+ <show_in_default>1</show_in_default>
911
+ <show_in_website>1</show_in_website>
912
+ <show_in_store>1</show_in_store>
913
+ <comment>
914
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
915
+ </title>
916
+
917
+ <allowspecific translate="label">
918
+ <label>Payment from Applicable Countries</label>
919
+ <frontend_type>allowspecific</frontend_type>
920
+ <sort_order>60</sort_order>
921
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
922
+ <show_in_default>1</show_in_default>
923
+ <show_in_website>1</show_in_website>
924
+ <show_in_store>1</show_in_store>
925
+ </allowspecific>
926
+
927
+ <specificcountry translate="label">
928
+ <label>Payment from Specific Countries</label>
929
+ <frontend_type>multiselect</frontend_type>
930
+ <sort_order>61</sort_order>
931
+ <source_model>adminhtml/system_config_source_country</source_model>
932
+ <show_in_default>1</show_in_default>
933
+ <show_in_website>1</show_in_website>
934
+ <show_in_store>1</show_in_store>
935
+ </specificcountry>
936
+
937
+ <min_order_total translate="label">
938
+ <label>Min Order Total</label>
939
+ <frontend_type>text</frontend_type>
940
+ <sort_order>70</sort_order>
941
+ <show_in_default>1</show_in_default>
942
+ <show_in_website>1</show_in_website>
943
+ <show_in_store>1</show_in_store>
944
+ <frontend_class>validate-number</frontend_class>
945
+ </min_order_total>
946
+
947
+ <max_order_total translate="label">
948
+ <label>Max Order Total</label>
949
+ <frontend_type>text</frontend_type>
950
+ <sort_order>80</sort_order>
951
+ <show_in_default>1</show_in_default>
952
+ <show_in_website>1</show_in_website>
953
+ <show_in_store>1</show_in_store>
954
+ <frontend_class>validate-number</frontend_class>
955
+ </max_order_total>
956
+
957
+ <sort_order translate="label">
958
+ <label>Sort Order</label>
959
+ <frontend_type>text</frontend_type>
960
+ <sort_order>100</sort_order>
961
+ <show_in_default>1</show_in_default>
962
+ <show_in_website>1</show_in_website>
963
+ <show_in_store>1</show_in_store>
964
+ <frontend_class>validate-number</frontend_class>
965
+ </sort_order>
966
+ </fields>
967
+ </mundipagg_fivecreditcards>
968
+ <mundipagg_boleto type="group" translate="label">
969
+ <label><![CDATA[MundiPagg - Boleto]]></label>
970
+ <sort_order>480</sort_order>
971
+ <show_in_default>1</show_in_default>
972
+ <show_in_website>1</show_in_website>
973
+ <show_in_store>1</show_in_store>
974
+ <comment>
975
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
976
+ <fields>
977
+ <active translate="label">
978
+ <label>Enabled</label>
979
+ <frontend_type>select</frontend_type>
980
+ <source_model>adminhtml/system_config_source_yesno</source_model>
981
+ <sort_order>1</sort_order>
982
+ <show_in_default>1</show_in_default>
983
+ <show_in_website>1</show_in_website>
984
+ <show_in_store>1</show_in_store>
985
+ </active>
986
+
987
+ <title translate="label">
988
+ <label>Title</label>
989
+ <frontend_type>text</frontend_type>
990
+ <sort_order>2</sort_order>
991
+ <show_in_default>1</show_in_default>
992
+ <show_in_website>1</show_in_website>
993
+ <show_in_store>1</show_in_store>
994
+ <comment>
995
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
996
+ </title>
997
+
998
+ <dias_validade_boleto translate="label">
999
+ <label>Boleto - Dias validade</label>
1000
+ <frontend_type>text</frontend_type>
1001
+ <validate>validate-digits</validate>
1002
+ <sort_order>50</sort_order>
1003
+ <show_in_default>1</show_in_default>
1004
+ <show_in_website>1</show_in_website>
1005
+ <show_in_store>1</show_in_store>
1006
+ <comment><![CDATA[Quantos dias o Boleto será válido para pagamento?]]></comment>
1007
+ </dias_validade_boleto>
1008
+
1009
+ <instrucoes_caixa translate="label">
1010
+ <label>Boleto - Instrucões Caixa</label>
1011
+ <frontend_type>textarea</frontend_type>
1012
+ <sort_order>51</sort_order>
1013
+ <show_in_default>1</show_in_default>
1014
+ <show_in_website>1</show_in_website>
1015
+ <show_in_store>1</show_in_store>
1016
+ <comment>
1017
+ <![CDATA[Texto sobre as instruções caixa customizado por você que irá aparecer nos seus Boletos Bancários]]></comment>
1018
+ </instrucoes_caixa>
1019
+
1020
+ <allowspecific translate="label">
1021
+ <label>Payment from Applicable Countries</label>
1022
+ <frontend_type>allowspecific</frontend_type>
1023
+ <sort_order>60</sort_order>
1024
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
1025
+ <show_in_default>1</show_in_default>
1026
+ <show_in_website>1</show_in_website>
1027
+ <show_in_store>1</show_in_store>
1028
+ </allowspecific>
1029
+
1030
+ <specificcountry translate="label">
1031
+ <label>Payment from Specific Countries</label>
1032
+ <frontend_type>multiselect</frontend_type>
1033
+ <sort_order>61</sort_order>
1034
+ <source_model>adminhtml/system_config_source_country</source_model>
1035
+ <show_in_default>1</show_in_default>
1036
+ <show_in_website>1</show_in_website>
1037
+ <show_in_store>1</show_in_store>
1038
+ </specificcountry>
1039
+
1040
+ <sort_order translate="label">
1041
+ <label>Sort Order</label>
1042
+ <frontend_type>text</frontend_type>
1043
+ <sort_order>100</sort_order>
1044
+ <show_in_default>1</show_in_default>
1045
+ <show_in_website>1</show_in_website>
1046
+ <show_in_store>1</show_in_store>
1047
+ <frontend_class>validate-number</frontend_class>
1048
+ </sort_order>
1049
+ </fields>
1050
+ </mundipagg_boleto>
1051
+ <mundipagg_debit type="group" translate="label">
1052
+ <label><![CDATA[MundiPagg - Debit]]></label>
1053
+ <sort_order>480</sort_order>
1054
+ <show_in_default>1</show_in_default>
1055
+ <show_in_website>1</show_in_website>
1056
+ <show_in_store>1</show_in_store>
1057
+ <comment>
1058
+ <![CDATA[<a href="http://www.mundipagg.com.br" target="_blank"><img title="MundiPagg" alt="MundiPagg" src="/skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png"/></a></span>]]></comment>
1059
+ <fields>
1060
+ <active translate="label">
1061
+ <label>Enabled</label>
1062
+ <frontend_type>select</frontend_type>
1063
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1064
+ <sort_order>1</sort_order>
1065
+ <show_in_default>1</show_in_default>
1066
+ <show_in_website>1</show_in_website>
1067
+ <show_in_store>1</show_in_store>
1068
+ </active>
1069
+
1070
+ <title translate="label">
1071
+ <label>Title</label>
1072
+ <frontend_type>text</frontend_type>
1073
+ <sort_order>2</sort_order>
1074
+ <show_in_default>1</show_in_default>
1075
+ <show_in_website>1</show_in_website>
1076
+ <show_in_store>1</show_in_store>
1077
+ <comment>
1078
+ <![CDATA[Frase que irá aparecer no seu checkout para descrever a forma de pagamento.]]></comment>
1079
+ </title>
1080
+
1081
+ <debit_types translate="label">
1082
+ <label>Debit</label>
1083
+ <frontend_type>multiselect</frontend_type>
1084
+ <source_model>Uecommerce_Mundipagg_Model_Source_Debit</source_model>
1085
+ <sort_order>3</sort_order>
1086
+ <show_in_default>1</show_in_default>
1087
+ <show_in_website>1</show_in_website>
1088
+ <show_in_store>1</show_in_store>
1089
+ <comment><![CDATA[Escolha os débitos que você aceita na sua loja]]></comment>
1090
+ </debit_types>
1091
+
1092
+ <apiDebitUrl translate="label">
1093
+ <label>Api Debit URL</label>
1094
+ <frontend_type>text</frontend_type>
1095
+ <sort_order>4</sort_order>
1096
+ <show_in_default>1</show_in_default>
1097
+ <show_in_website>1</show_in_website>
1098
+ <show_in_store>1</show_in_store>
1099
+ </apiDebitUrl>
1100
+
1101
+ <apiDebitStagingUrl translate="label">
1102
+ <label>Api Debit Staging URL</label>
1103
+ <frontend_type>text</frontend_type>
1104
+ <sort_order>5</sort_order>
1105
+ <show_in_default>1</show_in_default>
1106
+ <show_in_website>1</show_in_website>
1107
+ <show_in_store>1</show_in_store>
1108
+ </apiDebitStagingUrl>
1109
+
1110
+ <allowspecific translate="label">
1111
+ <label>Payment from Applicable Countries</label>
1112
+ <frontend_type>allowspecific</frontend_type>
1113
+ <sort_order>6</sort_order>
1114
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
1115
+ <show_in_default>1</show_in_default>
1116
+ <show_in_website>1</show_in_website>
1117
+ <show_in_store>1</show_in_store>
1118
+ </allowspecific>
1119
+
1120
+ <specificcountry translate="label">
1121
+ <label>Payment from Specific Countries</label>
1122
+ <frontend_type>multiselect</frontend_type>
1123
+ <sort_order>7</sort_order>
1124
+ <source_model>adminhtml/system_config_source_country</source_model>
1125
+ <show_in_default>1</show_in_default>
1126
+ <show_in_website>1</show_in_website>
1127
+ <show_in_store>1</show_in_store>
1128
+ </specificcountry>
1129
+
1130
+ <sort_order translate="label">
1131
+ <label>Sort Order</label>
1132
+ <frontend_type>text</frontend_type>
1133
+ <sort_order>8</sort_order>
1134
+ <show_in_default>1</show_in_default>
1135
+ <show_in_website>1</show_in_website>
1136
+ <show_in_store>1</show_in_store>
1137
+ <frontend_class>validate-number</frontend_class>
1138
+ </sort_order>
1139
+ </fields>
1140
+ </mundipagg_debit>
1141
+ </groups>
1142
+ </payment>
1143
+ </sections>
1144
+ </config>
app/code/community/Uecommerce/Mundipagg/etc/wsdl.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
4
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
5
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
6
+ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
7
+ <types>
8
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
9
+ <complexType name="shoppingCartPaymentEntity">
10
+ <all>
11
+ <element name="payment_id" type="xsd:string" minOccurs="0"/>
12
+ <element name="created_at" type="xsd:string" minOccurs="0"/>
13
+ <element name="updated_at" type="xsd:string" minOccurs="0"/>
14
+ <element name="method" type="xsd:string" minOccurs="0"/>
15
+ <element name="cc_type" type="xsd:string" minOccurs="0"/>
16
+ <element name="cc_number_enc" type="xsd:string" minOccurs="0"/>
17
+ <element name="cc_last4" type="xsd:string" minOccurs="0"/>
18
+ <element name="cc_cid_enc" type="xsd:string" minOccurs="0"/>
19
+ <element name="cc_owner" type="xsd:string" minOccurs="0"/>
20
+ <element name="cc_exp_month" type="xsd:string" minOccurs="0"/>
21
+ <element name="cc_exp_year" type="xsd:string" minOccurs="0"/>
22
+ <element name="cc_ss_owner" type="xsd:string" minOccurs="0"/>
23
+ <element name="cc_ss_start_month" type="xsd:string" minOccurs="0"/>
24
+ <element name="cc_ss_start_year" type="xsd:string" minOccurs="0"/>
25
+ <element name="cc_ss_issue" type="xsd:string" minOccurs="0"/>
26
+ <element name="po_number" type="xsd:string" minOccurs="0"/>
27
+ <element name="additional_data" type="xsd:string" minOccurs="0"/>
28
+ <element name="additional_information" type="xsd:string" minOccurs="0"/>
29
+ <element name="mundipagg_type" type="xsd:string" minOccurs="0"/>
30
+ <element name="mundipagg_creditcard_cc_holder_name_1_1" type="xsd:string" minOccurs="0"/>
31
+ <element name="mundipagg_creditcard_1_1_cc_number" type="xsd:string" minOccurs="0"/>
32
+ <element name="mundipagg_creditcard_expirationMonth_1_1" type="xsd:string" minOccurs="0"/>
33
+ <element name="mundipagg_creditcard_expirationYear_1_1" type="xsd:string" minOccurs="0"/>
34
+ <element name="mundipagg_creditcard_cc_cid_1_1" type="xsd:string" minOccurs="0"/>
35
+ <element name="mundipagg_creditcard_1_1_cc_type" type="xsd:string" minOccurs="0"/>
36
+ <element name="mundipagg_creditcard_new_credito_parcelamento_1_1" type="xsd:string" minOccurs="0"/>
37
+ </all>
38
+ </complexType>
39
+
40
+ <complexType name="shoppingCartPaymentMethodEntity">
41
+ <all>
42
+ <element name="po_number" type="xsd:string" minOccurs="0"/>
43
+ <element name="method" type="xsd:string" minOccurs="0"/>
44
+ <element name="cc_cid" type="xsd:string" minOccurs="0"/>
45
+ <element name="cc_owner" type="xsd:string" minOccurs="0"/>
46
+ <element name="cc_number" type="xsd:string" minOccurs="0"/>
47
+ <element name="cc_type" type="xsd:string" minOccurs="0"/>
48
+ <element name="cc_exp_year" type="xsd:string" minOccurs="0"/>
49
+ <element name="cc_exp_month" type="xsd:string" minOccurs="0"/>
50
+ <element name="mundipagg_type" type="xsd:string" minOccurs="0"/>
51
+ <element name="mundipagg_creditcard_cc_holder_name_1_1" type="xsd:string" minOccurs="0"/>
52
+ <element name="mundipagg_creditcard_1_1_cc_number" type="xsd:string" minOccurs="0"/>
53
+ <element name="mundipagg_creditcard_expirationMonth_1_1" type="xsd:string" minOccurs="0"/>
54
+ <element name="mundipagg_creditcard_expirationYear_1_1" type="xsd:string" minOccurs="0"/>
55
+ <element name="mundipagg_creditcard_cc_cid_1_1" type="xsd:string" minOccurs="0"/>
56
+ <element name="mundipagg_creditcard_1_1_cc_type" type="xsd:string" minOccurs="0"/>
57
+ <element name="mundipagg_creditcard_new_credito_parcelamento_1_1" type="xsd:string" minOccurs="0"/>
58
+ </all>
59
+ </complexType>
60
+ </schema>
61
+ </types>
62
+ </definitions>
app/code/community/Uecommerce/Mundipagg/etc/xtest.xml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <default>
3
+ <xtest>
4
+ <selenium>
5
+ <screenshot>
6
+ <breakpoints>1280x1024</breakpoints>
7
+ </screenshot>
8
+ </selenium>
9
+
10
+ <fixtures>
11
+
12
+ <customer>
13
+ <email>devnull@mundipagg.com.br</email>
14
+ <firstname>Test Firstname</firstname>
15
+ <lastname>Test Lastname</lastname>
16
+
17
+ <billing_address>
18
+ <firstname>Test Firstname</firstname>
19
+ <lastname>Test Firstname</lastname>
20
+ <street>Test Street</street>
21
+ <city>Test City</city>
22
+ <postcode>01310909</postcode>
23
+ <telephone>1199999999</telephone>
24
+ <country_id>BR</country_id>
25
+ <region_id></region_id>
26
+ </billing_address>
27
+
28
+ <shipping_address>
29
+ <firstname>Test Firstname</firstname>
30
+ <lastname>Test Lastname</lastname>
31
+ <street>Test Street</street>
32
+ <city>Test City</city>
33
+ <postcode>01310909</postcode>
34
+ <telephone>1199999999</telephone>
35
+ <country_id>BR</country_id>
36
+ <region_id></region_id>
37
+ </shipping_address>
38
+
39
+ </customer>
40
+
41
+ <order>
42
+
43
+ <customer_id>0</customer_id>
44
+ <customer_data>
45
+ <email>devnull@mundipagg.com.br</email>
46
+ <firstname>Test Firstname</firstname>
47
+ <lastname>Test Lastname</lastname>
48
+ </customer_data>
49
+
50
+ <payment_method>
51
+ <method>mundipagg_boleto</method>
52
+ <!-- some other options-->
53
+ </payment_method>
54
+
55
+ <shipping_method>
56
+ <method>flatrate_flatrate</method>
57
+ </shipping_method>
58
+
59
+ <billing_address>
60
+ <firstname>Test Firstname</firstname>
61
+ <lastname>Test Lastname</lastname>
62
+ <street>Test Street</street>
63
+ <city>Test City</city>
64
+ <postcode>33100</postcode>
65
+ <telephone>Xtest Phone</telephone>
66
+ <country_id>DE</country_id>
67
+ <region_id>88</region_id>
68
+ </billing_address>
69
+
70
+ <shipping_address>
71
+ <firstname>Xtest Firstname</firstname>
72
+ <lastname>Xtest Lastname</lastname>
73
+ <street>Xtest Street</street>
74
+ <city>Xtest City</city>
75
+ <postcode>01310909</postcode>
76
+ <telephone>1199999999</telephone>
77
+ <country_id>BR</country_id>
78
+ <region_id></region_id>
79
+ </shipping_address>
80
+
81
+ <items>
82
+
83
+ <item>
84
+ <qty>1</qty>
85
+ <sku>test</sku>
86
+ </item>
87
+
88
+ </items>
89
+
90
+ </order>
91
+ </fixtures>
92
+
93
+ <selenium>
94
+
95
+ <checkout>
96
+
97
+ <customer>
98
+ <email>selenium@mundipagg.com.br</email>
99
+ <firstname>Firstname</firstname>
100
+ <lastname>Lasntname</lastname>
101
+ </customer>
102
+
103
+ <addtocart>
104
+
105
+ <product_1>
106
+ <sku>test</sku>
107
+ <qty>1</qty>
108
+ </product_1>
109
+
110
+ </addtocart>
111
+
112
+ <billing_address>
113
+
114
+ <firstname>test firstname</firstname>
115
+ <lastname>test lastname</lastname>
116
+ <company>company</company>
117
+ <telephone>123456</telephone>
118
+ <street1>Teststreet 32</street1>
119
+ <city>Testcity</city>
120
+ <postcode>33100</postcode>
121
+ <use_for_shipping_no>1</use_for_shipping_no>
122
+
123
+ </billing_address>
124
+
125
+ <shipping_address>
126
+ <!-- todo -->
127
+ </shipping_address>
128
+
129
+ <shipping_method>
130
+ <method>flatrate_flatrate</method>
131
+ </shipping_method>
132
+
133
+ <payment_method>
134
+ <method>mundipagg_boleto</method>
135
+ </payment_method>
136
+
137
+ </checkout>
138
+
139
+ </selenium>
140
+
141
+ </xtest>
142
+ </default>
143
+ </config>
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/install-0.3.0.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_transactions` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `boleto_url` varchar(100) DEFAULT NULL,
42
+ `authentication_url` varchar(100) DEFAULT NULL,
43
+ `auth_code` varchar(100) DEFAULT NULL,
44
+ `reference_num` varchar(100) DEFAULT NULL,
45
+ `order_id` varchar(255) DEFAULT NULL,
46
+ `transaction_id` varchar(100) DEFAULT NULL,
47
+ `transaction_timestamp` varchar(100) DEFAULT NULL,
48
+ `response_code` varchar(100) DEFAULT NULL,
49
+ `response_message` varchar(100) DEFAULT NULL,
50
+ `avs_response_code` varchar(100) DEFAULT NULL,
51
+ `processor_code` varchar(100) DEFAULT NULL,
52
+ `processor_message` varchar(100) DEFAULT NULL,
53
+ `processor_reference_number` varchar(100) DEFAULT NULL,
54
+ `processor_transaction_id` varchar(100) DEFAULT NULL,
55
+ `error_message` varchar(100) DEFAULT NULL,
56
+ `save_on_file_token` varchar(100) DEFAULT NULL,
57
+ `save_on_file_error` varchar(100) DEFAULT NULL,
58
+ `error` TEXT,
59
+ PRIMARY KEY (`id`),
60
+ KEY `reference_num` (`reference_num`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
+
63
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_requests` (
64
+ `id` int(10) NOT NULL AUTO_INCREMENT,
65
+ `entity_id` int(10) DEFAULT NULL,
66
+ `entity_id_mundipagg` int(10) DEFAULT NULL,
67
+ `error` varchar(255) DEFAULT NULL,
68
+ `error_code` varchar(255) DEFAULT NULL,
69
+ `error_message` varchar(255) DEFAULT NULL,
70
+ `command` varchar(255) DEFAULT NULL,
71
+ `time` varchar(255) DEFAULT NULL,
72
+ PRIMARY KEY (`id`),
73
+ KEY `entity_id` (`entity_id`)
74
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
75
+
76
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
77
+ `id` int(10) NOT NULL AUTO_INCREMENT,
78
+ `entity_id` int(10) NOT NULL,
79
+ `address_id` int(10) NOT NULL,
80
+ `cc_type` varchar(20) DEFAULT '',
81
+ `credit_card_mask` varchar(20) NOT NULL,
82
+ `expires_at` date DEFAULT NULL,
83
+ `token` varchar(50) NOT NULL DEFAULT '',
84
+ `active` tinyint(1) NOT NULL DEFAULT '1',
85
+ PRIMARY KEY (`id`),
86
+ KEY `entity_id` (`entity_id`),
87
+ KEY `expires_at` (`expires_at`)
88
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
89
+
90
+ ");
91
+
92
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.0-0.3.5.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ ");
54
+
55
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
56
+
57
+ if (version_compare($mageVersion, '1.6.0', '>')) {
58
+ // UnderPaid
59
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
60
+
61
+ if (!$status->getStatus()) {
62
+ $status = Mage::getModel('sales/order_status');
63
+ $status->setStatus('underpaid');
64
+ $status->setLabel('Underpaid');
65
+ $status->assignState('pending');
66
+ $status->save();
67
+ }
68
+
69
+ // OverPaid
70
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
71
+
72
+ if (!$status->getStatus()) {
73
+ $status = Mage::getModel('sales/order_status');
74
+ $status->setStatus('overpaid');
75
+ $status->setLabel('Overpaid');
76
+ $status->assignState('processing');
77
+ $status->save();
78
+ }
79
+ }
80
+
81
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.5-0.4.0.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.3.5-1.0.1.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.0-1.0.1.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.1-0.4.2.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Thanks to Fillipe Almeida Dutra
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer = Mage::getResourceModel('sales/setup', 'default_setup');
90
+
91
+ // Interests
92
+ $installer->addAttribute('quote', 'mundipagg_base_interest',
93
+ array(
94
+ 'label' => 'Base Interest',
95
+ 'type' => 'decimal',
96
+ )
97
+ );
98
+
99
+ $installer->addAttribute('quote', 'mundipagg_interest',
100
+ array(
101
+ 'label' => 'Interest',
102
+ 'type' => 'decimal',
103
+ )
104
+ );
105
+
106
+ $installer->addAttribute('order', 'mundipagg_base_interest',
107
+ array(
108
+ 'label' => 'Base Interest',
109
+ 'type' => 'decimal',
110
+ )
111
+ );
112
+
113
+ $installer->addAttribute('order', 'mundipagg_interest',
114
+ array(
115
+ 'label' => 'Interest',
116
+ 'type' => 'decimal',
117
+ )
118
+ );
119
+
120
+ $installer->addAttribute('invoice', 'mundipagg_base_interest',
121
+ array(
122
+ 'label' => 'Base Interest',
123
+ 'type' => 'decimal',
124
+ )
125
+ );
126
+
127
+ $installer->addAttribute('invoice', 'mundipagg_interest',
128
+ array(
129
+ 'label' => 'Interest',
130
+ 'type' => 'decimal',
131
+ )
132
+ );
133
+
134
+ $installer->addAttribute('creditmemo', 'mundipagg_base_interest',
135
+ array(
136
+ 'label' => 'Base Interest',
137
+ 'type' => 'decimal',
138
+ )
139
+ );
140
+
141
+ $installer->addAttribute('creditmemo', 'mundipagg_interest',
142
+ array(
143
+ 'label' => 'Interest',
144
+ 'type' => 'decimal',
145
+ )
146
+ );
147
+
148
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-0.4.1-1.0.1.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/uecommerce_mundipagg_standard/active';
54
+
55
+ UPDATE ".$prefix."core_config_data SET `value` = 0 WHERE path = 'payment/mundipagg_standard/active';
56
+
57
+ UPDATE ".$prefix."sales_flat_quote_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
58
+
59
+ UPDATE ".$prefix."sales_flat_order_payment SET `method` = 'mundipagg_creditcard' WHERE method = 'mundipagg_standard';
60
+
61
+ ");
62
+
63
+ $mageVersion = Mage::helper('mundipagg/version')->convertVersionToCommunityVersion(Mage::getVersion());
64
+
65
+ if (version_compare($mageVersion, '1.6.0', '>')) {
66
+ // UnderPaid
67
+ $status = Mage::getModel('sales/order_status')->load('underpaid', 'status');
68
+
69
+ if (!$status->getStatus()) {
70
+ $status = Mage::getModel('sales/order_status');
71
+ $status->setStatus('underpaid');
72
+ $status->setLabel('Underpaid');
73
+ $status->assignState('pending');
74
+ $status->save();
75
+ }
76
+
77
+ // OverPaid
78
+ $status = Mage::getModel('sales/order_status')->load('overpaid', 'status');
79
+
80
+ if (!$status->getStatus()) {
81
+ $status = Mage::getModel('sales/order_status');
82
+ $status->setStatus('overpaid');
83
+ $status->setLabel('Overpaid');
84
+ $status->assignState('processing');
85
+ $status->save();
86
+ }
87
+ }
88
+
89
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.1-1.0.2.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.10-1.0.11.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.11-2.0.0.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2014 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Thanks to Fillipe Almeida Dutra
29
+ */
30
+
31
+ $installer = Mage::getResourceModel('sales/setup', 'default_setup');
32
+
33
+ $installer->startSetup();
34
+
35
+ // Interests
36
+ $installer->addAttribute('quote', 'mundipagg_base_interest',
37
+ array(
38
+ 'label' => 'Base Interest',
39
+ 'type' => 'decimal',
40
+ )
41
+ );
42
+
43
+ $installer->addAttribute('quote', 'mundipagg_interest',
44
+ array(
45
+ 'label' => 'Interest',
46
+ 'type' => 'decimal',
47
+ )
48
+ );
49
+
50
+ $installer->addAttribute('order', 'mundipagg_base_interest',
51
+ array(
52
+ 'label' => 'Base Interest',
53
+ 'type' => 'decimal',
54
+ )
55
+ );
56
+
57
+ $installer->addAttribute('order', 'mundipagg_interest',
58
+ array(
59
+ 'label' => 'Interest',
60
+ 'type' => 'decimal',
61
+ )
62
+ );
63
+
64
+ $installer->addAttribute('invoice', 'mundipagg_base_interest',
65
+ array(
66
+ 'label' => 'Base Interest',
67
+ 'type' => 'decimal',
68
+ )
69
+ );
70
+
71
+ $installer->addAttribute('invoice', 'mundipagg_interest',
72
+ array(
73
+ 'label' => 'Interest',
74
+ 'type' => 'decimal',
75
+ )
76
+ );
77
+
78
+ $installer->addAttribute('creditmemo', 'mundipagg_base_interest',
79
+ array(
80
+ 'label' => 'Base Interest',
81
+ 'type' => 'decimal',
82
+ )
83
+ );
84
+
85
+ $installer->addAttribute('creditmemo', 'mundipagg_interest',
86
+ array(
87
+ 'label' => 'Interest',
88
+ 'type' => 'decimal',
89
+ )
90
+ );
91
+
92
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.3-1.0.4.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.5-1.0.6.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.6-1.0.7.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.7-1.0.8.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.8-1.0.9.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-1.0.9-1.0.10.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.0-2.0.1.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+
37
+ $installer->run("
38
+
39
+ CREATE TABLE IF NOT EXISTS `".$prefix."mundipagg_card_on_file` (
40
+ `id` int(10) NOT NULL AUTO_INCREMENT,
41
+ `entity_id` int(10) NOT NULL,
42
+ `address_id` int(10) NOT NULL,
43
+ `cc_type` varchar(20) DEFAULT '',
44
+ `credit_card_mask` varchar(20) NOT NULL,
45
+ `expires_at` date DEFAULT NULL,
46
+ `token` varchar(50) NOT NULL DEFAULT '',
47
+ `active` tinyint(1) NOT NULL DEFAULT '1',
48
+ PRIMARY KEY (`id`),
49
+ KEY `entity_id` (`entity_id`),
50
+ KEY `expires_at` (`expires_at`)
51
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
52
+
53
+ ");
54
+
55
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.0-2.1.0.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
32
+
33
+ $installer->startSetup();
34
+
35
+ $reader = Mage::getSingleton('core/resource')->getConnection('core_read');
36
+
37
+ $result = $reader->query('select attribute_code from '.$prefix.'eav_attribute WHERE attribute_code = "mundipagg_recurrent"')->fetchAll();
38
+
39
+ if (empty($result)) {
40
+ $recurrent = array(
41
+ 'attribute_set' => 'Default',
42
+ 'group' => 'Recorrência',
43
+ 'label' => 'Produto de assinatura?',
44
+ 'visible' => true,
45
+ 'type' => 'int',
46
+ 'input' => 'select',
47
+ 'source' => 'eav/entity_attribute_source_boolean',
48
+ 'system' => false,
49
+ 'required' => true,
50
+ 'used_in_product_listing' => true,
51
+ 'is_visible_on_front' => true,
52
+ 'visible_on_front' => true
53
+ );
54
+
55
+ $installer->addAttribute('catalog_product', 'mundipagg_recurrent', $recurrent);
56
+ }
57
+
58
+ $result = $reader->query('select attribute_code from '.$prefix.'eav_attribute WHERE attribute_code = "mundipagg_frequency_enum"')->fetchAll();
59
+
60
+ if (empty($result)) {
61
+ $frequency_enum = array(
62
+ 'attribute_set' => 'Default',
63
+ 'group' => 'Recorrência',
64
+ 'label' => 'Frequência',
65
+ 'note' => 'O valor colocado na aba "Prices / Preços" sera o valor pago por: semana / mensal / trimestral / semestral / anual',
66
+ 'visible' => true,
67
+ 'type' => 'varchar',
68
+ 'input' => 'select',
69
+ 'system' => false,
70
+ 'required' => true,
71
+ 'used_in_product_listing' => true,
72
+ 'is_visible_on_front' => true,
73
+ 'visible_on_front' => true,
74
+ 'frontend_input' => 'select',
75
+ 'source' => 'mundipagg/source_frequency'
76
+ );
77
+
78
+ $installer->addAttribute('catalog_product', 'mundipagg_frequency_enum', $frequency_enum);
79
+ }
80
+
81
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.1-2.0.2.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ Mage::getConfig()->saveConfig('payment/mundipagg_standard/apiUrlStaging','https://stagingv2.mundipaggone.com/Sale/');
36
+ Mage::getConfig()->saveConfig('payment/mundipagg_standard/apiUrlProduction','https://transactionv2.mundipaggone.com/Sale/');
37
+ Mage::getConfig()->reinit();
38
+ Mage::getConfig()->cleanCache();
39
+ Mage::app()->reinitStores();
40
+
41
+ $installer->endSetup();
42
+
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.2-2.0.3.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.3-2.0.4.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.4-2.0.5.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.5-2.0.6.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.6-2.0.7.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.7-2.0.8.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.8-2.0.9.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.0.9-2.1.0.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
32
+
33
+ $installer->startSetup();
34
+
35
+ $reader = Mage::getSingleton('core/resource')->getConnection('core_read');
36
+
37
+ $result = $reader->query('select attribute_code from '.$prefix.'eav_attribute WHERE attribute_code = "mundipagg_recurrent"')->fetchAll();
38
+
39
+ if (empty($result)) {
40
+ $recurrent = array(
41
+ 'attribute_set' => 'Default',
42
+ 'group' => 'Recorrência',
43
+ 'label' => 'Produto de assinatura?',
44
+ 'visible' => true,
45
+ 'type' => 'int',
46
+ 'input' => 'select',
47
+ 'source' => 'eav/entity_attribute_source_boolean',
48
+ 'system' => false,
49
+ 'required' => true,
50
+ 'used_in_product_listing' => true,
51
+ 'is_visible_on_front' => true,
52
+ 'visible_on_front' => true
53
+ );
54
+
55
+ $installer->addAttribute('catalog_product', 'mundipagg_recurrent', $recurrent);
56
+ }
57
+
58
+ $result = $reader->query('select attribute_code from '.$prefix.'eav_attribute WHERE attribute_code = "mundipagg_frequency_enum"')->fetchAll();
59
+
60
+ if (empty($result)) {
61
+ $frequency_enum = array(
62
+ 'attribute_set' => 'Default',
63
+ 'group' => 'Recorrência',
64
+ 'label' => 'Frequência',
65
+ 'note' => 'O valor colocado na aba "Prices / Preços" sera o valor pago por: semana / mensal / trimestral / semestral / anual',
66
+ 'visible' => true,
67
+ 'type' => 'varchar',
68
+ 'input' => 'select',
69
+ 'system' => false,
70
+ 'required' => true,
71
+ 'used_in_product_listing' => true,
72
+ 'is_visible_on_front' => true,
73
+ 'visible_on_front' => true,
74
+ 'frontend_input' => 'select',
75
+ 'source' => 'mundipagg/source_frequency'
76
+ );
77
+
78
+ $installer->addAttribute('catalog_product', 'mundipagg_frequency_enum', $frequency_enum);
79
+ }
80
+
81
+ $result = $reader->query('select attribute_code from '.$prefix.'eav_attribute WHERE attribute_code = "mundipagg_recurrences"')->fetchAll();
82
+
83
+ if (empty($result)) {
84
+ $recurrences = array(
85
+ 'attribute_set' => 'Default',
86
+ 'group' => 'Recorrência',
87
+ 'label' => 'Número de Ciclos',
88
+ 'note' => 'Número de ciclos que serão cobrados antes de uma renovação da parte do cliente.',
89
+ 'visible' => true,
90
+ 'type' => 'int',
91
+ 'input' => 'text',
92
+ 'system' => false,
93
+ 'required' => true,
94
+ 'used_in_product_listing' => true,
95
+ 'is_visible_on_front' => true,
96
+ 'visible_on_front' => true,
97
+ 'frontend_input' => 'text',
98
+ 'default' => '1'
99
+ );
100
+
101
+ $installer->addAttribute('catalog_product', 'mundipagg_recurrences', $recurrences);
102
+ }
103
+
104
+ $installer->endSetup();
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.1.2-2.1.3.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $installer = $this;
32
+
33
+ $installer->startSetup();
34
+
35
+ Mage::getConfig()->saveConfig('payment/mundipagg_standard/apiUrlStaging','https://sandbox.mundipaggone.com/sale/');
36
+ Mage::getConfig()->reinit();
37
+ Mage::getConfig()->cleanCache();
38
+ Mage::app()->reinitStores();
39
+
40
+ $installer->endSetup();
41
+
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.5.7-2.5.8.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ Mage::getConfig()->saveConfig('payment/mundipagg_standard/environment_fcontrol', 1);
6
+ Mage::getConfig()->reinit();
7
+ Mage::getConfig()->cleanCache();
8
+ Mage::app()->reinitStores();
9
+
10
+ $installer->endSetup();
11
+
app/code/community/Uecommerce/Mundipagg/sql/mundipagg_setup/mysql4-upgrade-2.5.8-2.6.0.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $prefix = Mage::getConfig()->getTablePrefix();
4
+
5
+ $installer->startSetup();
6
+ $installer->run("
7
+
8
+ CREATE TABLE IF NOT EXISTS {$prefix}mundipagg_offline_retry (
9
+ id INT PRIMARY KEY AUTO_INCREMENT,
10
+ order_increment_id VARCHAR(50) NOT NULL,
11
+ create_date DATETIME NOT NULL COMMENT 'MundiPagg returned create date',
12
+ deadline DATETIME NOT NULL COMMENT 'MundiPagg time to retry the authorization'
13
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
14
+ ");
15
+
16
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/mundipagg.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ -->
32
+ <layout version="0.1.0">
33
+ <default></default>
34
+ <adminhtml_sales_order_create_index>
35
+ <reference name="head">
36
+ <action method="addJs"><file>uecommerce/mundipagg.js</file></action>
37
+ </reference>
38
+ </adminhtml_sales_order_create_index>
39
+ </layout>
app/design/adminhtml/default/default/template/mundipagg/boleto.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_code = $this->getMethodCode();
3
+
4
+ // We check if taxvat is enabled
5
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
6
+ ?>
7
+ <fieldset>
8
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
9
+ <li>
10
+ <div id="mundipagg_boleto">
11
+ <ul>
12
+ <?php if(!$_taxvat->isEnabled() && Mage::getSingleton('adminhtml/session_quote')->getCustomer()->getTaxvat() == ''): ?>
13
+ <li>
14
+ <div class="input-box" style="float:left;">
15
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label><br/>
16
+ <input type="text" id="<?php echo $_code ?>_boleto_taxvat" name="payment[boleto_taxvat]" title="<?php echo $this->__('Taxvat') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
17
+ </div>
18
+ </li>
19
+ <?php endif; ?>
20
+ <li>
21
+ <div id="boleto" style="float:left; text-align:center">
22
+ <img src="<?php echo $this->getSkinUrl('images/mundipagg/boleto.jpg');?>" alt="<?php echo $this->__('Boleto Bancário') ?>" /> <?php echo $this->__('Print your boleto after you have placed your order.') ?>
23
+ </div>
24
+ </li>
25
+ </ul>
26
+ </div>
27
+ </li>
28
+ </ul>
29
+ </fieldset>
app/design/adminhtml/default/default/template/mundipagg/form.phtml ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ //Return Standard model
32
+ $standard = $this->getStandard();
33
+
34
+ // Get Quote
35
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
36
+
37
+ if($quote->isVirtual()) {
38
+ $data = $quote->getBillingAddress();
39
+ } else {
40
+ $data = $quote->getShippingAddress();
41
+ }
42
+
43
+ $baseGrandTotal = $quote->getBaseGrandTotal();
44
+
45
+ $installmentsHelper = Mage::helper('mundipagg/installments');
46
+
47
+ // We check if taxvat is enabled
48
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
49
+
50
+ // Get current currency symbol
51
+ $currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
52
+
53
+ // Min installment value
54
+ $valorMinParcelamento = $standard->getConfigData('parcelamento_min');
55
+
56
+ //Credit Card Saved On File
57
+ $ccs = $this->getCcs();
58
+
59
+ $countCcs = count($ccs);
60
+
61
+ // Payment method
62
+ $_code = $this->getMethodCode();
63
+ ?>
64
+ <style type="text/css">
65
+ .issuers{
66
+ text-align: center;
67
+ padding-right: 10px;
68
+ }
69
+ </style>
70
+ <fieldset class="form-list">
71
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
72
+ <div>
73
+ <input type="hidden" id="baseGrandTotal" name="baseGrandTotal" value="<?php echo number_format($baseGrandTotal, "2", ",", ""); ?>"/>
74
+ </div>
75
+ <?php
76
+ // START CREDIT CARD PAYMENT METHOD
77
+ $num = 1;
78
+
79
+ switch ($_code):
80
+ case 'mundipagg_creditcardoneinstallment':
81
+ $num = 1;
82
+ $paymentMethod = '1CreditCardsOneInstallment';
83
+ $paymentMethodLabel = $this->__('Credit Card');
84
+ break;
85
+
86
+ case 'mundipagg_creditcard':
87
+ $num = 1;
88
+ $paymentMethod = '1CreditCards';
89
+ $paymentMethodLabel = $this->__('Credit Card');
90
+ break;
91
+
92
+ case 'mundipagg_twocreditcards':
93
+ $num = 2;
94
+ $paymentMethod = '2CreditCards';
95
+ $paymentMethodLabel = $this->__('Pay with 2 Credit Cards');
96
+ break;
97
+
98
+ case 'mundipagg_threecreditcards':
99
+ $num = 3;
100
+ $paymentMethod = '3CreditCards';
101
+ $paymentMethodLabel = $this->__('Pay with 3 Credit Cards');
102
+ break;
103
+
104
+ case 'mundipagg_fourcreditcards':
105
+ $num = 4;
106
+ $paymentMethod = '4CreditCards';
107
+ $paymentMethodLabel = $this->__('Pay with 4 Credit Cards');
108
+ break;
109
+
110
+ case 'mundipagg_fivecreditcards':
111
+ $num = 5;
112
+ $paymentMethod = '5CreditCards';
113
+ $paymentMethodLabel = $this->__('Pay with 5 Credit Cards');
114
+ break;
115
+ endswitch;
116
+ ?>
117
+ <li>
118
+ <div id="<?php echo $_code; ?>">
119
+ <?php if ( $_code == 'mundipagg_creditcardoneinstallment' || $_code == 'mundipagg_creditcard' || $_code == 'mundipagg_twocreditcards' || $_code == 'mundipagg_threecreditcards' || $_code == 'mundipagg_fourcreditcards' || $_code == 'mundipagg_fivecreditcards'): ?>
120
+ <ul>
121
+ <?php for($c=1;$c<=$num;$c++): ?>
122
+ <input type="hidden" id="mundipagg_type" name="payment[mundipagg_type]" value="<?php echo $paymentMethod ; ?>"/>
123
+ <?php $currentSelectedToken = null; ?>
124
+ <?php if( $countCcs > 0 ):?>
125
+ <li class="fields" style="margin-bottom: 5px;">
126
+ <div class="field">
127
+ <label class="required"><?php echo $this->__('Select a Credit Card or add a new one') ?><span class="required">*</span></label>
128
+ <div class="input-box">
129
+
130
+ <select id="<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>" data="group_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry tokens group_<?php echo $num; ?>_<?php echo $c;?>" onchange="token_or_not(<?php echo $num; ?>,<?php echo $c;?>,this)">
131
+ <option value="">...</option>
132
+ <?php
133
+ foreach($ccs as $id => $cc):
134
+
135
+ if($countCcs == 1){
136
+ $currentSelectedToken = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
137
+ }
138
+ $dataType = $currentSelectedToken?$currentSelectedToken:Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
139
+ echo '<option value="'.$cc->getId().'" data="'.$dataType.'">'.$cc->getCcType().' '.$cc->getCreditCardMask().'</option>';
140
+ endforeach;
141
+ ?>
142
+ <option value="new"><?php echo $this->__('New Credit Card') ?></option>
143
+ </select>
144
+ </div>
145
+ </div>
146
+ </li>
147
+ <?php if($num != 1): ?>
148
+ <div id="value_<?php echo $num; ?>_<?php echo $c;?>">
149
+ <li class="fields" style="margin-bottom: 5px;">
150
+ <div class="field">
151
+ <label class="required"><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
152
+ <div class="input-box">
153
+ <input type="text" id="<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry validate-greater-than-zero check_values group_<?php echo $num; ?>_<?php echo $c;?>" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');" onkeydown="remove_special_characters(event);" value=""/>
154
+ </div>
155
+ </div>
156
+ </li>
157
+ </div>
158
+ <?php endif; ?>
159
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
160
+ <div id="parcelamento_<?php echo $num; ?>_<?php echo $c;?>" <?php if($countCcs > 1): ?>style="display:none"<?php endif?>>
161
+ <li class="fields" style="margin-bottom: 5px;">
162
+ <div class="field">
163
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num == 2):?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
164
+ <div class="input-box">
165
+ <select id="<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry installment-token group_<?php echo $num; ?>_<?php echo $c;?>">
166
+ <?php foreach($this->getInstallments($currentSelectedToken) as $key => $parcel): ?>
167
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
168
+ <?php endforeach ?>
169
+ </select>
170
+ </div>
171
+ </div>
172
+ </li>
173
+ </div>
174
+ <?php endif; ?>
175
+ <?php endif; ?>
176
+
177
+ <div id="<?php echo $_code; ?>_new_credit_card_<?php echo $num; ?>_<?php echo $c;?>" <?php if( $countCcs > 0 ) { ?>style="display:none"<?php } ?>>
178
+
179
+ <li style="margin-bottom: 5px;">
180
+ <div class="field">
181
+ <label><?php echo $this->__('Credit Card Issuer') ?> <span class="required">*</span></label>
182
+ <div class="input-box">
183
+ <select id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type]" class="required-entry validate-cc-type-select" onchange="cc_cid(this, <?php echo $num; ?>,<?php echo $c;?>);">
184
+ <?php $_ccType = $this->getInfoData('creditCardType') ?>
185
+ <option value=""></option>
186
+ <?php $ccards = $standard->getCcTypes();?>
187
+ <?php foreach($ccards as $ccard): ?>
188
+ <option value="<?php echo $ccard;?>" <?php if($ccard==$_ccType): ?>selected="selected"<?php endif ?>><?php echo Mage::helper('mundipagg')->issuer($ccard);?></option>
189
+ <?php endforeach ?>
190
+ </select>
191
+ </div>
192
+ </div>
193
+ </li>
194
+ <li style="margin-bottom: 5px;">
195
+ <div class="field">
196
+ <label><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
197
+ <div class="input-box">
198
+ <input type="text" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-cc-number" onkeydown="remove_characters(event);" value=""/>
199
+ </div>
200
+ </div>
201
+ </li>
202
+ <li style="margin-bottom: 5px;">
203
+ <div class="field">
204
+ <label><?php echo $this->__('Credit Card Holder name') ?> <span class="required">*</span></label>
205
+ <div class="input-box">
206
+ <input type="text" id="<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry input-text" />
207
+ </div>
208
+ </div>
209
+ </li>
210
+ <li style="margin-bottom: 5px;">
211
+ <div class="field">
212
+ <label><?php echo $this->__('Expiration date') ?> <span class="required">*</span></label>
213
+ <div class="input-box">
214
+ <div class="v-fix">
215
+ <select id="<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>]" style="width: 145px;" class="required-entry validate-cc-exp-new">
216
+ <option value=""><?php echo $this->__('Month') ?></option>
217
+ <option value="1">01 - <?php echo $this->__('January') ?></option>
218
+ <option value="2">02 - <?php echo $this->__('February') ?></option>
219
+ <option value="3">03 - <?php echo $this->__('March') ?></option>
220
+ <option value="4">04 - <?php echo $this->__('April') ?></option>
221
+ <option value="5">05 - <?php echo $this->__('May') ?></option>
222
+ <option value="6">06 - <?php echo $this->__('June') ?></option>
223
+ <option value="7">07 - <?php echo $this->__('July') ?></option>
224
+ <option value="8">08 - <?php echo $this->__('August') ?></option>
225
+ <option value="9">09 - <?php echo $this->__('September') ?></option>
226
+ <option value="10">10 - <?php echo $this->__('October') ?></option>
227
+ <option value="11">11 - <?php echo $this->__('November') ?></option>
228
+ <option value="12">12 - <?php echo $this->__('December') ?></option>
229
+ </select>
230
+ </div>
231
+ <div class="v-fix" style="padding-left:6px;">
232
+ <select id="<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>]" style="width: 105px;" class="required-entry">
233
+ <option value=""><?php echo $this->__('Year') ?></option>
234
+ <?php
235
+ $i = date('Y');
236
+ $year = date('Y');
237
+ $year10 = $year + 10;
238
+ for( $i = $year; $i <= $year10; $i++ ):
239
+ ?>
240
+ <option value="<?php echo substr($i, -2);?>"><?php echo $i;?></option>
241
+ <?php endfor; ?>
242
+ </select>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </li>
247
+ <li style="margin-bottom: 5px;">
248
+ <div class="field">
249
+ <label><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label>
250
+ <div class="input-box">
251
+ <div class="v-fix">
252
+ <input type="text" id="<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>]" style="width: 30px" class="required-entry input-text validate-cc-cvn validate-length" maxlength="4" onkeydown="remove_characters(event);"/>
253
+ </div>
254
+ <div class="v-fix" style="padding-left:6px;">
255
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
256
+ </div>
257
+ </div>
258
+ </div>
259
+ </li>
260
+ <?php if($num != 1): ?>
261
+ <li style="margin-bottom: 5px;">
262
+ <div class="field">
263
+ <label><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
264
+ <div class="input-box">
265
+ <input type="text" id="<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry validate-greater-than-zero check_values" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>);" onkeydown="remove_special_characters(event);" value=""/>
266
+ </div>
267
+ </div>
268
+ </li>
269
+ <?php endif; ?>
270
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
271
+ <li style="margin-bottom: 5px;">
272
+ <div class="field">
273
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num ==2): ?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
274
+ <div class="input-box">
275
+ <select id="<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" onchange="checkInstallments(this, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');">
276
+ <?php foreach($this->getInstallments() as $key => $parcel): ?>
277
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
278
+ <?php endforeach ?>
279
+ </select>
280
+ </div>
281
+ </div>
282
+ </li>
283
+ <?php endif; ?>
284
+ <?php if ($standard->getConfigData('clearsale') && !$_taxvat->isEnabled() && Mage::getSingleton('adminhtml/session_quote')->getCustomer()->getTaxvat() == ''): ?>
285
+ <li style="margin-bottom: 5px;">
286
+ <div class="field">
287
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label>
288
+ <div class="input-box">
289
+ <input type="text" id="<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('CPF ou CNPJ') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
290
+ </div>
291
+ </div>
292
+ </li>
293
+ <?php endif;?>
294
+ <?php if($standard->getQuote()->getCheckoutMethod() != 'guest'): ?>
295
+ <li>
296
+ <div class="input-box" style="padding-top: 10px">
297
+ <div class="field">
298
+ <label><?php echo $this->__('Save Card On File') ?></label>
299
+ <input type="checkbox" id="<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>]" value="new"/>
300
+ </div>
301
+ </div>
302
+ </li>
303
+ <?php endif; ?>
304
+ </div>
305
+ <?php endfor; ?>
306
+ </ul>
307
+ <?php endif ?>
308
+ </div>
309
+ </li>
310
+ <?php // END CREDIT CARD PAYMENT METHOD ?>
311
+
312
+ <?php if ( $_code == 'mundipagg_boleto' ): ?>
313
+ <li>
314
+ <input type="hidden" id="mundipagg_type" name="payment[mundipagg_type]" value="BoletoBancario"/>
315
+ <br/>
316
+ <div id="mundipagg_boleto">
317
+ <ul >
318
+ <?php if(!$_taxvat->isEnabled() && Mage::getSingleton('adminhtml/session_quote')->getCustomer()->getTaxvat() == ''): ?>
319
+ <li>
320
+ <div class="input-box" style="float:left;">
321
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label><br/>
322
+ <input type="text" id="<?php echo $_code ?>_boleto_taxvat" name="payment[boleto_taxvat]" title="<?php echo $this->__('Taxvat') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
323
+ </div>
324
+ </li>
325
+ <?php endif; ?>
326
+ <li>
327
+ <div id="boleto" style="float:left; text-align:center">
328
+ <img src="<?php echo $this->getSkinUrl('images/mundipagg/boleto.jpg');?>" alt="<?php echo $this->__('Boleto Bancário') ?>" /> <?php echo $this->__('Print your boleto after you have placed your order.') ?>
329
+ </div>
330
+ </li>
331
+ </ul>
332
+ </div>
333
+ </li>
334
+ <?php endif ?>
335
+ </ul>
336
+ </fieldset>
337
+
338
+ <script type="text/javascript">
339
+ //<![CDATA[
340
+ window.baseUrl = '<?php echo Mage::helper("adminhtml")->getUrl();?>';
341
+ window.admin_area_url_installments_and_interest = '<?php echo Mage::helper("adminhtml")->getUrl("mundipagg/standard/installmentsandinterest"); ?>';
342
+ window.installmentsandinterestUrl = '<?php echo Mage::helper("adminhtml")->getUrl("mundipagg/standard/installmentsandinterest",array("_secure"=>true)); ?>';
343
+ window.ajaxLoaderGif = '<?php echo $this->getSkinUrl("images/mundipagg/ajax-loader.gif"); ?>';
344
+ window.isInstallmentsEnabled = '<?php echo Mage::helper("mundipagg/installments")->isInstallmentsEnabled(); ?>';
345
+
346
+ $$('.validate-cc-type-select').invoke('observe','change',function(){
347
+ brand_select = this;
348
+ amount = false;
349
+ if(this.value != '') {
350
+ this.up(3).select('select,input').each(function(sel){
351
+ if(sel.readAttribute('id').indexOf('new_value') != -1){
352
+ if(brand_select.value != '' && brand_select.value != undefined) {
353
+ amount = sel.value;
354
+ }
355
+ }
356
+ if(sel.readAttribute('id').indexOf('parcelamento') != -1){
357
+
358
+ updateInstallments(brand_select.value, sel, amount);
359
+ }
360
+ });
361
+ }
362
+ });
363
+
364
+ Validation.addAllThese([
365
+ ['validate-cc-exp-new', '<?php echo $this->jsQuoteEscape( Mage::helper('mundipagg')->__('Incorrect credit card expiration date.') )?>', function(v, elm) {
366
+ var ccExpMonth = v;
367
+ var ccExpYear = $( elm.id.replace("_expirationMonth", "_expirationYear") ).value;
368
+
369
+ var currentTime = new Date();
370
+ var currentMonth = currentTime.getMonth() + 1;
371
+ var currentYear = currentTime.getFullYear().toString().substr(2,2);
372
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
373
+ return false;
374
+ }
375
+ return true;
376
+ }]
377
+ ]);
378
+ //]]>
379
+ </script>
app/design/adminhtml/default/default/template/mundipagg/payment/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/mundipagg/payment/info/mundipagg.phtml ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ $helper = Mage::helper('mundipagg');
32
+
33
+ if(Mage::registry('current_order')):
34
+ $_order = $this->getOrder();
35
+ endif;
36
+
37
+ if(Mage::registry('current_invoice')):
38
+ $_order = $this->getInvoice()->getOrder();
39
+ endif;
40
+
41
+ if(Mage::registry('current_shipment')):
42
+ $_order = $this->getShipment()->getOrder();
43
+ endif;
44
+
45
+ if(Mage::registry('current_creditmemo')):
46
+ $data = Mage::registry('current_creditmemo')->getData();
47
+
48
+ $_order = Mage::getModel('sales/order')->load($data['order_id']);
49
+ endif;
50
+
51
+ $standard = Mage::getModel('mundipagg/standard');
52
+
53
+ $paymentAction = $standard->getPaymentAction();
54
+
55
+ if ($paymentAction == 'authorize') {
56
+ $paymentAction = 'authorization';
57
+ }
58
+ ?>
59
+ <div>
60
+ <p>
61
+ <?php
62
+ $PaymentMethod = $_order->getPayment()->getAdditionalInformation('PaymentMethod');
63
+
64
+ echo $helper->__('Method').': '.$helper->__($PaymentMethod).'<br/>';
65
+
66
+ if($orderKey = $_order->getPayment()->getAdditionalInformation('OrderKey')):
67
+ echo $helper->__('OrderKey').': '.$orderKey.'<br/>';
68
+ endif;
69
+
70
+ if($OrderReference = $_order->getPayment()->getAdditionalInformation('OrderReference')):
71
+ echo $helper->__('OrderReference').': '.$OrderReference.'<br/>';
72
+ endif;
73
+
74
+ // Informations about transaction
75
+ $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
76
+ ->addAttributeToFilter('order_id', array('eq' => $_order->getEntityId()))
77
+ ->addAttributeToFilter('txn_type', array('eq' => $paymentAction));
78
+ $authCode = '';
79
+ $tid = '';
80
+ $ccNumber = '';
81
+ $message = '';
82
+
83
+ foreach ($transaction as $t) :
84
+ $t = $t->getData();
85
+ $txDetail = $t['additional_information'];
86
+
87
+ if (!empty($txDetail)):
88
+ $authCode = isset($txDetail['AuthorizationCode']) ? $txDetail['AuthorizationCode'] : null;
89
+ $tid = isset($txDetail['TransactionIdentifier']) ? $txDetail['TransactionIdentifier'] : null;
90
+ $ccNumber = isset($txDetail['MaskedCreditCardNumber']) ? $txDetail['MaskedCreditCardNumber'] : null;
91
+
92
+ if(isset($txDetail['CreditCardNumber'])) {
93
+ $ccNumber = $txDetail['CreditCardNumber'];
94
+ }
95
+
96
+ $message = isset($txDetail['AcquirerMessage']) ? $txDetail['AcquirerMessage'] : null;
97
+ endif;
98
+ endforeach;
99
+
100
+ if($PaymentMethod == '1CreditCards' || $PaymentMethod == 'mundipagg_creditcard'):
101
+ // Token
102
+ $token = $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_token_1_1');
103
+
104
+ if($token && $token != 'new'):
105
+ echo $helper->__('Credit Card Issuer').': ';
106
+ echo $this->getInfo()->getAdditionalInformation('CreditCardBrandEnum_mundipagg_creditcard_token_1_1');
107
+ echo '<br/>';
108
+ if ($ccNumber) echo 'Numeração: '.$ccNumber.'<br>';
109
+
110
+ if ($this->getInfo()->getAdditionalInformation('mundipagg_creditcard_credito_parcelamento_1_1')):
111
+ echo $helper->__('InstallmentsCount').': ';
112
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_credito_parcelamento_1_1');
113
+ echo 'x<br/>';
114
+ endif;
115
+ else:
116
+ echo $helper->__('Credit Card Issuer').': ';
117
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_1_1_cc_type');
118
+ echo '<br/>';
119
+ if ($ccNumber) echo 'Numeração: '.$ccNumber.'<br>';
120
+
121
+ if ($this->getInfo()->getAdditionalInformation('mundipagg_creditcard_new_credito_parcelamento_1_1')):
122
+ echo $helper->__('InstallmentsCount').': ';
123
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_new_credito_parcelamento_1_1');
124
+ echo 'x<br/>';
125
+ endif;
126
+ endif;
127
+
128
+ if ($authCode):
129
+ echo 'Autorização: <b>'.$authCode.'</b><br/>';
130
+ endif;
131
+
132
+ if ($tid):
133
+ echo 'ID da Transação: '.$tid.'<br/>';
134
+ endif;
135
+
136
+ if ($message):
137
+ echo 'Retorno adquirente: '.$message.'<br/>';
138
+ endif;
139
+
140
+ if($CreditCardTransactionStatusEnum = $_order->getPayment()->getAdditionalInformation('1_CreditCardTransactionStatusEnum')):
141
+ echo $helper->__('Transaction Status').': '.$CreditCardTransactionStatusEnum.'<br/>';
142
+ else:
143
+ if($CreditCardTransactionStatusEnum = $_order->getPayment()->getAdditionalInformation('CreditCardTransactionStatusEnum')):
144
+ echo $helper->__('Transaction Status').': '.$CreditCardTransactionStatusEnum.'<br/>';
145
+ endif;
146
+ endif;
147
+ endif;
148
+
149
+ if($PaymentMethod == 'mundipagg_creditcardoneinstallment'):
150
+ // Token
151
+ $token = $this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_token_1_1');
152
+
153
+ if($token && $token != 'new'):
154
+ echo $helper->__('Credit Card Issuer').': ';
155
+ echo $this->getInfo()->getAdditionalInformation('CreditCardBrandEnum_mundipagg_creditcardoneinstallment_token_1_1');
156
+ echo '<br/>';
157
+ ?>
158
+ <?php
159
+ else:
160
+ echo $helper->__('Credit Card Issuer').': ';
161
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_1_1_cc_type');
162
+ echo '<br/>';
163
+ endif;
164
+
165
+ if ($authCode):
166
+ echo $helper->__('Autorização').': '.$authCode.'<br/>';
167
+ endif;
168
+
169
+ if ($tid):
170
+ echo $helper->__('Nosso Número').': '.$tid.'<br/>';
171
+ endif;
172
+
173
+ if ($message):
174
+ echo 'Retorno adquirente: '.$message.'<br/>';
175
+ endif;
176
+
177
+ if( $CreditCardTransactionStatusEnum = $_order->getPayment()->getAdditionalInformation('1_CreditCardTransactionStatusEnum') ):
178
+ echo $helper->__('Transaction Status').': '.$CreditCardTransactionStatusEnum.'<br/>';
179
+ else:
180
+ if($CreditCardTransactionStatusEnum = $_order->getPayment()->getAdditionalInformation('CreditCardTransactionStatusEnum')):
181
+ echo $helper->__('Transaction Status').': '.$CreditCardTransactionStatusEnum.'<br/>';
182
+ endif;
183
+ endif;
184
+ endif;
185
+
186
+ if(($PaymentMethod == 'BoletoBancario' || $PaymentMethod == 'mundipagg_boleto') && $boletoUrl = $_order->getPayment()->getAdditionalInformation('BoletoUrl')):
187
+
188
+ // Informations about transaction
189
+ if (version_compare(Mage::getVersion(), '1.5.0', '<')) {
190
+ $transactionType = 'payment';
191
+ } else {
192
+ $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER;
193
+ }
194
+
195
+ $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
196
+ ->addAttributeToFilter('order_id', array('eq' => $_order->getEntityId()))
197
+ ->addAttributeToFilter('txn_type', array('eq' => $transactionType))
198
+ ->addAttributeToFilter('is_closed', array('eq' => '1'));
199
+ $nossoNumero = '';
200
+ $barcode = '';
201
+
202
+ foreach ($transaction as $t):
203
+ $t = $t->getData();
204
+ $txDetail = $t['additional_information'];
205
+
206
+ if (!empty($txDetail)):
207
+ $nossoNumero = $txDetail['NossoNumero'];
208
+ $barcode = $txDetail['Barcode'];
209
+ endif;
210
+ endforeach;
211
+ ?>
212
+ <p>
213
+ <?php echo $helper->__('Nosso Número'); ?>: <b><?php echo $nossoNumero; ?></b>
214
+ </p>
215
+ <p>
216
+ <?php echo $helper->__('Código de Barras'); ?>: <?php echo $barcode; ?>
217
+ </p>
218
+ <p>
219
+ <a href="<?php echo $boletoUrl;?>" target="_blank"><?php echo $helper->__('Print boleto');?></a>
220
+ </p>
221
+ <?php
222
+ endif;
223
+
224
+ if($PaymentMethod == 'mundipagg_debit'):
225
+ $bankName = $this->getInfo()->getAdditionalInformation('BankName');
226
+ $bankPaymentDate = $this->getInfo()->getAdditionalInformation('BankPaymentDate');
227
+ ?>
228
+ <?php if($bankName): echo $helper->__('Banco'); ?>: <?php echo $bankName; endif;?>
229
+ <?php if($bankPaymentDate): echo $helper->__('Data de pagamento'); ?>: <?php echo $bankPaymentDate; endif;?>
230
+ <?php
231
+ endif;
232
+ ?>
233
+ </p>
234
+ </div>
app/design/adminhtml/default/default/template/mundipagg/system/config/button.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php echo $this->getButtonHtml(); ?>
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ function setOldSettings() {
6
+
7
+ new Ajax.Request('<?php echo $this->getAjaxOldSettingsUrl(); ?>', {
8
+ method: 'get',
9
+ onSuccess: function(transport){
10
+
11
+ if (transport.responseText){
12
+ responseJSON = JSON.parse(transport.responseText);
13
+ if(responseJSON.error){
14
+ alert(responseJSON.error);
15
+ return false;
16
+ }
17
+
18
+ if(responseJSON.success){
19
+ alert(responseJSON.success);
20
+ window.location.reload();
21
+ }
22
+
23
+ }
24
+ }
25
+ });
26
+ }
27
+ //]]>
28
+ </script>
app/design/frontend/base/default/layout/mundipagg.xml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Uecommerce
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Uecommerce EULA.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.uecommerce.com.br/
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the extension
15
+ * to newer versions in the future. If you wish to customize the extension
16
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
17
+ *
18
+ * @category Uecommerce
19
+ * @package Uecommerce_Mundipagg
20
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
21
+ * @license http://www.uecommerce.com.br/
22
+ */
23
+
24
+ /**
25
+ * Mundipagg Payment module
26
+ *
27
+ * @category Uecommerce
28
+ * @package Uecommerce_Mundipagg
29
+ * @author Uecommerce Dev Team
30
+ */
31
+ -->
32
+ <layout version="0.1.0">
33
+ <checkout_onepage_index>
34
+ <reference name="head">
35
+ <action method="addItem">
36
+ <type>skin_css</type>
37
+ <name>css/mundipagg.css</name>
38
+ </action>
39
+ </reference>
40
+ <reference name="before_body_end">
41
+ <block type="page/html_head" name="extra_js" as="extra_js" after="-" template="mundipagg/extras.phtml">
42
+ <action method="addItem">
43
+ <type>js</type>
44
+ <name>uecommerce/mundipagg.js</name>
45
+ </action>
46
+ </block>
47
+ <reference name="before_body_end">
48
+ <block type="core/template" name="fcontrol" template="mundipagg/antifraud/fcontrol.phtml"/>
49
+ </reference>
50
+ <reference name="before_body_end">
51
+ <block type="core/template" name="clearsale" template="mundipagg/antifraud/clearsale.phtml"/>
52
+ </reference>
53
+ <reference name="before_body_end">
54
+ <block type="core/template" name="stone" template="mundipagg/antifraud/stone.phtml"/>
55
+ </reference>
56
+ </reference>
57
+ </checkout_onepage_index>
58
+ <onepagecheckout_index_index translate="label">
59
+ <reference name="head">
60
+ <action method="addItem">
61
+ <type>skin_css</type>
62
+ <name>css/mundipagg.css</name>
63
+ </action>
64
+ </reference>
65
+ <reference name="before_body_end">
66
+ <block type="page/html_head" name="extra_js" as="extra_js" after="-" template="mundipagg/extras.phtml">
67
+ <action method="addItem">
68
+ <type>js</type>
69
+ <name>uecommerce/mundipagg.js</name>
70
+ </action>
71
+ </block>
72
+ </reference>
73
+ </onepagecheckout_index_index>
74
+ <onestepcheckout_index_index translate="label">
75
+ <reference name="head">
76
+ <action method="addItem">
77
+ <type>skin_css</type>
78
+ <name>css/mundipagg.css</name>
79
+ </action>
80
+ </reference>
81
+ <reference name="before_body_end">
82
+ <block type="page/html_head" name="extra_js" as="extra_js" after="-" template="mundipagg/extras.phtml">
83
+ <action method="addItem">
84
+ <type>js</type>
85
+ <name>uecommerce/mundipagg.js</name>
86
+ </action>
87
+ </block>
88
+ </reference>
89
+ </onestepcheckout_index_index>
90
+ <opc_index_index translate="label">
91
+ <reference name="head">
92
+ <action method="addItem">
93
+ <type>skin_css</type>
94
+ <name>css/mundipagg.css</name>
95
+ </action>
96
+ </reference>
97
+ <reference name="before_body_end">
98
+ <block type="page/html_head" name="extra_js" as="extra_js" after="-" template="mundipagg/extras.phtml">
99
+ <action method="addItem">
100
+ <type>js</type>
101
+ <name>uecommerce/mundipagg.js</name>
102
+ </action>
103
+ </block>
104
+ </reference>
105
+ </opc_index_index>
106
+ <mundipagg_standard_redirect module="Uecommerce_Mundipagg" translate="label">
107
+ <reference name="root">
108
+ <action method="setTemplate">
109
+ <template>page/1column.phtml</template>
110
+ </action>
111
+ </reference>
112
+ </mundipagg_standard_redirect>
113
+ <mundipagg_standard_partial module="Uecommerce_Mundipagg" translate="label">
114
+
115
+ <reference name="head">
116
+ <action method="addItem">
117
+ <type>skin_css</type>
118
+ <name>css/mundipagg.css</name>
119
+ </action>
120
+ </reference>
121
+ <reference name="before_body_end">
122
+ <block type="page/html_head" name="extra_js" as="extra_js" after="-" template="mundipagg/extras.phtml">
123
+ <action method="addItem">
124
+ <type>js</type>
125
+ <name>uecommerce/mundipagg.js</name>
126
+ </action>
127
+ </block>
128
+ </reference>
129
+ <reference name="root">
130
+ <action method="setTemplate">
131
+ <template>page/1column.phtml</template>
132
+ </action>
133
+ </reference>
134
+ </mundipagg_standard_partial>
135
+ <mundipagg_standard_cancel module="Uecommerce_Mundipagg" translate="label">
136
+ <reference name="root">
137
+ <action method="setTemplate">
138
+ <template>page/1column.phtml</template>
139
+ </action>
140
+ </reference>
141
+ </mundipagg_standard_cancel>
142
+ <mundipagg_standard_fcancel module="Uecommerce_Mundipagg" translate="label">
143
+ <reference name="root">
144
+ <action method="setTemplate">
145
+ <template>page/1column.phtml</template>
146
+ </action>
147
+ </reference>
148
+ </mundipagg_standard_fcancel>
149
+ <mundipagg_standard_success module="Uecommerce_Mundipagg" translate="label">
150
+ <reference name="root">
151
+ <action method="setTemplate">
152
+ <template>page/1column.phtml</template>
153
+ </action>
154
+ </reference>
155
+ </mundipagg_standard_success>
156
+ </layout>
app/design/frontend/base/default/template/mundipagg/antifraud/clearsale.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $antifraud = Mage::getStoreConfig('payment/mundipagg_standard/antifraud');
3
+ $antifraudProvider = Mage::getStoreConfig('payment/mundipagg_standard/antifraud_provider');
4
+
5
+ if ($antifraud && $antifraudProvider == Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_CLEARSALE): ?>
6
+
7
+ <script type="text/javascript">
8
+
9
+ var _csdp = _csdp || [];
10
+
11
+ if (jQuery == 'undefined') {
12
+ try {
13
+ var jQueryObj = document.createElement('script');
14
+ jQueryObj.type = 'text/javascript';
15
+ jQueryObj.async = true;
16
+ jQueryObj.src = 'https://code.jquery.com/jquery-1.12.4.min.js';
17
+ jQueryObj.integrity = "sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=";
18
+ jQueryObj.crossorigin = "anonymous";
19
+
20
+ document.getElementsByTagName('body')[0].appendChild(jQueryObj);
21
+
22
+ } catch (err) {
23
+
24
+ }
25
+ }
26
+
27
+ jQuery(document).ready(function () {
28
+
29
+ jQuery.ajax({
30
+ metho: 'POST',
31
+ url: '/mundipagg/clearsale/getConfig',
32
+ success: function(data){
33
+ setCsdp(data.entityCode, data.app, data.sessionId);
34
+ },
35
+ error: function(err){
36
+ }
37
+ });
38
+
39
+ var setCsdp = function(merchantKeyOnAntiFraud, App, sessionId){
40
+ _csdp.push(['Key', merchantKeyOnAntiFraud]);
41
+ _csdp.push(['App', App]);
42
+ _csdp.push(['SessionID', sessionId]);
43
+
44
+ (function () {
45
+ var csd = document.createElement('script');
46
+
47
+ csd.type = 'text/javascript';
48
+ csd.async = true;
49
+ csd.src = 'https://device.clearsale.com.br/profiler/fp.js';
50
+
51
+ var sc = document.getElementsByTagName('script')[0];
52
+ sc.parentNode.insertBefore(csd, sc);
53
+ })();
54
+
55
+ };
56
+
57
+ });
58
+
59
+ </script>
60
+
61
+ <?php endif; ?>
app/design/frontend/base/default/template/mundipagg/antifraud/fcontrol.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $fcontrol = Mage::getStoreConfig('payment/mundipagg_standard/antifraud');
3
+ $antifraudProvider = Mage::getStoreConfig('payment/mundipagg_standard/antifraud_provider');
4
+ $environment = Mage::getStoreConfig('payment/mundipagg_standard/environment_fcontrol');
5
+
6
+ if ($environment == Uecommerce_Mundipagg_Model_Source_FControlEnvironment::SANDBOX) {
7
+ $scriptUrl = '/js/uecommerce/fcontrol/hmlg-fcontrol-ed.min.js';
8
+ } else {
9
+ $scriptUrl = 'https://static.fcontrol.com.br/fingerprint/fcontrol-min-ed.js';
10
+ }
11
+
12
+ if ($fcontrol && $antifraudProvider == Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_FCONTROL): ?>
13
+
14
+ <script type="text/javascript" src="<?php echo $scriptUrl; ?>"></script>
15
+ <script type="text/javascript">
16
+ //jQuery.jQuery.noConflict();
17
+
18
+ jQuery(document).ready(function ($) {
19
+
20
+ $.ajax({
21
+ method: 'POST',
22
+ url: '/mundipagg/fcontrol/getConfig',
23
+ dataType: 'JSON'
24
+
25
+ }).done(function (data) {
26
+ var fp = new FcontrolFingerprint();
27
+ fp.send(data.key, data.sessionId);
28
+ });
29
+
30
+ $(document).ajaxComplete(function (event, request, settings) {
31
+ if (typeof settings.url != 'undefined') {
32
+ if (settings.url.match(/\/fcontrol\/fingerprint\//)) {
33
+
34
+ var logRequest = settings.data;
35
+ var logResponse = request.responseText;
36
+ var url = '/mundipagg/fcontrol/logFp';
37
+
38
+ $.post(url, {event: 'request', data: logRequest}, function () {
39
+ $.post(url, {event: 'response', data: logResponse});
40
+ });
41
+ }
42
+ }
43
+
44
+ });
45
+
46
+ var reportError = function (message) {
47
+ jQuery.ajax({
48
+ method: 'POST',
49
+ url: '/mundipagg/fcontrol/reportError',
50
+ dataType: 'JSON',
51
+ data: {message: message}
52
+ });
53
+ };
54
+
55
+ });
56
+
57
+ </script>
58
+
59
+ <?php endif; ?>
app/design/frontend/base/default/template/mundipagg/antifraud/stone.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $antifraud = Mage::getStoreConfig('payment/mundipagg_standard/antifraud');
3
+ $antifraudProvider = Mage::getStoreConfig('payment/mundipagg_standard/antifraud_provider');
4
+
5
+ if ($antifraud && $antifraudProvider == Uecommerce_Mundipagg_Model_Source_Antifraud::ANTIFRAUD_STONE): ?>
6
+
7
+ <script type="text/javascript">
8
+
9
+ var _csdp = _csdp || [];
10
+
11
+ if (jQuery == 'undefined') {
12
+ try {
13
+ var jQueryObj = document.createElement('script');
14
+ jQueryObj.type = 'text/javascript';
15
+ jQueryObj.async = true;
16
+ jQueryObj.src = 'https://code.jquery.com/jquery-1.12.4.min.js';
17
+ jQueryObj.integrity = "sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=";
18
+ jQueryObj.crossorigin = "anonymous";
19
+
20
+ document.getElementsByTagName('body')[0].appendChild(jQueryObj);
21
+
22
+ } catch (err) {
23
+
24
+ }
25
+ }
26
+
27
+ jQuery(document).ready(function () {
28
+
29
+ jQuery.ajax({
30
+ metho: 'POST',
31
+ url: '/mundipagg/stone/getConfig',
32
+ success: function(data){
33
+ setCsdp(data.entityCode, data.app, data.sessionId);
34
+ },
35
+ error: function(err){
36
+ }
37
+ });
38
+
39
+ var setCsdp = function(merchantKeyOnAntiFraud, App, sessionId){
40
+ _csdp.push(['Key', merchantKeyOnAntiFraud]);
41
+ _csdp.push(['App', App]);
42
+ _csdp.push(['SessionID', sessionId]);
43
+
44
+ (function () {
45
+ var csd = document.createElement('script');
46
+
47
+ csd.type = 'text/javascript';
48
+ csd.async = true;
49
+ csd.src = 'https://device.clearsale.com.br/profiler/fp.js';
50
+
51
+ var sc = document.getElementsByTagName('script')[0];
52
+ sc.parentNode.insertBefore(csd, sc);
53
+ })();
54
+
55
+ };
56
+
57
+ });
58
+
59
+ </script>
60
+
61
+ <?php endif; ?>
app/design/frontend/base/default/template/mundipagg/boleto.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_code = $this->getMethodCode();
3
+
4
+ // We check if taxvat is enabled
5
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
6
+ ?>
7
+ <fieldset>
8
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
9
+ <li>
10
+ <div id="mundipagg_boleto">
11
+ <ul >
12
+
13
+ <li>
14
+ <div id="boleto" style="float:left; text-align:center">
15
+ <img src="<?php echo $this->getSkinUrl('images/mundipagg/boleto.jpg');?>" alt="<?php echo $this->__('Boleto Bancário') ?>" /> <?php echo $this->__('Print your boleto after you have placed your order.') ?>
16
+ </div>
17
+ </li>
18
+ <?php if(!$_taxvat->isEnabled() && Mage::getSingleton('customer/session')->getCustomer()->getTaxvat() == ''): ?>
19
+ <li style="clear:both">
20
+ <div class="input-box">
21
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label><br/>
22
+ <input type="text" id="<?php echo $_code ?>_boleto_taxvat" name="payment[boleto_taxvat]" title="<?php echo $this->__('Taxvat') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
23
+ </div>
24
+ </li>
25
+ <?php endif; ?>
26
+ </ul>
27
+ </div>
28
+ </li>
29
+ </ul>
30
+ </fieldset>
app/design/frontend/base/default/template/mundipagg/cancel.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <div class="page-title">
32
+ <h1><?php echo Mage::helper('mundipagg')->__('Payment error')?></h1>
33
+ </div>
34
+ <div class="buttons-set">
35
+ <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>
36
+ </div>
app/design/frontend/base/default/template/mundipagg/debit.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_code = $this->getMethodCode();
3
+
4
+ // We check if taxvat is enabled
5
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
6
+ ?>
7
+
8
+ <fieldset>
9
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
10
+ <li>
11
+ <div id="mundipagg_debit">
12
+ <ul >
13
+ <li>
14
+ <div class="field">
15
+ <div class="input-box">
16
+ <ul class="inline input-radio">
17
+ <?php
18
+ $debitTypes = $this->getDebitTypes();
19
+ $_i = 1;
20
+ ?>
21
+ <?php foreach ($debitTypes as $debitType): ?>
22
+ <li>
23
+ <?php if(strpos($debitType, 'cielo') !== false) {
24
+ $value = 'Cielo';
25
+ } else {
26
+ $value = $debitType;
27
+ } ?>
28
+ <label for="<?php echo $_code . '_' . $debitType; ?>"><img src="<?php echo $this->getSkinUrl('images/mundipagg/' . $debitType . '.png'); ?>" alt="<?php echo $debitType ?>" border="0" style="cursor:pointer"/></label>
29
+ <input type="radio" name="payment[<?php echo $_code; ?>]" id="<?php echo $_code . '_' . $debitType; ?>" value="<?php echo $value ?>" class="<?php if ($_i == 1): ?>validate-one-required-by-name<?php endif; ?>">
30
+ </li>
31
+ <?php
32
+ $_i++;
33
+ endforeach
34
+ ?>
35
+ </ul>
36
+ </div>
37
+ </div>
38
+ </li>
39
+ <?php if (!$_taxvat->isEnabled() && Mage::getSingleton('customer/session')->getCustomer()->getTaxvat() == ''): ?>
40
+ <li>
41
+ <div class="input-box" style="float:left;">
42
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label><br/>
43
+ <input type="text" id="<?php echo $_code ?>_taxvat" name="payment[taxvat]" title="<?php echo $this->__('Taxvat') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
44
+ </div>
45
+ </li>
46
+ <?php endif; ?>
47
+ </ul>
48
+ </div>
49
+ </li>
50
+ </ul>
51
+ </fieldset>
app/design/frontend/base/default/template/mundipagg/extras.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->getCssJsHtml(); ?>
app/design/frontend/base/default/template/mundipagg/fcancel.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <div class="page-title">
32
+ <h1><?php echo $this->__('Order cancelled') ?></h1>
33
+ </div>
34
+ <div class="buttons-set">
35
+ <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>
36
+ </div>
app/design/frontend/base/default/template/mundipagg/form.phtml ADDED
@@ -0,0 +1,381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ //Return Standard model
32
+ $standard = $this->getStandard();
33
+
34
+ // Get Quote
35
+ $quote = $standard->getQuote();
36
+
37
+ $installmentsHelper = Mage::helper('mundipagg/installments');
38
+
39
+ if($quote->isVirtual()) {
40
+ $data = $quote->getBillingAddress();
41
+ } else {
42
+ $data = $quote->getShippingAddress();
43
+ }
44
+
45
+ $orderGrandTotal = $standard->getQuote()->getBaseGrandTotal();
46
+
47
+ // Partial payment?
48
+ $isPartial = Mage::getSingleton('checkout/session')->getApprovalRequestSuccess();
49
+
50
+ if($isPartial == 'partial'):
51
+ $authorizedAmount = Mage::getSingleton('checkout/session')->getAuthorizedAmount();
52
+
53
+ $baseGrandTotal = $orderGrandTotal - $authorizedAmount;
54
+ else :
55
+ $baseGrandTotal = $orderGrandTotal;
56
+ endif;
57
+
58
+ if($data->getMundipaggInterest()) {
59
+ $baseGrandTotal = $baseGrandTotal-$data->getMundipaggInterest();
60
+ }
61
+
62
+ // We check if taxvat is enabled
63
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
64
+
65
+ // Get current currency symbol
66
+ $currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
67
+
68
+ //Credit Card Saved On File
69
+ $ccs = $this->getCcs();
70
+
71
+ $countCcs = count($ccs);
72
+
73
+ // Payment method
74
+ $_code = $this->getMethodCode();
75
+ ?>
76
+
77
+ <fieldset class="form-list">
78
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
79
+ <div>
80
+ <input type="hidden" id="baseGrandTotal" name="baseGrandTotal" value="<?php echo number_format($baseGrandTotal, "2", ",", ""); ?>"/>
81
+ <?php if ($isPartial == 'partial'): ?>
82
+ <input type="hidden" name="partial" id="partial" value="1"/>
83
+ <input type="hidden" name="payment[multi]" id="multi" value="1"/>
84
+ <?php endif; ?>
85
+ </div>
86
+ <?php
87
+ // START CREDIT CARD PAYMENT METHOD
88
+ $num = 1;
89
+
90
+ switch ($_code):
91
+ case 'mundipagg_creditcardoneinstallment':
92
+ $num = 1;
93
+ $paymentMethod = '1CreditCardsOneInstallment';
94
+ $paymentMethodLabel = $this->__('Credit Card');
95
+ break;
96
+
97
+ case 'mundipagg_creditcard':
98
+ $num = 1;
99
+ $paymentMethod = '1CreditCards';
100
+ $paymentMethodLabel = $this->__('Credit Card');
101
+ break;
102
+
103
+ case 'mundipagg_twocreditcards':
104
+ $num = 2;
105
+ $paymentMethod = '2CreditCards';
106
+ $paymentMethodLabel = $this->__('Pay with 2 Credit Cards');
107
+ break;
108
+
109
+ case 'mundipagg_threecreditcards':
110
+ $num = 3;
111
+ $paymentMethod = '3CreditCards';
112
+ $paymentMethodLabel = $this->__('Pay with 3 Credit Cards');
113
+ break;
114
+
115
+ case 'mundipagg_fourcreditcards':
116
+ $num = 4;
117
+ $paymentMethod = '4CreditCards';
118
+ $paymentMethodLabel = $this->__('Pay with 4 Credit Cards');
119
+ break;
120
+
121
+ case 'mundipagg_fivecreditcards':
122
+ $num = 5;
123
+ $paymentMethod = '5CreditCards';
124
+ $paymentMethodLabel = $this->__('Pay with 5 Credit Cards');
125
+ break;
126
+ endswitch;
127
+ ?>
128
+ <li>
129
+ <div id="<?php echo $_code; ?>">
130
+ <?php if($num != 1 && $isPartial != 'partial'): ?>
131
+ <p></p>
132
+ <div>
133
+ <b><?php echo $this->__('Grand Total') ?>:</b> <?php echo $currencySymbol.number_format($baseGrandTotal, "2", ",", "."); ?>
134
+ </div>
135
+ <p></p>
136
+ <?php endif ?>
137
+ <?php if ( $_code == 'mundipagg_creditcardoneinstallment' || $_code == 'mundipagg_creditcard' || $_code == 'mundipagg_twocreditcards' || $_code == 'mundipagg_threecreditcards' || $_code == 'mundipagg_fourcreditcards' || $_code == 'mundipagg_fivecreditcards'): ?>
138
+ <ul>
139
+ <?php for($c=1;$c<=$num;$c++): ?>
140
+ <input type="hidden" id="mundipagg_type" name="payment[mundipagg_type]" value="<?php echo $paymentMethod ; ?>"/>
141
+ <?php $currentSelectedToken = null; ?>
142
+ <?php if($countCcs > 0 ):?>
143
+ <li class="fields" style="margin-bottom: 5px;">
144
+ <div class="field">
145
+ <label class="required"><?php echo $this->__('Select a Credit Card or add a new one') ?><span class="required">*</span></label>
146
+ <div class="input-box">
147
+
148
+ <select id="<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>" data="group_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry tokens group_<?php echo $num; ?>_<?php echo $c;?>" onchange="token_or_not(<?php echo $num; ?>,<?php echo $c;?>,this)">
149
+ <option value="">...</option>
150
+ <?php
151
+ $selected = '';
152
+
153
+ if($countCcs == 1):
154
+ $selected = 'selected="selected"';
155
+ endif;
156
+
157
+ foreach($ccs as $id => $cc):
158
+
159
+ if($countCcs == 1){
160
+ $currentSelectedToken = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
161
+ }
162
+ $dataType = $currentSelectedToken?$currentSelectedToken:Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
163
+ echo '<option value="'.$cc->getId().'" '.$selected.' data="'.$dataType.'">'.$cc->getCcType().' '.$cc->getCreditCardMask().'</option>';
164
+ endforeach;
165
+ ?>
166
+ <option value="new"><?php echo $this->__('New Credit Card') ?></option>
167
+ </select>
168
+ </div>
169
+ </div>
170
+ </li>
171
+ <?php if($num != 1): ?>
172
+ <div id="value_<?php echo $num; ?>_<?php echo $c;?>">
173
+ <li class="fields" style="margin-bottom: 5px;">
174
+ <div class="field">
175
+ <label class="required"><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
176
+ <div class="input-box">
177
+ <input type="text" id="<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry input-text validate-greater-than-zero check_values group_<?php echo $num; ?>_<?php echo $c;?>" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');" onkeydown="remove_special_characters(event);" value=""/>
178
+ </div>
179
+ </div>
180
+ </li>
181
+ </div>
182
+ <?php endif; ?>
183
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
184
+ <div id="parcelamento_<?php echo $num; ?>_<?php echo $c;?>" <?php if($countCcs > 1): ?>style="display:none"<?php endif?>>
185
+ <li class="fields" style="margin-bottom: 5px;">
186
+ <div class="field">
187
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num == 2):?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
188
+ <div class="input-box">
189
+ <select id="<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry installment-token group_<?php echo $num; ?>_<?php echo $c;?>" onchange="checkInstallments(this, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');">
190
+ <?php foreach($this->getInstallments($currentSelectedToken) as $key => $parcel): ?>
191
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
192
+ <?php endforeach ?>
193
+ </select>
194
+ </div>
195
+ </div>
196
+ </li>
197
+ </div>
198
+ <?php endif; ?>
199
+ <?php endif; ?>
200
+ <div class="division"></div>
201
+ <div id="<?php echo $_code; ?>_new_credit_card_<?php echo $num; ?>_<?php echo $c;?>" <?php if( $countCcs > 0 ) { ?>style="display:none"<?php } ?>>
202
+
203
+ <li style="margin-bottom: 5px;">
204
+ <div class="field">
205
+ <label class="required"><?php echo $this->__('Credit Card Issuer') ?> <span class="required">*</span></label>
206
+ <div class="input-box">
207
+ <ul class="inline input-radio">
208
+ <?php
209
+ $ccards = $standard->getCcTypes();
210
+ $_i = 1;
211
+ ?>
212
+ <?php foreach($ccards as $ccard): ?>
213
+ <li class="cc_brands">
214
+ <div class="cc_brand_types <?php echo strtolower($ccard); ?>">&nbsp;</div>
215
+ <!--<img src="<?php //echo $this->getSkinUrl('images/mundipagg/'.$ccard.'.png');?>" alt="<?php //echo $ccard ?>" border="0" class="cursor_hand" onclick="setCcType(this, '<?php //echo $_code; ?>', '<?php //echo $num; ?>', '<?php //echo $c;?>', '<?php //echo $ccard; ?>');">-->
216
+ <input type="radio" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_credito_instituicao]" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_credito_instituicao_<?php echo $ccard; ?>" value="<?php echo $ccard ?>" class="<?php if ($_i == 1): ?>validate-one-required-by-name<?php endif; ?>" onclick="setCcType(this, '<?php echo $_code; ?>', '<?php echo $num; ?>', '<?php echo $c;?>', '<?php echo $ccard; ?>');">
217
+ </li>
218
+ <?php
219
+ $_i++;
220
+ endforeach
221
+ ?>
222
+ </ul>
223
+ <p class="info-payment"><i><small><?php echo $this->__('The flag is automatically selected after entering the credit card number below.'); ?></small></i></p>
224
+ <input type="hidden" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type]" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type" value="" class="validate-cc-type-select"/>
225
+ </div>
226
+ </div>
227
+ </li>
228
+ <li style="margin-bottom: 5px;">
229
+ <div class="field">
230
+ <label class="required"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
231
+ <div class="input-box">
232
+ <input type="text" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-cc-number" onkeydown="remove_characters(event);" value=""/>
233
+ </div>
234
+ </div>
235
+ </li>
236
+ <li style="margin-bottom: 5px;">
237
+ <div class="field">
238
+ <label class="required"><?php echo $this->__('Credit Card Holder name') ?> <span class="required">*</span></label>
239
+ <div class="input-box">
240
+ <input type="text" id="<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry input-text" />
241
+ </div>
242
+ </div>
243
+ </li>
244
+ <li style="margin-bottom: 5px;">
245
+ <div class="field">
246
+ <label class="required"><?php echo $this->__('Expiration date') ?> <span class="required">*</span></label>
247
+ <div class="input-box">
248
+ <div class="v-fix">
249
+ <select id="<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>]" class="month required-entry validate-cc-exp-new">
250
+ <option value=""><?php echo $this->__('Month') ?></option>
251
+ <option value="1">01 - <?php echo $this->__('January') ?></option>
252
+ <option value="2">02 - <?php echo $this->__('February') ?></option>
253
+ <option value="3">03 - <?php echo $this->__('March') ?></option>
254
+ <option value="4">04 - <?php echo $this->__('April') ?></option>
255
+ <option value="5">05 - <?php echo $this->__('May') ?></option>
256
+ <option value="6">06 - <?php echo $this->__('June') ?></option>
257
+ <option value="7">07 - <?php echo $this->__('July') ?></option>
258
+ <option value="8">08 - <?php echo $this->__('August') ?></option>
259
+ <option value="9">09 - <?php echo $this->__('September') ?></option>
260
+ <option value="10">10 - <?php echo $this->__('October') ?></option>
261
+ <option value="11">11 - <?php echo $this->__('November') ?></option>
262
+ <option value="12">12 - <?php echo $this->__('December') ?></option>
263
+ </select>
264
+ </div>
265
+ <div class="v-fix" style="padding-left:6px;">
266
+ <select id="<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>]" class="year required-entry">
267
+ <option value=""><?php echo $this->__('Year') ?></option>
268
+ <?php
269
+ $i = date('Y');
270
+ $year = date('Y');
271
+ $year10 = $year + 10;
272
+ for( $i = $year; $i <= $year10; $i++ ):
273
+ ?>
274
+ <option value="<?php echo substr($i, -2);?>"><?php echo $i;?></option>
275
+ <?php endfor; ?>
276
+ </select>
277
+ </div>
278
+ </div>
279
+ </div>
280
+ </li>
281
+ <li style="margin-bottom: 5px;">
282
+ <div class="field">
283
+ <label class="required"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label>
284
+ <div class="input-box">
285
+ <div class="v-fix">
286
+ <input type="text" id="<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>]" style="width: 55px" class="required-entry input-text validate-cc-cvn validate-length" maxlength="4" onkeydown="remove_characters(event);"/>
287
+ </div>
288
+ <div class="v-fix" style="padding-left:6px;">
289
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
290
+ </div>
291
+ </div>
292
+ </div>
293
+ </li>
294
+ <?php if($num != 1): ?>
295
+ <li style="margin-bottom: 5px;">
296
+ <div class="field">
297
+ <label class="required"><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
298
+ <div class="input-box">
299
+ <input type="text" id="<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry validate-greater-than-zero check_values input-text" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');" onkeydown="remove_special_characters(event);" value=""/>
300
+ </div>
301
+ </div>
302
+ </li>
303
+ <?php endif; ?>
304
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
305
+ <li style="margin-bottom: 5px;">
306
+ <div class="field">
307
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num ==2): ?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
308
+ <div class="input-box">
309
+ <select id="<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" onchange="checkInstallments(this, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');">
310
+ <?php foreach($this->getInstallments() as $key => $parcel): ?>
311
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
312
+ <?php endforeach ?>
313
+ </select>
314
+ </div>
315
+ </div>
316
+ </li>
317
+ <?php endif; ?>
318
+ <?php if ($standard->getConfigData('clearsale') && !$_taxvat->isEnabled() && Mage::getSingleton('customer/session')->getCustomer()->getTaxvat() == ''): ?>
319
+ <li style="margin-bottom: 5px;">
320
+ <div class="field">
321
+ <label class="required"><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label>
322
+ <div class="input-box">
323
+ <input type="text" id="<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('CPF ou CNPJ') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
324
+ </div>
325
+ </div>
326
+ </li>
327
+ <?php endif;?>
328
+ <?php if($standard->getQuote()->getCheckoutMethod() != 'guest'): ?>
329
+ <?php if(Mage::getStoreConfig('payment/mundipagg_standard/save_cardonfile')): ?>
330
+ <li>
331
+
332
+ <div class="input-box" style="padding-top: 10px">
333
+ <div class="field">
334
+ <label class="required"><?php echo $this->__('Save Card On File') ?></label>
335
+ <input type="checkbox" id="<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>]" value="new"/>
336
+ </div>
337
+
338
+ </div>
339
+ </li>
340
+ <?php endif; ?>
341
+ <?php endif; ?>
342
+ </div>
343
+ <?php endfor; ?>
344
+ </ul>
345
+ <?php endif ?>
346
+ </div>
347
+ </li>
348
+ <?php // END CREDIT CARD PAYMENT METHOD ?>
349
+ </ul>
350
+ </fieldset>
351
+
352
+ <script type="text/javascript">
353
+ //<![CDATA[
354
+ Validation.addAllThese([
355
+ ['validate-cc-exp-new', '<?php echo $this->jsQuoteEscape( Mage::helper('mundipagg')->__('Incorrect credit card expiration date.') )?>', function(v, elm) {
356
+ var ccExpMonth = v;
357
+ var ccExpYear = $( elm.id.replace("_expirationMonth", "_expirationYear") ).value;
358
+
359
+ var currentTime = new Date();
360
+ var currentMonth = currentTime.getMonth() + 1;
361
+ var currentYear = currentTime.getFullYear().toString().substr(2,2);
362
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
363
+ return false;
364
+ }
365
+ return true;
366
+ }]
367
+ ]);
368
+
369
+ window.baseUrl = '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>';
370
+ window.installmentsandinterestUrl = '<?php echo Mage::getUrl('mundipagg/standard/installmentsandinterest',array('_secure'=>true)); ?>';
371
+ window.ajaxLoaderGif = '<?php echo $this->getSkinUrl('images/mundipagg/ajax-loader.gif'); ?>';
372
+ window.isInstallmentsEnabled = '<?php echo Mage::helper('mundipagg/installments')->isInstallmentsEnabled(); ?>';
373
+
374
+ $$('.validate-cc-number').invoke('observe','keyup',function(){
375
+ selectCredcard(this);
376
+ });
377
+ $$('.validate-cc-number').invoke('observe','blur',function(){
378
+ selectCredcard(this);
379
+ });
380
+ //]]>
381
+ </script>
app/design/frontend/base/default/template/mundipagg/parcelamento.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ $parcelamento = $this->getParcelamento();
4
+
5
+ if(!empty($parcelamento)):
6
+ ?>
7
+ <?php echo $this->__('ou')?> <strong><?php echo $parcelamento; ?></strong>
8
+ <?php endif;?>
app/design/frontend/base/default/template/mundipagg/partial.phtml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <div class="page-title">
32
+ <h1><?php echo $this->__('Order partially authorized') ?></h1>
33
+ </div>
34
+ <?php
35
+ $_coreHelper = $this->helper('core');
36
+ $orderGrandTotal = $this->getOrder()->getGrandTotal();
37
+ $restToPay = 0;
38
+
39
+ // Session
40
+ $authorizedAmount = Mage::getSingleton('checkout/session')->getAuthorizedAmount();
41
+
42
+ $restToPay = $orderGrandTotal - $authorizedAmount;
43
+
44
+ //Return Standard model
45
+ $standard = $this->getStandard();
46
+
47
+ // We check if taxvat is enabled
48
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
49
+
50
+ // Get current currency symbol
51
+ $currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
52
+
53
+ // Min installment value
54
+ $valorMinParcelamento = $standard->getConfigData('parcelamento_min');
55
+
56
+ //Credit Card Saved On File
57
+ $ccs = $this->getCcs();
58
+ ?>
59
+ <style type="text/css">
60
+ /*.issuers {text-align: center; padding-right: 10px;}
61
+ .cancel button.button span { border-color:red; background:red;}
62
+ .float-left {float:left;}*/
63
+ </style>
64
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout.js') ?>"></script>
65
+ <script type="text/javascript">
66
+ //<![CDATA[
67
+ var quoteBaseGrandTotal = <?php echo (float)$restToPay; ?>;
68
+ var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
69
+ var payment = new Payment('co-payment-form', '<?php echo $this->getUrl('mundipagg/standard/partialPost') ?>');
70
+ var lastPrice;
71
+ //]]>
72
+ </script>
73
+ <p>
74
+ <b><?php echo $this->__('Order total:') ?></b> <?php echo $_coreHelper->currency($orderGrandTotal, true, false); ?>
75
+ </p>
76
+ <p>
77
+ <b><?php echo $this->__('Amount authorized:') ?></b> <?php echo $_coreHelper->currency($authorizedAmount, true, false) ?>
78
+ </p>
79
+ <p>
80
+ <b><?php echo $this->__('Rest to pay:') ?></b> <?php echo $_coreHelper->currency($restToPay, true, false); ?>
81
+ </p>
82
+
83
+ <div class="page-title">
84
+ <h2><?php echo $this->__('Choose a payment method above to complete your order');?></h2>
85
+ </div>
86
+
87
+ <form action="<?php echo $this->getUrl('mundipagg/standard/partialPost') ?>" id="co-payment-form" method="post">
88
+ <dl class="sp-methods" id="checkout-payment-method-load">
89
+ <?php
90
+ $methods = $this->getMethods();
91
+ $oneMethod = count($methods) <= 1;
92
+ ?>
93
+ <?php
94
+ foreach ($methods as $_method):
95
+ $_code = $_method->getCode();
96
+ ?>
97
+ <dt>
98
+ <?php if(!$oneMethod): ?>
99
+ <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
100
+ <?php else: ?>
101
+ <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
102
+ <?php $oneMethod = $_code; ?>
103
+ <?php endif; ?>
104
+ <label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
105
+ </dt>
106
+ <?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
107
+ <dd>
108
+ <?php echo $html; ?>
109
+ </dd>
110
+ <?php endif; ?>
111
+ <?php endforeach; ?>
112
+ </dl>
113
+ <?php echo $this->getChildChildHtml('additional'); ?>
114
+ <script type="text/javascript">
115
+ //<![CDATA[
116
+ <?php echo $this->getChildChildHtml('scripts'); ?>
117
+ payment.init();
118
+ <?php if (is_string($oneMethod)): ?>
119
+ payment.switchMethod('<?php echo $oneMethod ?>');
120
+ <?php endif; ?>
121
+ //]]>
122
+ </script>
123
+ <div class="buttons-set" id="payment-buttons-container">
124
+ <div class="float-left cancel">
125
+ <button type="button" class="button" onclick="setLocation('<?php echo $this->getUrl('mundipagg/standard/fcancel') ?>');"><span><span><?php echo $this->__('Cancel') ?></span></span></button>
126
+ </div>
127
+ <div>
128
+ <button id="confirm" type="button" class="button" onclick="paymentFormSubmit(this);"><span><span><?php echo $this->__('Confirm') ?></span></span></button>
129
+ <span class="please-wait" id="payment-please-wait" style="display:none;">
130
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
131
+ </span>
132
+ </div>
133
+ </div>
134
+ </form>
135
+ <script type="text/javascript">
136
+ //<![CDATA[
137
+ var paymentForm = new VarienForm('co-payment-form', true);
138
+
139
+ function paymentFormSubmit(button) {
140
+ if(paymentForm.validator && paymentForm.validator.validate()){
141
+ button.disabled = true;
142
+ $('payment-please-wait').show();
143
+ paymentForm.submit();
144
+ }
145
+ }
146
+ //]]>
147
+ </script>
app/design/frontend/base/default/template/mundipagg/payment/info/mundipagg.phtml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <?php echo Mage::helper('mundipagg')->__($this->getInfo()->getAdditionalInformation('PaymentMethod'));?>
32
+ <br/>
33
+ <?php
34
+ if($this->getInfo()->getAdditionalInformation('PaymentMethod') == 'mundipagg_creditcard') {
35
+ // Token
36
+ $token = $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_token_1_1');
37
+
38
+ if($token && $token != 'new') {
39
+ echo Mage::helper('mundipagg')->__('Credit Card Issuer').': ';
40
+ echo $this->getInfo()->getAdditionalInformation('CreditCardBrandEnum_mundipagg_creditcard_token_1_1');
41
+
42
+ if ($this->getInfo()->getAdditionalInformation('mundipagg_creditcard_credito_parcelamento_1_1')) {
43
+ echo '<br/>';
44
+ echo Mage::helper('mundipagg')->__('InstallmentsCount').': ';
45
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_credito_parcelamento_1_1');
46
+ echo 'x<br/>';
47
+ }
48
+ ?>
49
+ <?php
50
+ } else {
51
+ echo Mage::helper('mundipagg')->__('Credit Card Issuer').': ';
52
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_1_1_cc_type');
53
+
54
+ if ($this->getInfo()->getAdditionalInformation('mundipagg_creditcard_new_credito_parcelamento_1_1')) {
55
+ echo '<br/>';
56
+ echo Mage::helper('mundipagg')->__('InstallmentsCount').': ';
57
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcard_new_credito_parcelamento_1_1');
58
+ echo 'x<br/>';
59
+ }
60
+ }
61
+ }
62
+
63
+ if(
64
+ $this->getInfo()->getAdditionalInformation('PaymentMethod') == 'mundipagg_creditcardoneinstallment'
65
+ ) {
66
+ // Token
67
+ $token = $this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_token_1_1');
68
+
69
+ if($token && $token != 'new') {
70
+ echo Mage::helper('mundipagg')->__('Credit Card Issuer').': ';
71
+ echo $this->getInfo()->getAdditionalInformation('CreditCardBrandEnum_mundipagg_creditcardoneinstallment_token_1_1');
72
+ echo '<br/>';
73
+ ?>
74
+ <?php
75
+ } else {
76
+ echo Mage::helper('mundipagg')->__('Credit Card Issuer').': ';
77
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_1_1_cc_type');
78
+ echo '<br/>';
79
+
80
+ if ($this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_new_credito_parcelamento_1_1')) {
81
+ echo Mage::helper('mundipagg')->__('InstallmentsCount').': ';
82
+ echo $this->getInfo()->getAdditionalInformation('mundipagg_creditcardoneinstallment_new_credito_parcelamento_1_1');
83
+ echo 'x<br/>';
84
+ }
85
+ }
86
+ }
87
+
88
+ if($boletoUrl = $this->getInfo()->getAdditionalInformation('BoletoUrl')):
89
+ ?>
90
+ <p>
91
+ <a href="<?php echo $boletoUrl;?>" target="_blank"><?php echo Mage::helper('mundipagg')->__('Print boleto');?></a>
92
+ </p>
93
+ <?php
94
+ endif;
95
+ ?>
app/design/frontend/base/default/template/mundipagg/redirect.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <div class="page-title">
32
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
33
+ </div>
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
+ <div class="buttons-set">
49
+ <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>
50
+ </div>
app/design/frontend/base/default/template/mundipagg/success.phtml ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+ ?>
31
+ <div class="page-title">
32
+ <h1><?php echo $this->__('Your order has been received') ?></h1>
33
+ </div>
34
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
35
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
36
+
37
+ <?php if ($this->getOrderId()):?>
38
+ <?php if ($this->getCanViewOrder()) :?>
39
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
40
+ <?php else :?>
41
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
42
+ <?php endif;?>
43
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
44
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
45
+ <p>
46
+ <?php echo $this->__('<a href="%s" target="_blank">Click here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
47
+ <?php echo $this->getChildHtml() ?>
48
+ </p>
49
+ <?php endif;?>
50
+ <?php endif;?>
51
+
52
+ <?php if ($this->getAgreementRefId()): ?>
53
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
54
+ <?php endif;?>
55
+
56
+ <?php if ($profiles = $this->getRecurringProfiles()):?>
57
+ <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
58
+ <ul class="disc">
59
+ <?php foreach($profiles as $profile):?>
60
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
61
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
62
+ <?php endforeach;?>
63
+ </ul>
64
+ <?php endif;?>
65
+
66
+ <?php
67
+ switch($this->getPaymentMethod()):
68
+ case 'mundipagg_boleto':
69
+ ?>
70
+ <p class="pagSucess"><?php echo $this->__('Your order has not been paid yet. <a href="%s" target="_blank">Click here to print</a> your Boleto Bancário.', $this->getBoletoUrl()) ?></p>
71
+ <?php endswitch; ?>
72
+ <!--
73
+ <?php
74
+ $helper = Mage::helper('core');
75
+
76
+ $_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
77
+
78
+ $paymentMethod = $_order->getPayment()->getAdditionalInformation('PaymentMethod');
79
+
80
+ if ($_order): ?>
81
+ <div class="page-title title-buttons">
82
+ <h1><?php echo $this->__('Order #%s - %s', $_order->getRealOrderId(), $_order->getStatusLabel()) ?></h1>
83
+ <?php echo $this->getChildHtml('buttons') ?>
84
+ </div>
85
+ <?php echo $this->getStatusHistoryRssUrl($_order) ?>
86
+ <p class="order-date"><?php echo $this->__('Order Date: %s', $this->formatDate($_order->getCreatedAtStoreDate(), 'long')) ?></p>
87
+
88
+ <table class="data-table" id="my-orders-table" summary="<?php echo $this->__('Items Ordered') ?>">
89
+ <col />
90
+ <col width="1" />
91
+ <col width="1" />
92
+ <col width="1" />
93
+ <col width="1" />
94
+ <thead>
95
+ <tr>
96
+ <th><?php echo $this->__('Product Name') ?></th>
97
+ <th><?php echo $this->__('SKU') ?></th>
98
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
99
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
100
+ <th class="a-right"><?php echo $this->__('Subtotal') ?></th>
101
+ </tr>
102
+ </thead>
103
+ <tfoot>
104
+ <tr class="subtotal first">
105
+ <td colspan="4" class="a-right">
106
+ <?php echo $this->__('Subtotal') ?>
107
+ </td>
108
+ <td class="last a-right">
109
+ <span class="price"><?php echo $helper->currency($_order->getSubtotal(), true, false) ?></span>
110
+ </td>
111
+ </tr>
112
+ <tr class="shipping">
113
+ <td colspan="4" class="a-right">
114
+ <?php echo $this->__('Shipping & Handling') ?>
115
+ </td>
116
+ <td class="last a-right">
117
+ <span class="price"><?php echo $helper->currency($_order->getShippingAmount(), true, false) ?></span>
118
+ </td>
119
+ </tr>
120
+
121
+ <?php if ($_order->getBaseDiscountAmount() < 0): ?>
122
+ <tr class="discount">
123
+ <td colspan="4" class="a-right">
124
+ <?php echo $this->__('Discount') ?>
125
+ </td>
126
+ <td class="last a-right">
127
+ <span class="price"><?php echo $helper->currency($_order->getBaseDiscountAmount(), true, false) ?></span>
128
+ </td>
129
+ </tr>
130
+ <?php endif; ?>
131
+
132
+ <tr class="grand_total last">
133
+ <td colspan="4" class="a-right">
134
+ <strong>Valor Total</strong>
135
+ </td>
136
+ <td class="last a-right">
137
+ <strong><span class="price"><?php echo $helper->currency($_order->getBaseGrandTotal(), true, false) ?></span></strong>
138
+ </td>
139
+ </tr>
140
+ </tfoot>
141
+
142
+ <?php $_items = $_order->getItemsCollection(); ?>
143
+ <?php $_index = 0; ?>
144
+ <?php $_count = $_items->count(); ?>
145
+ <?php foreach ($_items as $_item): ?>
146
+ <?php if ($_item->getParentItem()) continue; ?>
147
+ <tbody>
148
+ <tr>
149
+ <?php $productOptions = $_item->getProductOptions(); ?>
150
+ <td><?php echo $_item->getName() ?></td>
151
+ <td><?php echo $_item->getSku() ?></td>
152
+ <td><?php echo $helper->currency($_item->getBaseRowTotal(), true, false) ?></td>
153
+ <td><?php echo $_item->getQtyOrdered()*1 ?></td>
154
+ <td class="last"><?php echo $helper->currency($_item->getBaseRowTotal()*$_item->getQtyOrdered(), true, false) ?></td>
155
+ </tr>
156
+ </tbody>
157
+ <?php endforeach; ?>
158
+ </table>
159
+ <script type="text/javascript">decorateTable('my-orders-table', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
160
+
161
+ <br/><br/>
162
+
163
+ <?php if (!$_order->getIsVirtual()): ?>
164
+ <div class="col2-set order-info-box">
165
+ <div class="col-1">
166
+ <div class="box">
167
+ <div class="box-title">
168
+ <h2><?php echo $this->__('Shipping Address') ?></h2>
169
+ </div>
170
+ <div class="box-content">
171
+ <address><?php echo $_order->getShippingAddress()->format('html') ?></address>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ <div class="col-2">
176
+ <div class="box">
177
+ <div class="box-title">
178
+ <h2><?php echo $this->__('Shipping Method') ?></h2>
179
+ </div>
180
+ <div class="box-content">
181
+ <?php if ($_order->getShippingDescription()): ?>
182
+ <?php echo $this->escapeHtml($_order->getShippingDescription()) ?>
183
+ <?php else: ?>
184
+ <p><?php echo $this->helper('sales')->__('No shipping information available'); ?></p>
185
+ <?php endif; ?>
186
+ </div>
187
+ </div>
188
+ </div>
189
+ </div>
190
+ <?php endif; ?>
191
+ <div class="col2-set order-info-box">
192
+ <div class="col-1">
193
+ <div class="box">
194
+ <div class="box-title">
195
+ <h2><?php echo $this->__('Billing Address') ?></h2>
196
+ </div>
197
+ <div class="box-content">
198
+ <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
199
+ </div>
200
+ </div>
201
+ </div>
202
+ <div class="col-2">
203
+ <div class="box box-payment">
204
+ <div class="box-title">
205
+ <h2><?php echo $this->__('Payment Method') ?></h2>
206
+ </div>
207
+ <div class="box-content">
208
+ <?php echo Mage::helper('mundipagg')->__($paymentMethod) ?>
209
+ <?php if(($paymentMethod == 'BoletoBancario' || $paymentMethod == 'mundipagg_boleto') && $boletoUrl = $_order->getPayment()->getAdditionalInformation('BoletoUrl')):
210
+ ?>
211
+ <p>
212
+ <a href="<?php echo $boletoUrl;?>" target="_blank"><?php echo Mage::helper('mundipagg')->__('Print boleto');?></a>
213
+ </p>
214
+ <?php endif; ?>
215
+ </div>
216
+ </div>
217
+ </div>
218
+ </div>
219
+ <?php endif; ?>
220
+ -->
221
+
222
+ <div class="buttons-set">
223
+ <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>
224
+ </div>
app/design/frontend/base/default/template/mundipagg/totals.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /**
27
+ * @var $this Mage_Sales_Block_Order_Totals
28
+ * @see Mage_Sales_Block_Order_Totals
29
+ */
30
+ ?>
31
+ <?php foreach ($this->getTotals() as $_code => $_total): ?>
32
+ <?php if ($_total->getBlockName()): ?>
33
+ <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
34
+ <?php else:?>
35
+ <tr class="<?php echo $_code?>">
36
+ <td <?php echo $this->getLabelProperties()?>>
37
+ <?php if ($_total->getStrong()):?>
38
+ <strong><?php echo $this->escapeHtml($_total->getLabel());?></strong>
39
+ <?php else:?>
40
+ <?php echo $this->escapeHtml($_total->getLabel());?>
41
+ <?php endif?>
42
+ </td>
43
+ <td <?php echo $this->getValueProperties()?>>
44
+ <?php if ($_total->getStrong()):?>
45
+ <strong><?php echo $this->formatValue($_total) ?></strong>
46
+ <?php else:?>
47
+ <?php echo $this->formatValue($_total) ?>
48
+ <?php endif?>
49
+ </td>
50
+ </tr>
51
+ <?php endif?>
52
+ <?php endforeach?>
app/design/frontend/rwd/default/template/mundipagg/debit.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_code = $this->getMethodCode();
3
+
4
+ // We check if taxvat is enabled
5
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
6
+ ?>
7
+
8
+
9
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
10
+ <li>
11
+ <div id="mundipagg_debit">
12
+ <ul >
13
+ <li>
14
+ <div class="field">
15
+ <div class="input-box" >
16
+ <ul class="inline input-radio">
17
+ <?php
18
+ $debitTypes = $this->getDebitTypes();
19
+ $_i = 1;
20
+ ?>
21
+ <?php foreach($debitTypes as $debitType): ?>
22
+ <li>
23
+ <?php if(strpos($debitType, 'cielo') !== false) {
24
+ $value = 'Cielo';
25
+ } else {
26
+ $value = $debitType;
27
+ } ?>
28
+ <label for="<?php echo $_code . '_' . $debitType; ?>"><img src="<?php echo $this->getSkinUrl('images/mundipagg/' . $debitType . '.png'); ?>" alt="<?php echo $debitType ?>" border="0" style="cursor:pointer"/></label>
29
+ <input type="radio" name="payment[<?php echo $_code; ?>]" id="<?php echo $_code . '_' . $debitType; ?>" value="<?php echo $value ?>" class="<?php if ($_i == 1): ?>validate-one-required-by-name<?php endif; ?>">
30
+ </li>
31
+ <?php
32
+ $_i++;
33
+ endforeach
34
+ ?>
35
+ </ul>
36
+ </div>
37
+ </div>
38
+ </li>
39
+ <?php if(!$_taxvat->isEnabled() && Mage::getSingleton('customer/session')->getCustomer()->getTaxvat() == ''): ?>
40
+ <li style="clear:both">
41
+ <label><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label>
42
+ <div class="input-box">
43
+
44
+ <input type="text" id="<?php echo $_code ?>_taxvat" name="payment[taxvat]" title="<?php echo $this->__('Taxvat') ?>" class="validar_cpf required-entry input-text" onkeydown="remove_characters(event);"/>
45
+ </div>
46
+ </li>
47
+ <?php endif; ?>
48
+ </ul>
49
+ </div>
50
+ </li>
51
+ </ul>
52
+
app/design/frontend/rwd/default/template/mundipagg/form.phtml ADDED
@@ -0,0 +1,381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uecommerce
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Uecommerce EULA.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.uecommerce.com.br/
10
+ *
11
+ * DISCLAIMER
12
+ *
13
+ * Do not edit or add to this file if you wish to upgrade the extension
14
+ * to newer versions in the future. If you wish to customize the extension
15
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
16
+ *
17
+ * @category Uecommerce
18
+ * @package Uecommerce_Mundipagg
19
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
20
+ * @license http://www.uecommerce.com.br/
21
+ */
22
+
23
+ /**
24
+ * Mundipagg Payment module
25
+ *
26
+ * @category Uecommerce
27
+ * @package Uecommerce_Mundipagg
28
+ * @author Uecommerce Dev Team
29
+ */
30
+
31
+ //Return Standard model
32
+ $standard = $this->getStandard();
33
+
34
+ // Get Quote
35
+ $quote = $standard->getQuote();
36
+
37
+ $installmentsHelper = Mage::helper('mundipagg/installments');
38
+
39
+ if($quote->isVirtual()) {
40
+ $data = $quote->getBillingAddress();
41
+ } else {
42
+ $data = $quote->getShippingAddress();
43
+ }
44
+
45
+ $orderGrandTotal = $standard->getQuote()->getBaseGrandTotal();
46
+
47
+ // Partial payment?
48
+ $isPartial = Mage::getSingleton('checkout/session')->getApprovalRequestSuccess();
49
+
50
+ if($isPartial == 'partial'):
51
+ $authorizedAmount = Mage::getSingleton('checkout/session')->getAuthorizedAmount();
52
+
53
+ $baseGrandTotal = $orderGrandTotal - $authorizedAmount;
54
+ else :
55
+ $baseGrandTotal = $orderGrandTotal;
56
+ endif;
57
+
58
+ if($data->getMundipaggInterest()) {
59
+ $baseGrandTotal = $baseGrandTotal-$data->getMundipaggInterest();
60
+ }
61
+
62
+ // We check if taxvat is enabled
63
+ $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat');
64
+
65
+ // Get current currency symbol
66
+ $currencySymbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
67
+
68
+ //Credit Card Saved On File
69
+ $ccs = $this->getCcs();
70
+
71
+ $countCcs = count($ccs);
72
+
73
+ // Payment method
74
+ $_code = $this->getMethodCode();
75
+ ?>
76
+
77
+
78
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
79
+ <div>
80
+ <input type="hidden" id="baseGrandTotal" name="baseGrandTotal" value="<?php echo number_format($baseGrandTotal, "2", ",", ""); ?>"/>
81
+ <?php if ($isPartial == 'partial'): ?>
82
+ <input type="hidden" name="partial" id="partial" value="1"/>
83
+ <input type="hidden" name="payment[multi]" id="multi" value="1"/>
84
+ <?php endif; ?>
85
+ </div>
86
+ <?php
87
+ // START CREDIT CARD PAYMENT METHOD
88
+ $num = 1;
89
+
90
+ switch ($_code):
91
+ case 'mundipagg_creditcardoneinstallment':
92
+ $num = 1;
93
+ $paymentMethod = '1CreditCardsOneInstallment';
94
+ $paymentMethodLabel = $this->__('Credit Card');
95
+ break;
96
+
97
+ case 'mundipagg_creditcard':
98
+ $num = 1;
99
+ $paymentMethod = '1CreditCards';
100
+ $paymentMethodLabel = $this->__('Credit Card');
101
+ break;
102
+
103
+ case 'mundipagg_twocreditcards':
104
+ $num = 2;
105
+ $paymentMethod = '2CreditCards';
106
+ $paymentMethodLabel = $this->__('Pay with 2 Credit Cards');
107
+ break;
108
+
109
+ case 'mundipagg_threecreditcards':
110
+ $num = 3;
111
+ $paymentMethod = '3CreditCards';
112
+ $paymentMethodLabel = $this->__('Pay with 3 Credit Cards');
113
+ break;
114
+
115
+ case 'mundipagg_fourcreditcards':
116
+ $num = 4;
117
+ $paymentMethod = '4CreditCards';
118
+ $paymentMethodLabel = $this->__('Pay with 4 Credit Cards');
119
+ break;
120
+
121
+ case 'mundipagg_fivecreditcards':
122
+ $num = 5;
123
+ $paymentMethod = '5CreditCards';
124
+ $paymentMethodLabel = $this->__('Pay with 5 Credit Cards');
125
+ break;
126
+ endswitch;
127
+ ?>
128
+ <li>
129
+ <div id="<?php echo $_code; ?>">
130
+ <?php if($num != 1 && $isPartial != 'partial'): ?>
131
+ <p></p>
132
+ <div>
133
+ <b><?php echo $this->__('Grand Total') ?>:</b> <?php echo $currencySymbol.number_format($baseGrandTotal, "2", ",", "."); ?>
134
+ </div>
135
+ <p></p>
136
+ <?php endif ?>
137
+ <?php if ( $_code == 'mundipagg_creditcardoneinstallment' || $_code == 'mundipagg_creditcard' || $_code == 'mundipagg_twocreditcards' || $_code == 'mundipagg_threecreditcards' || $_code == 'mundipagg_fourcreditcards' || $_code == 'mundipagg_fivecreditcards'): ?>
138
+ <ul>
139
+ <?php for($c=1;$c<=$num;$c++): ?>
140
+ <input type="hidden" id="mundipagg_type" name="payment[mundipagg_type]" value="<?php echo $paymentMethod ; ?>"/>
141
+ <?php $currentSelectedToken = null; ?>
142
+ <?php if($countCcs > 0 ):?>
143
+ <li class="fields" style="margin-bottom: 5px;">
144
+ <div class="field">
145
+ <label class="required"><?php echo $this->__('Select a Credit Card or add a new one') ?><span class="required">*</span></label>
146
+ <div class="input-box">
147
+
148
+ <select id="<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>" data="group_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_token_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry tokens group_<?php echo $num; ?>_<?php echo $c;?>" onchange="token_or_not(<?php echo $num; ?>,<?php echo $c;?>,this)">
149
+ <option value="">...</option>
150
+ <?php
151
+ $selected = '';
152
+
153
+ if($countCcs == 1):
154
+ $selected = 'selected="selected"';
155
+ endif;
156
+
157
+ foreach($ccs as $id => $cc):
158
+
159
+ if($countCcs == 1){
160
+ $currentSelectedToken = Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
161
+ }
162
+ $dataType = $currentSelectedToken?$currentSelectedToken:Mage::getSingleton('mundipagg/source_cctypes')->getCcTypeForLabel($cc->getCcType());
163
+ echo '<option value="'.$cc->getId().'" '.$selected.' data="'.$dataType.'">'.$cc->getCcType().' '.$cc->getCreditCardMask().'</option>';
164
+ endforeach;
165
+ ?>
166
+ <option value="new"><?php echo $this->__('New Credit Card') ?></option>
167
+ </select>
168
+ </div>
169
+ </div>
170
+ </li>
171
+ <?php if($num != 1): ?>
172
+ <div id="value_<?php echo $num; ?>_<?php echo $c;?>">
173
+ <li class="fields" style="margin-bottom: 5px;">
174
+ <div class="field">
175
+ <label class="required"><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
176
+ <div class="input-box">
177
+ <input type="text" id="<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry validate-greater-than-zero input-text check_values group_<?php echo $num; ?>_<?php echo $c;?>" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');" onkeydown="remove_special_characters(event);" value=""/>
178
+ </div>
179
+ </div>
180
+ </li>
181
+ </div>
182
+ <?php endif; ?>
183
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
184
+ <div id="parcelamento_<?php echo $num; ?>_<?php echo $c;?>" <?php if($countCcs > 1): ?>style="display:none"<?php endif?>>
185
+ <li class="fields" style="margin-bottom: 5px;">
186
+ <div class="field">
187
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num == 2):?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
188
+ <div class="input-box">
189
+ <select id="<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry installment-token group_<?php echo $num; ?>_<?php echo $c;?>">
190
+ <?php foreach($this->getInstallments($currentSelectedToken) as $key => $parcel): ?>
191
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
192
+ <?php endforeach ?>
193
+ </select>
194
+ </div>
195
+ </div>
196
+ </li>
197
+ </div>
198
+ <?php endif; ?>
199
+ <?php endif; ?>
200
+ <div class="division"></div>
201
+ <div id="<?php echo $_code; ?>_new_credit_card_<?php echo $num; ?>_<?php echo $c;?>" <?php if( $countCcs > 0 ) { ?>style="display:none"<?php } ?>>
202
+
203
+ <li style="margin-bottom: 5px;">
204
+ <div class="field">
205
+ <label class="required"><?php echo $this->__('Credit Card Issuer') ?> <span class="required">*</span></label>
206
+ <div class="input-box">
207
+ <ul class="inline input-radio">
208
+ <?php
209
+ $ccards = $standard->getCcTypes();
210
+ $_i = 1;
211
+ ?>
212
+ <?php foreach($ccards as $ccard): ?>
213
+ <li class="cc_brands">
214
+ <div class="cc_brand_types <?php echo strtolower($ccard); ?>">&nbsp;</div>
215
+ <!--<img src="<?php //echo $this->getSkinUrl('images/mundipagg/'.$ccard.'.png');?>" alt="<?php //echo $ccard ?>" border="0" class="cursor_hand" onclick="setCcType(this, '<?php //echo $_code; ?>', '<?php //echo $num; ?>', '<?php //echo $c;?>', '<?php //echo $ccard; ?>');">-->
216
+ <input type="radio" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_credito_instituicao]" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_credito_instituicao_<?php echo $ccard; ?>" value="<?php echo $ccard ?>" class="<?php if ($_i == 1): ?>validate-one-required-by-name<?php endif; ?>" onclick="setCcType(this, '<?php echo $_code; ?>', '<?php echo $num; ?>', '<?php echo $c;?>', '<?php echo $ccard; ?>');">
217
+ </li>
218
+ <?php
219
+ $_i++;
220
+ endforeach
221
+ ?>
222
+ </ul>
223
+ <p class="info-payment"><i><small><?php echo $this->__('The flag is automatically selected after entering the credit card number below.'); ?></small></i></p>
224
+ <input type="hidden" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type]" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_type" value="" class="validate-cc-type-select"/>
225
+ </div>
226
+ </div>
227
+ </li>
228
+ <li style="margin-bottom: 5px;">
229
+ <div class="field">
230
+ <label class="required"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
231
+ <div class="input-box">
232
+ <input type="text" id="<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number" name="payment[<?php echo $_code; ?>_<?php echo $num; ?>_<?php echo $c;?>_cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-cc-number" onkeydown="remove_characters(event);" value=""/>
233
+ </div>
234
+ </div>
235
+ </li>
236
+ <li style="margin-bottom: 5px;">
237
+ <div class="field">
238
+ <label class="required"><?php echo $this->__('Credit Card Holder name') ?> <span class="required">*</span></label>
239
+ <div class="input-box">
240
+ <input type="text" id="<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_holder_name_<?php echo $num; ?>_<?php echo $c;?>]" class="required-entry input-text" />
241
+ </div>
242
+ </div>
243
+ </li>
244
+ <li style="margin-bottom: 5px;">
245
+ <div class="field">
246
+ <label class="required"><?php echo $this->__('Expiration date') ?> <span class="required">*</span></label>
247
+ <div class="input-box">
248
+ <div class="v-fix">
249
+ <select id="<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationMonth_<?php echo $num; ?>_<?php echo $c;?>]" class="month required-entry validate-cc-exp-new">
250
+ <option value=""><?php echo $this->__('Month') ?></option>
251
+ <option value="1">01 - <?php echo $this->__('January') ?></option>
252
+ <option value="2">02 - <?php echo $this->__('February') ?></option>
253
+ <option value="3">03 - <?php echo $this->__('March') ?></option>
254
+ <option value="4">04 - <?php echo $this->__('April') ?></option>
255
+ <option value="5">05 - <?php echo $this->__('May') ?></option>
256
+ <option value="6">06 - <?php echo $this->__('June') ?></option>
257
+ <option value="7">07 - <?php echo $this->__('July') ?></option>
258
+ <option value="8">08 - <?php echo $this->__('August') ?></option>
259
+ <option value="9">09 - <?php echo $this->__('September') ?></option>
260
+ <option value="10">10 - <?php echo $this->__('October') ?></option>
261
+ <option value="11">11 - <?php echo $this->__('November') ?></option>
262
+ <option value="12">12 - <?php echo $this->__('December') ?></option>
263
+ </select>
264
+ </div>
265
+ <div class="v-fix" style="padding-left:6px;">
266
+ <select id="<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_expirationYear_<?php echo $num; ?>_<?php echo $c;?>]" class="year required-entry">
267
+ <option value=""><?php echo $this->__('Year') ?></option>
268
+ <?php
269
+ $i = date('Y');
270
+ $year = date('Y');
271
+ $year10 = $year + 10;
272
+ for( $i = $year; $i <= $year10; $i++ ):
273
+ ?>
274
+ <option value="<?php echo substr($i, -2);?>"><?php echo $i;?></option>
275
+ <?php endfor; ?>
276
+ </select>
277
+ </div>
278
+ </div>
279
+ </div>
280
+ </li>
281
+ <li style="margin-bottom: 5px;">
282
+ <div class="field">
283
+ <label class="required"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label>
284
+ <div class="input-box">
285
+ <div class="v-fix">
286
+ <input type="text" id="<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_cid_<?php echo $num; ?>_<?php echo $c;?>]" style="width: 55px" class="required-entry input-text validate-cc-cvn validate-length" maxlength="4" onkeydown="remove_characters(event);"/>
287
+ </div>
288
+ <div class="v-fix" style="padding-left:6px;">
289
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
290
+ </div>
291
+ </div>
292
+ </div>
293
+ </li>
294
+ <?php if($num != 1): ?>
295
+ <li style="margin-bottom: 5px;">
296
+ <div class="field">
297
+ <label class="required"><?php echo $this->__('Value (Ex: 100,50)') ?> <span class="required">*</span></label>
298
+ <div class="input-box">
299
+ <input type="text" id="<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_value_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('Value (Ex: 100,50)') ?>" class="required-entry input-text validate-greater-than-zero check_values" onchange="calculateInstallmentValue(this, <?php echo $num;?>, <?php echo $c;?>, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');" onkeydown="remove_special_characters(event);" value=""/>
300
+ </div>
301
+ </div>
302
+ </li>
303
+ <?php endif; ?>
304
+ <?php if ($installmentsHelper->isInstallmentsEnabled() && $_code != 'mundipagg_creditcardoneinstallment'): ?>
305
+ <li style="margin-bottom: 5px;">
306
+ <div class="field">
307
+ <label class="required"><?php echo $this->__('Credit options') ?> <?php if($num ==2): ?><!--<a href="javascript:void(0);" onclick="javascript:void(0);">(<?php /*echo $this->__('click to update') */?>)</a>--><?php endif ?></label>
308
+ <div class="input-box">
309
+ <select id="<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_new_credito_parcelamento_<?php echo $num; ?>_<?php echo $c;?>]" onchange="checkInstallments(this, '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>');">
310
+ <?php foreach($this->getInstallments() as $key => $parcel): ?>
311
+ <option value="<?php echo $key ?>"><?php echo $parcel ?></option>
312
+ <?php endforeach ?>
313
+ </select>
314
+ </div>
315
+ </div>
316
+ </li>
317
+ <?php endif; ?>
318
+ <?php if ($standard->getConfigData('clearsale') && !$_taxvat->isEnabled() && Mage::getSingleton('customer/session')->getCustomer()->getTaxvat() == ''): ?>
319
+ <li style="margin-bottom: 5px;">
320
+ <div class="field">
321
+ <label class="required"><?php echo $this->__('CPF ou CNPJ') ?> <span class="required">*</span></label>
322
+ <div class="input-box">
323
+ <input type="text" id="<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_cc_taxvat_<?php echo $num; ?>_<?php echo $c;?>]" title="<?php echo $this->__('CPF ou CNPJ') ?>" class="validar_cpf required-entry" onkeydown="remove_characters(event);"/>
324
+ </div>
325
+ </div>
326
+ </li>
327
+ <?php endif;?>
328
+ <?php if($standard->getQuote()->getCheckoutMethod() != 'guest'): ?>
329
+ <?php if(Mage::getStoreConfig('payment/mundipagg_standard/save_cardonfile')): ?>
330
+ <li>
331
+
332
+ <div class="input-box" style="padding-top: 10px">
333
+ <div class="field">
334
+ <label class="required"><?php echo $this->__('Save Card On File') ?></label>
335
+ <input type="checkbox" id="<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>" name="payment[<?php echo $_code; ?>_save_token_<?php echo $num; ?>_<?php echo $c;?>]" value="new"/>
336
+ </div>
337
+
338
+ </div>
339
+ </li>
340
+ <?php endif; ?>
341
+ <?php endif; ?>
342
+ </div>
343
+ <?php endfor; ?>
344
+ </ul>
345
+ <?php endif ?>
346
+ </div>
347
+ </li>
348
+ <?php // END CREDIT CARD PAYMENT METHOD ?>
349
+ </ul>
350
+
351
+
352
+ <script type="text/javascript">
353
+ //<![CDATA[
354
+ Validation.addAllThese([
355
+ ['validate-cc-exp-new', '<?php echo $this->jsQuoteEscape( Mage::helper('mundipagg')->__('Incorrect credit card expiration date.') )?>', function(v, elm) {
356
+ var ccExpMonth = v;
357
+ var ccExpYear = $( elm.id.replace("_expirationMonth", "_expirationYear") ).value;
358
+
359
+ var currentTime = new Date();
360
+ var currentMonth = currentTime.getMonth() + 1;
361
+ var currentYear = currentTime.getFullYear().toString().substr(2,2);
362
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
363
+ return false;
364
+ }
365
+ return true;
366
+ }]
367
+ ]);
368
+
369
+ window.baseUrl = '<?php echo Mage::getUrl('',array('_secure'=>true)); ?>';
370
+ window.installmentsandinterestUrl = '<?php echo Mage::getUrl('mundipagg/standard/installmentsandinterest',array('_secure'=>true)); ?>';
371
+ window.ajaxLoaderGif = '<?php echo $this->getSkinUrl('images/mundipagg/ajax-loader.gif'); ?>';
372
+ window.isInstallmentsEnabled = '<?php echo Mage::helper('mundipagg/installments')->isInstallmentsEnabled(); ?>';
373
+
374
+ $$('.validate-cc-number').invoke('observe','keyup',function(){
375
+ selectCredcard(this);
376
+ });
377
+ $$('.validate-cc-number').invoke('observe','blur',function(){
378
+ selectCredcard(this);
379
+ });
380
+ //]]>
381
+ </script>
app/etc/modules/Uecommerce_Mundipagg.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Uecommerce_Mundipagg>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Uecommerce_Mundipagg>
8
+ </modules>
9
+ </config>
app/locale/en_US/Uecommerce_Mundipagg.csv ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Enabled"
2
+ "Title","Title"
3
+ "Environment","Environment"
4
+ "Debug","Debug"
5
+ "Api URL Staging","Api URL Staging"
6
+ "merchantKey Staging","merchantKey Staging"
7
+ "Api URL Production","Api URL Production"
8
+ "merchantKey Production","merchantKey Production"
9
+ "Payment Action","Payment Action"
10
+ "Payment Methods","Payment Methods"
11
+ "Return message AuthOnly","Return message AuthOnly"
12
+ "Return message AuthAndCaptureWithDelay","Return message AuthAndCaptureWithDelay"
13
+ "Credit Card Issuers","Credit Card Issuers"
14
+ "Payment from Applicable Countries","Payment from Applicable Countries"
15
+ "Payment from Specific Countries","Payment from Specific Countries"
16
+ "AuthOnly","AuthOnly"
17
+ "AuthAndCapture","AuthAndCapture"
18
+ "AuthAndCaptureWithDelay","AuthAndCaptureWithDelay"
19
+ "Credit Card","Credit Card"
20
+ "1 Credit Card","1 Credit Card"
21
+ "2 Credit Cards","2 Credit Cards"
22
+ "3 Credit Cards","3 Credit Cards"
23
+ "4 Credit Cards","4 Credit Cards"
24
+ "5 Credit Cards","5 Credit Cards"
25
+ "mundipagg_creditcard","Credit Card"
26
+ "mundipagg_twocreditcards","2 Credit Cards"
27
+ "mundipagg_threecreditcards","3 Credit Cards"
28
+ "mundipagg_fourcreditcards","4 Credit Cards"
29
+ "mundipagg_fivecreditcards","5 Credit Cards"
30
+ "mundipagg_boleto","Boleto Bancário"
31
+ "mundipagg_debit","Débito"
32
+ "Boleto Bancário","Boleto Bancário"
33
+ "CreditCard","Credit Card"
34
+ "BoletoBancario","Boleto Bancário"
35
+ "Visa","Visa"
36
+ "Mastercard","Mastercard"
37
+ "American Express","American Express"
38
+ "Diners","Diners"
39
+ "Select a payment method from backoffice","Select a payment method from backoffice"
40
+ "A vista","A vista"
41
+ "Total:","Total:"
42
+ "Select a Credit Card or add a new one","Select a Credit Card or add a new one"
43
+ "New Credit Card","New Credit Card"
44
+ "Credit Card Holder name","Credit Card Holder name"
45
+ "Credit Card Number","Credit Card Number"
46
+ "Expiration date","Expiration date"
47
+ "Month","Month"
48
+ "January","January"
49
+ "February","February"
50
+ "March","March"
51
+ "April","April"
52
+ "May","May"
53
+ "June","June"
54
+ "July","July"
55
+ "August","August"
56
+ "September","September"
57
+ "October","October"
58
+ "November","November"
59
+ "December","December"
60
+ "Year","Year"
61
+ "Card Verification Number","Card Verification Number"
62
+ "What is this?","What is this?"
63
+ "Credit options","Credit options"
64
+ "Total","Total"
65
+ "Boleto Bancârio","Boleto Bancârio"
66
+ "Save Card On File","Save Card On File"
67
+ "Card already exists on file.","Card already exists on file."
68
+ "CreditCard","CreditCard"
69
+ "1CreditCards","Pay with 1 Credit Card"
70
+ "2CreditCards","Pay with 2 Credit Cards"
71
+ "3CreditCards","Pay with 3 Credit Cards"
72
+ "4CreditCards","Pay with 4 Credit Cards"
73
+ "5CreditCards","Pay with 5 Credit Cards"
74
+ "Pay with 1 Credit Card","Pay with 1 Credit Card"
75
+ "Pay with 2 Credit Cards","Pay with 2 Credit Cards"
76
+ "Pay with 3 Credit Cards","Pay with 3 Credit Cards"
77
+ "Pay with 4 Credit Cards","Pay with 4 Credit Cards"
78
+ "Pay with 5 Credit Cards","Pay with 5 Credit Cards"
79
+ "Denied","Denied"
80
+ "Holder instituition error","Holder instituition error"
81
+ "Parameters sent error","Parameters sent error"
82
+ "Credentials error","Credentials error"
83
+ "Internal Error","Internal Error"
84
+ "for","for"
85
+ "Payment error","Payment Error"
86
+ "Method","Method"
87
+ "Payment Method","Payment Method"
88
+ "OrderKey","Order Key"
89
+ "Credit Card Issuer","Credit Card Issuer"
90
+ "Transaction Status","Transaction Status"
91
+ "AuthorizedPendingCapture","AuthorizedPendingCapture"
92
+ "NotAuthorized","NotAuthorized"
93
+ "ChargebackPreview","ChargebackPreview"
94
+ "RefundPreview","RefundPreview"
95
+ "DepositPreview","DepositPreview"
96
+ "Captured","Captured"
97
+ "PartialCapture","PartialCapture"
98
+ "Refunded","Refunded"
99
+ "Voided","Voided"
100
+ "Deposited","Deposited"
101
+ "OpenedPendindAuth","OpenedPendindAuth"
102
+ "Chargedback","Chargedback"
103
+ "WithError","WithError"
104
+ "Invalid","Invalid"
105
+ "PendingVoid","PendingVoid"
106
+ "PartialAuthorize","PartialAuthorize"
107
+ "PartialRefund","PartialRefund"
108
+ "Order status is: Opened","Order status is: Opened"
109
+ "Order status is: Closed","Order status is: Closed"
110
+ "Order status is: Paid","Order status is: Paid"
111
+ "Order status is: Overpaid","Order status is: Overpaid"
112
+ "Order status is: Canceled","Order status is: Canceled"
113
+ "Order status is: PartialPaid","Order status is: PartialPaid"
114
+ "No OrderKey found.","Chave do pedido não encontrada."
115
+ "Waiting for Boleto Bancário payment","Aguardando pagamento do Boleto Bancário"
116
+ "InstallmentCount","Parcela"
117
+ "InstallmentsCount","Parcelas"
118
+ "Print your boleto after you have placed your order.","You will be able to print your Boleto Bancârio after placing your order."
119
+ "<a href=""%s"" target=""_blank"">Click here to print</a> a copy of your order confirmation.","<a href=""%s"" target=""_blank"">Click here to print</a> a copy of your order."
120
+ "Your order has not been paid yet. <a href=""%s"" target=""_blank"">Click here to print</a> your Boleto Bancário.","Your order has not been paid yet. <a href=""%s"" target=""_blank"">Click here to print</a> your Boleto Bancário."
121
+ "Print boleto","Print boleto"
122
+ "Print boleto nº","Print boleto nº"
123
+ "Payment boleto nº","Payment date boleto nº"
124
+ "Value (Ex: 100,50)","Value (Ex: 100,50)"
125
+ "Installments does not match with quote.","Installments does not match with quote."
126
+ "Order partially authorized","Order partially authorized"
127
+ "Order total:","Order total:"
128
+ "Amount authorized:","Amount authorized:"
129
+ "Rest to pay:","Rest to pay:"
130
+ "on Credit Card nº","on Credit Card nº"
131
+ "authorized","authorized"
132
+ "not authorized","not authorized"
133
+ "Choose a payment method above to complete your order","Choose a payment method above to complete your order"
134
+ "Order cancelled","Order cancelled"
135
+ "You cannot capture having ClearSale activated.","You cannot capture having ClearSale activated."
136
+ "You cannot capture Boleto Bancário.","You cannot capture Boleto Bancário."
137
+ "Try again!","Try again!"
138
+ "Address_2","Number"
139
+ "Address_3","District"
140
+ "CPF or CNPJ is invalid","CPF or CNPJ is invalid"
141
+ "Grand Total","Grand Total"
142
+ "click to update","click to update"
143
+ "Unable to capture order.","Unable to capture order."
144
+ "Unable to void order.","Unable to void order."
145
+ "Unable to refund order.","Unable to refund order."
146
+ "Interest","Interest"
147
+ "Probably you had not installed the old version.","Probably you had not installed the old version."
148
+ "The old settings have been successfully restored! Please check and make tests in your store.","The old settings have been successfully restored! Please check and make tests in your store."
149
+ "Set old settings","Set old settings"
150
+ "If you just update the module and its old version is below 2.0.0, you can click this button to generate the installments as were set in the old version of the module.","If you just update the module and its old version is below 2.0.0, you can click this button to generate the installments as were set in the old version of the module."
151
+ "If you have already set manually, CAUTION! This function will reset all installments.","If you have already set manually, CAUTION! This function will reset all installments."
app/locale/pt_BR/Uecommerce_Mundipagg.csv ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Ativar"
2
+ "Title","Título"
3
+ "Environment","Ambiente"
4
+ "Debug","Debug"
5
+ "Api URL Staging","Api URL Staging"
6
+ "merchantKey Staging","merchantKey Staging"
7
+ "Api URL Production","Api URL Produção"
8
+ "merchantKey Production","merchantKey Produção"
9
+ "Payment Action","Tipo"
10
+ "Payment Methods","Métodos de pagamento"
11
+ "Return message AuthOnly","Mensagem de retorno de AuthOnly"
12
+ "Return message AuthAndCaptureWithDelay","Mensagem de retorno de AuthAndCaptureWithDelay"
13
+ "Credit Card Issuers","Bandeiras"
14
+ "Payment from Applicable Countries","Pagamento autorizado para os paises"
15
+ "Payment from Specific Countries","Pagamento específico dos paises"
16
+ "AuthOnly","AuthOnly"
17
+ "AuthAndCapture","AuthAndCapture"
18
+ "AuthAndCaptureWithDelay","AuthAndCaptureWithDelay"
19
+ "Credit Card","Cartão de Crédito"
20
+ "1 Credit Card","Cartão de Crédito"
21
+ "2 Credit Cards","2 Cartões de Crédito"
22
+ "3 Credit Cards","3 Cartões de Crédito"
23
+ "4 Credit Cards","4 Cartões de Crédito"
24
+ "5 Credit Cards","5 Cartões de Crédito"
25
+ "Pay with 1 Credit Card","Pagar com 1 Cartão de Crédito"
26
+ "Pay with 2 Credit Cards","Pagar com 2 Cartões de Crédito"
27
+ "Pay with 3 Credit Cards","Pagar com 3 Cartões de Crédito"
28
+ "Pay with 4 Credit Cards","Pagar com 4 Cartões de Crédito"
29
+ "Pay with 5 Credit Cards","Pagar com 5 Cartões de Crédito"
30
+ "Boleto Bancário","Boleto Bancário"
31
+ "CreditCard","Cartão de Crédito"
32
+ "BoletoBancario","Boleto Bancário"
33
+ "Visa","Visa"
34
+ "Mastercard","Mastercard"
35
+ "American Express","American Express"
36
+ "Diners","Diners"
37
+ "Select a payment method from backoffice","Selecione uma forma de pagamento no backoffice"
38
+ "A vista","A vista"
39
+ "Total:","Total:"
40
+ "Select a Credit Card or add a new one","Selecione um Cartão de Crédito ou adicione um novo"
41
+ "New Credit Card","Novo Cartão de Crédito"
42
+ "Credit Card Holder name","Nome completo no Cartão de Crédito"
43
+ "Credit Card Number","Número do Cartão de Crédito"
44
+ "Expiration date","Data de expiração do Cartão de Crédito"
45
+ "Month","Mês"
46
+ "January","Janeiro"
47
+ "February","Fevereiro"
48
+ "March","Março"
49
+ "April","Abril"
50
+ "May","Maio"
51
+ "June","Junho"
52
+ "July","Julho"
53
+ "August","Agosto"
54
+ "September","Setembro"
55
+ "October","Outubro"
56
+ "November","Novembro"
57
+ "December","Dezembro"
58
+ "Year","Ano"
59
+ "Card Verification Number","Código de segurança"
60
+ "What is this?","O que é?"
61
+ "Credit options","Parcelar em"
62
+ "Total","Total"
63
+ "Boleto Bancârio","Boleto Bancário"
64
+ "Save Card On File","Usar este Cartão para futuras compras"
65
+ "Card already exists on file.","Esse Cartão de Crédito já existe no arquivo."
66
+ "CreditCard","Cartão de Crédito"
67
+ "1CreditCardsOneInstallment","Cartão de Crédito a vista"
68
+ "1CreditCards","Cartão de Crédito"
69
+ "2CreditCards","2 Cartões de Crédito"
70
+ "3CreditCards","3 Cartões de Crédito"
71
+ "4CreditCards","4 Cartões de Crédito"
72
+ "5CreditCards","5 Cartões de Crédito"
73
+ "mundipagg_creditcardoneinstallment","Cartão de Crédito a vista"
74
+ "mundipagg_creditcard","Cartão de Crédito"
75
+ "mundipagg_twocreditcards","2 Cartões de Crédito"
76
+ "mundipagg_threecreditcards","3 Cartões de Crédito"
77
+ "mundipagg_fourcreditcards","4 Cartões de Crédito"
78
+ "mundipagg_fivecreditcards","5 Cartões de Crédito"
79
+ "mundipagg_boleto","Boleto Bancário"
80
+ "mundipagg_debit","Débito"
81
+ "Denied","Negado"
82
+ "Holder instituition error","Erro instituição titular"
83
+ "Parameters sent error","Dados enviados errados"
84
+ "Credentials error","Senha errada"
85
+ "Internal Error","Erro interno"
86
+ "for","para"
87
+ "Payment error","A transação não foi aprovada."
88
+ "Payment ok","A transação foi aprovada."
89
+ "Method","Método"
90
+ "Payment Method","Método de pagamento"
91
+ "OrderKey","Chave do pedido"
92
+ "Credit Card Issuer","Bandeira"
93
+ "Transaction Status","Status da transação"
94
+ "AuthorizedPendingCapture","AuthorizedPendingCapture"
95
+ "NotAuthorized","NotAuthorized"
96
+ "ChargebackPreview","ChargebackPreview"
97
+ "RefundPreview","RefundPreview"
98
+ "DepositPreview","DepositPreview"
99
+ "Captured","Capturado"
100
+ "PartialCapture","Capturado partialmente"
101
+ "Refunded","Reembolsado"
102
+ "Voided","Estornado"
103
+ "Deposited","Depositado"
104
+ "OpenedPendindAuth","Aberto pendente de autorização"
105
+ "Chargedback","Charged back"
106
+ "WithError","Com erro"
107
+ "Invalid","Inválido"
108
+ "PendingVoid","Aguardando estorno"
109
+ "PartialAuthorize","Autorizado parcialmente"
110
+ "PartialRefund","Reembolsado parcialmente"
111
+ "Order status is: Opened","Status do pedido: Aberto"
112
+ "Order status is: Closed","Status do pedido: Fechado"
113
+ "Order status is: Paid","Status do pedido: Pago"
114
+ "Order status is: Overpaid","Status do pedido: Pago a mais"
115
+ "Order status is: Canceled","Status do pedido: Cancelado"
116
+ "Order status is: PartialPaid","Status do pedido: Pago parcialmente"
117
+ "No OrderKey found.","Chave do pedido não encontrada."
118
+ "Waiting for Boleto Bancário payment","Aguardando pagamento do Boleto Bancário"
119
+ "InstallmentCount","Parcela"
120
+ "InstallmentsCount","Parcelas"
121
+ "Print your boleto after you have placed your order.","Imprima o boleto bancário após a finalização do pedido."
122
+ "<a href=""%s"" target=""_blank"">Click here to print</a> a copy of your order confirmation.","<a href=""%s"" target=""_blank"">Clique aqui para imprimir</a> a confirmação do pedido."
123
+ "Your order has not been paid yet. <a href=""%s"" target=""_blank"">Click here to print</a> your Boleto Bancário.","<a href=""%s"" target=""_blank"">Clique aqui para imprimir</a> seu Boleto Bancário."
124
+ "Print boleto","Imprimir boleto"
125
+ "Print boleto nº","Imprimir boleto nº"
126
+ "Payment boleto nº","Payment date boleto nº"
127
+ "Value (Ex: 100,50)","Valor a passar neste Cartão (Ex: 100,50)"
128
+ "Installments does not match with quote.","Soma dos valores por Cartão não coincidem."
129
+ "Order partially authorized","Pedido parcialmente autorizado"
130
+ "Order total:","Valor total do pedido:"
131
+ "Amount authorized:","Total autorizado:"
132
+ "Rest to pay:","Falta a autorizar:"
133
+ "on Credit Card nº","no Cartão de Crédito nº"
134
+ "authorized","autorizado"
135
+ "not authorized","não autorizado"
136
+ "Choose a payment method above to complete your order","Escolha um método de pagamento abaixo para concluir seu pedido"
137
+ "Order cancelled","Pedido cancelado"
138
+ "You cannot capture having ClearSale activated.","Você tem ClearSale ativado, seu pedido será analisado pelo mesmo."
139
+ "You cannot capture Boleto Bancário.","Você não pode capturar um Boleto Bancário, o pagamento será notificado pela sua URL de retorno."
140
+ "Try again!","Tente novamente por favor."
141
+ "Address_2","Número"
142
+ "Address_3","Bairro"
143
+ "CPF or CNPJ is invalid","O CPF ou CNPJ informado é inválido"
144
+ "Grand Total","Valor Total"
145
+ "click to update","clique para atualizar"
146
+ "Product Name","Produto"
147
+ "Price","Valor"
148
+ "Qty","Qtd"
149
+ "Order #%s - %s","Pedido #%s - %s"
150
+ "Order Date: %s","Data do pedido: %s"
151
+ "Billing Address","Endereço de Cobrança"
152
+ "Shipping Address","Endereço de Envio"
153
+ "Shipping Method","Método de Envio"
154
+ "Shipping & Handling","Envio"
155
+ "Discount","Desconto"
156
+ "Continue Shopping","Continuar comprando"
157
+ "Unable to capture order.","Impossível capturar o pedido."
158
+ "Unable to void order.","Impossível cancelar o pedido."
159
+ "Unable to refund order.","Impossível estornar o pedido."
160
+ "Interest","Juros Cartões"
161
+ "Installments default","Parcelamentos Padrões"
162
+ "Add Installment Boundary","Adicionar Parcela"
163
+ "Amount (incl.)","Total 'Até' - (menor ou igual)"
164
+ "Maximum Number of Installments","Número da Parcela"
165
+ "Interest Rate (%)","Taxa de Juros (%)"
166
+ "Installments and Interest","Parcelamentos e Juros"
167
+ "Installments for Visa","Parcelamentos para Visa"
168
+ "Installments for Mastercard","Parcelamentos para Mastercard"
169
+ "Installments for Amex","Parcelamentos para Amex"
170
+ "Installments for Diners","Parcelamentos para Diners"
171
+ "Installments for Elo","Parcelamentos para Elo"
172
+ "Installments for Hipercard","Parcelamentos para Hipercard"
173
+ "The flag is automatically selected after entering the credit card number below.","A bandeira será selecionada automaticamente após digitar o Número do Cartão de Crédito abaixo."
174
+ "Enable feature (use the card for future purchases)","Habilitar funcionalidade (usar o cartão em futuras compras)"
175
+ "The taxvat is invalid","O CPF ou CNPJ informado é inválido"
176
+ "Check the values to pass on each card","Confira os valores a passar em cada cartão"
177
+ "Expiration date of the incorrect card","Data de expiração do Cartão incorreta"
178
+ "Total amount with interest: USD{%%%}","<b>Valor total c/ juros: </b>R${%%%}"
179
+ "with interest","c/ juros"
180
+ "without interest","s/ juros"
181
+ "Daily","Diário"
182
+ "Weekly","Semanal"
183
+ "Monthly","Mensal"
184
+ "Yearly","Anual"
185
+ "Quarterly","Trimestral"
186
+ "Biannual","Semestral"
187
+ "it is not possible to divide by %s times","Não é possível dividir em %s vezes"
188
+ "Probably you had not installed the old version.","Provavelmente você não tinha instalado a versão antiga."
189
+ "The old settings have been successfully restored! Please check and make tests in your store.","As configurações antigas foram restauradas com sucesso! Por favor, verifique e fazer testes em sua loja."
190
+ "Set old settings","Resetar configurações antigas"
191
+ "If you just update the module and its old version is below 2.0.0, you can click this button to generate the installments as were set in the old version of the module.","Se você acabou de atualizar o módulo e sua versão antiga está abaixo 2.0.0, você pode clicar neste botão para gerar as parcelas como foram definidas na versão antiga do módulo."
192
+ "If you have already set manually, CAUTION! This function will reset all installments.","Se você já tiver configurado manualmente, CUIDADO! Esta função irá repor todas as parcelas."
193
+ "Environment FControl","Ambiente FControl"
194
+ "FControl sandbox key","Chave FControl sandbox"
195
+ "FControl production key","Chave FControl produção"
196
+ "Production","Produção"
197
+ "Max time to retry in minutes","Tempo máximo para retentativa em minutos"
198
+ "Max time to wait for an authorization. After this, the order will be cancelled.","Tempo máximo para esperar por uma autorização. Após este prazo, pedido será cancelado."
199
+ "Fingerprint environment","Ambiente fingerprint"
js/uecommerce/mundipagg.js ADDED
@@ -0,0 +1,872 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function validaCPF(cpf,pType) {
2
+ if (Validation.get('IsEmpty').test(cpf)) {
3
+ return false;
4
+ }
5
+
6
+ var valid = true;
7
+ var cpf = cpf.replace(/[.\//-]/g,'');
8
+
9
+ if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
10
+ valid = false;
11
+ add = 0;
12
+ for (i=0; i < 9; i ++)
13
+ add += parseInt(cpf.charAt(i)) * (10 - i);
14
+ rev = 11 - (add % 11);
15
+ if (rev == 10 || rev == 11)
16
+ rev = 0;
17
+ if (rev != parseInt(cpf.charAt(9)))
18
+ valid = false;
19
+ add = 0;
20
+ for (i = 0; i < 10; i ++)
21
+ add += parseInt(cpf.charAt(i)) * (11 - i);
22
+ rev = 11 - (add % 11);
23
+ if (rev == 10 || rev == 11)
24
+ rev = 0;
25
+ if (rev != parseInt(cpf.charAt(10)))
26
+ valid = false;
27
+
28
+ if(valid) {
29
+ return true;
30
+ }
31
+
32
+ if (cpf.length >= 14) {
33
+ if ( cpf.substring(12,14) == checkCNPJ( cpf.substring(0,12) ) ) {
34
+ return true;
35
+ }
36
+ }
37
+
38
+ return false;
39
+ }
40
+
41
+ function checkCNPJ(vCNPJ) {
42
+ var mControle = "";
43
+ var aTabCNPJ = new Array(5,4,3,2,9,8,7,6,5,4,3,2);
44
+ for (i = 1 ; i <= 2 ; i++) {
45
+ mSoma = 0;
46
+ for (j = 0 ; j < vCNPJ.length ; j++)
47
+ mSoma = mSoma + (vCNPJ.substring(j,j+1) * aTabCNPJ[j]);
48
+ if (i == 2 ) mSoma = mSoma + ( 2 * mDigito );
49
+ mDigito = ( mSoma * 10 ) % 11;
50
+ if (mDigito == 10 ) mDigito = 0;
51
+ mControle1 = mControle ;
52
+ mControle = mDigito;
53
+ aTabCNPJ = new Array(6,5,4,3,2,9,8,7,6,5,4,3);
54
+ }
55
+
56
+ return( (mControle1 * 10) + mControle );
57
+ }
58
+
59
+ Number.prototype.formatMoney = function(decPlaces, thouSeparator, decSeparator) {
60
+ var n = this,
61
+ decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
62
+ decSeparator = decSeparator == undefined ? "." : decSeparator,
63
+ thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
64
+ sign = n < 0 ? "-" : "",
65
+ i = parseFloat(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
66
+ j = (j = i.length) > 3 ? j % 3 : 0;
67
+ return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
68
+ };
69
+
70
+ function remove_characters(event) {
71
+ /* Allow: backspace, delete, tab, escape, and enter */
72
+ if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
73
+ /* Allow: Ctrl+A */
74
+ (event.keyCode == 65 && event.ctrlKey === true) ||
75
+ /* Allow: home, end, left, right */
76
+ (event.keyCode >= 35 && event.keyCode <= 39)) {
77
+ /* let it happen, don't do anything */
78
+ return;
79
+ } else {
80
+ /* Ensure that it is a number and stop the keypress */
81
+ if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
82
+ event.preventDefault();
83
+ }
84
+ }
85
+ }
86
+
87
+ function selectCredcard(ele){
88
+ var check = checkCredcardType(ele.value);
89
+
90
+ ele.up(2).previous().select('.cc_brand_types').each(function(el) {
91
+ el.removeClassName('active');
92
+ });
93
+
94
+ var id = ele.id;
95
+
96
+ var realId = id
97
+ .replace('mundipagg_creditcard','')
98
+ .replace('mundipagg_twocreditcards_','')
99
+ .replace('mundipagg_threecreditcards_','')
100
+ .replace('mundipagg_fourcreditcards_','')
101
+ .replace('mundipagg_fivecreditcards_','')
102
+ .replace('_cc_number','');
103
+
104
+ var cardType = id.replace('mundipagg_','').replace('_cc_number','').replace('_'+realId,'');
105
+
106
+ if(check){
107
+ var parentElement = ele.up(2).previous().select('li');
108
+
109
+ parentElement.each(function(element){
110
+ var inpt = element.select('input')[0];
111
+
112
+ if( inpt.value == check){
113
+ inpt.click();
114
+ inpt.previous().addClassName('active');
115
+
116
+ if(window.isInstallmentsEnabled) {
117
+ if (window[realId] != check) {
118
+ window[realId] = check;
119
+ window['brand_' + realId] = check;
120
+
121
+ selects = ele.up(3).select('select');
122
+ selects.each(function (select) {
123
+ if (select.name.indexOf('parcelamento') != -1) {
124
+ installmentElement = select;
125
+ }
126
+ });
127
+
128
+ if (window['installmentElement'] != undefined) {
129
+ window['select_html_' + realId] = installmentElement.innerHTML;
130
+ window['select_' + realId] = installmentElement;
131
+
132
+ if ($('mundipagg_' + cardType + '_new_value_' + realId) != undefined) {
133
+ if ($('mundipagg_' + cardType + '_new_value_' + realId).value == '') {
134
+ updateInstallments(check, installmentElement);
135
+ } else {
136
+ updateInstallments(check, installmentElement, $('mundipagg_' + cardType + '_new_value_' + realId).value);
137
+ }
138
+ } else {
139
+ updateInstallments(check, installmentElement);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ });
146
+ }else{
147
+ if (window[realId] != undefined) {
148
+ window[realId] = undefined;
149
+ if ($('mundipagg_'+cardType+'_new_value_' + realId) != undefined) {
150
+ totalValue = $('mundipagg_'+cardType+'_new_value_' + realId).value;
151
+ } else {
152
+ totalValue = '';
153
+ }
154
+ if (window['select_' + realId] != undefined && totalValue == '') {
155
+ window['select_' + realId].innerHTML = window['select_html_' + realId];
156
+ } else {
157
+ if (window.installmentElement !== undefined) {
158
+ updateInstallments(0, installmentElement, $('mundipagg_'+cardType+'_new_value_' + realId).value);
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Javascript method based on helper Mundipagg: https://github.com/mundipagg/mundipagg-one-php/blob/master/lib/One/Helper/CreditCardHelper.php
167
+ *
168
+ * @param string cardNumber Número do cartão
169
+ * @return string Bandeira do cartão
170
+ */
171
+ function checkCredcardType(cardNumber){
172
+ var flag = false;
173
+ /* Extrai somente números do cartão (Note: Not only draw numbers, letters as well).*/
174
+ cardNumber = cardNumber.toString().replace(/[^0-9a-zA-Z ]/g,'');
175
+
176
+ if(inArray(cardNumber.substring(0,6),['401178','401179', '504175', '509002', '509003', '438935', '457631',
177
+ '451416', '457632', '431274', '438935', '451416', '457393', '457631', '457632', '504175', '506726',
178
+ '506727', '506739', '506741', '506742', '506744', '506747', '506748', '506778', '627780', '636297',
179
+ '636368', '636369', '636297', '637095']) ||
180
+ isBetween(cardNumber.substring(0,6), '650031', '650033') ||
181
+ isBetween(cardNumber.substring(0,6), '650035', '650051') ||
182
+ isBetween(cardNumber.substring(0,6), '650405', '650439') ||
183
+ isBetween(cardNumber.substring(0,6), '650485', '650538') ||
184
+ isBetween(cardNumber.substring(0,6), '650541', '650598') ||
185
+ isBetween(cardNumber.substring(0,6), '650700', '650718') ||
186
+ isBetween(cardNumber.substring(0,6), '650720', '650727') ||
187
+ isBetween(cardNumber.substring(0,6), '650901', '650920') ||
188
+ isBetween(cardNumber.substring(0,6), '506699', '506778') ||
189
+ isBetween(cardNumber.substring(0,6), '651652', '651679') ||
190
+ isBetween(cardNumber.substring(0,6), '509000', '509999') ||
191
+ isBetween(cardNumber.substring(0,6), '655000', '655019') ||
192
+ isBetween(cardNumber.substring(0,6), '655021', '655058')
193
+ ){
194
+ flag = 'EL';
195
+ }
196
+ else if(cardNumber.substring(0,4) == '6011' || cardNumber.substring(0,3) == '622' || inArray(cardNumber.substring(0,2), ['64', '65'])){
197
+ /* Flag not implemented in the module yet.*/
198
+ flag = 'discover';
199
+ }
200
+ else if(inArray(cardNumber.substring(0,3), ['301', '305']) || inArray(cardNumber.substring(0,2),['36', '38'])){
201
+ flag = 'DI';
202
+ }
203
+ else if(inArray(cardNumber.substring(0,2), ['34', '37'])){
204
+ flag = 'AE';
205
+ }
206
+ else if(cardNumber.substring(0,2) == '50'){
207
+ /* Flag not implemented in the module yet.*/
208
+ flag = 'aura';
209
+ }
210
+ else if(inArray(cardNumber.substring(0,2),['38', '60'])){
211
+ flag = 'HI';
212
+ }
213
+ else if(cardNumber[0] == '4'){
214
+ flag = 'VI';
215
+ }
216
+ else if(cardNumber[0] == '5'){
217
+ flag = 'MC';
218
+ }
219
+
220
+ return flag;
221
+ }
222
+
223
+ /**
224
+ * Javascript method inArray equivalent PHP
225
+ */
226
+ function inArray(neddle, arraySearch){
227
+ return arraySearch.filter(function(item){return item == neddle;}).length;
228
+ }
229
+
230
+ function isBetween(neddle, first, last)
231
+ {
232
+ return (neddle >= first && neddle <= last);
233
+ }
234
+
235
+ function updateInstallments(ccType, element ,total) {
236
+ if(window['admin_area_url'] == undefined) {
237
+ var url = window.installmentsandinterestUrl;
238
+ } else {
239
+ var url = window['admin_area_url_installments_and_interest'];
240
+ }
241
+
242
+ /* Force select */
243
+ document.getElementById(element.id).selectedIndex = element.value - 1;
244
+
245
+ /* Get actual parcel */
246
+ var parcel = element.value;
247
+
248
+ if(!total) {
249
+ total = $('baseGrandTotal').value;
250
+ }
251
+
252
+ if(window.ajax_loader_mundipagg_img != undefined) {
253
+ mundipagg_img = window.ajax_loader_mundipagg_img;
254
+ } else {
255
+ mundipagg_img = window.ajaxLoaderGif;
256
+ }
257
+
258
+ loading = new Element('img', {src:mundipagg_img});
259
+ loading.addClassName('mundipagg_reload');
260
+
261
+ element.insert({
262
+ 'after':loading
263
+ });
264
+
265
+ element.options.length = 0;
266
+
267
+ var id = element.id.replace('_new_credito_parcelamento','')+'_cc_number';
268
+
269
+ new Ajax.Request(url,{
270
+ method:'post',
271
+ parameters:{cctype:ccType,total:total},
272
+ onSuccess:function(response) {
273
+ var res = JSON.parse(response.responseText);
274
+
275
+ if(res['installments'] != undefined) {
276
+ i=0;
277
+
278
+ if(res.installments.length == 1) {
279
+ element.options[0] = new Option(res.installments[0],0,false,false);
280
+ } else {
281
+ for(key in res.installments) {
282
+ if(/^-?[\d.]+(?:e-?\d+)?$/.test(key)) {
283
+ /* Set option as selected */
284
+ if(key == parcel) {
285
+ var selected = true;
286
+ } else {
287
+ var selected = false;
288
+ }
289
+
290
+ element.options[i] = new Option(res.installments[key],key,selected,false);
291
+
292
+ /* Select option */
293
+ if(key == parcel) {
294
+ document.getElementById(element.id).selectedIndex = key - 1;
295
+ }
296
+
297
+ i++;
298
+ }
299
+ }
300
+ }
301
+
302
+ if(res['brand'] != undefined) {
303
+ window['brand_' + id.replace('mundipagg_twocreditcards_', '').replace('_cc_number', '')] = res.brand;
304
+ }
305
+ } else {
306
+ window['select_'+id].innerHTML = window['select_html_'+id];
307
+ window['brand_'+id.replace('mundipagg_twocreditcards_','').replace('_cc_number','')] = undefined;
308
+ }
309
+
310
+ $$('.mundipagg_reload')[0].remove();
311
+
312
+ if($('order-billing_method') != undefined) {
313
+ var data = {};
314
+ this.loadArea(['totals'], true, data);
315
+ }
316
+ }
317
+ });
318
+ }
319
+
320
+ function remove_special_characters(event) {
321
+ /* Allow: backspace, delete, tab, escape, comma, enter and decimal point */
322
+ if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 188 || event.keyCode == 13 || event.keyCode == 110 ||
323
+ /* Allow: Ctrl+A */
324
+ (event.keyCode == 65 && event.ctrlKey === true) ||
325
+ /* Allow: home, end, left, right */
326
+ (event.keyCode >= 35 && event.keyCode <= 39)) {
327
+ /* let it happen, don't do anything */
328
+ return;
329
+ } else {
330
+ /* Ensure that it is a number and stop the keypress */
331
+ if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
332
+ event.preventDefault();
333
+ }
334
+ }
335
+ }
336
+
337
+ if(Validation) {
338
+ Validation.add('validar_cpf', 'The taxvat is invalid', function(v){return validaCPF(v,0);});
339
+
340
+ /**
341
+ * Hash with credit card types which can be simply extended in payment modules
342
+ * 0 - regexp for card number
343
+ * 1 - regexp for cvn
344
+ * 2 - check or not credit card number trough Luhn algorithm by
345
+ * function validateCreditCard which you can find above in this file
346
+ */
347
+ Validation.creditCartTypes = $H({
348
+ 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
349
+ 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
350
+ 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
351
+ 'DI': [false, new RegExp('^[0-9]{3}$'), true],
352
+ 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false],
353
+ 'EL': [false, new RegExp('^([0-9]{3})?$'), true],
354
+ 'HI': [false, new RegExp('^([0-9]{3})?$'), false]
355
+ });
356
+
357
+ Validation.add('check_values', 'Check the values to pass on each card', function(){return check_values();});
358
+
359
+ Validation.add('validate-cc-exp-cus', 'Expiration date of the incorrect card', function(v,elm){return verify_cc_expiration_date(v,elm);});
360
+ }
361
+
362
+ function verify_cc_expiration_date(v,elm) {
363
+ var ccExpMonth = v;
364
+ var ccExpYear = $(elm.id.substr(0,elm.id.indexOf('_expirationMonth')) + '_expirationYear').value;
365
+ var currentTime = new Date();
366
+ var currentMonth = currentTime.getMonth() + 1;
367
+ var currentYear = currentTime.getFullYear();
368
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
369
+ return false;
370
+ }
371
+ return true;
372
+ }
373
+
374
+ function token_or_not(num,c,field) {
375
+ var type = $$('input[name="payment\\[method\\]"]:checked').first().value;
376
+
377
+ if( document.getElementById(type+'_token_'+num+'_'+c).value == 'new' ) {
378
+ /* Remove disable fields */
379
+ $(type+'_'+num+'_'+c+'_cc_type').enable();
380
+ $(type+'_'+num+'_'+c+'_cc_number').enable();
381
+ $(type+'_cc_holder_name_'+num+'_'+c).enable();
382
+ $(type+'_expirationMonth_'+num+'_'+c).enable();
383
+ $(type+'_expirationYear_'+num+'_'+c).enable();
384
+ $(type+'_cc_cid_'+num+'_'+c).enable();
385
+
386
+ if(document.getElementById(type+'_new_credito_parcelamento_'+num+'_'+c)!= null) {
387
+ $(type+'_new_credito_parcelamento_'+num+'_'+c).enable();
388
+ }
389
+
390
+ if(document.getElementById(type+'_new_value_'+num+'_'+c)!= null) {
391
+ $(type+'_new_value_'+num+'_'+c).enable();
392
+ }
393
+
394
+ /* Show new credit card fields */
395
+ $(type+'_new_credit_card_'+num+'_'+c).show();
396
+
397
+ if($('parcelamento_'+num+'_'+c) != null) {
398
+ $('parcelamento_' + num + '_' + c).hide();
399
+ }
400
+ if(document.getElementById('value_'+num+'_'+c)!= null) {
401
+ $('value_'+num+'_'+c).hide();
402
+ }
403
+ } else {
404
+ /* Disable fields */
405
+ $(type+'_'+num+'_'+c+'_cc_type').disable();
406
+ $(type+'_'+num+'_'+c+'_cc_number').disable();
407
+ $(type+'_cc_holder_name_'+num+'_'+c).disable();
408
+ $(type+'_expirationMonth_'+num+'_'+c).disable();
409
+ $(type+'_expirationYear_'+num+'_'+c).disable();
410
+ $(type+'_cc_cid_'+num+'_'+c).disable();
411
+
412
+ if(document.getElementById(type+'_new_credito_parcelamento_'+num+'_'+c)!= null) {
413
+ $(type+'_new_credito_parcelamento_'+num+'_'+c).disable();
414
+ }
415
+
416
+ if(document.getElementById(type+'_new_value_'+num+'_'+c)!= null) {
417
+ $(type+'_new_value_'+num+'_'+c).disable();
418
+ }
419
+
420
+ /* Hide new credit card fields */
421
+ $(type+'_new_credit_card_'+num+'_'+c).hide();
422
+
423
+ if($('parcelamento_'+num+'_'+c) != null) {
424
+ $('parcelamento_' + num + '_' + c).show();
425
+ }
426
+
427
+ if(document.getElementById('value_'+num+'_'+c)!= null) {
428
+ $('value_'+num+'_'+c).show();
429
+ }
430
+ group = '.'+field.readAttribute('data');
431
+
432
+ field.select('option').each(function(opt){
433
+ if(opt.value == field.value){
434
+ if(opt.readAttribute('data')){
435
+ grandTotal = 0;
436
+
437
+ fieldValue = field.up(3).select(group+'.check_values')[0];
438
+ if(fieldValue != undefined) {
439
+ grandTotal = fieldValue.value;
440
+ }
441
+ if(field.up(3).select(group+'.installment-token')[0] != undefined) {
442
+ updateInstallments(opt.readAttribute('data'), field.up(3).select(group + '.installment-token')[0], grandTotal);
443
+ }
444
+ }
445
+ }
446
+ });
447
+ }
448
+ }
449
+
450
+ function cc_cid(field, num, c) {
451
+ var type = $$('input[name="payment\\[method\\]"]:checked').first().value;
452
+ var cc_cid = document.getElementById(type+'_cc_cid_'+num+'_'+c);
453
+
454
+ if(field.value == 'AE') {
455
+ cc_cid.removeClassName('minimum-length-3');
456
+ cc_cid.removeClassName('maximum-length-3');
457
+ cc_cid.addClassName('minimum-length-4');
458
+ cc_cid.addClassName('maximum-length-4');
459
+ } else {
460
+ cc_cid.removeClassName('minimum-length-4');
461
+ cc_cid.removeClassName('maximum-length-4');
462
+ cc_cid.addClassName('minimum-length-3');
463
+ cc_cid.addClassName('maximum-length-3');
464
+ }
465
+ }
466
+
467
+ function hide_methods(dont_hide) {
468
+ if(document.getElementById('1CreditCardsOneInstallment')!= null && dont_hide != '1CreditCardsOneInstallment'){
469
+ document.getElementById('1CreditCardsOneInstallment').style.display='none';
470
+ }
471
+
472
+ if(document.getElementById('1CreditCards')!= null && dont_hide != '1CreditCards'){
473
+ document.getElementById('1CreditCards').style.display='none';
474
+ }
475
+
476
+ if(document.getElementById('2CreditCards')!= null && dont_hide != '2CreditCards'){
477
+ document.getElementById('2CreditCards').style.display='none';
478
+ }
479
+
480
+ if(document.getElementById('3CreditCards')!= null && dont_hide != '3CreditCards'){
481
+ document.getElementById('3CreditCards').style.display='none';
482
+ }
483
+
484
+ if(document.getElementById('4CreditCards')!= null && dont_hide != '4CreditCards'){
485
+ document.getElementById('4CreditCards').style.display='none';
486
+ }
487
+
488
+ if(document.getElementById('5CreditCards')!= null && dont_hide != '5CreditCards'){
489
+ document.getElementById('5CreditCards').style.display='none';
490
+ }
491
+
492
+ if(document.getElementById('BoletoBancario')!= null && dont_hide != 'BoletoBancario'){
493
+ document.getElementById('BoletoBancario').style.display='none';
494
+ }
495
+
496
+ $(dont_hide).show();
497
+ }
498
+
499
+ function hide_methods_admin(dont_hide) {
500
+ if(document.getElementById('1CreditCardsOneInstallment')!= null && dont_hide != '1CreditCardsOneInstallment'){
501
+ document.getElementById('1CreditCardsOneInstallment').style.display='none';
502
+ }
503
+
504
+ if(document.getElementById('1CreditCards')!= null && dont_hide != '1CreditCards'){
505
+ document.getElementById('1CreditCards').style.display='none';
506
+ }
507
+
508
+ if(document.getElementById('2CreditCards')!= null && dont_hide != '2CreditCards'){
509
+ document.getElementById('2CreditCards').style.display='none';
510
+ }
511
+
512
+ if(document.getElementById('3CreditCards')!= null && dont_hide != '3CreditCards'){
513
+ document.getElementById('3CreditCards').style.display='none';
514
+ }
515
+
516
+ if(document.getElementById('4CreditCards')!= null && dont_hide != '4CreditCards'){
517
+ document.getElementById('4CreditCards').style.display='none';
518
+ }
519
+
520
+ if(document.getElementById('5CreditCards')!= null && dont_hide != '5CreditCards'){
521
+ document.getElementById('5CreditCards').style.display='none';
522
+ }
523
+
524
+ if(document.getElementById('BoletoBancario')!= null && dont_hide != 'BoletoBancario'){
525
+ document.getElementById('BoletoBancario').style.display='none';
526
+ }
527
+
528
+ $(dont_hide).show();
529
+ }
530
+
531
+ function calculateInstallmentValue(field, num, c, url) {
532
+ var type = $$('input[name="payment\\[method\\]"]:checked').first().value;
533
+
534
+ var total = $('baseGrandTotal').value;
535
+ if($('partial') != undefined){
536
+ total = String(quoteBaseGrandTotal);
537
+ }
538
+ var total_oc = parseFloat(total.replace(',','.'));
539
+ var field_id = type + '_credito_parcelamento_' + num + '_' + c;
540
+ var field_id_new = type + '_new_credito_parcelamento_' + num + '_' + c;
541
+ var rest = '';
542
+ var response = '';
543
+ var vfield = field.value;
544
+ var vfield_oc = parseFloat(vfield.replace(',', '.'));
545
+
546
+
547
+
548
+ if(vfield_oc >= total_oc) {
549
+ vfield_oc = total_oc - (total_oc - 0.01);
550
+ }
551
+
552
+ if(parseFloat(vfield_oc)) {
553
+ selects = field.up(3).select('select');
554
+
555
+ selects.each(function(select){
556
+ if(select.name.indexOf('parcelamento') != -1){
557
+ installmentElement = select;
558
+ }
559
+ });
560
+
561
+ var id = field.id;
562
+ var realId = id
563
+ .replace('mundipagg_creditcard','')
564
+ .replace('mundipagg_twocreditcards_','')
565
+ .replace('mundipagg_threecreditcards_','')
566
+ .replace('mundipagg_fourcreditcards_','')
567
+ .replace('mundipagg_fivecreditcards_','')
568
+ .replace('_cc_number','')
569
+ .replace('value_','');
570
+ window['brand_'+realId] = undefined;
571
+
572
+ if($('parcelamento_'+realId) != undefined){
573
+
574
+ installmentElement = $('parcelamento_'+realId).select('select')[0];
575
+ field.up(3).previous().select('.tokens')[0].select('option').each(function(opt){
576
+ if(opt.selected){
577
+ window['brand_'+realId] = opt.readAttribute('data');
578
+ }
579
+ });
580
+ }
581
+
582
+ var cardType = id.replace('mundipagg_','').replace('_cc_number','').replace('_'+realId,'');
583
+
584
+ if(window['installmentElement'] != undefined) {
585
+ window['select_html_' + realId] = installmentElement.innerHTML;
586
+ window['select_' + realId] = installmentElement;
587
+ if (window['brand_' + realId] != undefined) {
588
+ updateInstallments(window['brand_' + realId], installmentElement, vfield_oc);
589
+ } else {
590
+ var brand = field.up(3).select('.cc_brand_types.active')[0];
591
+ if (brand != undefined) {
592
+ window['brand_' + realId] = brand.next().value;
593
+ updateInstallments(window['brand_' + realId], installmentElement, vfield_oc);
594
+ } else {
595
+ updateInstallments(0, installmentElement, vfield_oc);
596
+ }
597
+
598
+ }
599
+ }
600
+
601
+ /* If more than 2 decimals we reduce to 2 */
602
+ $(field).value = (vfield_oc.toFixed(2)).replace('.',',');
603
+
604
+ /* If two Credit Cards we can deduct second credit card installments */
605
+ if(type == 'mundipagg_twocreditcards' && num == 2) {
606
+ new_value_oc = (total.replace(',', '.') - vfield_oc).toFixed(2);
607
+ new_value = String(new_value_oc).replace('.',',');
608
+
609
+ if(c != 2) {
610
+ if( typeof($$('#mundipagg_twocreditcards_value_2_2')[0]) != 'undefined') {
611
+ $$('#mundipagg_twocreditcards_value_2_2')[0].value = new_value;
612
+ }
613
+
614
+ $$('#mundipagg_twocreditcards_new_value_2_2')[0].value = new_value;
615
+ selects = $$('#mundipagg_twocreditcards_new_value_2_2')[0].up(3).select('select');
616
+ installmentElement = undefined;
617
+ selects.each(function(select){
618
+ if(select.name.indexOf('parcelamento') != -1){
619
+ installmentElement = select;
620
+ }
621
+ });
622
+ if($('parcelamento_2_2') != undefined && window['installmentElement'] == undefined){
623
+ installmentElement = $('parcelamento_2_2').select('select')[0];
624
+
625
+ }
626
+ if($('parcelamento_2_2') != undefined){
627
+ $('mundipagg_twocreditcards_token_2_2').select('option').each(function(opt){
628
+ if(opt.selected){
629
+ window['brand_2_2'] = opt.readAttribute('data');
630
+
631
+ }
632
+ });
633
+ }
634
+
635
+ if(window['installmentElement'] != undefined) {
636
+ window['select_html_2_2'] = installmentElement.innerHTML;
637
+ window['select_2_2'] = installmentElement;
638
+
639
+ if (window['brand_2_2'] != undefined) {
640
+ updateInstallments(window['brand_2_2'], installmentElement, new_value);
641
+
642
+ if ($('parcelamento_2_2') != undefined) {
643
+
644
+ updateInstallments(window['brand_2_2'], $('parcelamento_2_2').select('select')[0], new_value);
645
+ }
646
+ } else {
647
+
648
+ updateInstallments(0, installmentElement, new_value);
649
+ if ($('parcelamento_2_2') != undefined) {
650
+ updateInstallments(0, $('parcelamento_2_2').select('select')[0], new_value);
651
+ }
652
+ }
653
+ }
654
+ }
655
+
656
+ if(c != 1) {
657
+ if( typeof($$('#mundipagg_twocreditcards_value_2_1')[0]) != 'undefined') {
658
+ $$('#mundipagg_twocreditcards_value_2_1')[0].value = new_value;
659
+ }
660
+
661
+ $$('#mundipagg_twocreditcards_new_value_2_1')[0].value = new_value;
662
+ selects = $$('#mundipagg_twocreditcards_new_value_2_1')[0].up(3).select('select');
663
+ installmentElement = undefined;
664
+ selects.each(function(select){
665
+ if(select.name.indexOf('parcelamento') != -1){
666
+ installmentElement = select;
667
+ }
668
+ });
669
+
670
+ if($('parcelamento_2_1') != undefined && window['installmentElement'] == undefined){
671
+ installmentElement = $('parcelamento_2_1').select('select')[0];
672
+
673
+ }
674
+ if($('parcelamento_2_1') != undefined){
675
+ $('mundipagg_twocreditcards_token_2_1').select('option').each(function(opt){
676
+ if(opt.selected){
677
+ window['brand_2_1'] = opt.readAttribute('data');
678
+ }
679
+ });
680
+ }
681
+
682
+ if(window['installmentElement'] != undefined) {
683
+ window['select_html_2_1'] = installmentElement.innerHTML;
684
+ window['select_2_1'] = installmentElement;
685
+
686
+ if (window['brand_2_1'] != undefined) {
687
+ updateInstallments(window['brand_2_1'], installmentElement, new_value);
688
+ if ($('parcelamento_2_1') != undefined) {
689
+
690
+ updateInstallments(window['brand_2_1'], $('parcelamento_2_1').select('select')[0], new_value);
691
+ }
692
+ } else {
693
+ updateInstallments(0, installmentElement, new_value);
694
+ if ($('parcelamento_2_1') != undefined) {
695
+ updateInstallments(0, $('parcelamento_2_1').select('select')[0], new_value);
696
+ }
697
+ }
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+
704
+ function installments(field, field_new, num, c, val, url) {
705
+ if(!isNaN(parseFloat(val)) && isFinite(val) && val > 0) {
706
+ new Ajax.Request(url + 'mundipagg/standard/installments', {
707
+ method: 'post',
708
+ parameters: {val: val},
709
+ onSuccess: function(response) {
710
+ if (200 == response.status){
711
+ var result = eval("(" + response.responseText + ")");
712
+
713
+ var installments = result.qtdParcelasMax;
714
+ var currencySymbol = result.currencySymbol;
715
+
716
+ if(installments != null) {
717
+ if(document.getElementById(field) != null) {
718
+ document.getElementById(field).options.length = 0;
719
+ }
720
+
721
+ if(document.getElementById(field_new) != null) {
722
+ document.getElementById(field_new).options.length = 0;
723
+ }
724
+
725
+ for(var i = 1;i<=installments;i++) {
726
+ var amount = val / i;
727
+ amount = (amount.toFixed(2)).replace('.',',');
728
+
729
+ if(i == 1) {
730
+ var label = i + 'x de ' + currencySymbol + amount;
731
+ } else {
732
+ var label = i + 'x de ' + currencySymbol + amount + " sem juros";
733
+ }
734
+
735
+ if(document.getElementById(field) != null) {
736
+ $(field).options[$(field).options.length] = new Option(label, i);
737
+ }
738
+
739
+ if(document.getElementById(field_new) != null) {
740
+ $(field_new).options[$(field_new).options.length] = new Option(label, i);
741
+ }
742
+ }
743
+ } else {
744
+ if(document.getElementById(field) != null) {
745
+ document.getElementById(field).options.length = 0;
746
+ }
747
+ }
748
+ }
749
+ },
750
+ onFailure: function(response) {
751
+ alert('Por favor tente novamente!');
752
+ }
753
+ });
754
+ }
755
+ }
756
+
757
+ function check_values() {
758
+ var method = $$('input[name="payment\\[method\\]"]:checked').first().value;
759
+ var type = $$('#mundipagg_type:enabled')[0].value;
760
+ var num = type[0].substring(0, 1);
761
+ var total = ($('baseGrandTotal').value).replace(',','.');
762
+ var total_fields = 0.00;
763
+ var total_fields_new = 0.00;
764
+
765
+ for(var i=1;i<=num;i++){
766
+ if(document.getElementById(method+'_value_'+ num +'_'+ i) != null) {
767
+ var fieldv = ($(method+'_value_'+ num +'_'+ i).value).replace(',','.');
768
+
769
+ total_fields = parseFloat(fieldv) + parseFloat(total_fields);
770
+ }
771
+
772
+ if(document.getElementById(method+'_new_value_'+ num +'_'+ i) != null) {
773
+ var fieldv_new = ($(method+'_new_value_'+ num +'_'+ i).value).replace(',','.');
774
+
775
+ total_fields_new = parseFloat(fieldv_new) + parseFloat(total_fields_new);
776
+ }
777
+ }
778
+
779
+ if( (Math.abs(total - total_fields) < 0.000001) && (Math.abs(total - total_fields_new) < 0.000001) ) {
780
+ return false;
781
+ }
782
+
783
+ return true;
784
+ }
785
+
786
+ function setCcType(field, code, num, c, issuer)
787
+ {
788
+ $$('#' + code + '_' + num + '_' + c + '_cc_type')[0].value = issuer;
789
+ $(code + '_' + num + '_' + c + '_credito_instituicao_' + issuer).checked=true
790
+
791
+ field = $(code + '_' + num + '_' + c + '_credito_instituicao_' + issuer);
792
+
793
+ cc_cid(field, num, c)
794
+ }
795
+
796
+ function setTotalInterestHtml(field){
797
+ var container = field.up(5);
798
+ var totalFieldElement = container.select('div')[0];
799
+ var totalFieldValue = parseFloat(totalFieldElement.innerHTML.replace(/\s/g, "").replace('<b>ValorTotal:</b>','').replace('R$','').replace('.','').replace(',','.'));
800
+ var containerSelects = container.select('select');
801
+ var template = '<div class="total_juros">'+Translator.translate('Total amount with interest: USD{%%%}')+'</div>';
802
+ var totalInterest = 0;
803
+
804
+ containerSelects.each(function(select){
805
+ if(select.readAttribute('id').indexOf('credito_parcelamento') != -1){
806
+ if(window.getComputedStyle(select.up(3)).getPropertyValue('display') == 'block'){
807
+ var selectedText = select.options[select.selectedIndex].text;
808
+ if(selectedText.indexOf('Total') != -1){
809
+ realCurrentInterest = 0;
810
+ newTotalInterest = parseFloat(selectedText.substring(selectedText.indexOf('Total'), selectedText.length).replace('Total: R$','').replace(')','').replace(/\s/g, "").replace('.','').replace(',','.'));
811
+ if($(select.readAttribute('id').replace('credito_parcelamento','value')) != undefined) {
812
+ currentValueField = parseFloat($(select.readAttribute('id').replace('credito_parcelamento', 'value')).value.replace('.','').replace(',', '.'));
813
+ }else{
814
+ currentValueField = NaN;
815
+ }
816
+
817
+ if(!isNaN(currentValueField)){
818
+ realCurrentInterest = parseFloat(newTotalInterest - currentValueField );
819
+ totalInterest = parseFloat(totalInterest + parseFloat(realCurrentInterest));
820
+ }else{
821
+ realCurrentInterest = parseFloat(newTotalInterest - totalFieldValue);
822
+ totalInterest = parseFloat(totalInterest + parseFloat(realCurrentInterest));
823
+ }
824
+ }
825
+ }
826
+ }
827
+ });
828
+
829
+ if(Object.keys(totalFieldElement.select('.total_juros')).length){
830
+ totalFieldElement.select('.total_juros')[0].remove();
831
+ }
832
+
833
+ if(totalInterest > 0){
834
+ var strNumber = parseFloat(totalFieldValue + totalInterest).toFixed(2);
835
+ while (strNumber.match(/^\d{4}/)){
836
+ strNumber = strNumber.replace(/(\d)(\d{3}(\.|$))/, '$1.$2');
837
+ }
838
+ strNumber = strNumber.substring(0,parseInt(strNumber.length - 3))+','+strNumber.substring(parseInt(strNumber.length - 2), strNumber.length);
839
+ totalFieldElement.insert(template.replace('{%%%}',strNumber));
840
+ }
841
+ }
842
+
843
+ function checkInstallments(field, url)
844
+ {
845
+ if ($('onestepcheckout-form') == null) {
846
+ params = $('co-payment-form').serialize(true);
847
+ } else {
848
+ params = $('onestepcheckout-form').serialize(true);
849
+ }
850
+
851
+ if(window['mundipaggTotalInterest'] == undefined) {
852
+ window.mundipaggTotalInterest = 0;
853
+ }
854
+
855
+ setTotalInterestHtml(field);
856
+
857
+ new Ajax.Request(url + 'checkout/onepage/savePayment', {
858
+ method: 'post',
859
+ parameters: params,
860
+ onSuccess: function(response) {
861
+ if (200 == response.status){
862
+ var result = eval("(" + response.responseText + ")");
863
+ }
864
+ },
865
+ onFailure: function(response) {
866
+ console.log('failed');
867
+ },
868
+ onComplete: function(response) {
869
+
870
+ }
871
+ });
872
+ }
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Mundipagg_Integracao</name>
4
+ <version>2.6.1</version>
5
+ <stability>stable</stability>
6
+ <license>MIT</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>M&#xF3;dulo para integra&#xE7;&#xE3;o com o gateway de pagamentos MundiPagg.&#xD;
10
+ &#xD;
11
+ Mundipagg payment gateway integration.</summary>
12
+ <description>Com esta extens&#xE3;o voc&#xEA; poder&#xE1; integrar sua loja Magento com o gateway de pagamentos MundiPagg.&#xD;
13
+ &#xD;
14
+ With this extension you can process payments through brazilian payment gateway Mundipagg</description>
15
+ <notes>Hotfix on 2.6.0 migration</notes>
16
+ <authors><author><name>MundiPagg</name><user>MundiPagg</user><email>mundi@mundipagg.com</email></author></authors>
17
+ <date>2016-07-07</date>
18
+ <time>20:11:31</time>
19
+ <contents><target name="magecommunity"><dir name="Uecommerce"><dir name="Mundipagg"><dir name="Block"><dir name="Adminhtml"><dir name="Form"><dir name="Field"><file name="Installments.php" hash="ec8343e197cb194d978400bbdf64d446"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="2140a7836eaa57e03727433ccddf93d6"/></dir><dir name="Invoice"><file name="Totals.php" hash="ee304d9034ae0763e5db464f933b8c27"/><file name="View.php" hash="b0e3c170cd0184a5dfbe4fa7a486b471"/></dir><file name="Totals.php" hash="71b20a4c0022c14a5f7f8d008aabe1da"/></dir><dir name="Transactions"><dir name="Detail"><file name="Grid.php" hash="d67911c431587e4327eec95540cf548a"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="aa40a974b89c92ea9652c42e093d16f9"/></dir></dir></dir><file name="Version.php" hash="e3a89823e48e7a526a3afe8ce8c0d0ee"/></dir><dir name="Checkout"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="c903e413c47e3dea87ec09d609543a27"/></dir></dir></dir><file name="Info.php" hash="c5743b8887caffc12ee2b502d7256101"/><file name="Parcelamento.php" hash="bbfad3557dd7c29e2a21a213cf915e0c"/><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="be3e89b0e2f008fcc0293286d44df7da"/></dir><dir name="Invoice"><file name="Totals.php" hash="a39c41f45ef44b72d15cfd12fea4e9c6"/></dir><file name="Totals.php" hash="6f56aa360f48c715b30afd4e5cd4ddfa"/></dir></dir><dir name="Standard"><file name="Boleto.php" hash="4471015b8a82311f84e52e774460bf38"/><file name="Cancel.php" hash="095eaf31c6567fad440279aeb2994caa"/><file name="Debit.php" hash="c707d9572b6079457b9265cc09c920c6"/><file name="Fcancel.php" hash="4bc5b0fb68fb7fd11159788eafe958af"/><file name="Form.php" hash="0f7f97654c5e819ac178e5d888fae6ee"/><file name="Partial.php" hash="fb5877a8f6c56ac1d6fc48eb864d8e60"/><file name="Redirect.php" hash="70f576c8d64c25e3ce627f6c36b2ff41"/><file name="Success.php" hash="f5825fcb7a4d75cc0dfd3d448e48e905"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="91d5069c18069fcb2a0a436fb768a194"/></dir><dir name="Helper"><file name="Data.php" hash="230133453d65c7e7a7681ba095e5942c"/><file name="Installments.php" hash="3d34c4b9432d09a99e13c7f6b3f657ae"/><file name="Log.php" hash="a95575e22743a7b823ec3f088844f18f"/><file name="Util.php" hash="8d76ffdc3e7ace2598d373f1aef20228"/><file name="Version.php" hash="00066d5bf31a7c49db004f2bd0d5c462"/></dir><dir name="Model"><file name="Api.php" hash="f709ee240d281c5beff792b81cebb7fa"/><file name="Boleto.php" hash="a7da1d58eb0fccb53eae51ba97d93dc5"/><file name="Cardonfile.php" hash="98395928a16313f8b4127e4e210cf953"/><file name="Creditcard.php" hash="007a43e7530ea5471b6a9aaa5405ce21"/><file name="Creditcardoneinstallment.php" hash="2e4222fd04dbc4f5ee116d4d7f4eae04"/><dir name="Customer"><file name="Session.php" hash="7f15498648de23cf4feb5143071ec260"/></dir><file name="Customers.php" hash="a779e96a969b83d1b38df351eb4670d0"/><file name="Debit.php" hash="8a3387bf74b1f03b9614fbdb64ab9dd5"/><file name="Fivecreditcards.php" hash="6975e6170345bb3f20fde79ae40b81fe"/><file name="Fourcreditcards.php" hash="2da3d901173c19e53a96adb197b1533a"/><file name="Observer.php" hash="5fb123fe9bd7ee7593bc38984a3d3ae0"/><file name="Offlineretry.php" hash="394849df4873908dd43d3c15f75dc9d0"/><dir name="Order"><dir name="Invoice"><file name="Interest.php" hash="6bba5e87bae1a7ee94a827819b2ea4ce"/></dir></dir><file name="Providervalidation.php" hash="4906944bae20e3f683d6e5c4ba5304e3"/><dir name="Quote"><dir name="Address"><file name="Interest.php" hash="93aa0189a8556597697dbb239dbf3be7"/></dir></dir><file name="Recurrency.php" hash="76bb429ac4c849e27c8fabdd96bb9654"/><dir name="Resource"><dir name="Cardonfile"><file name="Collection.php" hash="7b7d13bc6d7be8e5e1c5f945d59117f6"/></dir><file name="Cardonfile.php" hash="47d0107a9b1c3415aaf8784298361e84"/><dir name="Customers"><file name="Collection.php" hash="6caadd817abbcda527ba6d102585f2ff"/></dir><file name="Customers.php" hash="f50289a4c8362ddf7a79e4aa7c8a6387"/><dir name="Offlineretry"><file name="Collection.php" hash="80f0689c66a30110e68c2fdafb3014a8"/></dir><file name="Offlineretry.php" hash="08c804fd3b001f4f3ac19ebbcfca59fb"/><file name="Setup.php" hash="42bda31d8497e1b0983775e17f7325a5"/></dir><dir name="Source"><file name="Antifraud.php" hash="8362e0bb2209bbf904a7f9b2edd59cee"/><file name="Banks.php" hash="b5d456a807cdf750a6458144e955cf2c"/><file name="CctypeProductInstallments.php" hash="7837f6865c905ba8f5393d080ebc1b3d"/><file name="Cctypes.php" hash="b55eb988a6a09f24b1088f15644961d0"/><file name="Debit.php" hash="9366bc3b900cf96ad5d2bce7e8d93ba7"/><file name="Environment.php" hash="099a28ea462481333437a6479276e8b0"/><file name="FControlEnvironment.php" hash="5159f6e4d86ee9d280285b7198fa01e9"/><file name="Frequency.php" hash="7864991042d0ec3fd5920d9047127b14"/><file name="Installments.php" hash="b04c05b92f7b8b5c025f23aad4457917"/><file name="PaymentAction.php" hash="c16639be23fd85c285f474922fd528a7"/><file name="PaymentMethods.php" hash="e12514ad00bf3fe3fb4e569b11da2c10"/></dir><file name="Standard.php" hash="f1c096a26841a0d05cc20926742e5c71"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Installments.php" hash="f0901bf05acd0b2c3fda41965f949583"/></dir></dir></dir><file name="Threecreditcards.php" hash="73fcdc4ef1dd38128b60454f90184ff5"/><file name="Twocreditcards.php" hash="c010f631d556a08d2d1aa65dc6b60703"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Test"><dir name="Selenium"><file name="Abstract.php" hash="caf0cd5ca47b13fb00be4230d1bb9132"/><file name="BoletoTest.php" hash="0718dc551376686dc6daaa3b57ddd1f9"/><dir name="CcTypes"><file name="CreditcardTest.php" hash="fde35369e57eb70f29f8defe1d7f06af"/><file name="CreditcardoneinstallmentTest.php" hash="cabcf9a3f56497e32679c1d2d063a6d7"/><file name="FivecreditcardsTest.php" hash="a903b89e20b9e754df7ed22dc9e8eecf"/><file name="FourcheditcardsTest.php" hash="3619a03b24af1a768cbc87be430b4323"/><file name="ThreecreditcardsTest.php" hash="d59c7b8a7de6320cff170e435fbe6e9e"/><file name="TwocreditcardsTest.php" hash="58db59f790aa7c65a324e6a552c2e05c"/></dir><file name="CcTypes.php" hash="de1d2e73a74e4b9fcde14adce60c0f82"/><file name="DebitTest.php" hash="1409a8f2de15e13792dcba2099a887cc"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="e5a51c9660f704bcbfb302d34493a5a6"/></dir><file name="ClearsaleController.php" hash="bc06365f0d577d66228d9f0c3e471089"/><file name="FcontrolController.php" hash="1af534f1cdadbfdbe702aed12c7a2e1d"/><file name="StandardController.php" hash="820a847ecc074f2d89addcb0e0960cfb"/><file name="StoneController.php" hash="80c6f59a868ac82fc22bcf586bbecfdd"/></dir><dir name="etc"><file name="config.xml" hash="0f3e292fb16614b12b9674691ca4eaaf"/><file name="jstranslator.xml" hash="8b1ea10d9b3072a795567dba6dae938c"/><file name="system.xml" hash="729b8fe191793b7422d974e10f173992"/><file name="wsdl.xml" hash="a59b87019a8bdb03d97191e2d06be325"/><file name="xtest.xml" hash="b34ee3b6e37a890b73374b5ea3a1c40f"/></dir><dir name="sql"><dir name="mundipagg_setup"><file name="install-0.3.0.php" hash="ede73bb07d71fec55340c4249ff4a258"/><file name="mysql4-upgrade-0.3.0-0.3.5.php" hash="d3c200cce4a814feaa0858c0c8abd928"/><file name="mysql4-upgrade-0.3.5-0.4.0.php" hash="297f1b37b7703f7a0d621d227c8cbeb9"/><file name="mysql4-upgrade-0.3.5-1.0.1.php" hash="d22a0a81e392885433ca58dc196c2a86"/><file name="mysql4-upgrade-0.4.0-1.0.1.php" hash="297f1b37b7703f7a0d621d227c8cbeb9"/><file name="mysql4-upgrade-0.4.1-0.4.2.php" hash="4a2962a1eb974c75e153f48cc77f00d4"/><file name="mysql4-upgrade-0.4.1-1.0.1.php" hash="d22a0a81e392885433ca58dc196c2a86"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="297f1b37b7703f7a0d621d227c8cbeb9"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.10-1.0.11.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.11-2.0.0.php" hash="83c95c6060bb8678be3b8944a6823fd9"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-1.0.9-1.0.10.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.0-2.0.1.php" hash="a437df63647a52381ed5e056ccbb0cff"/><file name="mysql4-upgrade-2.0.0-2.1.0.php" hash="30dc2c3c763893d3bac6b9fde0c56477"/><file name="mysql4-upgrade-2.0.1-2.0.2.php" hash="4959ae51e69913d8ac642bc2ab848464"/><file name="mysql4-upgrade-2.0.2-2.0.3.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.3-2.0.4.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.4-2.0.5.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.5-2.0.6.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.6-2.0.7.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.7-2.0.8.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.8-2.0.9.php" hash="4c18b9eb1e0a08d858dde48280eed2c0"/><file name="mysql4-upgrade-2.0.9-2.1.0.php" hash="3488f42f3d9e6a57ce4176c0a7954171"/><file name="mysql4-upgrade-2.1.2-2.1.3.php" hash="7d7823cb555a32295d179a96e2bf987a"/><file name="mysql4-upgrade-2.5.7-2.5.8.php" hash="45c4f1fd5336b7ce578c672e8f1d57b0"/><file name="mysql4-upgrade-2.5.8-2.6.0.php" hash="bf06e3d6ab5fa0c89629385db4231006"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mundipagg.xml" hash="b6677c25d67015f895a72afbca87041c"/></dir><dir name="template"><dir name="mundipagg"><file name="boleto.phtml" hash="11cc5b254644727d6bdded8a834965c7"/><file name="form.phtml" hash="566e1838cab471ce41a1f74156e3b3bf"/><dir name="payment"><dir name="info"><file name="mundipagg.phtml" hash="608c6f547291d4d2d703615784f44403"/></dir><file name=".DS_Store" hash="26750fda0756757b7494103fb2069171"/></dir><dir name="system"><dir name="config"><file name="button.phtml" hash="6a7f6c88cf156d31d34a818ac37bd158"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mundipagg.xml" hash="c2ebd0374a3c6a6a4d8c3db84c8abf5a"/></dir><dir name="template"><dir name="mundipagg"><dir name="antifraud"><file name="clearsale.phtml" hash="088a189dd94401f39c90ad0a1471994f"/><file name="fcontrol.phtml" hash="b5c72881ec073a618fefd48fb3a46ebd"/><file name="stone.phtml" hash="681ddf22694c725bb6e84e79681936fa"/></dir><file name="boleto.phtml" hash="dc31735a2753812d36e3080bf5b01ac2"/><file name="cancel.phtml" hash="540639b1ccd698397286f668bbf23746"/><file name="debit.phtml" hash="78f60f0227e99ff0c1d7dbf6bd5aa202"/><file name="extras.phtml" hash="f3eba84e971e890922141d90f6bdd53f"/><file name="fcancel.phtml" hash="9ce1d7634acf519669e21978b41aa277"/><file name="form.phtml" hash="faff82dad9768f016f81648aa8b9b800"/><file name="parcelamento.phtml" hash="56a89503637e5ad753b0d410f2f5c7ad"/><file name="partial.phtml" hash="6f01f6950ca176748939559e0e4ec487"/><dir name="payment"><dir name="info"><file name="mundipagg.phtml" hash="c110a21db08013d38add1b79977350e4"/></dir></dir><file name="redirect.phtml" hash="a8a1123eab776934c64f57b4f9cfd517"/><file name="success.phtml" hash="dfb9bd58a4614bfd6317bc98b2a68c8f"/><file name="totals.phtml" hash="5a78aa3fe60d4b13bf8451f23bb9edd9"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="template"><dir name="mundipagg"><file name="debit.phtml" hash="4d2ae58447d3893499556ae068f800f8"/><file name="form.phtml" hash="dd83f04f33982e17fdea1713a3eb1b3a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Uecommerce_Mundipagg.xml" hash="b292eeabde8e2cd06db0c31aff54fd98"/></dir></target><target name="mage"><dir name="js"><dir name="uecommerce"><file name="mundipagg.js" hash="c887a21c210250da640bafce773e43ab"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="mundipagg"><file name="ajax-loader.gif" hash="7b9776076d5fceef4993b55c9383dedd"/><file name="boleto.jpg" hash="237570c55c811b4b13f73ab92f28e599"/><file name="mundipagg-avatar-blue.png" hash="9e81f9c54ac7ce3de570d7065f4b4c07"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="mundipagg.css" hash="90c32001f3a9b858c9506f5135c04972"/></dir><dir name="images"><dir name="mundipagg"><file name="001.png" hash="25d10d6fee7fc3e5dc48021a15de8fb0"/><file name="237.png" hash="cbea9caff342edd9b9b9509bbbbae6fb"/><file name="341.png" hash="3645161fc56322ec34ebfcc006390e5d"/><file name="AE.png" hash="40ea216476033961d50f452bf4bca4df"/><file name="DI.png" hash="0f4264379e7b8ba6b1a30a3d69240ae2"/><file name="EL.png" hash="ad180c308d285f73fc044121cb6aeac0"/><file name="HI.png" hash="c25430ddd8e441cc2fc3ef68219e7668"/><file name="MC.png" hash="836466c092121163320e9e6279f11f8b"/><file name="VBV.jpg" hash="1a7db765956829e80715a299b799f580"/><file name="VBV.png" hash="d6fb7de65fda842f03e2b9fc89d5e6aa"/><file name="VI.png" hash="cc0709d50773fa2815f7bfeb741a4219"/><file name="ajax-loader.gif" hash="7b9776076d5fceef4993b55c9383dedd"/><file name="boleto.jpg" hash="237570c55c811b4b13f73ab92f28e599"/><file name="cc_types.png" hash="fdae60f96ee668354161b5a865b8e7ef"/><file name="cielo_mastercard.png" hash="e2c2af12ea24f1b82490fdcc62fbb871"/><file name="cielo_visa.png" hash="d2f0c660714dc319b73c0dac9c9108d0"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="images"><dir name="mundipagg"><file name="EL.png" hash="ad180c308d285f73fc044121cb6aeac0"/><file name="HI.png" hash="c25430ddd8e441cc2fc3ef68219e7668"/><file name="ae.png" hash="40ea216476033961d50f452bf4bca4df"/><file name="boleto.jpg" hash="237570c55c811b4b13f73ab92f28e599"/><file name="cielo_mastercard.png" hash="e2c2af12ea24f1b82490fdcc62fbb871"/><file name="cielo_visa.png" hash="d2f0c660714dc319b73c0dac9c9108d0"/><file name="di.png" hash="0f4264379e7b8ba6b1a30a3d69240ae2"/><file name="mc.png" hash="836466c092121163320e9e6279f11f8b"/><file name="vi.png" hash="cc0709d50773fa2815f7bfeb741a4219"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Uecommerce_Mundipagg.csv" hash="ae581dc54ea4ada4a9a3c9f4c51f09c7"/></dir><dir name="pt_BR"><file name="Uecommerce_Mundipagg.csv" hash="a9e68878dcac2b008a7e46350952a8a1"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>5.5.99</max></php></required></dependencies>
22
+ </package>
skin/adminhtml/default/default/images/mundipagg/.DS_Store ADDED
Binary file
skin/adminhtml/default/default/images/mundipagg/ajax-loader.gif ADDED
Binary file
skin/adminhtml/default/default/images/mundipagg/boleto.jpg ADDED
Binary file
skin/adminhtml/default/default/images/mundipagg/mundipagg-avatar-blue.png ADDED
Binary file
skin/frontend/base/default/css/mundipagg.css ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Uecommerce
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Uecommerce EULA.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.uecommerce.com.br/
9
+ *
10
+ * DISCLAIMER
11
+ *
12
+ * Do not edit or add to this file if you wish to upgrade the extension
13
+ * to newer versions in the future. If you wish to customize the extension
14
+ * for your needs please refer to http://www.uecommerce.com.br/ for more information
15
+ *
16
+ * @category Uecommerce
17
+ * @package Uecommerce_Mundipagg
18
+ * @copyright Copyright (c) 2012 Uecommerce (http://www.uecommerce.com.br/)
19
+ * @license http://www.uecommerce.com.br/
20
+ */
21
+
22
+ /**
23
+ * Mundipagg Payment module
24
+ *
25
+ * @category Uecommerce
26
+ * @package Uecommerce_Mundipagg
27
+ * @author Uecommerce Dev Team
28
+ */
29
+
30
+ .issuers{
31
+ text-align: center;
32
+ padding-right: 10px;
33
+ }
34
+
35
+ .cursor_hand {
36
+ cursor: pointer;
37
+ }
38
+
39
+ ul.inline {
40
+ float:left;
41
+ }
42
+
43
+ ul.inline li {
44
+ float: left;
45
+ width: 30%;
46
+ margin-right: 2%;
47
+ text-align: center;
48
+ }
49
+
50
+ ul.inline.input-radio > li {
51
+ width: 40px;
52
+ margin-right:4px
53
+ }
54
+
55
+ fieldset ul.inline.input-radio > li{
56
+ margin-right: 3px
57
+ }
58
+
59
+ ul.inline li img {
60
+ width: 100%;
61
+ height: auto;
62
+ clear: both;
63
+ display: block;
64
+ margin-bottom: 5px;
65
+ }
66
+
67
+ .sp-methods select.month {
68
+ width: 145px;
69
+ }
70
+
71
+ .cc_brand_types{
72
+ width:42px;
73
+ height:26px;
74
+ margin-right: 10px;
75
+ background: url('../images/mundipagg/cc_types.png');
76
+ margin-bottom: 5px;
77
+ }
78
+
79
+ .cc_brand_types.vi{
80
+ background-position: 0 -26px;
81
+ }
82
+ .cc_brand_types.vi.active{
83
+ background-position: 0 0;
84
+ }
85
+ .cc_brand_types.mc{
86
+ background-position: -42px -26px;
87
+ }
88
+ .cc_brand_types.mc.active{
89
+ background-position: -42px 0;
90
+ }
91
+ .cc_brand_types.ae{
92
+ background-position: -208px -26px;
93
+ }
94
+ .cc_brand_types.ae.active{
95
+ background-position: -208px 0;
96
+ }
97
+ .cc_brand_types.di{
98
+ background-position: -167px -26px;
99
+ }
100
+ .cc_brand_types.di.active{
101
+ background-position: -167px 0;
102
+ }
103
+ .cc_brand_types.el{
104
+ background-position: -126px -26px;
105
+ }
106
+ .cc_brand_types.el.active{
107
+ background-position: -126px 0;
108
+ }
109
+ .cc_brand_types.hi{
110
+ background-position: -84px -26px;
111
+ }
112
+ .cc_brand_types.hi.active{
113
+ background-position: -84px 0;
114
+ }
115
+
116
+ .cc_brands input[type=radio]{display:none}
117
+
118
+ .mundipagg_reload{
119
+ position: absolute;
120
+ z-index: 10;
121
+ margin-top: -19px;
122
+ }
123
+
124
+ .division{width:100%;clear:both;height: 10px;border-top:1px solid #ddd;margin-top:10px}
125
+
126
+ .info-payment{clear:both}
127
+
128
+ #onestepcheckout-payment-method-wrapper .field{width: 100%}
129
+
skin/frontend/base/default/images/mundipagg/.DS_Store ADDED
Binary file
skin/frontend/base/default/images/mundipagg/001.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/237.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/341.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/AE.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/DI.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/EL.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/HI.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/MC.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/VBV.jpg ADDED
Binary file
skin/frontend/base/default/images/mundipagg/VBV.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/VI.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/ajax-loader.gif ADDED
Binary file
skin/frontend/base/default/images/mundipagg/boleto.jpg ADDED
Binary file
skin/frontend/base/default/images/mundipagg/cc_types.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/cielo_mastercard.png ADDED
Binary file
skin/frontend/base/default/images/mundipagg/cielo_visa.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/.DS_Store ADDED
Binary file
skin/frontend/default/default/images/mundipagg/EL.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/HI.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/ae.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/boleto.jpg ADDED
Binary file
skin/frontend/default/default/images/mundipagg/cielo_mastercard.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/cielo_visa.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/di.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/mc.png ADDED
Binary file
skin/frontend/default/default/images/mundipagg/vi.png ADDED
Binary file