MercadoPagoTransparent - Version 0.0.4

Version Notes

"MercadoPago v2.1.2

New internal module file structure

- Javascript code refactored

- New plugin configuration layout

- Added Customers & Cards feature

- Magento orders now contain subtotals related to MP coupons and financing cost.

- Document type and card token validation on checkout

- Venezuela added as available country.

- Compatibility with OSC extensions innovarti and ideasa

MercadoEnvios 0.1.0

- New module available for Argentina, Brazil and Mexico only with Standard Checkout

- Package size and weight attributes can be mapped with magento attributes, and its units can be converted through admin panel.

- Different shipping methods per country can be enabled/disabled.

- Shipping cost is calculated and shown in cart page and checkout.

- Free shipping option is available.

- Tracking information order can be accessed through order details admin section or my account.

- Shipping label can be printed through order details admin section."

Download this release

Release Info

Developer Developers MercadoPago Brasil
Extension MercadoPagoTransparent
Version 0.0.4
Comparing to
See all releases


Code changes from version 0.0.3 to 0.0.4

Files changed (138) hide show
  1. app/code/community/MercadoPago/Block/Custom/Form.php +0 -72
  2. app/code/community/MercadoPago/Block/Custom/Info.php +0 -37
  3. app/code/community/MercadoPago/Block/Customticket/Form.php +0 -69
  4. app/code/community/MercadoPago/Block/Customticket/Info.php +0 -38
  5. app/code/community/MercadoPago/Block/Standard/Form.php +0 -27
  6. app/code/community/MercadoPago/Block/Standard/Info.php +0 -40
  7. app/code/community/MercadoPago/Block/Standard/Pay.php +0 -27
  8. app/code/community/MercadoPago/Core/Block/AbstractForm.php +35 -0
  9. app/code/community/MercadoPago/{Block/Success.php → Core/Block/AbstractSuccess.php} +37 -48
  10. app/code/community/MercadoPago/Core/Block/Adminhtml/System/Config/Fieldset/Payment.php +50 -0
  11. app/code/community/MercadoPago/Core/Block/Custom/Form.php +55 -0
  12. app/code/community/MercadoPago/Core/Block/Custom/Info.php +39 -0
  13. app/code/community/MercadoPago/Core/Block/Custom/Success.php +12 -0
  14. app/code/community/MercadoPago/Core/Block/Customticket/Form.php +44 -0
  15. app/code/community/MercadoPago/Core/Block/Customticket/Info.php +40 -0
  16. app/code/community/MercadoPago/Core/Block/Customticket/Success.php +12 -0
  17. app/code/community/MercadoPago/Core/Block/Discount.php +26 -0
  18. app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Discount/Coupon.php +29 -0
  19. app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Finance/Cost.php +29 -0
  20. app/code/community/MercadoPago/Core/Block/Standard/Form.php +27 -0
  21. app/code/community/MercadoPago/Core/Block/Standard/Info.php +40 -0
  22. app/code/community/MercadoPago/Core/Block/Standard/Pay.php +27 -0
  23. app/code/community/MercadoPago/Core/Block/Standard/Success.php +12 -0
  24. app/code/community/MercadoPago/Core/Helper/Data.php +221 -0
  25. app/code/community/MercadoPago/Core/Helper/Message/Abstract.php +26 -0
  26. app/code/community/MercadoPago/Core/Helper/Response.php +32 -0
  27. app/code/community/MercadoPago/Core/Helper/StatusDetailMessage.php +28 -0
  28. app/code/community/MercadoPago/Core/Helper/StatusMessage.php +47 -0
  29. app/code/community/MercadoPago/Core/Helper/StatusOrderMessage.php +21 -0
  30. app/code/community/MercadoPago/Core/Model/Api/Exception.php +34 -0
  31. app/code/community/MercadoPago/Core/Model/Api/V0/Exception.php +20 -0
  32. app/code/community/MercadoPago/Core/Model/Api/V1/Exception.php +43 -0
  33. app/code/community/MercadoPago/Core/Model/Core.php +552 -0
  34. app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost.php +59 -0
  35. app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Creditmemo.php +24 -0
  36. app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Invoice.php +24 -0
  37. app/code/community/MercadoPago/Core/Model/Custom/Payment.php +279 -0
  38. app/code/community/MercadoPago/Core/Model/CustomPayment.php +94 -0
  39. app/code/community/MercadoPago/Core/Model/CustomTicket/Payment.php +115 -0
  40. app/code/community/MercadoPago/Core/Model/Discount/Coupon.php +57 -0
  41. app/code/community/MercadoPago/Core/Model/Discount/Coupon/Creditmemo.php +24 -0
  42. app/code/community/MercadoPago/Core/Model/Discount/Coupon/Invoice.php +24 -0
  43. app/code/community/MercadoPago/Core/Model/Observer.php +181 -0
  44. app/code/community/MercadoPago/Core/Model/Source/CategoryId.php +47 -0
  45. app/code/community/MercadoPago/Core/Model/Source/Country.php +46 -0
  46. app/code/community/MercadoPago/Core/Model/Source/Installments.php +43 -0
  47. app/code/community/MercadoPago/Core/Model/Source/Order/Status.php +18 -0
  48. app/code/community/MercadoPago/Core/Model/Source/PaymentMethods.php +65 -0
  49. app/code/community/MercadoPago/{Block/Discount.php → Core/Model/Source/TypeCheckout.php} +11 -7
  50. app/code/community/MercadoPago/Core/Model/Standard/Payment.php +318 -0
  51. app/code/community/MercadoPago/Core/controllers/ApiController.php +82 -0
  52. app/code/community/MercadoPago/Core/controllers/NotificationsController.php +207 -0
  53. app/code/community/MercadoPago/Core/controllers/PayController.php +44 -0
  54. app/code/community/MercadoPago/Core/controllers/SuccessController.php +67 -0
  55. app/code/community/MercadoPago/{etc → Core/etc}/config.xml +103 -55
  56. app/code/community/MercadoPago/Core/etc/system.xml +448 -0
  57. app/code/community/MercadoPago/Core/sql/mercadopago_setup/install-2.1.0.php +22 -0
  58. app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.0-2.1.1.php +23 -0
  59. app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.1-2.1.2.php +25 -0
  60. app/code/community/MercadoPago/Helper/Data.php +0 -32
  61. app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Carrier.php +60 -0
  62. app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Mapping.php +51 -0
  63. app/code/community/MercadoPago/MercadoEnvios/Helper/Data.php +266 -0
  64. app/code/community/MercadoPago/MercadoEnvios/Helper/ItemData.php +20 -0
  65. app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Attribute/Validation/Mapping.php +22 -0
  66. app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/FreeMethod.php +14 -0
  67. app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/Method.php +30 -0
  68. app/code/community/MercadoPago/MercadoEnvios/Model/Observer.php +176 -0
  69. app/code/community/MercadoPago/MercadoEnvios/Model/Shipping/Carrier/MercadoEnvios.php +197 -0
  70. app/code/community/MercadoPago/MercadoEnvios/etc/config.xml +123 -0
  71. app/code/community/MercadoPago/MercadoEnvios/etc/system.xml +169 -0
  72. app/code/community/MercadoPago/Model/Core.php +0 -314
  73. app/code/community/MercadoPago/Model/Custom/Payment.php +0 -436
  74. app/code/community/MercadoPago/Model/CustomTicket/Payment.php +0 -82
  75. app/code/community/MercadoPago/Model/Observer.php +0 -146
  76. app/code/community/MercadoPago/Model/Source/CategoryId.php +0 -48
  77. app/code/community/MercadoPago/Model/Source/Country.php +0 -32
  78. app/code/community/MercadoPago/Model/Source/Installments.php +0 -41
  79. app/code/community/MercadoPago/Model/Source/PaymentMethods.php +0 -45
  80. app/code/community/MercadoPago/Model/Source/TypeCheckout.php +0 -31
  81. app/code/community/MercadoPago/Model/Standard/Payment.php +0 -298
  82. app/code/community/MercadoPago/OneStepCheckout/Block/Custom/Form.php +51 -0
  83. app/code/community/MercadoPago/OneStepCheckout/Block/Customticket/Form.php +42 -0
  84. app/code/community/MercadoPago/OneStepCheckout/Helper/Data.php +12 -0
  85. app/code/community/MercadoPago/OneStepCheckout/Model/Observer.php +16 -0
  86. app/code/community/MercadoPago/OneStepCheckout/etc/config.xml +52 -0
  87. app/code/community/MercadoPago/OneStepCheckout/etc/system.xml +23 -0
  88. app/code/community/MercadoPago/controllers/ApiController.php +0 -81
  89. app/code/community/MercadoPago/controllers/NotificationsController.php +0 -347
  90. app/code/community/MercadoPago/controllers/PayController.php +0 -43
  91. app/code/community/MercadoPago/controllers/SuccessController.php +0 -37
  92. app/code/community/MercadoPago/etc/system.xml +0 -403
  93. app/design/adminhtml/default/default/layout/mercadopago.xml +53 -0
  94. app/design/adminhtml/default/default/template/mercadopago/array_dropdown.phtml +50 -0
  95. app/design/adminhtml/default/default/template/mercadopago/custom/info.phtml +0 -0
  96. app/design/adminhtml/default/default/template/mercadopago/custom_ticket/info.phtml +4 -4
  97. app/design/adminhtml/default/default/template/mercadopago/standard/info.phtml +0 -0
  98. app/design/frontend/base/default/layout/mercadopago.xml +103 -0
  99. app/design/frontend/base/default/template/mercadopago/clean.phtml +0 -0
  100. app/design/frontend/base/default/template/mercadopago/custom/form.phtml +192 -187
  101. app/design/frontend/base/default/template/mercadopago/custom/info.phtml +0 -0
  102. app/design/frontend/base/default/template/mercadopago/custom/success.phtml +45 -0
  103. app/design/frontend/base/default/template/mercadopago/custom_ticket/form.phtml +62 -61
  104. app/design/frontend/base/default/template/mercadopago/custom_ticket/info.phtml +4 -4
  105. app/design/frontend/base/default/template/mercadopago/custom_ticket/success.phtml +38 -0
  106. app/design/frontend/base/default/template/mercadopago/discount.phtml +5 -5
  107. app/design/frontend/base/default/template/mercadopago/onestepcheckout/custom/form.phtml +218 -0
  108. app/design/frontend/base/default/template/mercadopago/standard/form.phtml +12 -12
  109. app/design/frontend/base/default/template/mercadopago/standard/info.phtml +0 -0
  110. app/design/frontend/base/default/template/mercadopago/standard/pay.phtml +0 -0
  111. app/design/frontend/base/default/template/mercadopago/standard/success.phtml +45 -0
  112. app/design/frontend/base/default/template/mercadopago/success.phtml +0 -135
  113. app/etc/modules/{MercadoPago.xml → MercadoPago_Core.xml} +2 -2
  114. app/etc/modules/MercadoPago_MercadoEnvios.xml +12 -0
  115. app/etc/modules/MercadoPago_OneStepCheckout.xml +12 -0
  116. app/locale/en_US/MercadoPago_Core.csv +166 -0
  117. app/locale/es_AR/MercadoPago_Core.csv +172 -0
  118. app/locale/es_CL/MercadoPago_Core.csv +115 -0
  119. app/locale/es_CO/{mercadopago.csv → MercadoPago_Core.csv} +17 -17
  120. app/locale/es_ES/{mercadopago.csv → MercadoPago_Core.csv} +17 -17
  121. app/locale/{es_AR/mercadopago.csv → es_MX/MercadoPago_Core.csv} +23 -18
  122. app/locale/{es_MX/mercadopago.csv → es_VE/MercadoPago_Core.csv} +2 -1
  123. app/locale/pt_BR/{mercadopago.csv → MercadoPago_Core.csv} +64 -18
  124. js/mercadopago/jquery-1.11.0.min.js +0 -0
  125. js/mercadopago/mercadopago.js +1034 -532
  126. js/mercadopago/mercadopago_osc.js +1179 -0
  127. js/mercadopago/tiny.min.js +1 -0
  128. js/mercadopago/tinyJ.js +198 -0
  129. lib/{mercadopago/mercadopago.php → MercadoPago/Lib/Api.php} +81 -142
  130. lib/MercadoPago/Lib/RestClient.php +105 -0
  131. package.xml +50 -13
  132. skin/adminhtml/default/default/mercadopago/images/cards.jpg +0 -0
  133. skin/adminhtml/default/default/mercadopago/images/logo.png +0 -0
  134. skin/adminhtml/default/default/mercadopago/images/mercadoenvios.png +0 -0
  135. skin/adminhtml/default/default/mercadopago/styles.css +52 -0
  136. skin/frontend/base/default/mercadopago/css/style-success.css +56 -0
  137. skin/frontend/base/default/mercadopago/css/style.css +69 -91
  138. skin/frontend/base/default/mercadopago/images/loading.gif +0 -0
app/code/community/MercadoPago/Block/Custom/Form.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Custom_Form extends Mage_Payment_Block_Form_Cc{
19
-
20
- protected function _construct(){
21
- parent::_construct();
22
- $this->setTemplate('mercadopago/custom/form.phtml');
23
- }
24
-
25
- protected function _prepareLayout(){
26
-
27
- //pega public key para settar no aquivo mercadopago.js
28
- $model = Mage::getModel('mercadopago/custom_payment');
29
- $public_key = $model->getConfigData('public_key');
30
-
31
- //init js no header
32
- $block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
33
- $block->setText(
34
- sprintf(
35
- '
36
- <script type="text/javascript">var PublicKeyMercadoPagoTransparent = "' . $public_key .'";</script>
37
- <script type="text/javascript" src="%s"></script>',
38
- Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js'
39
- )
40
- );
41
-
42
- $head = Mage::app()->getLayout()->getBlock('after_body_start');
43
-
44
- if($head){
45
- $head->append($block);
46
- }
47
-
48
- return parent::_prepareLayout();
49
- }
50
-
51
- /*
52
- *
53
- * fun��o especifica para mexico
54
- *
55
- */
56
- function getCardsPaymentMethods(){
57
- $payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
58
- $payment_methods_types = array("credit_card", "debit_card", "prepaid_card");
59
- $types = array();
60
-
61
- //percorre todos os payments methods
62
- foreach($payment_methods['response'] as $pm){
63
-
64
- //filtra por payment_methods
65
- if(in_array($pm['payment_type_id'], $payment_methods_types)){
66
- $types[] = $pm;
67
- }
68
- }
69
-
70
- return $types;
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Custom/Info.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Custom_Info extends Mage_Payment_Block_Info_Cc{
19
-
20
- protected function _construct(){
21
- parent::_construct();
22
- $this->setTemplate('mercadopago/custom/info.phtml');
23
- $this->setModuleName('Mage_Payment');
24
- }
25
-
26
- public function getOrder() {
27
- return $this->getInfo();
28
- }
29
-
30
- public function getInfoPayment(){
31
-
32
- $order_id = $this->getInfo()->getOrder()->getIncrementId();
33
- $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
34
-
35
- return $info_payments;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Customticket/Form.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Customticket_Form extends Mage_Payment_Block_Form_Cc{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
-
24
- $this->setTemplate('mercadopago/custom_ticket/form.phtml');
25
-
26
- }
27
-
28
- protected function _prepareLayout(){
29
-
30
- //pega public key para settar no aquivo mercadopago.js
31
- $model = Mage::getModel('mercadopago/custom_payment');
32
- $public_key = $model->getConfigData('public_key');
33
-
34
- //init js no header
35
- $block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
36
- $block->setText(
37
- sprintf(
38
- '
39
- <script type="text/javascript">var PublicKeyMercadoPagoTransparent = "' . $public_key .'";</script>
40
- <script type="text/javascript" src="%s"></script>',
41
- Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js'
42
- )
43
- );
44
-
45
- $head = Mage::app()->getLayout()->getBlock('after_body_start');
46
-
47
- if($head){
48
- $head->append($block);
49
- }
50
-
51
- return parent::_prepareLayout();
52
- }
53
-
54
- function getTicketsOptions(){
55
- $payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
56
- $tickets = array();
57
-
58
- //percorre todos os payments methods
59
- foreach($payment_methods['response'] as $pm){
60
-
61
- //filtra por tickets
62
- if($pm['payment_type_id'] == "ticket"){
63
- $tickets[] = $pm;
64
- }
65
- }
66
-
67
- return $tickets;
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Customticket/Info.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_CustomTicket_Info extends Mage_Payment_Block_Info_Cc{
19
-
20
- protected function _construct(){
21
- parent::_construct();
22
- $this->setTemplate('mercadopago/custom_ticket/info.phtml');
23
- $this->setModuleName('Mage_Payment');
24
- }
25
-
26
-
27
- public function getOrder() {
28
- return $this->getInfo();
29
- }
30
-
31
- public function getInfoPayment(){
32
-
33
- $order_id = $this->getInfo()->getOrder()->getIncrementId();
34
- $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
35
-
36
- return $info_payments;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Standard/Form.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Standard_Form extends Mage_Payment_Block_Form_Cc{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
-
24
- $this->setTemplate('mercadopago/standard/form.phtml');
25
-
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Standard/Info.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Standard_Info extends Mage_Payment_Block_Info_Cc{
19
-
20
- protected function _construct(){
21
- parent::_construct();
22
- $this->setTemplate('mercadopago/standard/info.phtml');
23
- $this->setModuleName('Mage_Payment');
24
- }
25
-
26
-
27
- public function getOrder() {
28
-
29
- return $this->getInfo();
30
-
31
- }
32
-
33
- public function getInfoPayment(){
34
-
35
- $order_id = $this->getInfo()->getOrder()->getIncrementId();
36
- $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
37
-
38
- return $info_payments;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Block/Standard/Pay.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Standard_Pay extends Mage_Core_Block_Template{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
-
24
- $this->setTemplate('mercadopago/standard/pay.phtml');
25
-
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Core/Block/AbstractForm.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_AbstractForm
4
+ extends Mage_Payment_Block_Form_Cc
5
+ {
6
+ protected function _prepareLayout()
7
+ {
8
+
9
+ $public_key = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_PUBLIC_KEY);
10
+
11
+ //init js no header
12
+ $block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
13
+ $block->setText(
14
+ sprintf(
15
+ '
16
+ <script type="text/javascript">var PublicKeyMercadoPagoCustom = "' . $public_key . '";</script>
17
+ <script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script>
18
+ <script type="text/javascript" src="%s"></script>
19
+ <script type="text/javascript" src="%s"></script>
20
+ <script type="text/javascript" src="%s"></script>',
21
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js',
22
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tiny.min.js',
23
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tinyJ.js'
24
+ )
25
+ );
26
+
27
+ $head = Mage::app()->getLayout()->getBlock('after_body_start');
28
+
29
+ if ($head) {
30
+ $head->append($block);
31
+ }
32
+
33
+ return parent::_prepareLayout();
34
+ }
35
+ }
app/code/community/MercadoPago/{Block/Success.php → Core/Block/AbstractSuccess.php} RENAMED
@@ -1,74 +1,63 @@
1
  <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
-
18
- class MercadoPago_Block_Success extends Mage_Core_Block_Template{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
- $this->setTemplate('mercadopago/success.phtml');
24
-
25
  }
26
-
27
- public function getOrder() {
 
28
  $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
29
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
 
30
  return $order;
31
  }
32
-
33
- public function getPayment(){
34
- $order = $this->getOrder();
35
- $payment = $order->getPayment();
36
- return $payment;
37
- }
38
-
39
- public function getTotal(){
40
  $order = $this->getOrder();
41
  $total = $order->getBaseGrandTotal();
42
-
43
  if (!$total) {
44
  $total = $order->getBasePrice() + $order->getBaseShippingAmount();
45
  }
46
-
47
  $total = number_format($total, 2, '.', '');
48
-
49
  return $total;
50
  }
51
-
52
- public function getEntityId(){
 
53
  $order = $this->getOrder();
54
-
55
  return $order->getEntityId();
56
  }
57
-
58
- public function getPaymentMethod(){
 
59
  $payment_method = $this->getPayment()->getMethodInstance()->getCode();
60
-
61
  return $payment_method;
62
  }
63
-
64
- public function getInfoPayment(){
 
65
  $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
66
  $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
67
-
68
  return $info_payments;
69
  }
70
-
71
- public function getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment){
 
72
  return Mage::getModel('mercadopago/core')->getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment);
73
  }
74
- }
1
  <?php
2
+
3
+ class MercadoPago_Core_Block_AbstractSuccess
4
+ extends Mage_Core_Block_Template
5
+ {
6
+
7
+ public function getPayment()
8
+ {
9
+ $order = $this->getOrder();
10
+ $payment = $order->getPayment();
11
+
12
+ return $payment;
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
+
15
+ public function getOrder()
16
+ {
17
  $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
18
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
19
+
20
  return $order;
21
  }
22
+
23
+ public function getTotal()
24
+ {
 
 
 
 
 
25
  $order = $this->getOrder();
26
  $total = $order->getBaseGrandTotal();
27
+
28
  if (!$total) {
29
  $total = $order->getBasePrice() + $order->getBaseShippingAmount();
30
  }
31
+
32
  $total = number_format($total, 2, '.', '');
33
+
34
  return $total;
35
  }
36
+
37
+ public function getEntityId()
38
+ {
39
  $order = $this->getOrder();
40
+
41
  return $order->getEntityId();
42
  }
43
+
44
+ public function getPaymentMethod()
45
+ {
46
  $payment_method = $this->getPayment()->getMethodInstance()->getCode();
47
+
48
  return $payment_method;
49
  }
50
+
51
+ public function getInfoPayment()
52
+ {
53
  $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
54
  $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
55
+
56
  return $info_payments;
57
  }
58
+
59
+ public function getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment)
60
+ {
61
  return Mage::getModel('mercadopago/core')->getMessageByStatus($status, $status_detail, $payment_method, $amount, $installment);
62
  }
63
+ }
app/code/community/MercadoPago/Core/Block/Adminhtml/System/Config/Fieldset/Payment.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Adminhtml_System_Config_Fieldset_Payment
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
5
+ {
6
+
7
+ /**
8
+ * Return header title part of html for payment solution
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
+ * @return string
13
+ */
14
+ protected function _getHeaderTitleHtml($element)
15
+ {
16
+ $configData = $this->getData('config_data');
17
+ $imageUrl = $configData['payment/mercadopago_standard/banner_checkout'];
18
+
19
+ $html = '<div class="config-heading meli" ><div class="heading"><strong id="meli-logo">' . $element->getLegend();
20
+ $html .= '</strong></div>';
21
+
22
+ $html .= '<div class="button-container meli-cards" style="background: url(' . $imageUrl . ') no-repeat 0 0px;"><button type="button"'
23
+ . ' class="meli-payment-btn button'
24
+ . '" id="' . $element->getHtmlId()
25
+ . '-head" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \''
26
+ . $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">'
27
+ . $this->__('Configure') . '</span><span class="state-opened">'
28
+ . $this->__('Close') . '</span></button></div></div>';
29
+
30
+
31
+
32
+ return $html;
33
+ }
34
+
35
+ /**
36
+ * Collapsed or expanded fieldset when page loaded
37
+ *
38
+ * @param Varien_Data_Form_Element_Abstract $element
39
+ *
40
+ * @return bool
41
+ *
42
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
43
+ * @SuppressWarnings(PHPMD.BooleanGetMethodName)
44
+ */
45
+ protected function _getCollapseState($element)
46
+ {
47
+ return false;
48
+ }
49
+
50
+ }
app/code/community/MercadoPago/Core/Block/Custom/Form.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Block_Custom_Form
18
+ extends MercadoPago_Core_Block_AbstractForm
19
+ {
20
+ protected function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->setTemplate('mercadopago/custom/form.phtml');
24
+ }
25
+
26
+ /*
27
+ *
28
+ * Only used in Mexico
29
+ *
30
+ */
31
+ public function getCardsPaymentMethods()
32
+ {
33
+ $payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
34
+ $payment_methods_types = array("credit_card", "debit_card", "prepaid_card");
35
+ $types = array();
36
+
37
+ //percorre todos os payments methods
38
+ foreach ($payment_methods['response'] as $pm) {
39
+
40
+ //filtra por payment_methods
41
+ if (in_array($pm['payment_type_id'], $payment_methods_types)) {
42
+ $types[] = $pm;
43
+ }
44
+ }
45
+
46
+ return $types;
47
+ }
48
+
49
+ public function getCustomerAndCards()
50
+ {
51
+ $customer = Mage::getModel('mercadopago/custom_payment')->getCustomerAndCards();
52
+
53
+ return $customer;
54
+ }
55
+ }
app/code/community/MercadoPago/Core/Block/Custom/Info.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Custom_Info
19
+ extends Mage_Payment_Block_Info_Cc
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->setTemplate('mercadopago/custom/info.phtml');
25
+ }
26
+
27
+ public function getOrder()
28
+ {
29
+ return $this->getInfo();
30
+ }
31
+
32
+ public function getInfoPayment()
33
+ {
34
+ $order_id = $this->getInfo()->getOrder()->getIncrementId();
35
+ $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
36
+
37
+ return $info_payments;
38
+ }
39
+ }
app/code/community/MercadoPago/Core/Block/Custom/Success.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Custom_Success
4
+ extends MercadoPago_Core_Block_AbstractSuccess
5
+ {
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('mercadopago/custom/success.phtml');
10
+ }
11
+
12
+ }
app/code/community/MercadoPago/Core/Block/Customticket/Form.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Customticket_Form
19
+ extends MercadoPago_Core_Block_AbstractForm
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+
25
+ $this->setTemplate('mercadopago/custom_ticket/form.phtml');
26
+ }
27
+
28
+ public function getTicketsOptions()
29
+ {
30
+ $payment_methods = Mage::getModel('mercadopago/core')->getPaymentMethods();
31
+ $tickets = array();
32
+
33
+ //percorre todos os payments methods
34
+ foreach ($payment_methods['response'] as $pm) {
35
+
36
+ //filtra por tickets
37
+ if ($pm['payment_type_id'] == "ticket") {
38
+ $tickets[] = $pm;
39
+ }
40
+ }
41
+
42
+ return $tickets;
43
+ }
44
+ }
app/code/community/MercadoPago/Core/Block/Customticket/Info.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Customticket_Info
19
+ extends Mage_Payment_Block_Info_Cc
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->setTemplate('mercadopago/custom_ticket/info.phtml');
25
+ }
26
+
27
+
28
+ public function getOrder()
29
+ {
30
+ return $this->getInfo();
31
+ }
32
+
33
+ public function getInfoPayment()
34
+ {
35
+ $order_id = $this->getInfo()->getOrder()->getIncrementId();
36
+ $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
37
+
38
+ return $info_payments;
39
+ }
40
+ }
app/code/community/MercadoPago/Core/Block/Customticket/Success.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Customticket_Success
4
+ extends MercadoPago_Core_Block_AbstractSuccess
5
+ {
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('mercadopago/custom_ticket/success.phtml');
10
+ }
11
+
12
+ }
app/code/community/MercadoPago/Core/Block/Discount.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Discount
19
+ extends Mage_Core_Block_Template
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->setTemplate('mercadopago/discount.phtml');
25
+ }
26
+ }
app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Discount/Coupon.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Sales_Order_Totals_Discount_Coupon
4
+ extends Mage_Core_Block_Abstract
5
+ {
6
+ public function getSource()
7
+ {
8
+ return $this->getParentBlock()->getSource();
9
+ }
10
+
11
+ /**
12
+ * Add this total to parent
13
+ */
14
+ public function initTotals()
15
+ {
16
+ if ((float)$this->getSource()->getDiscountCouponAmount() == 0) {
17
+ return $this;
18
+ }
19
+ $total = new Varien_Object(array(
20
+ 'code' => 'discount_coupon',
21
+ 'field' => 'discount_coupon_amount',
22
+ 'value' => $this->getSource()->getDiscountCouponAmount(),
23
+ 'label' => $this->__('Discount Mercado Pago'),
24
+ ));
25
+ $this->getParentBlock()->addTotalBefore($total, 'shipping');
26
+
27
+ return $this;
28
+ }
29
+ }
app/code/community/MercadoPago/Core/Block/Sales/Order/Totals/Finance/Cost.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Sales_Order_Totals_Finance_Cost
4
+ extends Mage_Core_Block_Abstract
5
+ {
6
+ public function getSource()
7
+ {
8
+ return $this->getParentBlock()->getSource();
9
+ }
10
+
11
+ /**
12
+ * Add this total to parent
13
+ */
14
+ public function initTotals()
15
+ {
16
+ if ((float)$this->getSource()->getFinanceCostAmount() == 0) {
17
+ return $this;
18
+ }
19
+ $total = new Varien_Object(array(
20
+ 'code' => 'financing_cost',
21
+ 'field' => 'financing_cost_amount',
22
+ 'value' => $this->getSource()->getFinanceCostAmount(),
23
+ 'label' => $this->__('Financing Cost'),
24
+ ));
25
+ $this->getParentBlock()->addTotalBefore($total, 'shipping');
26
+
27
+ return $this;
28
+ }
29
+ }
app/code/community/MercadoPago/Core/Block/Standard/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Standard_Form
19
+ extends Mage_Payment_Block_Form_Cc
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+
25
+ $this->setTemplate('mercadopago/standard/form.phtml');
26
+ }
27
+ }
app/code/community/MercadoPago/Core/Block/Standard/Info.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Standard_Info
19
+ extends Mage_Payment_Block_Info_Cc
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->setTemplate('mercadopago/standard/info.phtml');
25
+ }
26
+
27
+
28
+ public function getOrder()
29
+ {
30
+ return $this->getInfo();
31
+ }
32
+
33
+ public function getInfoPayment()
34
+ {
35
+ $order_id = $this->getInfo()->getOrder()->getIncrementId();
36
+ $info_payments = Mage::getModel('mercadopago/core')->getInfoPaymentByOrder($order_id);
37
+
38
+ return $info_payments;
39
+ }
40
+ }
app/code/community/MercadoPago/Core/Block/Standard/Pay.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Block_Standard_Pay
19
+ extends Mage_Core_Block_Template
20
+ {
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+
25
+ $this->setTemplate('mercadopago/standard/pay.phtml');
26
+ }
27
+ }
app/code/community/MercadoPago/Core/Block/Standard/Success.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Block_Standard_Success
4
+ extends MercadoPago_Core_Block_AbstractSuccess
5
+ {
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('mercadopago/standard/success.phtml');
10
+ }
11
+
12
+ }
app/code/community/MercadoPago/Core/Helper/Data.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Helper_Data
18
+ extends Mage_Payment_Helper_Data
19
+ {
20
+
21
+ const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
22
+ const XML_PATH_PUBLIC_KEY = 'payment/mercadopago_custom_checkout/public_key';
23
+ const XML_PATH_CLIENT_ID = 'payment/mercadopago_standard/client_id';
24
+ const XML_PATH_CLIENT_SECRET = 'payment/mercadopago_standard/client_secret';
25
+
26
+ const PLATFORM_V1_WHITELABEL = 'v1-whitelabel';
27
+ const PLATFORM_DESKTOP = 'Desktop';
28
+ const TYPE = 'magento';
29
+
30
+ public function log($message, $file = "mercadopago.log", $array = null)
31
+ {
32
+ $actionLog = Mage::getStoreConfig('payment/mercadopago/logs');
33
+
34
+ if ($actionLog) {
35
+ if (!is_null($array)) {
36
+ $message .= " - " . json_encode($array);
37
+ }
38
+
39
+ Mage::log($message, null, $file, $actionLog);
40
+ }
41
+ }
42
+
43
+ public function getApiInstance()
44
+ {
45
+ $params = func_num_args();
46
+ if ($params > 2 || $params < 1) {
47
+ Mage::throwException("Invalid arguments. Use CLIENT_ID and CLIENT SECRET, or ACCESS_TOKEN");
48
+ }
49
+ if ($params == 1) {
50
+ $api = new MercadoPago_Lib_Api(func_get_arg(0));
51
+ $api->set_platform(self::PLATFORM_V1_WHITELABEL);
52
+ } else {
53
+ $api = new MercadoPago_Lib_Api(func_get_arg(0), func_get_arg(1));
54
+ $api->set_platform(self::PLATFORM_DESKTOP);
55
+ }
56
+ if (Mage::getStoreConfigFlag('payment/mercadopago_standard/sandbox_mode')) {
57
+ $api->sandbox_mode(true);
58
+ }
59
+
60
+ $api->set_type(self::TYPE . ' ' . (string) Mage::getConfig()->getModuleConfig("MercadoPago_Core")->version);
61
+
62
+ return $api;
63
+
64
+ }
65
+
66
+ public function isValidAccessToken($accessToken)
67
+ {
68
+ $mp = Mage::helper('mercadopago')->getApiInstance($accessToken);
69
+ $response = $mp->get("/v1/payment_methods");
70
+ if ($response['status'] == 401 || $response['status'] == 400) {
71
+ return false;
72
+ }
73
+
74
+ return true;
75
+ }
76
+
77
+ public function isValidClientCredentials($clientId, $clientSecret)
78
+ {
79
+ $mp = Mage::helper('mercadopago')->getApiInstance($clientId, $clientSecret);
80
+ try {
81
+ $mp->get_access_token();
82
+ } catch (Exception $e) {
83
+ return false;
84
+ }
85
+
86
+ return true;
87
+ }
88
+
89
+ public function getAccessToken()
90
+ {
91
+ $clientId = Mage::getStoreConfig(self::XML_PATH_CLIENT_ID);
92
+ $clientSecret = Mage::getStoreConfig(self::XML_PATH_CLIENT_SECRET);
93
+ try {
94
+ $accessToken = $this->getApiInstance($clientId, $clientSecret)->get_access_token();
95
+ } catch (\Exception $e) {
96
+ $accessToken = false;
97
+ }
98
+
99
+ return $accessToken;
100
+ }
101
+
102
+ public function getStatusOrder($status)
103
+ {
104
+ switch ($status) {
105
+ case 'approved': {
106
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_approved');
107
+ break;
108
+ }
109
+ case 'refunded': {
110
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_refunded');
111
+ break;
112
+ }
113
+ case 'in_mediation': {
114
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_mediation');
115
+ break;
116
+ }
117
+ case 'cancelled': {
118
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_cancelled');
119
+ break;
120
+ }
121
+ case 'rejected': {
122
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_rejected');
123
+ break;
124
+ }
125
+ case 'chargeback': {
126
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_chargeback');
127
+ break;
128
+ }
129
+ default: {
130
+ $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_process');
131
+ }
132
+ }
133
+
134
+ return $status;
135
+ }
136
+
137
+ /**
138
+ * Get the assigned state of an order status
139
+ *
140
+ * @param string $status
141
+ */
142
+ public function _getAssignedState($status)
143
+ {
144
+ $item = Mage::getResourceModel('sales/order_status_collection')
145
+ ->joinStates()
146
+ ->addFieldToFilter('main_table.status', $status);
147
+
148
+ return array_pop($item->getItems())->getState();
149
+ }
150
+
151
+ public function getMessage($status, $payment)
152
+ {
153
+ $rawMessage = Mage::helper('mercadopago')->__(Mage::helper('mercadopago/statusOrderMessage')->getMessage($status));
154
+ $rawMessage .= Mage::helper('mercadopago')->__('<br/> Payment id: %s', $payment['id']);
155
+ $rawMessage .= Mage::helper('mercadopago')->__('<br/> Status: %s', $payment['status']);
156
+ $rawMessage .= Mage::helper('mercadopago')->__('<br/> Status Detail: %s', $payment['status_detail']);
157
+
158
+ return $rawMessage;
159
+ }
160
+
161
+ public function setOrderSubtotals($data, $order)
162
+ {
163
+ if (isset($data['total_paid_amount'])){
164
+ $balance = $this->_getMultiCardValue($data['total_paid_amount']);
165
+ } else {
166
+ $balance = $data['transaction_details']['total_paid_amount'];
167
+ }
168
+ $shippingCost = $this->_getMultiCardValue($data['shipping_cost']);
169
+
170
+ $order->setGrandTotal($balance);
171
+ $order->setBaseGrandTotal($balance);
172
+ if ($shippingCost > 0) {
173
+ $order->setBaseShippingAmount($shippingCost);
174
+ $order->setShippingAmount($shippingCost);
175
+ }
176
+
177
+ $couponAmount = $this->_getMultiCardValue($data['coupon_amount']);
178
+ $transactionAmount = $this->_getMultiCardValue($data['transaction_amount']);
179
+
180
+ if ($couponAmount) {
181
+ $order->setDiscountCouponAmount($couponAmount * -1);
182
+ $order->setBaseDiscountCouponAmount($couponAmount * -1);
183
+ $balance = $balance - ($transactionAmount - $couponAmount + $shippingCost);
184
+ } else {
185
+ $balance = $balance - $transactionAmount - $shippingCost;
186
+ }
187
+
188
+ if (Zend_Locale_Math::round($balance,4) > 0) {
189
+ $order->setFinanceCostAmount($balance);
190
+ $order->setBaseFinanceCostAmount($balance);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * @param $payment
196
+ *
197
+ * @return mixed
198
+ */
199
+ public function setPayerInfo(&$payment)
200
+ {
201
+ $payment["trunc_card"] = "xxxx xxxx xxxx " . $payment['card']["last_four_digits"];
202
+ $payment["cardholder_name"] = $payment['card']["cardholder"]["name"];
203
+ $payment['payer_first_name'] = $payment['payer']['first_name'];
204
+ $payment['payer_last_name'] = $payment['payer']['last_name'];
205
+ $payment['payer_email'] = $payment['payer']['email'];
206
+
207
+ return $payment;
208
+ }
209
+
210
+ protected function _getMultiCardValue($fullValue) {
211
+ $finalValue = 0;
212
+ $values = explode('|', $fullValue);
213
+ foreach ($values as $value) {
214
+ $value = (float) str_replace(' ', '', $value);
215
+ $finalValue = $finalValue + $value;
216
+ }
217
+
218
+ return $finalValue;
219
+ }
220
+
221
+ }
app/code/community/MercadoPago/Core/Helper/Message/Abstract.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class MercadoPago_Core_Helper_Message_Abstract
4
+ extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+ public abstract function getMessageMap();
8
+
9
+
10
+ /**
11
+ * @param $key
12
+ * @param null $args array()
13
+ *
14
+ * @return string
15
+ */
16
+ public function getMessage($key)
17
+ {
18
+ $messageMap = $this->getMessageMap();
19
+ if (isset($messageMap[$key])) {
20
+ return $messageMap[$key];
21
+ }
22
+
23
+ return '';
24
+ }
25
+
26
+ }
app/code/community/MercadoPago/Core/Helper/Response.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Helper_Response
18
+ {
19
+ /*
20
+ * HTTP Response Codes
21
+ */
22
+ const HTTP_OK = 200;
23
+ const HTTP_CREATED = 201;
24
+ const HTTP_MULTI_STATUS = 207;
25
+ const HTTP_BAD_REQUEST = 400;
26
+ const HTTP_UNAUTHORIZED = 401;
27
+ const HTTP_FORBIDDEN = 403;
28
+ const HTTP_NOT_FOUND = 404;
29
+ const HTTP_METHOD_NOT_ALLOWED = 405;
30
+ const HTTP_NOT_ACCEPTABLE = 406;
31
+ const HTTP_INTERNAL_ERROR = 500;
32
+ }
app/code/community/MercadoPago/Core/Helper/StatusDetailMessage.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Helper_StatusDetailMessage
4
+ extends MercadoPago_Core_Helper_Message_Abstract
5
+ {
6
+ protected $messagesMap = [
7
+ "cc_rejected_bad_filled_card_number" => 'Check the card number.',
8
+ "cc_rejected_bad_filled_date" => 'Check the expiration date.',
9
+ "cc_rejected_bad_filled_other" => 'Check the data.',
10
+ "cc_rejected_bad_filled_security_code" => 'Check the security code.',
11
+ "cc_rejected_blacklist" => 'We could not process your payment.',
12
+ "cc_rejected_call_for_authorize" => 'You must authorize to %s the payment of $ %s to MercadoPago.',
13
+ "cc_rejected_card_disabled" => 'Call %s to activate your card.<br/>The phone is on the back of your card.',
14
+ "cc_rejected_card_error" => 'We could not process your payment.',
15
+ "cc_rejected_duplicated_payment" => 'You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.',
16
+ "cc_rejected_high_risk" => 'Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.',
17
+ "cc_rejected_insufficient_amount" => 'Your %s do not have sufficient funds.',
18
+ "cc_rejected_invalid_installments" => '%s does not process payments in %s installments.',
19
+ "cc_rejected_max_attempts" => 'You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.',
20
+ "cc_rejected_other_reason" => '%s did not process the payment.',
21
+ ];
22
+
23
+ public function getMessageMap()
24
+ {
25
+ return $this->messagesMap;
26
+ }
27
+
28
+ }
app/code/community/MercadoPago/Core/Helper/StatusMessage.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Helper_StatusMessage
4
+ extends MercadoPago_Core_Helper_Message_Abstract
5
+ {
6
+ protected $messagesMap = [
7
+ "approved" => [
8
+ 'title' => 'Done, your payment was accredited!',
9
+ 'message' => ''
10
+ ],
11
+
12
+ "in_process" => [
13
+ 'title' => 'We are processing the payment.',
14
+ 'message' => 'In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.'
15
+ ],
16
+
17
+ "authorized" => [
18
+ 'title' => 'We are processing the payment.',
19
+ 'message' => 'In less than an hour we will send you by e-mail the result.'
20
+ ],
21
+
22
+ "pending" => [
23
+ 'title' => 'We are processing the payment.',
24
+ 'message' => 'In less than an hour we will send you by e-mail the result.'
25
+ ],
26
+
27
+ "rejected" => [
28
+ 'title' => 'We could not process your payment.',
29
+ 'message' => ''
30
+ ],
31
+
32
+ "cancelled" => [
33
+ 'title' => 'Payments were canceled.',
34
+ 'message' => 'Contact for more information.'
35
+ ],
36
+
37
+ "other" => [
38
+ 'title' => 'Thank you for your purchase!',
39
+ 'message' => ''
40
+ ]
41
+ ];
42
+
43
+ public function getMessageMap()
44
+ {
45
+ return $this->messagesMap;
46
+ }
47
+ }
app/code/community/MercadoPago/Core/Helper/StatusOrderMessage.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Helper_StatusOrderMessage
4
+ extends MercadoPago_Core_Helper_Message_Abstract
5
+ {
6
+ protected $messagesMap = [
7
+ "approved" => 'Automatic notification of the Mercado Pago: The payment was approved.',
8
+ "refunded" => 'Automatic notification of the Mercado Pago: The payment was refunded.',
9
+ "pending" => 'Automatic notification of the Mercado Pago: The payment is being processed.',
10
+ "in_process" => 'Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.',
11
+ "in_mediation" => 'Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.',
12
+ "cancelled" => 'Automatic notification of the Mercado Pago: The payment was cancelled.',
13
+ "rejected" => 'Automatic notification of the Mercado Pago: The payment was rejected.',
14
+ "chargeback" => 'Automatic notification of the Mercado Pago: One chargeback was initiated for this payment.',
15
+ ];
16
+
17
+ public function getMessageMap()
18
+ {
19
+ return $this->messagesMap;
20
+ }
21
+ }
app/code/community/MercadoPago/Core/Model/Api/Exception.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which thrown by MercadoPago API in case of processable error codes
5
+ */
6
+ class MercadoPago_Core_Model_Api_Exception
7
+ extends Mage_Core_Exception
8
+ {
9
+
10
+ const GENERIC_USER_MESSAGE = "We could not process your payment in this moment. Please check the form data and retry later";
11
+
12
+ protected $messagesMap;
13
+
14
+ /**
15
+ * Get error message which can be displayed to website user
16
+ *
17
+ * @return string
18
+ */
19
+ public function getUserMessage($error=null)
20
+ {
21
+ if (!empty($error)) {
22
+ if (Mage::getStoreConfigFlag('payment/mercadopago/debug_mode')) {
23
+ return $error['description'];
24
+ } else {
25
+ $code = $error['code'];
26
+ if (isset($this->messagesMap[$code])) {
27
+ return Mage::helper('mercadopago')->__($this->messagesMap[$code]);
28
+ }
29
+ }
30
+ }
31
+
32
+ return Mage::helper('mercadopago')->__(self::GENERIC_USER_MESSAGE);
33
+ }
34
+ }
app/code/community/MercadoPago/Core/Model/Api/V0/Exception.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which thrown by MercadoPago API in case of processable error codes
5
+ */
6
+ class MercadoPago_Core_Model_Api_V0_Exception extends MercadoPago_Core_Model_Api_Exception
7
+ {
8
+ protected $messagesMap =
9
+ array(
10
+ 106 => 'Cannot operate between users from different countries.',
11
+ 109 => 'Payment method does not process installments.',
12
+ 129 => 'Cannot pay this amount with this paymentMethod.',
13
+ 150 => 'You user cannot do payments currently',
14
+ 151 => 'You user cannot do payments currently with this payment method.',
15
+ 204 => 'Unavailable paymentmethod currently.',
16
+ 801 => 'Already posted the same request in the last minute.',
17
+ 'campaign_code_doesnt_match' => "Doesn't find a campaign with the given code."
18
+ );
19
+
20
+ }
app/code/community/MercadoPago/Core/Model/Api/V1/Exception.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which thrown by MercadoPago API in case of processable error codes from api v1
5
+ */
6
+ class MercadoPago_Core_Model_Api_V1_Exception
7
+ extends MercadoPago_Core_Model_Api_Exception
8
+ {
9
+ protected $messagesMap =
10
+ [
11
+ 1000 => 'The items Quantity has exceeded the limits. We could not process your payment.',
12
+ 2001 => 'Already posted the same request in the last minute.',
13
+ 2017 => 'The transaction amount is invalid. We could not process your payment.',
14
+ 2020 => 'You user cannot do payments currently',
15
+ 2022 => 'You have exceeded the max number of refunds for this payment.',
16
+ 2024 => 'Payment too old to be refunded',
17
+ 2034 => 'You user cannot do payments currently',
18
+ 2039 => 'Coupon code is invalid',
19
+ 2040 => 'Your user e-mail does not exist. Please check data and retry later',
20
+ 2043 => 'Coupon code is invalid',
21
+ 3000 => 'You must provide your cardholder name with your card data',
22
+ 3011 => 'Not found payment method or credit card. Please check the form data and retry.',
23
+ 3012 => 'Security code is invalid. Please check the form data and retry.',
24
+ 3013 => 'Security code is a required field. Please check the form data and retry.',
25
+ 3014 => 'Payment method or credit card invalid. Please check the form data and retry.',
26
+ 3015 => 'Credit card number is invalid. Please check the form data and retry.',
27
+ 3016 => 'Credit card number is invalid. Please check the form data and retry.',
28
+ 3018 => 'Expiration month can not be empty. Please check the form data and retry.',
29
+ 3019 => 'Expiration year can not be empty. Please check the form data and retry.',
30
+ 3020 => 'Cardholder name can not empty. Please check the form data and retry.',
31
+ 3021 => 'Cardholder document number can not be empty. Please check the form data and retry.',
32
+ 3022 => 'Cardholder document type can not be empty. Please check the form data and retry.',
33
+ 3023 => 'Cardholder document subtype can not be empty. Please check the form data and retry.',
34
+ 3029 => 'Expiration month is invalid. Please check the form data and retry.',
35
+ 3030 => 'Expiration year is invalid. Please check the form data and retry.',
36
+ 4004 => 'Installments attribute can not be empty. Please check the form data and retry.',
37
+ 4026 => 'Coupon amount is invalid. Please check the form data and retry.',
38
+ 'campaign_code_doesnt_match' => "Doesn't find a campaign with the given code.",
39
+ 'amount_doesnt_match' => "Doesn't find a campaign to amount given",
40
+ 'transaction_amount_invalid' => "Amount discount is invalid"
41
+ ];
42
+
43
+ }
app/code/community/MercadoPago/Core/Model/Core.php ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Core
18
+ extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ protected $_code = 'mercadopago';
21
+
22
+ protected $_isGateway = true;
23
+ protected $_canOrder = true;
24
+ protected $_canAuthorize = true;
25
+ protected $_canCapture = true;
26
+ protected $_canCapturePartial = true;
27
+ protected $_canRefund = true;
28
+ protected $_canRefundInvoicePartial = true;
29
+ protected $_canVoid = true;
30
+ protected $_canUseInternal = true;
31
+ protected $_canUseCheckout = true;
32
+ protected $_canUseForMultishipping = true;
33
+ protected $_canFetchTransactionInfo = true;
34
+ protected $_canCreateBillingAgreement = true;
35
+ protected $_canReviewPayment = true;
36
+
37
+ const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
38
+ const LOG_FILE = 'mercadopago-custom.log';
39
+
40
+ /**
41
+ * @return Mage_Checkout_Model_Session
42
+ */
43
+ protected function _getCheckout()
44
+ {
45
+ return Mage::getSingleton('checkout/session');
46
+ }
47
+
48
+ /**
49
+ * Get admin checkout session namespace
50
+ *
51
+ * @return Mage_Adminhtml_Model_Session_Quote
52
+ */
53
+ protected function _getAdminCheckout()
54
+ {
55
+ return Mage::getSingleton('adminhtml/session_quote');
56
+ }
57
+
58
+ /**
59
+ * Retrieves Quote
60
+ *
61
+ * @param integer $quoteId
62
+ *
63
+ * @return Mage_Sales_Model_Quote
64
+ */
65
+ protected function _getQuote($quoteId = null)
66
+ {
67
+ if (!empty($quoteId)) {
68
+ return Mage::getModel('sales/quote')->load($quoteId);
69
+ } else {
70
+ if (Mage::app()->getStore()->isAdmin()) {
71
+ return $this->_getAdminCheckout()->getQuote();
72
+ } else {
73
+ return $this->_getCheckout()->getQuote();
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Retrieves Order
80
+ *
81
+ * @param integer $incrementId
82
+ *
83
+ * @return Mage_Sales_Model_Order
84
+ */
85
+ protected function _getOrder($incrementId)
86
+ {
87
+ return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
88
+ }
89
+
90
+ public function getInfoPaymentByOrder($order_id)
91
+ {
92
+ $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
93
+ $payment = $order->getPayment();
94
+ $info_payments = array();
95
+ $fields = array(
96
+ array("field" => "cardholderName", "title" => "Card Holder Name: %s"),
97
+ array("field" => "trunc_card", "title" => "Card Number: %s"),
98
+ array("field" => "payment_method", "title" => "Payment Method: %s"),
99
+ array("field" => "expiration_date", "title" => "Expiration Date: %s"),
100
+ array("field" => "installments", "title" => "Installments: %s"),
101
+ array("field" => "statement_descriptor", "title" => "Statement Descriptor: %s"),
102
+ array("field" => "payment_id", "title" => "Payment id (MercadoPago): %s"),
103
+ array("field" => "status", "title" => "Payment Status: %s"),
104
+ array("field" => "status_detail", "title" => "Payment Detail: %s"),
105
+ array("field" => "activation_uri", "title" => "Generate Ticket")
106
+ );
107
+
108
+ foreach ($fields as $field):
109
+ if ($payment->getAdditionalInformation($field['field']) != ""):
110
+ $text = Mage::helper('mercadopago')->__($field['title'], $payment->getAdditionalInformation($field['field']));
111
+ $info_payments[$field['field']] = array(
112
+ "text" => $text,
113
+ "value" => $payment->getAdditionalInformation($field['field'])
114
+ );
115
+ endif;
116
+ endforeach;
117
+
118
+ return $info_payments;
119
+ }
120
+
121
+ protected function validStatusTwoPayments($status)
122
+ {
123
+ $array_status = explode(" | ", $status);
124
+ $status_verif = true;
125
+ $status_final = "";
126
+ foreach ($array_status as $status):
127
+
128
+ if ($status_final == "") {
129
+ $status_final = $status;
130
+ } else {
131
+ if ($status_final != $status) {
132
+ $status_verif = false;
133
+ }
134
+ }
135
+ endforeach;
136
+
137
+ if ($status_verif === false) {
138
+ $status_final = "other";
139
+ }
140
+
141
+ return $status_final;
142
+ }
143
+
144
+ public function getMessageByStatus($status, $status_detail, $payment_method, $installment, $amount)
145
+ {
146
+ $status = $this->validStatusTwoPayments($status);
147
+ $status_detail = $this->validStatusTwoPayments($status_detail);
148
+
149
+ $message = array(
150
+ "title" => "",
151
+ "message" => ""
152
+ );
153
+
154
+ $rawMessage = Mage::helper('mercadopago/statusMessage')->getMessage($status);
155
+ $message['title'] = Mage::helper('mercadopago')->__($rawMessage['title']);
156
+
157
+ if ($status == 'rejected') {
158
+ if ($status_detail == 'cc_rejected_invalid_installments') {
159
+ $message['message'] = Mage::helper('mercadopago')
160
+ ->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method), $installment);
161
+ } elseif ($status_detail == 'cc_rejected_call_for_authorize') {
162
+ $message['message'] = Mage::helper('mercadopago')
163
+ ->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method), $amount);
164
+ } else {
165
+ $message['message'] = Mage::helper('mercadopago')
166
+ ->__(Mage::helper('mercadopago/statusDetailMessage')->getMessage($status_detail), strtoupper($payment_method));
167
+ }
168
+ } else {
169
+ $message['message'] = Mage::helper('mercadopago')->__($rawMessage['message']);
170
+ }
171
+
172
+ return $message;
173
+ }
174
+
175
+ protected function getCustomerInfo($customer, $order)
176
+ {
177
+ $email = htmlentities($customer->getEmail());
178
+ if ($email == "") {
179
+ $email = $order['customer_email'];
180
+ }
181
+
182
+ $first_name = htmlentities($customer->getFirstname());
183
+ if ($first_name == "") {
184
+ $first_name = $order->getBillingAddress()->getFirstname();
185
+ }
186
+
187
+ $last_name = htmlentities($customer->getLastname());
188
+ if ($last_name == "") {
189
+ $last_name = $order->getBillingAddress()->getLastname();
190
+ }
191
+
192
+ return array('email' => $email, 'first_name' => $first_name, 'last_name' => $last_name);
193
+ }
194
+
195
+ protected function getItemsInfo($order)
196
+ {
197
+ $dataItems = array();
198
+ foreach ($order->getAllVisibleItems() as $item) {
199
+ $product = $item->getProduct();
200
+ $image = (string)Mage::helper('catalog/image')->init($product, 'image');
201
+
202
+ $dataItems[] = array(
203
+ "id" => $item->getSku(),
204
+ "title" => $product->getName(),
205
+ "description" => $product->getName(),
206
+ "picture_url" => $image,
207
+ "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
208
+ "quantity" => (int)number_format($item->getQtyOrdered(), 0, '.', ''),
209
+ "unit_price" => (float)number_format($product->getPrice(), 2, '.', '')
210
+ );
211
+ }
212
+
213
+ /* verify discount and add it like an item */
214
+ $discount = $this->getDiscount();
215
+ if ($discount != 0) {
216
+ $dataItems[] = array(
217
+ "title" => "Discount by the Store",
218
+ "description" => "Discount by the Store",
219
+ "quantity" => 1,
220
+ "unit_price" => (float)number_format($discount, 2, '.', '')
221
+ );
222
+ }
223
+
224
+ return $dataItems;
225
+
226
+ }
227
+
228
+ protected function getCouponInfo($coupon, $coupon_code)
229
+ {
230
+ $infoCoupon = array();
231
+ $infoCoupon['coupon_amount'] = (float)$coupon['response']['coupon_amount'];
232
+ $infoCoupon['coupon_code'] = $coupon_code;
233
+ $infoCoupon['campaign_id'] = $coupon['response']['id'];
234
+ if ($coupon['status'] == 200) {
235
+ Mage::helper('mercadopago')->log("Coupon applied. API response 200.", self::LOG_FILE);
236
+ } else {
237
+ Mage::helper('mercadopago')->log("Coupon invalid, not applied.", self::LOG_FILE);
238
+ }
239
+
240
+ return $infoCoupon;
241
+ }
242
+
243
+ public function makeDefaultPreferencePaymentV1($payment_info = array())
244
+ {
245
+ $quote = $this->_getQuote();
246
+ $order_id = $quote->getReservedOrderId();
247
+ $order = $this->_getOrder($order_id);
248
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
249
+
250
+ $billing_address = $quote->getBillingAddress()->getData();
251
+ $customerInfo = $this->getCustomerInfo($customer, $order);
252
+
253
+ /* INIT PREFERENCE */
254
+ $preference = array();
255
+
256
+ $preference['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . "mercadopago/notifications/custom";
257
+
258
+ $preference['transaction_amount'] = (float)$this->getAmount();
259
+
260
+ $preference['external_reference'] = $order_id;
261
+ $preference['payer']['email'] = $customerInfo['email'];
262
+
263
+ if (!empty($payment_info['identification_type'])) {
264
+ $preference['payer']['identification']['type'] = $payment_info['identification_type'];
265
+ $preference['payer']['identification']['number'] = $payment_info['identification_number'];
266
+ }
267
+ $preference['additional_info']['items'] = $this->getItemsInfo($order);
268
+
269
+ $preference['additional_info']['payer']['first_name'] = $customerInfo['first_name'];
270
+ $preference['additional_info']['payer']['last_name'] = $customerInfo['last_name'];
271
+
272
+ $preference['additional_info']['payer']['address'] = array(
273
+ "zip_code" => $billing_address['postcode'],
274
+ "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
275
+ "street_number" => ''
276
+ );
277
+
278
+ $preference['additional_info']['payer']['registration_date'] = date('Y-m-d', $customer->getCreatedAtTimestamp()) . "T" . date('H:i:s', $customer->getCreatedAtTimestamp());
279
+
280
+ $shipping = $order->getShippingAddress()->getData();
281
+
282
+ $preference['additional_info']['shipments']['receiver_address'] = array(
283
+ "zip_code" => $shipping['postcode'],
284
+ "street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
285
+ "street_number" => '',
286
+ "floor" => "-",
287
+ "apartment" => "-",
288
+
289
+ );
290
+
291
+ $preference['additional_info']['payer']['phone'] = array(
292
+ "area_code" => "0",
293
+ "number" => $shipping['telephone']
294
+ );
295
+
296
+ if (!empty($payment_info['coupon_code'])) {
297
+ $coupon_code = $payment_info['coupon_code'];
298
+ Mage::helper('mercadopago')->log("Validating coupon_code: " . $coupon_code, self::LOG_FILE);
299
+
300
+ $coupon = $this->validCoupon($coupon_code);
301
+ Mage::helper('mercadopago')->log("Response API Coupon: ", self::LOG_FILE, $coupon);
302
+
303
+ $couponInfo = $this->getCouponInfo($coupon, $coupon_code);
304
+ $preference['coupon_amount'] = $couponInfo['coupon_amount'];
305
+ $preference['coupon_code'] = $couponInfo['coupon_code'];
306
+ $preference['campaign_id'] = $couponInfo['campaign_id'];
307
+
308
+ }
309
+
310
+ $sponsor_id = Mage::getStoreConfig('payment/mercadopago/sponsor_id');
311
+ Mage::helper('mercadopago')->log("Sponsor_id", 'mercadopago-standard.log', $sponsor_id);
312
+ if (!empty($sponsor_id)) {
313
+ Mage::helper('mercadopago')->log("Sponsor_id identificado", self::LOG_FILE, $sponsor_id);
314
+ $preference['sponsor_id'] = (int)$sponsor_id;
315
+ }
316
+
317
+ return $preference;
318
+ }
319
+
320
+
321
+ public function postPaymentV1($preference)
322
+ {
323
+
324
+ //obtem access_token
325
+ $access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
326
+ Mage::helper('mercadopago')->log("Access Token for Post", self::LOG_FILE, $access_token);
327
+
328
+ //seta sdk php mercadopago
329
+ $mp = Mage::helper('mercadopago')->getApiInstance($access_token);
330
+ $response = $mp->post("/v1/payments", $preference);
331
+ Mage::helper('mercadopago')->log("POST /v1/payments", self::LOG_FILE, $response);
332
+
333
+ if ($response['status'] == 200 || $response['status'] == 201) {
334
+ return $response;
335
+ } else {
336
+ $e = "";
337
+ $exception = new MercadoPago_Core_Model_Api_V1_Exception();
338
+ if (count($response['response']['cause']) > 0) {
339
+ foreach ($response['response']['cause'] as $error) {
340
+ $e .= $exception->getUserMessage($error) . " ";
341
+ }
342
+ } else {
343
+ $e = $exception->getUserMessage();
344
+ }
345
+
346
+ Mage::helper('mercadopago')->log("error post pago: " . $e, self::LOG_FILE);
347
+ Mage::helper('mercadopago')->log("response post pago: ", self::LOG_FILE, $response);
348
+
349
+ $exception->setMessage($e);
350
+ throw $exception;
351
+ }
352
+ }
353
+
354
+ public function getPayment($payment_id)
355
+ {
356
+ $clienId = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
357
+ $clientSecret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
358
+ $mp = Mage::helper('mercadopago')->getApiInstance($clienId, $clientSecret);
359
+
360
+ return $mp->get_payment($payment_id);
361
+ }
362
+
363
+ public function getPaymentV1($payment_id)
364
+ {
365
+ $this->access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
366
+ $mp = Mage::helper('mercadopago')->getApiInstance($this->access_token);
367
+
368
+ return $mp->get("/v1/payments/" . $payment_id);
369
+ }
370
+
371
+ public function getMerchantOrder($merchant_order_id)
372
+ {
373
+ $clientId = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
374
+ $clientSecret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
375
+ $mp = Mage::helper('mercadopago')->getApiInstance($clientId, $clientSecret);
376
+
377
+ return $mp->get("/merchant_orders/" . $merchant_order_id);
378
+ }
379
+
380
+ public function getPaymentMethods()
381
+ {
382
+ $this->access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
383
+
384
+ $mp = Mage::helper('mercadopago')->getApiInstance($this->access_token);
385
+
386
+ $payment_methods = $mp->get("/v1/payment_methods");
387
+
388
+ return $payment_methods;
389
+ }
390
+
391
+ public function getEmailCustomer()
392
+ {
393
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
394
+ $email = $customer->getEmail();
395
+
396
+ if (empty($email)) {
397
+ $quote = $this->_getQuote();
398
+ $email = $quote->getBillingAddress()->getEmail();
399
+ }
400
+
401
+ return $email;
402
+ }
403
+
404
+
405
+ public function getAmount()
406
+ {
407
+ $quote = $this->_getQuote();
408
+ $total = $quote->getBaseSubtotalWithDiscount() + $quote->getShippingAddress()->getShippingAmount() + $quote->getShippingAddress()->getBaseTaxAmount();
409
+
410
+ return (float)$total;
411
+
412
+ }
413
+
414
+ public function validCoupon($id)
415
+ {
416
+ $this->access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
417
+
418
+ $mp = Mage::helper('mercadopago')->getApiInstance($this->access_token);
419
+
420
+ $params = array(
421
+ "transaction_amount" => $this->getAmount(),
422
+ "payer_email" => $this->getEmailCustomer(),
423
+ "coupon_code" => $id
424
+ );
425
+
426
+ $details_discount = $mp->get("/discount_campaigns", $params);
427
+
428
+ //add value on return api discount
429
+ $details_discount['response']['transaction_amount'] = $params['transaction_amount'];
430
+ $details_discount['response']['params'] = $params;
431
+
432
+
433
+ return $details_discount;
434
+ }
435
+
436
+ public function setStatusOrder($payment, $stateObject = null)
437
+ {
438
+ $helper = Mage::helper('mercadopago');
439
+ $order = Mage::getModel('sales/order')->loadByIncrementId($payment["external_reference"]);
440
+ $status = $payment['status'];
441
+
442
+ if (isset($payment['status_final'])) {
443
+ $status = $payment['status_final'];
444
+ }
445
+ $message = $helper->getMessage($status, $payment);
446
+
447
+ try {
448
+ if ($status == 'approved') {
449
+ Mage::helper('mercadopago')->setOrderSubtotals($payment, $order);
450
+
451
+ if (!$order->hasInvoices()) {
452
+ $invoice = $order->prepareInvoice();
453
+ $invoice->register()->pay();
454
+ Mage::getModel('core/resource_transaction')
455
+ ->addObject($invoice)
456
+ ->addObject($invoice->getOrder())
457
+ ->save();
458
+
459
+ $invoice->sendEmail(true, $message);
460
+ }
461
+ //Associate card to customer
462
+ $additionalInfo = $order->getPayment()->getAdditionalInformation();
463
+ if (isset($additionalInfo['token'])) {
464
+ Mage::getModel('mercadopago/custom_payment')->customerAndCards($additionalInfo['token'], $payment);
465
+ }
466
+
467
+
468
+ } elseif ($status == 'refunded' || $status == 'cancelled') {
469
+ $order->cancel();
470
+ }
471
+
472
+ $statusOrder = $helper->getStatusOrder($status);
473
+ if ($stateObject) {
474
+ $stateObject->setStatus($statusOrder);
475
+ $stateObject->setState($helper->_getAssignedState($statusOrder));
476
+ $stateObject->setIsNotified(true);
477
+ }
478
+
479
+ $order->setState($helper->_getAssignedState($statusOrder));
480
+ $order->addStatusToHistory($statusOrder, $message, true);
481
+ $order->sendOrderUpdateEmail(true, $message);
482
+
483
+ $status_save = $order->save();
484
+ $helper->log("Update order", 'mercadopago.log', $status_save->getData());
485
+ $helper->log($message, 'mercadopago.log');
486
+
487
+ return ['text' => $message, 'code' => MercadoPago_Core_Helper_Response::HTTP_OK];
488
+ } catch (Exception $e) {
489
+ $helper->log("error in set order status: " . $e, 'mercadopago.log');
490
+
491
+ return ['text' => $e, 'code' => MercadoPago_Core_Helper_Response::HTTP_BAD_REQUEST];
492
+ }
493
+ }
494
+
495
+ public function updateOrder($data)
496
+ {
497
+ Mage::helper('mercadopago')->log("Update Order", 'mercadopago-notification.log');
498
+
499
+ try {
500
+ $order = Mage::getModel('sales/order')->loadByIncrementId($data["external_reference"]);
501
+
502
+ $payment_order = $order->getPayment();
503
+
504
+ $additionalFields = array(
505
+ 'status',
506
+ 'status_detail',
507
+ 'payment_id',
508
+ 'transaction_amount',
509
+ 'cardholderName',
510
+ 'installments',
511
+ 'statement_descriptor',
512
+ 'trunc_card'
513
+
514
+ );
515
+
516
+ foreach ($additionalFields as $field) {
517
+ if (isset($data[$field])) {
518
+ $payment_order->setAdditionalInformation($field, $data[$field]);
519
+ }
520
+ }
521
+
522
+ if (isset($data['payment_method_id'])) {
523
+ $payment_order->setAdditionalInformation('payment_method', $data['payment_method_id']);
524
+ }
525
+
526
+ $payment_status = $payment_order->save();
527
+ Mage::helper('mercadopago')->log("Update Payment", 'mercadopago.log', $payment_status->getData());
528
+
529
+ if ($data['payer_first_name']) {
530
+ $order->setCustomerFirstname($data['payer_first_name']);
531
+ }
532
+
533
+ if ($data['payer_last_name']) {
534
+ $order->setCustomerLastname($data['payer_last_name']);
535
+ }
536
+
537
+ if ($data['payer_email']) {
538
+ $order->setCustomerEmail($data['payer_email']);
539
+ }
540
+
541
+
542
+ $status_save = $order->save();
543
+ Mage::helper('mercadopago')->log("Update order", 'mercadopago.log', $status_save->getData());
544
+ } catch (Exception $e) {
545
+ Mage::helper('mercadopago')->log("error in update order status: " . $e, 'mercadopago.log');
546
+ $this->getResponse()->setBody($e);
547
+
548
+ $this->getResponse()->setHttpResponseCode(MercadoPago_Core_Helper_Response::HTTP_BAD_REQUEST);
549
+ }
550
+ }
551
+
552
+ }
app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Custom_Finance_Cost
4
+ extends Mage_Sales_Model_Quote_Address_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'financing_cost';
8
+
9
+ public function collect(Mage_Sales_Model_Quote_Address $address)
10
+ {
11
+ if ($this->_getFinancingCondition($address)) {
12
+
13
+ $postData = Mage::app()->getRequest()->getPost();
14
+ parent::collect($address);
15
+
16
+ $totalAmount = (float)$postData['total_amount'];
17
+ $amount = (float)$postData['amount'] - (float)$postData['mercadopago-discount-amount'];
18
+ $balance = $totalAmount - $amount;
19
+
20
+ $address->setFinanceCostAmount($balance);
21
+ $address->setBaseFinanceCostAmount($balance);
22
+
23
+ $this->_setAmount($balance);
24
+ $this->_setBaseAmount($balance);
25
+
26
+ return $this;
27
+ }
28
+
29
+ if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
30
+ $address->setFinanceCostAmount(0);
31
+ $address->setBaseFinanceCostAmount(0);
32
+ }
33
+
34
+ return $this;
35
+ }
36
+
37
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
38
+ {
39
+ if ($this->_getFinancingCondition($address)) {
40
+ if ($address->getFinanceCostAmount() > 0) {
41
+ $address->addTotal(array(
42
+ 'code' => $this->getCode(),
43
+ 'title' => Mage::helper('mercadopago')->__('Financing Cost'),
44
+ 'value' => $address->getFinanceCostAmount()
45
+ ));
46
+ }
47
+ }
48
+
49
+ return $this;
50
+ }
51
+
52
+ protected function _getFinancingCondition($address)
53
+ {
54
+ $req = Mage::app()->getRequest()->getParam('total_amount');
55
+
56
+ return (!empty($req) && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING);
57
+
58
+ }
59
+ }
app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Creditmemo.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Custom_Finance_Cost_Creditmemo
4
+ extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'financing_cost';
8
+
9
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
10
+ {
11
+ $order = $creditmemo->getOrder();
12
+ $amount = $order->getFinanceCostAmount();
13
+ $baseAmount = $order->getBaseFinanceCostAmount();
14
+ if ($amount) {
15
+ $creditmemo->setFinanceCostAmount($amount);
16
+ $creditmemo->setBaseFinanceCostAmount($baseAmount);
17
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
18
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseAmount);
19
+ }
20
+
21
+ return $this;
22
+ }
23
+
24
+ }
app/code/community/MercadoPago/Core/Model/Custom/Finance/Cost/Invoice.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Custom_Finance_Cost_Invoice
4
+ extends Mage_Sales_Model_Order_Invoice_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'financing_cost';
8
+
9
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
10
+ {
11
+ $order = $invoice->getOrder();
12
+ $amount = $order->getFinanceCostAmount();
13
+ $baseAmount = $order->getBaseFinanceCostAmount();
14
+ if ($amount) {
15
+ $invoice->setFinanceCostAmount($amount);
16
+ $invoice->setBaseFinanceCostAmount($baseAmount);
17
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
18
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
19
+ }
20
+
21
+ return $this;
22
+ }
23
+
24
+ }
app/code/community/MercadoPago/Core/Model/Custom/Payment.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+ class MercadoPago_Core_Model_Custom_Payment
17
+ extends MercadoPago_Core_Model_CustomPayment
18
+ {
19
+ //configura o block do formulario e de informações sobre o pagamento
20
+ protected $_formBlockType = 'mercadopago/custom_form';
21
+ protected $_infoBlockType = 'mercadopago/custom_info';
22
+
23
+ protected $_code = 'mercadopago_custom';
24
+
25
+ const LOG_FILE = 'mercadopago-custom.log';
26
+ const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
27
+
28
+ public static $exclude_inputs_opc = ['issuer_id', 'card_expiration_month', 'card_expiration_year', 'card_holder_name', 'doc_type', 'doc_number'];
29
+
30
+ /**
31
+ * @param string $paymentAction
32
+ * @param object $stateObject
33
+ *
34
+ * @return bool
35
+ *
36
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
37
+ */
38
+ public function initialize($paymentAction, $stateObject)
39
+ {
40
+
41
+ if ($this->getInfoInstance()->getAdditionalInformation('token') == "") {
42
+ Mage::throwException(Mage::helper('mercadopago')->__('Verify the form data or wait until the validation of the payment data'));
43
+ }
44
+
45
+ $response = $this->preparePostPayment();
46
+
47
+ if ($response !== false):
48
+
49
+ $payment = $response['response'];
50
+ //set status
51
+ $this->getInfoInstance()->setAdditionalInformation('status', $payment['status']);
52
+ $this->getInfoInstance()->setAdditionalInformation('status_detail', $payment['status_detail']);
53
+
54
+ if ($response['status'] == 200 || $response['status'] == 201) {
55
+ Mage::helper('mercadopago')->log("Received Payment data", self::LOG_FILE, $payment);
56
+
57
+ $payment = Mage::helper('mercadopago')->setPayerInfo($payment);
58
+ $core = Mage::getModel('mercadopago/core');
59
+ Mage::helper('mercadopago')->log("Update Order", self::LOG_FILE);
60
+ $core->updateOrder($payment);
61
+ $core->setStatusOrder($payment, $stateObject);
62
+ }
63
+
64
+ return true;
65
+ endif;
66
+
67
+ return false;
68
+ }
69
+
70
+ protected function cleanFieldsOcp($info)
71
+ {
72
+ foreach (self::$exclude_inputs_opc as $field) {
73
+ $info[$field] = '';
74
+ }
75
+
76
+ return $info;
77
+ }
78
+
79
+ public function assignData($data)
80
+ {
81
+
82
+ // route /checkout/onepage/savePayment
83
+ if (!($data instanceof Varien_Object)) {
84
+ $data = new Varien_Object($data);
85
+ }
86
+
87
+ $info_form = $data->getData();
88
+ $info_form = $info_form['mercadopago_custom'];
89
+ if (isset($info_form['one_click_pay']) && $info_form['one_click_pay'] == 1) {
90
+ $info_form = $this->cleanFieldsOcp($info_form);
91
+ }
92
+
93
+ if (empty($info_form['token'])) {
94
+ $exception = new MercadoPago_Core_Model_Api_V1_Exception();
95
+ $exception->setMessage($exception->getUserMessage());
96
+ throw $exception;
97
+ }
98
+
99
+ Mage::helper('mercadopago')->log("info form", self::LOG_FILE, $info_form);
100
+ $info = $this->getInfoInstance();
101
+ $info->setAdditionalInformation($info_form);
102
+ $info->setAdditionalInformation('payment_type_id', "credit_card");
103
+ if (!empty($info_form['card_expiration_month']) && !empty($info_form['card_expiration_year'])) {
104
+ $info->setAdditionalInformation('expiration_date', $info_form['card_expiration_month'] . "/" . $info_form['card_expiration_year']);
105
+ }
106
+ $info->setAdditionalInformation('payment_method', $info_form['payment_method_id']);
107
+ $info->setAdditionalInformation('cardholderName', $info_form['card_holder_name']);
108
+
109
+ return $this;
110
+ }
111
+
112
+
113
+ public function getDiscount()
114
+ {
115
+ $discount = 0;
116
+ $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
117
+
118
+ if (isset($totals['discount']) && $totals['discount']->getValue()) {
119
+ $discount = $totals['discount']->getValue();
120
+ }
121
+
122
+ return $discount;
123
+ }
124
+
125
+ protected function getPaymentInfo($payment)
126
+ {
127
+ $payment_info = [];
128
+
129
+ if ($payment->getAdditionalInformation("coupon_code") != "") {
130
+ $payment_info['coupon_code'] = $payment->getAdditionalInformation("coupon_code");
131
+ }
132
+
133
+ if ($payment->getAdditionalInformation("doc_number") != "") {
134
+ $payment_info['identification_type'] = $payment->getAdditionalInformation("doc_type");
135
+ $payment_info['identification_number'] = $payment->getAdditionalInformation("doc_number");
136
+ }
137
+
138
+ return $payment_info;
139
+ }
140
+
141
+ public function preparePostPayment()
142
+ {
143
+ Mage::helper('mercadopago')->log("Credit Card -> init prepare post payment", self::LOG_FILE);
144
+ $core = Mage::getModel('mercadopago/core');
145
+ $quote = $this->_getQuote();
146
+ $order_id = $quote->getReservedOrderId();
147
+ $order = $this->_getOrder($order_id);
148
+
149
+ $payment = $order->getPayment();
150
+ $payment_info = $this->getPaymentInfo($payment);
151
+
152
+ $preference = $core->makeDefaultPreferencePaymentV1($payment_info);
153
+
154
+ $preference['installments'] = (int)$payment->getAdditionalInformation("installments");
155
+ $preference['payment_method_id'] = $payment->getAdditionalInformation("payment_method");
156
+ $preference['token'] = $payment->getAdditionalInformation("token");
157
+
158
+ if ($payment->getAdditionalInformation("issuer_id") != "") {
159
+ $preference['issuer_id'] = (int)$payment->getAdditionalInformation("issuer_id");
160
+ }
161
+
162
+ if ($payment->getAdditionalInformation("customer_id") != "") {
163
+ $preference['payer']['id'] = $payment->getAdditionalInformation("customer_id");
164
+ }
165
+
166
+ $preference['binary_mode'] = Mage::getStoreConfigFlag('payment/mercadopago_custom/binary_mode');
167
+ $preference['statement_descriptor'] = Mage::getStoreConfig('payment/mercadopago_custom/statement_descriptor');
168
+
169
+ Mage::helper('mercadopago')->log("Credit Card -> PREFERENCE to POST /v1/payments", self::LOG_FILE, $preference);
170
+
171
+ /* POST /v1/payments */
172
+ $response = $core->postPaymentV1($preference);
173
+
174
+ $order->save();
175
+
176
+ return $response;
177
+ }
178
+
179
+ public function customerAndCards($token, $payment_created)
180
+ {
181
+ $customer = $this->getOrCreateCustomer($payment_created['payer']['email']);
182
+
183
+ if ($customer !== false) {
184
+ $this->checkAndcreateCard($customer, $token, $payment_created);
185
+ }
186
+ }
187
+
188
+ public function getOrCreateCustomer($email)
189
+ {
190
+ if (empty($email)){
191
+ return false;
192
+ }
193
+ $access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
194
+
195
+ $mp = Mage::helper('mercadopago')->getApiInstance($access_token);
196
+
197
+ $customer = $mp->get("/v1/customers/search", ["email" => $email]);
198
+
199
+ Mage::helper('mercadopago')->log("Response search customer", self::LOG_FILE, $customer);
200
+
201
+ if ($customer['status'] == 200) {
202
+
203
+ if ($customer['response']['paging']['total'] > 0) {
204
+ return $customer['response']['results'][0];
205
+ } else {
206
+ Mage::helper('mercadopago')->log("Customer not found: " . $email, self::LOG_FILE);
207
+
208
+ $customer = $mp->post("/v1/customers", ["email" => $email]);
209
+
210
+ Mage::helper('mercadopago')->log("Response create customer", self::LOG_FILE, $customer);
211
+
212
+ if ($customer['status'] == 201) {
213
+ return $customer['response'];
214
+ } else {
215
+ return false;
216
+ }
217
+ }
218
+ } else {
219
+ return false;
220
+ }
221
+ }
222
+
223
+ public function checkAndcreateCard($customer, $token, $payment)
224
+ {
225
+ $access_token = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
226
+
227
+ $mp = Mage::helper('mercadopago')->getApiInstance($access_token);
228
+
229
+ foreach ($customer['cards'] as $card) {
230
+
231
+
232
+ if ($card['first_six_digits'] == $payment['card']['first_six_digits']
233
+ && $card['last_four_digits'] == $payment['card']['last_four_digits']
234
+ && $card['expiration_month'] == $payment['card']['expiration_month']
235
+ && $card['expiration_year'] == $payment['card']['expiration_year']
236
+ ) {
237
+ Mage::helper('mercadopago')->log("Card already exists", self::LOG_FILE, $card);
238
+
239
+ return $card;
240
+ }
241
+ }
242
+ $params = ["token" => $token];
243
+ if (isset($payment['issuer_id'])){
244
+ $params['issuer_id'] = (int)$payment['issuer_id'];
245
+ }
246
+ if (isset($payment['payment_method_id'])){
247
+ $params['payment_method_id'] = $payment['payment_method_id'];
248
+ }
249
+ $card = $mp->post("/v1/customers/" . $customer['id'] . "/cards", $params);
250
+
251
+ Mage::helper('mercadopago')->log("Response create card", self::LOG_FILE, $card);
252
+
253
+ if ($card['status'] == 201) {
254
+ return $card['response'];
255
+ }
256
+
257
+ return false;
258
+ }
259
+
260
+ public function getCustomerAndCards()
261
+ {
262
+ $email = Mage::getModel('mercadopago/core')->getEmailCustomer();
263
+
264
+ $customer = $this->getOrCreateCustomer($email);
265
+
266
+ return $customer;
267
+ }
268
+
269
+
270
+ public function getOrderPlaceRedirectUrl()
271
+ {
272
+ return Mage::getUrl('mercadopago/success', ['_secure' => true]);
273
+ }
274
+
275
+ public function getCode() {
276
+ return $this->_code;
277
+ }
278
+
279
+ }
app/code/community/MercadoPago/Core/Model/CustomPayment.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: dami
6
+ * Date: 20/10/15
7
+ * Time: 17:26
8
+ */
9
+ abstract class MercadoPago_Core_Model_CustomPayment
10
+ extends Mage_Payment_Model_Method_Abstract
11
+ {
12
+
13
+ protected $_canSaveCc = false;
14
+ protected $_isGateway = true;
15
+ protected $_canAuthorize = true;
16
+ protected $_canCapture = true;
17
+ protected $_canVoid = true;
18
+ protected $_canCancelInvoice = true;
19
+ protected $_isInitializeNeeded = true;
20
+ protected $_canFetchTransactionInfo = true;
21
+ protected $_canCreateBillingAgreement = true;
22
+ protected $_canReviewPayment = true;
23
+
24
+ /**
25
+ * Check whether payment method can be used
26
+ *
27
+ * @param Mage_Sales_Model_Quote|null $quote
28
+ *
29
+ * @return bool
30
+ */
31
+ public function isAvailable($quote = null)
32
+ {
33
+ $parent = parent::isAvailable($quote);
34
+ $accessToken = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_ACCESS_TOKEN);
35
+ $publicKey = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_PUBLIC_KEY);
36
+ $custom = (!empty($publicKey) && !empty($accessToken));
37
+
38
+ if (!$parent || !$custom) {
39
+ return false;
40
+ }
41
+
42
+ return Mage::helper('mercadopago')->isValidAccessToken($accessToken);
43
+ }
44
+
45
+ /**
46
+ * @return Mage_Checkout_Model_Session
47
+ */
48
+ protected function _getCheckout()
49
+ {
50
+ return Mage::getSingleton('checkout/session');
51
+ }
52
+
53
+ /**
54
+ * Get admin checkout session namespace
55
+ *
56
+ * @return Mage_Adminhtml_Model_Session_Quote
57
+ */
58
+ protected function _getAdminCheckout()
59
+ {
60
+ return Mage::getSingleton('adminhtml/session_quote');
61
+ }
62
+
63
+ /**
64
+ * Retrieves Quote
65
+ *
66
+ * @param integer $quoteId
67
+ *
68
+ * @return Mage_Sales_Model_Quote
69
+ */
70
+ protected function _getQuote($quoteId = null)
71
+ {
72
+ if (!empty($quoteId)) {
73
+ return Mage::getModel('sales/quote')->load($quoteId);
74
+ } else {
75
+ if (Mage::app()->getStore()->isAdmin()) {
76
+ return $this->_getAdminCheckout()->getQuote();
77
+ } else {
78
+ return $this->_getCheckout()->getQuote();
79
+ }
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Retrieves Order
85
+ *
86
+ * @param integer $incrementId
87
+ *
88
+ * @return Mage_Sales_Model_Order
89
+ */
90
+ protected function _getOrder($incrementId)
91
+ {
92
+ return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
93
+ }
94
+ }
app/code/community/MercadoPago/Core/Model/CustomTicket/Payment.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_CustomTicket_Payment
18
+ extends MercadoPago_Core_Model_CustomPayment
19
+ {
20
+ //configura o lugar do arquivo para listar meios de pagamento
21
+ protected $_formBlockType = 'mercadopago/customticket_form';
22
+ protected $_infoBlockType = 'mercadopago/customticket_info';
23
+
24
+ protected $_code = 'mercadopago_customticket';
25
+
26
+ /**
27
+ * @param string $paymentAction
28
+ * @param object $stateObject
29
+ *
30
+ * @return bool
31
+ *
32
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
33
+ */
34
+ public function initialize($paymentAction, $stateObject)
35
+ {
36
+ $response = $this->preparePostPayment();
37
+
38
+ if ($response !== false) {
39
+ $this->getInfoInstance()->setAdditionalInformation('activation_uri', $response['response']['transaction_details']['external_resource_url']);
40
+
41
+ return true;
42
+ }
43
+
44
+ return false;
45
+ }
46
+
47
+ public function assignData($data)
48
+ {
49
+
50
+ // route /checkout/onepage/savePayment
51
+ if (!($data instanceof Varien_Object)) {
52
+ $data = new Varien_Object($data);
53
+ }
54
+
55
+ //get array info
56
+ $info_form = $data->getData();
57
+ $info_form = $info_form['mercadopago_customticket'];
58
+
59
+ Mage::helper('mercadopago')->log("info form", 'mercadopago-custom.log', $info_form);
60
+
61
+ $info = $this->getInfoInstance();
62
+ $info->setAdditionalInformation('payment_method', $info_form['payment_method_ticket']);
63
+
64
+ if (isset($info_form['coupon_code'])) {
65
+ $info->setAdditionalInformation('coupon_code', $info_form['coupon_code']);
66
+ }
67
+
68
+ return $this;
69
+ }
70
+
71
+ public function preparePostPayment()
72
+ {
73
+ Mage::helper('mercadopago')->log("Ticket -> init prepare post payment", 'mercadopago-custom.log');
74
+ $core = Mage::getModel('mercadopago/core');
75
+ $quote = $this->_getQuote();
76
+ $order_id = $quote->getReservedOrderId();
77
+ $order = $this->_getOrder($order_id);
78
+
79
+ //pega payment dentro da order para pegar as informacoes adicionadas pela funcao assignData()
80
+ $payment = $order->getPayment();
81
+
82
+ $payment_info = array();
83
+
84
+ /* verifica se o pagamento possui coupon_code */
85
+ if ($payment->getAdditionalInformation("coupon_code") != "") {
86
+ $payment_info['coupon_code'] = $payment->getAdditionalInformation("coupon_code");
87
+ }
88
+
89
+ /* cria a preferencia padrão */
90
+ $preference = $core->makeDefaultPreferencePaymentV1($payment_info);
91
+
92
+ /* adiciona informações sobre pagamento com ticket */
93
+ $preference['payment_method_id'] = $payment->getAdditionalInformation("payment_method");
94
+
95
+ Mage::helper('mercadopago')->log("Ticket -> PREFERENCE to POST /v1/payments", 'mercadopago-custom.log', $preference);
96
+
97
+ /* POST /v1/payments */
98
+
99
+ return $core->postPaymentV1($preference);
100
+ }
101
+
102
+ public function getOrderPlaceRedirectUrl()
103
+ {
104
+ // requisicao vem da pagina de finalizacao de pedido
105
+ return Mage::getUrl('mercadopago/success', array('_secure' => true));
106
+ }
107
+
108
+
109
+ public function getSuccessBlockType()
110
+ {
111
+ return $this->_successBlockType;
112
+ }
113
+
114
+
115
+ }
app/code/community/MercadoPago/Core/Model/Discount/Coupon.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Discount_Coupon
4
+ extends Mage_Sales_Model_Quote_Address_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'discount_coupon';
8
+
9
+ public function collect(Mage_Sales_Model_Quote_Address $address)
10
+ {
11
+ if ($this->_getDiscountCondition($address)) {
12
+
13
+ $postData = Mage::app()->getRequest()->getPost();
14
+ parent::collect($address);
15
+
16
+ $balance = $postData['mercadopago-discount-amount'] * -1;
17
+
18
+ $address->setDiscountCouponAmount($balance);
19
+ $address->setBaseDiscountCouponAmount($balance);
20
+
21
+ $this->_setAmount($balance);
22
+ $this->_setBaseAmount($balance);
23
+
24
+ return $this;
25
+ }
26
+ if ($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
27
+ $address->setDiscountCouponAmount(0);
28
+ $address->setBaseDiscountCouponAmount(0);
29
+ }
30
+
31
+ return $this;
32
+
33
+ }
34
+
35
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
36
+ {
37
+ if ($this->_getDiscountCondition($address)) {
38
+ if ($address->getDiscountCouponAmount() < 0) {
39
+ $address->addTotal([
40
+ 'code' => $this->getCode(),
41
+ 'title' => Mage::helper('mercadopago')->__('Discount Mercado Pago'),
42
+ 'value' => $address->getDiscountCouponAmount()
43
+ ]);
44
+ }
45
+ }
46
+
47
+ return $this;
48
+ }
49
+
50
+ protected function _getDiscountCondition($address)
51
+ {
52
+ $req = Mage::app()->getRequest()->getParam('total_amount');
53
+
54
+ return (!empty($req) && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING);
55
+
56
+ }
57
+ }
app/code/community/MercadoPago/Core/Model/Discount/Coupon/Creditmemo.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Discount_Coupon_Creditmemo
4
+ extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'financing_cost';
8
+
9
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
10
+ {
11
+ $order = $creditmemo->getOrder();
12
+ $amount = $order->getDiscountCouponAmount();
13
+ $baseAmount = $order->getBaseDiscountCouponAmount();
14
+ if ($amount) {
15
+ $creditmemo->setDiscountCouponAmount($amount);
16
+ $creditmemo->setBaseDiscountCouponAmount($baseAmount);
17
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
18
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseAmount);
19
+ }
20
+
21
+ return $this;
22
+ }
23
+
24
+ }
app/code/community/MercadoPago/Core/Model/Discount/Coupon/Invoice.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_Core_Model_Discount_Coupon_Invoice
4
+ extends Mage_Sales_Model_Order_Invoice_Total_Abstract
5
+ {
6
+
7
+ protected $_code = 'discount_coupon';
8
+
9
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
10
+ {
11
+ $order = $invoice->getOrder();
12
+ $amount = $order->getDiscountCouponAmount();
13
+ $baseAmount = $order->getBaseDiscountCouponAmount();
14
+ if ($amount) {
15
+ $invoice->setDiscountCouponAmount($amount);
16
+ $invoice->setDiscountCouponAmount($baseAmount);
17
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
18
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
19
+ }
20
+
21
+ return $this;
22
+ }
23
+
24
+ }
app/code/community/MercadoPago/Core/Model/Observer.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Observer
18
+ {
19
+ private $banners = [
20
+ "mercadopago_custom" => [
21
+ "mla" => "http://imgmp.mlstatic.com/org-img/banners/ar/medios/online/468X60.jpg",
22
+ "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg",
23
+ "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
24
+ "mlm" => "http://imgmp.mlstatic.com/org-img/banners/mx/medios/MLM_468X60.JPG",
25
+ "mlc" => "https://secure.mlstatic.com/developers/site/cloud/banners/cl/468x60.gif",
26
+ "mlv" => "https://imgmp.mlstatic.com/org-img/banners/ve/medios/468X60.jpg",
27
+ ],
28
+ "mercadopago_customticket" => [
29
+ "mla" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
30
+ "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png",
31
+ "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
32
+ "mlm" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
33
+ "mlc" => "https://secure.mlstatic.com/developers/site/cloud/banners/cl/468x60.gif",
34
+ "mlv" => "https://imgmp.mlstatic.com/org-img/banners/ve/medios/468X60.jpg",
35
+ ],
36
+ "mercadopago_standard" => [
37
+ "mla" => "http://imgmp.mlstatic.com/org-img/banners/ar/medios/online/468X60.jpg",
38
+ "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg",
39
+ "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
40
+ "mlc" => "https://secure.mlstatic.com/developers/site/cloud/banners/cl/468x60.gif",
41
+ "mlv" => "https://imgmp.mlstatic.com/org-img/banners/ve/medios/468X60.jpg",
42
+ "mlm" => "http://imgmp.mlstatic.com/org-img/banners/mx/medios/MLM_468X60.JPG"
43
+ ]
44
+ ];
45
+
46
+ private $available_transparent_credit_cart = ['mla', 'mlb', 'mlm', 'mco', 'mlv', 'mlc'];
47
+ private $available_transparent_ticket = ['mla', 'mlb', 'mlm'];
48
+
49
+ const LOG_FILE = 'mercadopago.log';
50
+
51
+ /**
52
+ * @param $observer
53
+ *
54
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
55
+ */
56
+ public function checkAndValidData($observer)
57
+ {
58
+ $this->validateAccessToken();
59
+
60
+ $this->validateClientCredentials();
61
+
62
+ $this->setSponsor();
63
+
64
+ $this->availableCheckout();
65
+
66
+ $this->checkBanner('mercadopago_custom');
67
+ $this->checkBanner('mercadopago_customticket');
68
+ $this->checkBanner('mercadopago_standard');
69
+ }
70
+
71
+
72
+ public function availableCheckout()
73
+ {
74
+ //verifica se o pais selecionado possui integracao para utilizar os checkouts transparents
75
+
76
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
77
+
78
+ if (!in_array($country, $this->available_transparent_credit_cart)) {
79
+ Mage::getConfig()->saveConfig('payment/mercadopago_custom/active', 0);
80
+ }
81
+
82
+ if (!in_array($country, $this->available_transparent_ticket)) {
83
+ Mage::getConfig()->saveConfig('payment/mercadopago_customticket/active', 0);
84
+ }
85
+ }
86
+
87
+ public function checkBanner($type_checkout)
88
+ {
89
+ //get country
90
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
91
+ if (!isset($this->banners[$type_checkout][$country])) {
92
+ return;
93
+ }
94
+ $default_banner = $this->banners[$type_checkout][$country];
95
+
96
+ $current_banner = Mage::getStoreConfig('payment/' . $type_checkout . '/banner_checkout');
97
+
98
+ Mage::helper('mercadopago')->log("Type Checkout Path: " . $type_checkout, self::LOG_FILE);
99
+ Mage::helper('mercadopago')->log("Current Banner: " . $current_banner, self::LOG_FILE);
100
+ Mage::helper('mercadopago')->log("Default Banner: " . $default_banner, self::LOG_FILE);
101
+
102
+ if (in_array($current_banner, $this->banners[$type_checkout])) {
103
+ Mage::helper('mercadopago')->log("Banner default need update...", self::LOG_FILE);
104
+
105
+ if ($default_banner != $current_banner) {
106
+ Mage::getConfig()->saveConfig('payment/' . $type_checkout . '/banner_checkout', $default_banner);
107
+
108
+ Mage::helper('mercadopago')->log('payment/' . $type_checkout . '/banner_checkout setted ' . $default_banner, self::LOG_FILE);
109
+ }
110
+ }
111
+ }
112
+
113
+
114
+ public function setSponsor()
115
+ {
116
+ Mage::helper('mercadopago')->log("Sponsor_id: " . Mage::getStoreConfig('payment/mercadopago/sponsor_id'), self::LOG_FILE);
117
+
118
+ $sponsor_id = "";
119
+ Mage::helper('mercadopago')->log("Valid user test", self::LOG_FILE);
120
+
121
+ $access_token = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_ACCESS_TOKEN);
122
+ Mage::helper('mercadopago')->log("Get access_token: " . $access_token, self::LOG_FILE);
123
+
124
+ $mp = Mage::helper('mercadopago')->getApiInstance($access_token);
125
+ $user = $mp->get("/users/me");
126
+ Mage::helper('mercadopago')->log("API Users response", self::LOG_FILE, $user);
127
+
128
+ if ($user['status'] == 200 && !in_array("test_user", $user['response']['tags'])) {
129
+
130
+ switch ($user['response']['site_id']) {
131
+ case 'MLA':
132
+ $sponsor_id = 186172525;
133
+ break;
134
+ case 'MLB':
135
+ $sponsor_id = 186175129;
136
+ break;
137
+ case 'MLM':
138
+ $sponsor_id = 186175064;
139
+ break;
140
+ case 'MCO':
141
+ $sponsor_id = 206959966;
142
+ break;
143
+ case 'MLC':
144
+ $sponsor_id = 206959756;
145
+ break;
146
+ case 'MLV':
147
+ $sponsor_id = 206960619;
148
+ break;
149
+ default:
150
+ $sponsor_id = "";
151
+ break;
152
+ }
153
+
154
+ Mage::helper('mercadopago')->log("Sponsor id setted", self::LOG_FILE, $sponsor_id);
155
+ }
156
+
157
+ Mage::getConfig()->saveConfig('payment/mercadopago/sponsor_id', $sponsor_id);
158
+ Mage::helper('mercadopago')->log("Sponsor saved", self::LOG_FILE, $sponsor_id);
159
+ }
160
+
161
+ protected function validateAccessToken()
162
+ {
163
+ $accessToken = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_ACCESS_TOKEN);
164
+ if (!empty($accessToken)) {
165
+ if (!Mage::helper('mercadopago')->isValidAccessToken($accessToken)) {
166
+ Mage::throwException(Mage::helper('mercadopago')->__('Mercado Pago - Custom Checkout: Invalid access token'));
167
+ }
168
+ }
169
+ }
170
+
171
+ protected function validateClientCredentials()
172
+ {
173
+ $clientId = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
174
+ $clientSecret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
175
+ if (!empty($clientId) && !empty($clientSecret)) {
176
+ if (!Mage::helper('mercadopago')->isValidClientCredentials($clientId, $clientSecret)) {
177
+ Mage::throwException(Mage::helper('mercadopago')->__('Mercado Pago - Classic Checkout: Invalid client id or client secret'));
178
+ }
179
+ }
180
+ }
181
+ }
app/code/community/MercadoPago/Core/Model/Source/CategoryId.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Source_CategoryId
18
+ extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ Mage::helper('mercadopago')->log("Get Categories... ", 'mercadopago.log');
23
+
24
+ $response = MercadoPago_Lib_RestClient::get("/item_categories");
25
+ Mage::helper('mercadopago')->log("API item_categories", 'mercadopago.log', $response);
26
+
27
+ $response = $response['response'];
28
+
29
+ $cat = array();
30
+ $count = 0;
31
+ foreach ($response as $v) {
32
+ //force category others first
33
+ if ($v['id'] == "others") {
34
+ $cat[0] = array('value' => $v['id'], 'label' => Mage::helper('mercadopago')->__($v['description']));
35
+ } else {
36
+ $count++;
37
+ $cat[$count] = array('value' => $v['id'], 'label' => Mage::helper('mercadopago')->__($v['description']));
38
+ }
39
+
40
+ };
41
+
42
+ //force order by key
43
+ ksort($cat);
44
+
45
+ return $cat;
46
+ }
47
+ }
app/code/community/MercadoPago/Core/Model/Source/Country.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Source_Country
18
+ extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ $country = array();
23
+ $country[] = array('value' => "mla", 'label' => Mage::helper('mercadopago')->__("Argentina"), 'code' => 'AR');
24
+ $country[] = array('value' => "mlb", 'label' => Mage::helper('mercadopago')->__("Brasil"), 'code' => 'BR');
25
+ $country[] = array('value' => "mco", 'label' => Mage::helper('mercadopago')->__("Colombia"), 'code' => 'CO');
26
+ $country[] = array('value' => "mlm", 'label' => Mage::helper('mercadopago')->__("Mexico"), 'code' => 'MX');
27
+ $country[] = array('value' => "mlc", 'label' => Mage::helper('mercadopago')->__("Chile"), 'code' => 'CL');
28
+ $country[] = array('value' => "mlv", 'label' => Mage::helper('mercadopago')->__("Venezuela"), 'code' => 'VE');
29
+
30
+ //force order by key
31
+ ksort($country);
32
+
33
+ return $country;
34
+ }
35
+
36
+ public function getCodeByValue($value)
37
+ {
38
+ $countries = $this->toOptionArray();
39
+ foreach ($countries as $country) {
40
+ if ($value == $country['value']) {
41
+ return $country['code'];
42
+ }
43
+ }
44
+ return '';
45
+ }
46
+ }
app/code/community/MercadoPago/Core/Model/Source/Installments.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+
18
+ class MercadoPago_Core_Model_Source_Installments
19
+ extends Mage_Payment_Model_Method_Abstract
20
+ {
21
+ public function toOptionArray()
22
+ {
23
+ $installment = array();
24
+
25
+ Mage::helper('mercadopago')->log("Get installments ... ", 'mercadopago.log');
26
+
27
+ $installment[] = array("value" => 1, "label" => "1");
28
+ $installment[] = array("value" => 2, "label" => "2");
29
+ $installment[] = array("value" => 3, "label" => "3");
30
+ $installment[] = array("value" => 4, "label" => "4");
31
+ $installment[] = array("value" => 5, "label" => "5");
32
+ $installment[] = array("value" => 6, "label" => "6");
33
+ $installment[] = array("value" => 9, "label" => "9");
34
+ $installment[] = array("value" => 10, "label" => "10");
35
+ $installment[] = array("value" => 12, "label" => "12");
36
+ $installment[] = array("value" => 15, "label" => "15");
37
+ $installment[] = array("value" => 24, "label" => "24");
38
+
39
+ Mage::helper('mercadopago')->log("Installments ... ", 'mercadopago.log', $installment);
40
+
41
+ return $installment;
42
+ }
43
+ }
app/code/community/MercadoPago/Core/Model/Source/Order/Status.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order Statuses source model
4
+ */
5
+ class MercadoPago_Core_Model_Source_Order_Status extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
6
+ {
7
+ // set null to enable all possible
8
+ protected $_stateStatuses = array(
9
+ Mage_Sales_Model_Order::STATE_NEW,
10
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
11
+ Mage_Sales_Model_Order::STATE_PROCESSING,
12
+ //Mage_Sales_Model_Order::STATE_COMPLETE,
13
+ //Mage_Sales_Model_Order::STATE_CLOSED,
14
+ Mage_Sales_Model_Order::STATE_CANCELED,
15
+ Mage_Sales_Model_Order::STATE_HOLDED,
16
+ );
17
+
18
+ }
app/code/community/MercadoPago/Core/Model/Source/PaymentMethods.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Source_PaymentMethods
18
+ extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ const XML_PATH_ACCESS_TOKEN = 'payment/mercadopago_custom_checkout/access_token';
21
+
22
+ public function toOptionArray()
23
+ {
24
+ $methods = array();
25
+ $helper = Mage::helper('mercadopago');
26
+
27
+ //adiciona um valor vazio caso nao queria excluir nada
28
+ $methods[] = array("value" => "", "label" => "");
29
+
30
+ $accessToken = Mage::getStoreConfig(self::XML_PATH_ACCESS_TOKEN);
31
+ $clientId = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
32
+ $clientSecret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
33
+ if (empty($accessToken) && !$helper->isValidClientCredentials($clientId, $clientSecret)) {
34
+ return $methods;
35
+ }
36
+
37
+ //if accessToken is empty uses clientId and clientSecret to obtain it
38
+ if (empty($accessToken)) {
39
+ $accessToken = $helper->getAccessToken();
40
+ }
41
+
42
+ $helper->log("Get payment methods by country... ", 'mercadopago.log');
43
+ $helper->log("API payment methods: " . "/v1/payment_methods?access_token=" . $accessToken, 'mercadopago.log');
44
+ $response = MercadoPago_Lib_RestClient::get("/v1/payment_methods?access_token=" . $accessToken);
45
+
46
+ $helper->log("API payment methods", 'mercadopago.log', $response);
47
+
48
+ if (isset($response['error'])) {
49
+ return $methods;
50
+ }
51
+
52
+ $response = $response['response'];
53
+
54
+ foreach ($response as $m) {
55
+ if ($m['id'] != 'account_money') {
56
+ $methods[] = array(
57
+ 'value' => $m['id'],
58
+ 'label' => $helper->__($m['name'])
59
+ );
60
+ }
61
+ }
62
+
63
+ return $methods;
64
+ }
65
+ }
app/code/community/MercadoPago/{Block/Discount.php → Core/Model/Source/TypeCheckout.php} RENAMED
@@ -15,12 +15,16 @@
15
  */
16
 
17
 
18
- class MercadoPago_Block_Discount extends Mage_Core_Block_Template{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
- $this->setTemplate('mercadopago/discount.phtml');
 
 
 
24
 
 
25
  }
26
- }
15
  */
16
 
17
 
18
+ class MercadoPago_Core_Model_Source_TypeCheckout extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ $arr = array(
23
+ array("value"=> "iframe", 'label'=>Mage::helper('mercadopago')->__("Iframe")),
24
+ array("value"=> "redirect", 'label'=>Mage::helper('mercadopago')->__("Redirect")),
25
+ array("value"=> "lightbox", 'label'=>Mage::helper('mercadopago')->__("Lightbox"))
26
+ );
27
 
28
+ return $arr;
29
  }
30
+ }
app/code/community/MercadoPago/Core/Model/Standard/Payment.php ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_Model_Standard_Payment
18
+ extends Mage_Payment_Model_Method_Abstract
19
+ {
20
+ protected $_formBlockType = 'mercadopago/standard_form';
21
+ protected $_infoBlockType = 'mercadopago/standard_info';
22
+
23
+ protected $_code = 'mercadopago_standard';
24
+
25
+ protected $_isGateway = true;
26
+ protected $_canOrder = true;
27
+ protected $_canAuthorize = true;
28
+ protected $_canCapture = true;
29
+ protected $_canCapturePartial = true;
30
+ protected $_canRefund = true;
31
+ protected $_canRefundInvoicePartial = true;
32
+ protected $_canVoid = true;
33
+ protected $_canFetchTransactionInfo = true;
34
+ protected $_canCreateBillingAgreement = true;
35
+ protected $_canReviewPayment = true;
36
+
37
+ const LOG_FILE = 'mercadopago-standard.log';
38
+
39
+ public function postPago()
40
+ {
41
+ //seta sdk php mercadopago
42
+ $client_id = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
43
+ $client_secret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
44
+ $mp = Mage::helper('mercadopago')->getApiInstance($client_id, $client_secret);
45
+
46
+ //monta a prefernecia
47
+ $pref = $this->makePreference();
48
+ Mage::helper('mercadopago')->log("make array", self::LOG_FILE, $pref);
49
+
50
+ //faz o posto do pagamento
51
+ $response = $mp->create_preference($pref);
52
+ Mage::helper('mercadopago')->log("create preference result", self::LOG_FILE, $response);
53
+
54
+ $array_assign = [];
55
+
56
+ if ($response['status'] == 200 || $response['status'] == 201) {
57
+ $payment = $response['response'];
58
+ if (Mage::getStoreConfigFlag('payment/mercadopago_standard/sandbox_mode')) {
59
+ $init_point = $payment['sandbox_init_point'];
60
+ } else {
61
+ $init_point = $payment['init_point'];
62
+ }
63
+
64
+ $array_assign = [
65
+ "init_point" => $init_point,
66
+ "type_checkout" => $this->getConfigData('type_checkout'),
67
+ "iframe_width" => $this->getConfigData('iframe_width'),
68
+ "iframe_height" => $this->getConfigData('iframe_height'),
69
+ "banner_checkout" => $this->getConfigData('banner_checkout'),
70
+ "status" => 201
71
+ ];
72
+
73
+ Mage::helper('mercadopago')->log("Array preference ok", self::LOG_FILE);
74
+ } else {
75
+ $array_assign = [
76
+ "message" => Mage::helper('mercadopago')->__('An error has occurred. Please refresh the page.'),
77
+ "json" => json_encode($response),
78
+ "status" => 400
79
+ ];
80
+
81
+ Mage::helper('mercadopago')->log("Array preference error", self::LOG_FILE);
82
+ }
83
+
84
+ return $array_assign;
85
+ }
86
+
87
+ public function getOrderPlaceRedirectUrl()
88
+ {
89
+ // requisicao vem da pagina de finalizacao de pedido
90
+ return Mage::getUrl('mercadopago/pay', ['_secure' => true]);
91
+ }
92
+
93
+ public function getDiscount($order)
94
+ {
95
+ $discount = 0;
96
+ $order = $order->getData();
97
+
98
+ if (isset($order['base_discount_amount']) && $order['base_discount_amount'] < 0) {
99
+ $discount = $order['base_discount_amount'];
100
+ }
101
+
102
+ return $discount;
103
+ }
104
+
105
+ protected function getItems($order)
106
+ {
107
+ $items = [];
108
+ foreach ($order->getAllVisibleItems() as $item) {
109
+ $product = $item->getProduct();
110
+ $image = (string)Mage::helper('catalog/image')->init($product, 'image');
111
+
112
+ $items[] = [
113
+ "id" => $item->getSku(),
114
+ "title" => $product->getName(),
115
+ "description" => $product->getName(),
116
+ "picture_url" => $image,
117
+ "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
118
+ "quantity" => (int)number_format($item->getQtyOrdered(), 0, '.', ''),
119
+ "unit_price" => (float)number_format($item->getPrice(), 2, '.', '')
120
+ ];
121
+ }
122
+
123
+ return $items;
124
+ }
125
+
126
+ protected function getTotalItems($items)
127
+ {
128
+ $total = 0;
129
+ foreach ($items as $item) {
130
+ $total += $item['unit_price'] * $item['quantity'];
131
+ }
132
+
133
+ return $total;
134
+ }
135
+
136
+ protected function getExcludedPaymentsMethods()
137
+ {
138
+ $excludedMethods = [];
139
+ $excluded_payment_methods = $this->getConfigData('excluded_payment_methods');
140
+ $arr_epm = explode(",", $excluded_payment_methods);
141
+ if (count($arr_epm) > 0) {
142
+ foreach ($arr_epm as $m) {
143
+ $excludedMethods[] = ["id" => $m];
144
+ }
145
+ }
146
+
147
+ return $excludedMethods;
148
+ }
149
+
150
+ public function makePreference()
151
+ {
152
+ $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
153
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
154
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
155
+ $payment = $order->getPayment();
156
+ $paramsShipment = new Varien_Object();
157
+
158
+ Mage::dispatchEvent('mercadopago_standard_make_preference_before',
159
+ ['params' => $paramsShipment, 'order' => $order]);
160
+
161
+ $arr = [];
162
+ $arr['external_reference'] = $orderIncrementId;
163
+ $arr['items'] = $this->getItems($order);
164
+
165
+ $this->_calculateDiscountAmount($arr['items'], $order);
166
+ $this->_calculateBaseTaxAmount($arr['items'], $order);
167
+ $total_item = $this->getTotalItems($arr['items']);
168
+ $total_item += (float)$order->getBaseShippingAmount();
169
+ $order_amount = (float)$order->getBaseGrandTotal();
170
+ if (!$order_amount) {
171
+ $order_amount = (float)$order->getBasePrice() + $order->getBaseShippingAmount();
172
+ }
173
+ if ($total_item > $order_amount || $total_item < $order_amount) {
174
+ $diff_price = $order_amount - $total_item;
175
+ $arr['items'][] = [
176
+ "title" => "Difference amount of the items with a total",
177
+ "description" => "Difference amount of the items with a total",
178
+ "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
179
+ "quantity" => 1,
180
+ "unit_price" => (float)$diff_price
181
+ ];
182
+ Mage::helper('mercadopago')->log("Total itens: " . $total_item, self::LOG_FILE);
183
+ Mage::helper('mercadopago')->log("Total order: " . $order_amount, self::LOG_FILE);
184
+ Mage::helper('mercadopago')->log("Difference add itens: " . $diff_price, self::LOG_FILE);
185
+ }
186
+
187
+ $shippingAddress = $order->getShippingAddress();
188
+ $shipping = $shippingAddress->getData();
189
+
190
+ $arr['payer']['phone'] = [
191
+ "area_code" => "-",
192
+ "number" => $shipping['telephone']
193
+ ];
194
+
195
+ $arr['shipments'] = $this->_getParamShipment($paramsShipment,$order,$shippingAddress);
196
+
197
+ $billing_address = $order->getBillingAddress()->getData();
198
+
199
+ $arr['payer']['date_created'] = date('Y-m-d', $customer->getCreatedAtTimestamp()) . "T" . date('H:i:s', $customer->getCreatedAtTimestamp());
200
+ $arr['payer']['email'] = htmlentities($customer->getEmail());
201
+ $arr['payer']['first_name'] = htmlentities($customer->getFirstname());
202
+ $arr['payer']['last_name'] = htmlentities($customer->getLastname());
203
+
204
+ if (isset($payment['additional_information']['doc_number']) && $payment['additional_information']['doc_number'] != "") {
205
+ $arr['payer']['identification'] = [
206
+ "type" => "CPF",
207
+ "number" => $payment['additional_information']['doc_number']
208
+ ];
209
+ }
210
+
211
+ $arr['payer']['address'] = [
212
+ "zip_code" => $billing_address['postcode'],
213
+ "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
214
+ "street_number" => ""
215
+ ];
216
+
217
+ $arr['back_urls'] = [
218
+ "success" => Mage::getUrl('mercadopago/success'),
219
+ "pending" => Mage::getUrl('mercadopago/success'),
220
+ "failure" => Mage::getUrl('checkout/onepage/failure')
221
+ ];
222
+
223
+ $arr['notification_url'] = Mage::getUrl('mercadopago/notifications/standard');
224
+
225
+ $arr['payment_methods']['excluded_payment_methods'] = $this->getExcludedPaymentsMethods();
226
+ $installments = $this->getConfigData('installments');
227
+ $arr['payment_methods']['installments'] = (int)$installments;
228
+
229
+ $auto_return = $this->getConfigData('auto_return');
230
+ if ($auto_return == 1) {
231
+ $arr['auto_return'] = "approved";
232
+ }
233
+
234
+ $sponsor_id = Mage::getStoreConfig('payment/mercadopago/sponsor_id');
235
+ Mage::helper('mercadopago')->log("Sponsor_id", self::LOG_FILE, $sponsor_id);
236
+ if (!empty($sponsor_id)) {
237
+ Mage::helper('mercadopago')->log("Sponsor_id identificado", self::LOG_FILE, $sponsor_id);
238
+ $arr['sponsor_id'] = (int)$sponsor_id;
239
+ }
240
+
241
+ return $arr;
242
+ }
243
+
244
+ protected function getReceiverAddress($shippingAddress)
245
+ {
246
+ return [
247
+ "floor" => "-",
248
+ "zip_code" => $shippingAddress->getPostcode(),
249
+ "street_name" => $shippingAddress->getStreet()[0] . " - " . $shippingAddress->getCity() . " - " . $shippingAddress->getCountryId(),
250
+ "apartment" => "-",
251
+ "street_number" => ""
252
+ ];
253
+ }
254
+
255
+ protected function _getParamShipment($params,$order,$shippingAddress) {
256
+ $paramsShipment = $params->getValues();
257
+ if (empty($paramsShipment)) {
258
+ $paramsShipment = $params->getData();
259
+ $paramsShipment['cost'] = (float)$order->getBaseShippingAmount();
260
+ }
261
+ $paramsShipment['receiver_address'] = $this->getReceiverAddress($shippingAddress);
262
+ return $paramsShipment;
263
+ }
264
+
265
+ public function getSuccessBlockType()
266
+ {
267
+ return $this->_successBlockType;
268
+ }
269
+
270
+ /**
271
+ * Check whether payment method can be used
272
+ *
273
+ * @param Mage_Sales_Model_Quote|null $quote
274
+ *
275
+ * @return bool
276
+ */
277
+ public function isAvailable($quote = null)
278
+ {
279
+ $parent = parent::isAvailable($quote);
280
+ $clientId = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
281
+ $clientSecret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
282
+ $standard = (!empty($clientId) && !empty($clientSecret));
283
+
284
+ if (!$parent || !$standard) {
285
+ return false;
286
+ }
287
+
288
+ return Mage::helper('mercadopago')->isValidClientCredentials($clientId, $clientSecret);
289
+
290
+ }
291
+
292
+ protected function _calculateDiscountAmount(&$arr, $order)
293
+ {
294
+ if ($order->getDiscountAmount() < 0) {
295
+ $arr[] = [
296
+ "title" => "Store discount coupon",
297
+ "description" => "Store discount coupon",
298
+ "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
299
+ "quantity" => 1,
300
+ "unit_price" => (float)$order->getDiscountAmount()
301
+ ];
302
+ }
303
+ }
304
+
305
+ protected function _calculateBaseTaxAmount(&$arr, $order)
306
+ {
307
+ if ($order->getBaseTaxAmount() > 0) {
308
+ $arr[] = [
309
+ "title" => "Store taxes",
310
+ "description" => "Store taxes",
311
+ "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
312
+ "quantity" => 1,
313
+ "unit_price" => (float)$order->getBaseTaxAmount()
314
+ ];
315
+ }
316
+ }
317
+
318
+ }
app/code/community/MercadoPago/Core/controllers/ApiController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class MercadoPago_Core_ApiController
18
+ extends Mage_Core_Controller_Front_Action
19
+ {
20
+ // action: /mercadopago/api/amount
21
+
22
+ public function amountAction()
23
+ {
24
+ $core = Mage::getModel('mercadopago/core');
25
+
26
+ $response = array(
27
+ "amount" => $core->getAmount()
28
+ );
29
+
30
+ $jsonData = Mage::helper('core')->jsonEncode($response);
31
+ $this->getResponse()->setHeader('Content-type', 'application/json');
32
+ $this->getResponse()->setBody($jsonData);
33
+ }
34
+
35
+ // action: /mercadopago/api/cupom?id=:cupom_id
36
+
37
+ public function couponAction()
38
+ {
39
+ $response = array();
40
+ $core = Mage::getModel('mercadopago/core');
41
+
42
+ $coupon_id = $this->getRequest()->getParam('id');
43
+ if (!empty($coupon_id)) {
44
+ $response = $core->validCoupon($coupon_id);
45
+ } else {
46
+ $response = array(
47
+ "status" => 400,
48
+ "response" => array(
49
+ "error" => "invalid_id",
50
+ "message" => "invalid id"
51
+ )
52
+ );
53
+ }
54
+
55
+ $jsonData = Mage::helper('core')->jsonEncode($response);
56
+ $this->getResponse()->setHeader('Content-type', 'application/json');
57
+ $this->getResponse()->setBody($jsonData);
58
+ }
59
+
60
+
61
+ /*
62
+ *
63
+ * Test Request
64
+ *
65
+ */
66
+
67
+ public function testAction()
68
+ {
69
+ $core = Mage::getModel('mercadopago/core');
70
+
71
+ $payment_methods = $core->getPaymentMethods();
72
+
73
+ $response = array(
74
+ "getPaymentMethods" => $payment_methods['status'],
75
+ "public_key" => Mage::getStoreConfig('payment/mercadopago_custom/public_key')
76
+ );
77
+
78
+ $jsonData = Mage::helper('core')->jsonEncode($response);
79
+ $this->getResponse()->setHeader('Content-type', 'application/json');
80
+ $this->getResponse()->setBody($jsonData);
81
+ }
82
+ }
app/code/community/MercadoPago/Core/controllers/NotificationsController.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class MercadoPago_Core_NotificationsController
18
+ extends Mage_Core_Controller_Front_Action
19
+ {
20
+ protected $_return = null;
21
+ protected $_order = null;
22
+ protected $_order_id = null;
23
+ protected $_mpcartid = null;
24
+ protected $_sendemail = false;
25
+ protected $_hash = null;
26
+
27
+ const LOG_FILE = 'mercadopago-notification.log';
28
+
29
+ protected function _getDataPayments($merchantOrder)
30
+ {
31
+ $data = array();
32
+ $core = Mage::getModel('mercadopago/core');
33
+ foreach ($merchantOrder['payments'] as $payment) {
34
+ $response = $core->getPayment($payment['id']);
35
+ $payment = $response['response']['collection'];
36
+ $data = $this->formatArrayPayment($data, $payment);
37
+ }
38
+
39
+ return $data;
40
+ }
41
+
42
+ protected function getStatusFinal($dataStatus)
43
+ {
44
+ $status_final = "";
45
+ $statuses = explode('|', $dataStatus);
46
+ foreach ($statuses as $status) {
47
+ $status = str_replace(' ', '', $status);
48
+ if ($status_final == "") {
49
+ $status_final = $status;
50
+ } else {
51
+ if ($status_final != $status) {
52
+ $status_final = false;
53
+ }
54
+ }
55
+ }
56
+
57
+ return $status_final;
58
+ }
59
+
60
+
61
+ public function standardAction()
62
+ {
63
+ $request = $this->getRequest();
64
+ //notification received
65
+ Mage::helper('mercadopago')->log("Standard Received notification", self::LOG_FILE, $request->getParams());
66
+
67
+ $core = Mage::getModel('mercadopago/core');
68
+
69
+ $id = $request->getParam('id');
70
+ $topic = $request->getParam('topic');
71
+
72
+ if (!empty($id) && $topic == 'merchant_order') {
73
+ $response = $core->getMerchantOrder($id);
74
+ Mage::helper('mercadopago')->log("Return merchant_order", self::LOG_FILE, $response);
75
+ if ($response['status'] == 200 || $response['status'] == 201) {
76
+ $merchant_order = $response['response'];
77
+
78
+ if (count($merchant_order['payments']) > 0) {
79
+ $data = $this->_getDataPayments($merchant_order);
80
+ $status_final = $this->getStatusFinal($data['status']);
81
+ $shipmentData = (isset($merchant_order['shipments'][0])) ? $merchant_order['shipments'][0] : [];
82
+ Mage::helper('mercadopago')->log("Update Order", self::LOG_FILE);
83
+ $core->updateOrder($data);
84
+ if(!empty($shipmentData)) {
85
+ Mage::dispatchEvent('mercadopago_standard_notification_before_set_status',
86
+ array('shipmentData' => $shipmentData,
87
+ 'orderId' => $merchant_order['external_reference'])
88
+ );
89
+ }
90
+ if ($status_final != false) {
91
+ $data['status_final'] = $status_final;
92
+ Mage::helper('mercadopago')->log("Received Payment data", self::LOG_FILE, $data);
93
+ $setStatusResponse = $core->setStatusOrder($data);
94
+ $this->getResponse()->setBody($setStatusResponse['text']);
95
+ $this->getResponse()->setHttpResponseCode($setStatusResponse['code']);
96
+ } else {
97
+ $this->getResponse()->setBody("Status not final");
98
+ $this->getResponse()->setHttpResponseCode(MercadoPago_Core_Helper_Response::HTTP_OK);
99
+ }
100
+
101
+ Mage::dispatchEvent('mercadopago_standard_notification_received',
102
+ array('payment' => $data,
103
+ 'merchant_order' => $merchant_order)
104
+ );
105
+
106
+ Mage::helper('mercadopago')->log("Http code", self::LOG_FILE, $this->getResponse()->getHttpResponseCode());
107
+ return;
108
+ }
109
+ }
110
+ } else {
111
+ Mage::helper('mercadopago')->log("Merchant Order not found", self::LOG_FILE, $request->getParams());
112
+ $this->getResponse()->setBody("Merchant Order not found");
113
+ $this->getResponse()->setHttpResponseCode(MercadoPago_Core_Helper_Response::HTTP_NOT_FOUND);
114
+ }
115
+
116
+ Mage::helper('mercadopago')->log("Http code", self::LOG_FILE, $this->getResponse()->getHttpResponseCode());
117
+ }
118
+
119
+ public function customAction()
120
+ {
121
+ $request = $this->getRequest();
122
+ Mage::helper('mercadopago')->log("Custom Received notification", self::LOG_FILE, $request->getParams());
123
+
124
+ $core = Mage::getModel('mercadopago/core');
125
+
126
+ $dataId = $request->getParam('data_id');
127
+ $type = $request->getParam('type');
128
+ if (!empty($dataId) && $type == 'payment') {
129
+ $response = $core->getPaymentV1($dataId);
130
+ Mage::helper('mercadopago')->log("Return payment", self::LOG_FILE, $response);
131
+
132
+ if ($response['status'] == 200 || $response['status'] == 201) {
133
+ $payment = $response['response'];
134
+
135
+ $payment = Mage::helper('mercadopago')->setPayerInfo($payment);
136
+
137
+ Mage::helper('mercadopago')->log("Update Order", self::LOG_FILE);
138
+ $core->updateOrder($payment);
139
+ $setStatusResponse = $core->setStatusOrder($payment);
140
+ $this->getResponse()->setBody($setStatusResponse['text']);
141
+ $this->getResponse()->setHttpResponseCode($setStatusResponse['code']);
142
+ Mage::helper('mercadopago')->log("Http code", self::LOG_FILE, $this->getResponse()->getHttpResponseCode());
143
+ return;
144
+ }
145
+ }
146
+
147
+ Mage::helper('mercadopago')->log("Payment not found", self::LOG_FILE, $request->getParams());
148
+ $this->getResponse()->getBody("Payment not found");
149
+ $this->getResponse()->setHttpResponseCode(MercadoPago_Core_Helper_Response::HTTP_NOT_FOUND);
150
+ Mage::helper('mercadopago')->log("Http code", self::LOG_FILE, $this->getResponse()->getHttpResponseCode());
151
+ }
152
+
153
+ public function formatArrayPayment($data, $payment)
154
+ {
155
+ Mage::helper('mercadopago')->log("Format Array", self::LOG_FILE);
156
+
157
+ $fields = array(
158
+ "status",
159
+ "status_detail",
160
+ "id",
161
+ "payment_method_id",
162
+ "transaction_amount",
163
+ "total_paid_amount",
164
+ "coupon_amount",
165
+ "installments",
166
+ "shipping_cost",
167
+ );
168
+
169
+ foreach ($fields as $field) {
170
+ if (isset($payment[$field])) {
171
+ if (isset($data[$field])) {
172
+ $data[$field] .= " | " . $payment[$field];
173
+ } else {
174
+ $data[$field] = $payment[$field];
175
+ }
176
+ }
177
+ }
178
+
179
+ if (isset($payment["last_four_digits"])) {
180
+ if (isset($data["trunc_card"])) {
181
+ $data["trunc_card"] .= " | " . "xxxx xxxx xxxx " . $payment["last_four_digits"];
182
+ } else {
183
+ $data["trunc_card"] = "xxxx xxxx xxxx " . $payment["last_four_digits"];
184
+ }
185
+ }
186
+
187
+ if (isset($payment['cardholder']['name'])) {
188
+ if (isset($data["cardholder_name"])) {
189
+ $data["cardholder_name"] .= " | " . $payment["cardholder"]["name"];
190
+ } else {
191
+ $data["cardholder_name"] = $payment["cardholder"]["name"];
192
+ }
193
+ }
194
+
195
+ if (isset($payment['statement_descriptor'])) {
196
+ $data['statement_descriptor'] = $payment['statement_descriptor'];
197
+ }
198
+
199
+ $data['external_reference'] = $payment['external_reference'];
200
+ $data['payer_first_name'] = $payment['payer']['first_name'];
201
+ $data['payer_last_name'] = $payment['payer']['last_name'];
202
+ $data['payer_email'] = $payment['payer']['email'];
203
+
204
+ return $data;
205
+ }
206
+
207
+ }
app/code/community/MercadoPago/Core/controllers/PayController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Payment Gateway
11
+ * @package MercadoPago
12
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class MercadoPago_Core_PayController
18
+ extends Mage_Core_Controller_Front_Action
19
+ {
20
+ public function indexAction()
21
+ {
22
+ $standard = Mage::getModel('mercadopago/standard_payment');
23
+
24
+ //chama model para fazer o post do pagamento e obter as informacoes para mostrar o checkout
25
+ $array_assign = $standard->postPago();
26
+
27
+ $this->loadLayout();
28
+
29
+ $block = Mage::app()->getLayout()->createBlock('mercadopago/standard_pay');
30
+
31
+ //envia as informações para view
32
+ $block->assign($array_assign);
33
+
34
+ //insere o block
35
+ $this->getLayout()->getBlock('content')->append($block);
36
+ $this->_initLayoutMessages('core/session');
37
+
38
+ //adiciona uma clean page
39
+ $root = $this->getLayout()->getBlock('root');
40
+ $root->setTemplate("mercadopago/clean.phtml");
41
+
42
+ $this->renderLayout();
43
+ }
44
+ }
app/code/community/MercadoPago/Core/controllers/SuccessController.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class MercadoPago_Core_SuccessController
5
+ */
6
+ class MercadoPago_Core_SuccessController
7
+ extends Mage_Core_Controller_Front_Action
8
+ {
9
+
10
+ /**
11
+ * @var Mage_Sales_Model_Order
12
+ */
13
+ protected $_order;
14
+
15
+ /**
16
+ * @return Mage_Sales_Model_Order
17
+ */
18
+ protected function getOrder()
19
+ {
20
+ if (empty($this->_order)) {
21
+ $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
22
+ $this->_order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
23
+ }
24
+
25
+ return $this->_order;
26
+ }
27
+
28
+ /**
29
+ * Send email of new order
30
+ */
31
+ protected function sendNewOrderMail()
32
+ {
33
+ $order = $this->getOrder();
34
+ if ($order->getCanSendNewEmailFlag()) {
35
+ try {
36
+ $order->sendNewOrderEmail();
37
+ } catch (Exception $e) {
38
+ Mage::logException($e);
39
+ }
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Return handle name depending on payment method
45
+ *
46
+ * @return string
47
+ */
48
+ protected function getCheckoutHandle()
49
+ {
50
+ $order = $this->getOrder();
51
+ $handle = $order->getPayment()->getMethod();
52
+ $handle .= '_success';
53
+
54
+ return $handle;
55
+ }
56
+
57
+ public function indexAction()
58
+ {
59
+ $this->sendNewOrderMail();
60
+ $checkoutTypeHandle = $this->getCheckoutHandle();
61
+ $this->loadLayout(['default', $checkoutTypeHandle]);
62
+
63
+ $this->_initLayoutMessages('core/session');
64
+
65
+ $this->renderLayout();
66
+ }
67
+ }
app/code/community/MercadoPago/{etc → Core/etc}/config.xml RENAMED
@@ -17,63 +17,93 @@
17
  -->
18
  <config>
19
  <modules>
20
-
21
- <MercadoPago>
22
- <version>2.0.0</version>
23
- </MercadoPago>
24
-
25
- <MercadoPago_Custom>
26
- <version>2.0.0</version>
27
- </MercadoPago_Custom>
28
-
29
- <MercadoPago_CustomTicket>
30
- <version>2.0.0</version>
31
- </MercadoPago_CustomTicket>
32
-
33
- <MercadoPago_Standard>
34
- <version>2.0.0</version>
35
- </MercadoPago_Standard>
36
-
37
  </modules>
38
 
39
  <global>
40
  <models>
41
  <mercadopago>
42
- <class>MercadoPago_Model</class>
43
  </mercadopago>
44
  </models>
45
-
 
 
 
 
 
 
 
46
  <blocks>
47
  <mercadopago>
48
- <class>MercadoPago_Block</class>
49
  </mercadopago>
50
  </blocks>
51
-
52
  <helpers>
53
  <mercadopago>
54
- <class>MercadoPago_Helper</class>
55
  </mercadopago>
56
- <mercadopago_custom>
57
- <class>MercadoPago_Helper</class>
58
- </mercadopago_custom>
59
- <mercadopago_customticket>
60
- <class>MercadoPago_Helper</class>
61
- </mercadopago_customticket>
62
- <mercadopago_standard>
63
- <class>MercadoPago_Helper</class>
64
- </mercadopago_standard>
65
  </helpers>
66
-
67
- <events>
68
  <admin_system_config_changed_section_payment>
69
  <observers>
70
  <observer>
71
- <class>MercadoPago_Model_Observer</class>
72
  <method>checkAndValidData</method>
73
  </observer>
74
  </observers>
75
- </admin_system_config_changed_section_payment>
76
  </events>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </global>
78
 
79
 
@@ -82,33 +112,47 @@
82
  <mercadopago>
83
  <use>standard</use>
84
  <args>
85
- <module>MercadoPago</module>
86
  <frontName>mercadopago</frontName>
87
  </args>
88
  </mercadopago>
89
  </routers>
90
  <translate>
91
  <modules>
92
- <mercadopago>
93
  <files>
94
- <default>mercadopago.csv</default>
95
  </files>
96
- </mercadopago>
97
  </modules>
98
  </translate>
 
 
 
 
 
 
 
99
  </frontend>
100
 
101
 
102
  <adminhtml>
103
  <translate>
104
  <modules>
105
- <translations>
106
  <files>
107
- <default>mercadopago.csv</default>
108
  </files>
109
- </translations>
110
  </modules>
111
  </translate>
 
 
 
 
 
 
 
112
  </adminhtml>
113
 
114
 
@@ -125,37 +169,39 @@
125
  <order_status_cancelled>pending</order_status_cancelled>
126
  <order_status_chargeback>pending</order_status_chargeback>
127
  <logs>0</logs>
 
128
  </mercadopago>
129
-
130
  <mercadopago_custom>
131
- <active>1</active>
132
- <model>MercadoPago_Model_Custom_Payment</model>
133
  <!-- nome do modulo na exibição para o comprador -->
134
- <title translate="label">Credit Card - MercadoPago</title>
135
  <allowspecific>0</allowspecific>
136
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg</banner_checkout>
137
  <sort_order>-2</sort_order>
138
  <payment_action>authorize</payment_action>
139
  <coupon_mercadopago>0</coupon_mercadopago>
140
  </mercadopago_custom>
141
-
142
  <mercadopago_customticket>
143
- <active>1</active>
144
- <model>MercadoPago_Model_CustomTicket_Payment</model>
145
  <!-- nome do modulo na exibição para o comprador -->
146
- <title translate="label">Ticket - MercadoPago</title>
147
  <allowspecific>0</allowspecific>
 
148
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png</banner_checkout>
149
  <sort_order>-1</sort_order>
150
  <payment_action>authorize</payment_action>
151
  <coupon_mercadopago>0</coupon_mercadopago>
152
  </mercadopago_customticket>
153
-
154
  <mercadopago_standard>
155
- <active>1</active>
156
- <model>MercadoPago_Model_Standard_Payment</model>
157
  <!-- nome do modulo na exibição para o comprador -->
158
- <title>MercadoPago</title>
159
  <allowspecific>0</allowspecific>
160
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg</banner_checkout>
161
  <sort_order>-1</sort_order>
@@ -164,8 +210,10 @@
164
  <auto_return>1</auto_return>
165
  <iframe_width>900</iframe_width>
166
  <iframe_height>700</iframe_height>
 
167
  </mercadopago_standard>
168
-
169
  </payment>
170
  </default>
 
171
  </config>
17
  -->
18
  <config>
19
  <modules>
20
+ <MercadoPago_Core>
21
+ <version>2.1.5</version>
22
+ </MercadoPago_Core>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </modules>
24
 
25
  <global>
26
  <models>
27
  <mercadopago>
28
+ <class>MercadoPago_Core_Model</class>
29
  </mercadopago>
30
  </models>
31
+ <resources>
32
+ <mercadopago_setup>
33
+ <setup>
34
+ <module>MercadoPago_Core</module>
35
+ <class>Mage_Sales_Model_Resource_Setup</class>
36
+ </setup>
37
+ </mercadopago_setup>
38
+ </resources>
39
  <blocks>
40
  <mercadopago>
41
+ <class>MercadoPago_Core_Block</class>
42
  </mercadopago>
43
  </blocks>
44
+
45
  <helpers>
46
  <mercadopago>
47
+ <class>MercadoPago_Core_Helper</class>
48
  </mercadopago>
 
 
 
 
 
 
 
 
 
49
  </helpers>
50
+
51
+ <events>
52
  <admin_system_config_changed_section_payment>
53
  <observers>
54
  <observer>
55
+ <class>MercadoPago_Core_Model_Observer</class>
56
  <method>checkAndValidData</method>
57
  </observer>
58
  </observers>
59
+ </admin_system_config_changed_section_payment>
60
  </events>
61
+ <sales>
62
+ <quote>
63
+ <totals>
64
+ <mercadopago>
65
+ <class>mercadopago/custom_finance_cost</class>
66
+ <before>grand_total</before>
67
+ <after>tax</after>
68
+ </mercadopago>
69
+ <discount_mercadopago>
70
+ <class>mercadopago/discount_coupon</class>
71
+ <before>grand_total</before>
72
+ <after>tax</after>
73
+ </discount_mercadopago>
74
+ </totals>
75
+ </quote>
76
+ <order_invoice>
77
+ <totals>
78
+ <mercadopago>
79
+ <class>mercadopago/custom_finance_cost_invoice</class>
80
+ </mercadopago>
81
+ <discount_mercadopago>
82
+ <class>mercadopago/discount_coupon_invoice</class>
83
+ </discount_mercadopago>
84
+ </totals>
85
+ </order_invoice>
86
+ <order_creditmemo>
87
+ <totals>
88
+ <mercadopago>
89
+ <class>mercadopago/custom_finance_cost_creditmemo</class>
90
+ </mercadopago>
91
+ <discount_mercadopago>
92
+ <class>mercadopago/discount_coupon_creditmemo</class>
93
+ </discount_mercadopago>
94
+ </totals>
95
+ </order_creditmemo>
96
+ </sales>
97
+
98
+ <fieldsets>
99
+ <sales_convert_quote_address>
100
+ <finance_cost_amount><to_order>*</to_order></finance_cost_amount>
101
+ <base_finance_cost_amount><to_order>*</to_order></base_finance_cost_amount>
102
+ <discount_coupon_amount><to_order>*</to_order></discount_coupon_amount>
103
+ <base_discount_coupon_amount><to_order>*</to_order></base_discount_coupon_amount>
104
+ </sales_convert_quote_address>
105
+ </fieldsets>
106
+
107
  </global>
108
 
109
 
112
  <mercadopago>
113
  <use>standard</use>
114
  <args>
115
+ <module>MercadoPago_Core</module>
116
  <frontName>mercadopago</frontName>
117
  </args>
118
  </mercadopago>
119
  </routers>
120
  <translate>
121
  <modules>
122
+ <mercadopago_core>
123
  <files>
124
+ <default>MercadoPago_Core.csv</default>
125
  </files>
126
+ </mercadopago_core>
127
  </modules>
128
  </translate>
129
+ <layout>
130
+ <updates>
131
+ <mercadopago_core>
132
+ <file>mercadopago.xml</file>
133
+ </mercadopago_core>
134
+ </updates>
135
+ </layout>
136
  </frontend>
137
 
138
 
139
  <adminhtml>
140
  <translate>
141
  <modules>
142
+ <mercadopago_core>
143
  <files>
144
+ <default>MercadoPago_Core.csv</default>
145
  </files>
146
+ </mercadopago_core>
147
  </modules>
148
  </translate>
149
+ <layout>
150
+ <updates>
151
+ <mercadopago_core>
152
+ <file>mercadopago.xml</file>
153
+ </mercadopago_core>
154
+ </updates>
155
+ </layout>
156
  </adminhtml>
157
 
158
 
169
  <order_status_cancelled>pending</order_status_cancelled>
170
  <order_status_chargeback>pending</order_status_chargeback>
171
  <logs>0</logs>
172
+ <debug_mode>0</debug_mode>
173
  </mercadopago>
174
+
175
  <mercadopago_custom>
176
+ <active>0</active>
177
+ <model>mercadopago/custom_payment</model>
178
  <!-- nome do modulo na exibição para o comprador -->
179
+ <title translate="label">Credit Card - Mercado Pago</title>
180
  <allowspecific>0</allowspecific>
181
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg</banner_checkout>
182
  <sort_order>-2</sort_order>
183
  <payment_action>authorize</payment_action>
184
  <coupon_mercadopago>0</coupon_mercadopago>
185
  </mercadopago_custom>
186
+
187
  <mercadopago_customticket>
188
+ <active>0</active>
189
+ <model>mercadopago/customTicket_payment</model>
190
  <!-- nome do modulo na exibição para o comprador -->
191
+ <title translate="label">Ticket - Mercado Pago</title>
192
  <allowspecific>0</allowspecific>
193
+ <binary_mode>0</binary_mode>
194
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png</banner_checkout>
195
  <sort_order>-1</sort_order>
196
  <payment_action>authorize</payment_action>
197
  <coupon_mercadopago>0</coupon_mercadopago>
198
  </mercadopago_customticket>
199
+
200
  <mercadopago_standard>
201
+ <active>0</active>
202
+ <model>mercadopago/standard_payment</model>
203
  <!-- nome do modulo na exibição para o comprador -->
204
+ <title>Mercado Pago</title>
205
  <allowspecific>0</allowspecific>
206
  <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg</banner_checkout>
207
  <sort_order>-1</sort_order>
210
  <auto_return>1</auto_return>
211
  <iframe_width>900</iframe_width>
212
  <iframe_height>700</iframe_height>
213
+ <sandbox_mode>0</sandbox_mode>
214
  </mercadopago_standard>
215
+
216
  </payment>
217
  </default>
218
+
219
  </config>
app/code/community/MercadoPago/Core/etc/system.xml ADDED
@@ -0,0 +1,448 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL).
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Payment Gateway
12
+ * @package MercadoPago
13
+ * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
+ * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ -->
18
+
19
+ <config>
20
+ <sections>
21
+ <payment translate="label">
22
+ <groups>
23
+ <mercadopago type="group">
24
+ <label>Mercado Pago - Global Configuration</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>100</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ <fields>
31
+ <country translate="label">
32
+ <label>Country</label>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>mercadopago/source_country</source_model>
35
+ <sort_order>50</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </country>
40
+ <category_id translate="label">
41
+ <label>Category of your store</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>mercadopago/source_categoryId</source_model>
44
+ <sort_order>60</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </category_id>
49
+ <order_status_approved translate="label">
50
+ <label>Choose the status of approved orders</label>
51
+ <comment>To manage the status available go to System > Order Statuses</comment>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>mercadopago/source_order_status</source_model>
54
+ <sort_order>70</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </order_status_approved>
59
+ <order_status_refunded translate="label">
60
+ <label>Choose the status of refunded orders</label>
61
+ <comment>To manage the status available go to System > Order Statuses</comment>
62
+ <frontend_type>select</frontend_type>
63
+ <source_model>mercadopago/source_order_status</source_model>
64
+ <sort_order>80</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </order_status_refunded>
69
+ <order_status_in_process translate="label">
70
+ <label>Choose the status when payment is pending</label>
71
+ <comment>To manage the status available go to System > Order Statuses</comment>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>mercadopago/source_order_status</source_model>
74
+ <sort_order>90</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </order_status_in_process>
79
+ <order_status_in_mediation translate="label">
80
+ <label>Choose the status when client open a mediation</label>
81
+ <comment>To manage the status available go to System > Order Statuses</comment>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>mercadopago/source_order_status</source_model>
84
+ <sort_order>100</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </order_status_in_mediation>
89
+ <order_status_rejected translate="label">
90
+ <label>Choose the status when payment was reject</label>
91
+ <comment>To manage the status available go to System > Order Statuses</comment>
92
+ <frontend_type>select</frontend_type>
93
+ <source_model>mercadopago/source_order_status</source_model>
94
+ <sort_order>110</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </order_status_rejected>
99
+ <order_status_cancelled translate="label">
100
+ <label>Choose the status when payment was canceled</label>
101
+ <comment>To manage the status available go to System > Order Statuses</comment>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>mercadopago/source_order_status</source_model>
104
+ <sort_order>120</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </order_status_cancelled>
109
+ <order_status_chargeback translate="label">
110
+ <label>Choose the status when payment was chargeback</label>
111
+ <comment>To manage the status available go to System > Order Statuses</comment>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>mercadopago/source_order_status</source_model>
114
+ <sort_order>130</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </order_status_chargeback>
119
+ <logs translate="label">
120
+ <label>Logs</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>140</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>0</show_in_store>
127
+ <comment>Enable logs to analise plugin activity</comment>
128
+ </logs>
129
+ <debug_mode translate="label">
130
+ <label>Debug Mode</label>
131
+ <frontend_type>select</frontend_type>
132
+ <source_model>adminhtml/system_config_source_yesno</source_model>
133
+ <sort_order>150</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ <comment>Enable to display actual error messages to frontend users (not recommended on production environment)</comment>
138
+ </debug_mode>
139
+ </fields>
140
+ </mercadopago>
141
+
142
+ <mercadopago_custom_checkout translate="label" module="mercadopago">
143
+ <label>Mercado Pago - Custom Checkout</label>
144
+ <sort_order>110</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ <fields>
149
+ <public_key translate="label">
150
+ <label>Public Key</label>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>0</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </public_key>
157
+ <access_token translate="label">
158
+ <label>Access Token</label>
159
+ <frontend_type>text</frontend_type>
160
+ <sort_order>10</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>0</show_in_store>
164
+ <comment><![CDATA[
165
+ <span>Click to get your Access Token for: </span>
166
+ <a href="https://www.mercadopago.com/mla/account/credentials" target="_blank">Argentina</a>
167
+ <a href="https://www.mercadopago.com/mlb/account/credentials" target="_blank">Brazil</a><br>
168
+ <a href="https://www.mercadopago.com/mco/account/credentials" target="_blank">Colombia</a>
169
+ <a href="https://www.mercadopago.com/mlm/account/credentials" target="_blank">Mexico</a>
170
+ <a href="https://www.mercadopago.com/mlv/account/credentials" target="_blank">Venezuela</a>
171
+ <a href="https://www.mercadopago.com/mlc/account/credentials" target="_blank">Chile</a>
172
+ ]]>
173
+ </comment>
174
+ </access_token>
175
+ <mercadopago_custom type="group" translate="label">
176
+ <label>Checkout Custom - Credit Card</label>
177
+ <frontend_type>text</frontend_type>
178
+ <frontend_model>mercadopago/adminhtml_system_config_fieldset_payment</frontend_model>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ <sort_order>20</sort_order>
183
+ <fields>
184
+ <active translate="label">
185
+ <label>Enabled</label>
186
+ <frontend_type>select</frontend_type>
187
+ <source_model>adminhtml/system_config_source_yesno</source_model>
188
+ <sort_order>10</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>0</show_in_store>
192
+ </active>
193
+ <title translate="label">
194
+ <label>Payment Title</label>
195
+ <frontend_type>text</frontend_type>
196
+ <sort_order>20</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>0</show_in_store>
200
+ </title>
201
+ <statement_descriptor translate="label">
202
+ <label>Statement Descriptor</label>
203
+ <frontend_type>text</frontend_type>
204
+ <sort_order>40</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>0</show_in_store>
208
+ <comment>Check availability for your country</comment>
209
+ </statement_descriptor>
210
+ <binary_mode translate="label">
211
+ <label>Binary Mode</label>
212
+ <frontend_type>select</frontend_type>
213
+ <source_model>adminhtml/system_config_source_yesno</source_model>
214
+ <sort_order>50</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>0</show_in_store>
218
+ </binary_mode>
219
+ <banner_checkout translate="label">
220
+ <label>Banner Checkout</label>
221
+ <frontend_type>text</frontend_type>
222
+ <sort_order>60</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>0</show_in_store>
226
+ </banner_checkout>
227
+ <sort_order translate="label">
228
+ <label>Checkout Position</label>
229
+ <frontend_type>text</frontend_type>
230
+ <sort_order>70</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>0</show_in_store>
234
+ <frontend_class>validate-number</frontend_class>
235
+ </sort_order>
236
+ <coupon_mercadopago translate="label">
237
+ <label>Marketing - Coupon Mercado Pago</label>
238
+ <frontend_type>select</frontend_type>
239
+ <source_model>adminhtml/system_config_source_yesno</source_model>
240
+ <sort_order>80</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>1</show_in_website>
243
+ <show_in_store>0</show_in_store>
244
+ </coupon_mercadopago>
245
+
246
+ </fields>
247
+ </mercadopago_custom>
248
+ <mercadopago_customticket type="group" translate="label">
249
+ <label>Checkout Custom - Ticket</label>
250
+ <frontend_type>text</frontend_type>
251
+ <frontend_model>mercadopago/adminhtml_system_config_fieldset_payment</frontend_model>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ <sort_order>30</sort_order>
256
+ <fields>
257
+ <active translate="label">
258
+ <label>Enabled</label>
259
+ <frontend_type>select</frontend_type>
260
+ <source_model>adminhtml/system_config_source_yesno</source_model>
261
+ <sort_order>10</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>0</show_in_store>
265
+ <comment>For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'</comment>
266
+ </active>
267
+ <title translate="label">
268
+ <label>Payment Title</label>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>20</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>0</show_in_store>
274
+ </title>
275
+ <banner_checkout translate="label">
276
+ <label>Banner Checkout</label>
277
+ <frontend_type>text</frontend_type>
278
+ <sort_order>30</sort_order>
279
+ <show_in_default>1</show_in_default>
280
+ <show_in_website>1</show_in_website>
281
+ <show_in_store>0</show_in_store>
282
+ </banner_checkout>
283
+ <sort_order translate="label">
284
+ <label>Checkout Position</label>
285
+ <frontend_type>text</frontend_type>
286
+ <sort_order>40</sort_order>
287
+ <show_in_default>1</show_in_default>
288
+ <show_in_website>1</show_in_website>
289
+ <show_in_store>0</show_in_store>
290
+ <frontend_class>validate-number</frontend_class>
291
+ </sort_order>
292
+ <coupon_mercadopago translate="label">
293
+ <label>Marketing - Coupon Mercado Pago</label>
294
+ <frontend_type>select</frontend_type>
295
+ <source_model>adminhtml/system_config_source_yesno</source_model>
296
+ <sort_order>50</sort_order>
297
+ <show_in_default>1</show_in_default>
298
+ <show_in_website>1</show_in_website>
299
+ <show_in_store>0</show_in_store>
300
+ </coupon_mercadopago>
301
+
302
+ </fields>
303
+ </mercadopago_customticket>
304
+ </fields>
305
+ </mercadopago_custom_checkout>
306
+
307
+ <mercadopago_standard_checkout translate="label" module="mercadopago">
308
+ <label>Mercado Pago - Classic Checkout</label>
309
+ <sort_order>130</sort_order>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>1</show_in_website>
312
+ <show_in_store>0</show_in_store>
313
+ <fields>
314
+ <mercadopago_standard type="group" translate="label">
315
+ <label>Checkout Classic</label>
316
+ <frontend_type>text</frontend_type>
317
+ <frontend_model>mercadopago/adminhtml_system_config_fieldset_payment</frontend_model>
318
+ <show_in_default>1</show_in_default>
319
+ <show_in_website>1</show_in_website>
320
+ <show_in_store>1</show_in_store>
321
+ <sort_order>20</sort_order>
322
+ <fields>
323
+ <active translate="label">
324
+ <label>Enabled</label>
325
+ <frontend_type>select</frontend_type>
326
+ <source_model>adminhtml/system_config_source_yesno</source_model>
327
+ <sort_order>10</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>0</show_in_store>
331
+ <comment>For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'</comment>
332
+ </active>
333
+ <client_id translate="label">
334
+ <label>Client Id</label>
335
+ <frontend_type>text</frontend_type>
336
+ <sort_order>15</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>0</show_in_store>
340
+ </client_id>
341
+ <client_secret translate="label">
342
+ <label>Client Secret</label>
343
+ <frontend_type>text</frontend_type>
344
+ <sort_order>17</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>0</show_in_store>
348
+ </client_secret>
349
+ <title translate="label">
350
+ <label>Payment Title</label>
351
+ <frontend_type>text</frontend_type>
352
+ <sort_order>20</sort_order>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>1</show_in_website>
355
+ <show_in_store>0</show_in_store>
356
+ </title>
357
+ <banner_checkout translate="label">
358
+ <label>Banner Checkout</label>
359
+ <frontend_type>text</frontend_type>
360
+ <sort_order>30</sort_order>
361
+ <show_in_default>1</show_in_default>
362
+ <show_in_website>1</show_in_website>
363
+ <show_in_store>0</show_in_store>
364
+ </banner_checkout>
365
+ <sort_order translate="label">
366
+ <label>Checkout Position</label>
367
+ <frontend_type>text</frontend_type>
368
+ <sort_order>40</sort_order>
369
+ <show_in_default>1</show_in_default>
370
+ <show_in_website>1</show_in_website>
371
+ <show_in_store>0</show_in_store>
372
+ <frontend_class>validate-number</frontend_class>
373
+ </sort_order>
374
+ <type_checkout>
375
+ <label>Type Checkout</label>
376
+ <frontend_type>select</frontend_type>
377
+ <source_model>mercadopago/source_typeCheckout</source_model>
378
+ <sort_order>50</sort_order>
379
+ <show_in_default>1</show_in_default>
380
+ <show_in_website>1</show_in_website>
381
+ <show_in_store>1</show_in_store>
382
+ </type_checkout>
383
+ <auto_return translate="label">
384
+ <label>Auto Redirect</label>
385
+ <frontend_type>select</frontend_type>
386
+ <source_model>adminhtml/system_config_source_yesno</source_model>
387
+ <sort_order>60</sort_order>
388
+ <show_in_default>1</show_in_default>
389
+ <show_in_website>1</show_in_website>
390
+ <show_in_store>0</show_in_store>
391
+ <comment>Auto-redirect the buyer when finishing the payment.</comment>
392
+ </auto_return>
393
+ <excluded_payment_methods translate="label">
394
+ <label>Exclude Payment Methods</label>
395
+ <comment>Select payment methods not accepted</comment>
396
+ <frontend_type>multiselect</frontend_type>
397
+ <source_model>mercadopago/source_paymentMethods</source_model>
398
+ <sort_order>70</sort_order>
399
+ <show_in_default>1</show_in_default>
400
+ <show_in_website>1</show_in_website>
401
+ <show_in_store>1</show_in_store>
402
+ <can_be_empty>1</can_be_empty>
403
+ </excluded_payment_methods>
404
+ <installments>
405
+ <label>Maximum number of accepted installments</label>
406
+ <frontend_type>select</frontend_type>
407
+ <source_model>mercadopago/source_installments</source_model>
408
+ <sort_order>90</sort_order>
409
+ <show_in_default>1</show_in_default>
410
+ <show_in_website>1</show_in_website>
411
+ <show_in_store>1</show_in_store>
412
+ </installments>
413
+ <iframe_width translate="label">
414
+ <label>Width Checkout Iframe</label>
415
+ <frontend_type>text</frontend_type>
416
+ <sort_order>100</sort_order>
417
+ <show_in_default>1</show_in_default>
418
+ <show_in_website>1</show_in_website>
419
+ <show_in_store>0</show_in_store>
420
+ <frontend_class>validate-number</frontend_class>
421
+ </iframe_width>
422
+ <iframe_height translate="label">
423
+ <label>Height Checkout Iframe</label>
424
+ <frontend_type>text</frontend_type>
425
+ <sort_order>110</sort_order>
426
+ <show_in_default>1</show_in_default>
427
+ <show_in_website>1</show_in_website>
428
+ <show_in_store>0</show_in_store>
429
+ <frontend_class>validate-number</frontend_class>
430
+ </iframe_height>
431
+ <sandbox_mode translate="label">
432
+ <label>Sandbox Mode</label>
433
+ <frontend_type>select</frontend_type>
434
+ <source_model>adminhtml/system_config_source_yesno</source_model>
435
+ <sort_order>160</sort_order>
436
+ <show_in_default>1</show_in_default>
437
+ <show_in_website>1</show_in_website>
438
+ <show_in_store>0</show_in_store>
439
+ <comment>Enable to test checkout with real credit cards. For further information check this link: <![CDATA[<a href="https://www.mercadopago.com.ar/developers/en/solutions/payments/basic-checkout/test/basic-sandbox/" target="_blank">Basic Checkout Sandbox</a>]]></comment>
440
+ </sandbox_mode>
441
+ </fields>
442
+ </mercadopago_standard>
443
+ </fields>
444
+ </mercadopago_standard_checkout>
445
+ </groups>
446
+ </payment>
447
+ </sections>
448
+ </config>
app/code/community/MercadoPago/Core/sql/mercadopago_setup/install-2.1.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ /**
6
+ * Add 'custom_attribute' attribute for entities
7
+ */
8
+ $entities = array(
9
+ 'quote_address',
10
+ 'order',
11
+ );
12
+ $options = array(
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
14
+ 'visible' => true,
15
+ 'required' => false
16
+ );
17
+ foreach ($entities as $entity) {
18
+ $installer->addAttribute($entity, 'finance_cost_amount', $options);
19
+ $installer->addAttribute($entity, 'base_finance_cost_amount', $options);
20
+ }
21
+
22
+ $installer->endSetup();
app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.0-2.1.1.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ /**
6
+ * Add 'custom_attribute' attribute for entities
7
+ */
8
+ $entities = array(
9
+ 'quote_address',
10
+ 'order',
11
+ );
12
+ $options = array(
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL,
14
+ 'size' => '12,4',
15
+ 'visible' => true,
16
+ 'required' => false
17
+ );
18
+ foreach ($entities as $entity) {
19
+ $installer->addAttribute($entity, 'discount_coupon_amount', $options);
20
+ $installer->addAttribute($entity, 'base_discount_coupon_amount', $options);
21
+ }
22
+
23
+ $installer->endSetup();
app/code/community/MercadoPago/Core/sql/mercadopago_setup/upgrade-2.1.1-2.1.2.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ /**
6
+ * Add 'custom_attribute' attribute for entities
7
+ */
8
+ $entities = array(
9
+ 'invoice',
10
+ 'creditmemo',
11
+ );
12
+ $options = array(
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL,
14
+ 'size' => '12,4',
15
+ 'visible' => true,
16
+ 'required' => false
17
+ );
18
+ foreach ($entities as $entity) {
19
+ $installer->addAttribute($entity, 'discount_coupon_amount', $options);
20
+ $installer->addAttribute($entity, 'base_discount_coupon_amount', $options);
21
+ $installer->addAttribute($entity, 'finance_cost_amount', $options);
22
+ $installer->addAttribute($entity, 'base_finance_cost_amount', $options);
23
+ }
24
+
25
+ $installer->endSetup();
app/code/community/MercadoPago/Helper/Data.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_Helper_Data extends Mage_Payment_Helper_Data{
18
-
19
-
20
- public function log($message, $file = "mercadopago.log", $array = null){
21
- //pega a configuração de log no admin, essa variavel vem como true por padrão
22
- $action_log = Mage::getStoreConfig('payment/mercadopago/logs');
23
-
24
- //caso tenha um array, transforma em json para melhor visualização
25
- if(!is_null($array))
26
- $message .= " - " . json_encode($array);
27
-
28
- //set log
29
- Mage::log($message, null, $file, $action_log);
30
- }
31
-
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Carrier.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Block_Adminhtml_System_Config_Fieldset_Carrier
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
5
+ {
6
+
7
+ const XML_PATH_STANDARD_ACTIVE = 'payment/mercadopago_standard/active';
8
+
9
+
10
+ /**
11
+ * Return header title part of html for payment solution
12
+ *
13
+ * @param Varien_Data_Form_Element_Abstract $element
14
+ * @return string
15
+ */
16
+ protected function _getHeaderTitleHtml($element)
17
+ {
18
+ $isPaymentEnabled = '';
19
+ $disabledLegend = '';
20
+
21
+ if (!Mage::getStoreConfigFlag(self::XML_PATH_STANDARD_ACTIVE)) {
22
+ $isPaymentEnabled = 'disabled';
23
+ $disabledLegend = $this->__("Checkout Classic Method must be enabled");
24
+ } else {
25
+ if (!Mage::helper('mercadopago_mercadoenvios')->isCountryEnabled()) {
26
+ $isPaymentEnabled = 'disabled';
27
+ $disabledLegend = $this->__("MercadoEnvios is not enabled in the country where Mercado Pago is configured");
28
+ }
29
+ }
30
+
31
+ $html = '<div class="config-heading" ><div class="heading"><strong id="meen-logo"><div class="meli-legend">' . $element->getLegend();
32
+ $html .= '</div></strong></div>';
33
+
34
+ $html .= '<div class="button-container"><button '. $isPaymentEnabled .' type="button"'
35
+ . ' class="meli-btn button '. $isPaymentEnabled .' '
36
+ . '" id="' . $element->getHtmlId()
37
+ . '-head" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \''
38
+ . $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">'
39
+ . $this->__('Configure') . '</span><span class="state-opened">'
40
+ . $this->__('Close') . '</span></button></div>';
41
+
42
+ $html .= ' <div class="disabled-legend">' . $disabledLegend . '</div> </div>';
43
+ return $html;
44
+ }
45
+
46
+ /**
47
+ * Collapsed or expanded fieldset when page loaded
48
+ *
49
+ * @param Varien_Data_Form_Element_Abstract $element
50
+ * @return bool
51
+ *
52
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
53
+ * @SuppressWarnings(PHPMD.BooleanGetMethodName)
54
+ */
55
+ protected function _getCollapseState($element)
56
+ {
57
+ return false;
58
+ }
59
+
60
+ }
app/code/community/MercadoPago/MercadoEnvios/Block/Adminhtml/System/Config/Fieldset/Mapping.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Block_Adminhtml_System_Config_Fieldset_Mapping
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
+ {
6
+
7
+ public function __construct()
8
+ {
9
+ $this->addColumn('mercadoenvios', array(
10
+ 'label' => Mage::helper('adminhtml')->__('MercadoEnvíos'),
11
+ 'style' => 'width:120px',
12
+ ));
13
+ $this->addColumn('magentoproduct', array(
14
+ 'label' => Mage::helper('adminhtml')->__('Product Attribute'),
15
+ 'style' => 'width:120px',
16
+ ));
17
+
18
+ $this->addColumn('unit', array(
19
+ 'label' => Mage::helper('adminhtml')->__('Attribute Unit'),
20
+ 'style' => 'width:120px',
21
+ ));
22
+
23
+ $this->setTemplate('mercadopago/array_dropdown.phtml');
24
+ parent::__construct();
25
+ }
26
+
27
+ protected function _getAttributes()
28
+ {
29
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
30
+ ->addFieldToFilter('is_visible', 1)
31
+ ->addFieldToFilter('frontend_input', ['nin' => ['boolean', 'date', 'datetime', 'gallery', 'image', 'media_image', 'select', 'multiselect', 'textarea']])
32
+ ->load();
33
+
34
+ return $attributes;
35
+ }
36
+
37
+ protected function _getStoredMappingValues()
38
+ {
39
+ $prevValues = [];
40
+ foreach ($this->getArrayRows() as $key => $_row) {
41
+ $prevValues[$key] = ['attribute_code' => $_row->getData('attribute_code'), 'unit' => $_row->getData('unit')];
42
+ }
43
+
44
+ return $prevValues;
45
+ }
46
+
47
+ protected function _getMeLabel()
48
+ {
49
+ return [$this->__('Length'), $this->__('Width'), $this->__('Height'), $this->__('Weight')];
50
+ }
51
+ }
app/code/community/MercadoPago/MercadoEnvios/Helper/Data.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Helper_Data
4
+ extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+ const XML_PATH_ATTRIBUTES_MAPPING = 'carriers/mercadoenvios/attributesmapping';
8
+ const ME_LENGTH_UNIT = 'cm';
9
+ const ME_WEIGHT_UNIT = 'gr';
10
+ const ME_SHIPMENT_URL = 'https://api.mercadolibre.com/shipments/';
11
+ const ME_SHIPMENT_LABEL_URL = 'https://api.mercadolibre.com/shipment_labels';
12
+ const ME_SHIPMENT_TRACKING_URL = 'https://api.mercadolibre.com/sites/';
13
+
14
+ protected $_mapping;
15
+ protected $_products = [];
16
+
17
+ public static $enabled_methods = ['mla', 'mlb', 'mlm'];
18
+
19
+ /**
20
+ * @param $quote Mage_Sales_Model_Quote
21
+ */
22
+ public function getDimensions($items)
23
+ {
24
+ $width = 0;
25
+ $height = 0;
26
+ $length = 0;
27
+ $weight = 0;
28
+ $helperItem = Mage::helper('mercadopago_mercadoenvios/itemData');
29
+ foreach ($items as $item) {
30
+ if (!$helperItem->itemHasChildren($item)) {
31
+ $width += $this->_getShippingDimension($item, 'width');
32
+ $height += $this->_getShippingDimension($item, 'height');
33
+ $length += $this->_getShippingDimension($item, 'length');
34
+ $weight += $this->_getShippingDimension($item, 'weight');
35
+ }
36
+ }
37
+ $height = ceil($height);
38
+ $width = ceil($width);
39
+ $length = ceil($length);
40
+ $weight = ceil($weight);
41
+
42
+ if (!($height > 0 && $length > 0 && $width > 0 && $weight > 0)) {
43
+ $this->log('Invalid dimensions in cart:', ['width'=>$width,'height'=>$height,'length'=>$length,'weight'=>$weight,]);
44
+ Mage::throwException('Invalid dimensions cart');
45
+ }
46
+
47
+ return $height . 'x' . $width . 'x' . $length . ',' . $weight;
48
+
49
+ }
50
+
51
+ /**
52
+ * @param $item Mage_Sales_Model_Quote_Item
53
+ */
54
+ protected function _getShippingDimension($item, $type)
55
+ {
56
+ $attributeMapped = $this->_getConfigAttributeMapped($type);
57
+ if (!empty($attributeMapped)) {
58
+ if (!isset($this->_products[$item->getProductId()])) {
59
+ $this->_products[$item->getProductId()] = Mage::getModel('catalog/product')->load($item->getProductId());
60
+ }
61
+ $product = $this->_products[$item->getProductId()];
62
+ $helperItem = Mage::helper('mercadopago_mercadoenvios/itemData');
63
+ $result = $product->getData($attributeMapped);
64
+ $result = $this->getAttributesMappingUnitConversion($type, $result);
65
+ $qty = $helperItem->itemGetQty($item);
66
+ $result = $result * $qty;
67
+ if (empty($result)) {
68
+ $this->log('Invalid dimension product: PRODUCT ', $item->getData());
69
+ Mage::throwException('Invalid dimensions product');
70
+ }
71
+
72
+ return $result;
73
+ }
74
+
75
+ return 0;
76
+ }
77
+
78
+ protected function _getConfigAttributeMapped($type)
79
+ {
80
+ return (isset($this->getAttributeMapping()[$type]['code'])) ? $this->getAttributeMapping()[$type]['code'] : null;
81
+ }
82
+
83
+ public function getAttributeMapping()
84
+ {
85
+ if (empty($this->_mapping)) {
86
+ $mapping = Mage::getStoreConfig(self::XML_PATH_ATTRIBUTES_MAPPING);
87
+ $mapping = unserialize($mapping);
88
+ $mappingResult = [];
89
+ foreach ($mapping as $key => $map) {
90
+ $mappingResult[$key] = ['code' => $map['attribute_code'], 'unit' => $map['unit']];
91
+ }
92
+ $this->_mapping = $mappingResult;
93
+ }
94
+
95
+ return $this->_mapping;
96
+ }
97
+
98
+ /**
99
+ * @return Mage_Sales_Model_Quote
100
+ */
101
+ public function getQuote()
102
+ {
103
+ if (Mage::app()->getStore()->isAdmin()) {
104
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
105
+ } else {
106
+ $quote = Mage::getModel('checkout/cart')->getQuote();
107
+ }
108
+
109
+ return $quote;
110
+ }
111
+
112
+ public function isMercadoEnviosMethod($method)
113
+ {
114
+ $shippingMethod = substr($method, 0, strpos($method, '_'));
115
+
116
+ return ($shippingMethod == MercadoPago_MercadoEnvios_Model_Shipping_Carrier_MercadoEnvios::CODE);
117
+ }
118
+
119
+ /**
120
+ * @param $attributeType string
121
+ * @param $value string
122
+ *
123
+ * @return string
124
+ */
125
+ public function getAttributesMappingUnitConversion($attributeType, $value)
126
+ {
127
+ $this->_getConfigAttributeMapped($attributeType);
128
+
129
+ if ($attributeType == 'weight') {
130
+ //check if needs conversion
131
+ if ($this->_mapping[$attributeType]['unit'] != self::ME_WEIGHT_UNIT) {
132
+ $unit = new Zend_Measure_Weight((float)$value);
133
+ $unit->convertTo(Zend_Measure_Weight::GRAM);
134
+
135
+ return $unit->getValue();
136
+ }
137
+
138
+ } elseif ($this->_mapping[$attributeType]['unit'] != self::ME_LENGTH_UNIT) {
139
+ $unit = new Zend_Measure_Length((float)$value);
140
+ $unit->convertTo(Zend_Measure_Length::CENTIMETER);
141
+
142
+ return $unit->getValue();
143
+ }
144
+
145
+ return $value;
146
+ }
147
+
148
+ public function getFreeMethod($request)
149
+ {
150
+ $freeMethod = Mage::getStoreConfig('carriers/mercadoenvios/free_method');
151
+ if (!empty($freeMethod)) {
152
+ if (!Mage::getStoreConfigFlag('carriers/mercadoenvios/free_shipping_enable')) {
153
+ return $freeMethod;
154
+ } else {
155
+ if (Mage::getStoreConfig('carriers/mercadoenvios/free_shipping_subtotal') <= $request->getPackageValue()) {
156
+ return $freeMethod;
157
+ }
158
+ }
159
+ }
160
+
161
+ return null;
162
+ }
163
+
164
+ public function isCountryEnabled()
165
+ {
166
+ return (in_array(Mage::getStoreConfig('payment/mercadopago/country'), self::$enabled_methods));
167
+ }
168
+
169
+ public function getTrackingUrlByShippingInfo($_shippingInfo)
170
+ {
171
+ $tracking = Mage::getModel('sales/order_shipment_track');
172
+ $tracking = $tracking->getCollection()
173
+ ->addFieldToFilter(
174
+ ['entity_id', 'parent_id', 'order_id'],
175
+ [
176
+ ['eq' => $_shippingInfo->getTrackId()],
177
+ ['eq' => $_shippingInfo->getShipId()],
178
+ ['eq' => $_shippingInfo->getOrderId()],
179
+ ]
180
+ )
181
+ ->setPageSize(1)
182
+ ->setCurPage(1)
183
+ ->load();
184
+
185
+ foreach ($_shippingInfo->getTrackingInfo() as $track) {
186
+ $lastTrack = array_pop($track);
187
+ if (isset($lastTrack['title']) && $lastTrack['title'] == MercadoPago_MercadoEnvios_Model_Observer::CODE) {
188
+ $item = array_pop($tracking->getItems());
189
+ if ($item->getId()) {
190
+ return $item->getDescription();
191
+ }
192
+ }
193
+ }
194
+
195
+ return '';
196
+ }
197
+
198
+ public function getTrackingPrintUrl($shipmentId)
199
+ {
200
+ if ($shipmentId) {
201
+ if ($shipment = Mage::getModel('sales/order_shipment')->load($shipmentId)) {
202
+ if ($shipment->getShippingLabel()) {
203
+ $params = [
204
+ 'shipment_ids' => $shipment->getShippingLabel(),
205
+ 'response_type' => 'zpl2',
206
+ 'access_token' => Mage::helper('mercadopago')->getAccessToken()
207
+ ];
208
+
209
+ return self::ME_SHIPMENT_LABEL_URL . '?' . http_build_query($params);
210
+ }
211
+ }
212
+ }
213
+
214
+ return '';
215
+ }
216
+
217
+ public function getShipmentInfo($shipmentId)
218
+ {
219
+ $client = new Varien_Http_Client(self::ME_SHIPMENT_URL . $shipmentId);
220
+ $client->setMethod(Varien_Http_Client::GET);
221
+ $client->setParameterGet('access_token', Mage::helper('mercadopago')->getAccessToken());
222
+
223
+ try {
224
+ $response = $client->request();
225
+ } catch (Exception $e) {
226
+ $this->log($e);
227
+ throw new Exception($e);
228
+ }
229
+
230
+ return json_decode($response->getBody());
231
+ }
232
+
233
+ public function getServiceInfo($serviceId, $country)
234
+ {
235
+ $client = new Varien_Http_Client(self::ME_SHIPMENT_TRACKING_URL . $country . '/shipping_services');
236
+ $client->setMethod(Varien_Http_Client::GET);
237
+ try {
238
+ $response = $client->request();
239
+ } catch (Exception $e) {
240
+ $this->log($e);
241
+ throw new Exception($e);
242
+ }
243
+
244
+ $response = json_decode($response->getBody());
245
+ foreach ($response as $result) {
246
+ if ($result->id == $serviceId) {
247
+ return $result;
248
+ }
249
+ }
250
+
251
+ return '';
252
+ }
253
+
254
+ public function log($message, $array = null, $level = Zend_Log::ERR, $file = "mercadoenvios.log")
255
+ {
256
+ $actionLog = Mage::getStoreConfig('carriers/mercadoenvios/log');
257
+ if ($actionLog) {
258
+ if (!is_null($array)) {
259
+ $message .= " - " . json_encode($array);
260
+ }
261
+
262
+ Mage::log($message, $level, $file, $actionLog);
263
+ }
264
+ }
265
+
266
+ }
app/code/community/MercadoPago/MercadoEnvios/Helper/ItemData.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Helper_ItemData
4
+ extends Mage_Core_Helper_Abstract
5
+ {
6
+ public function itemHasChildren($item)
7
+ {
8
+ $children = $item->getChildren();
9
+
10
+ return (!empty($children) || (get_class($item) == 'Mage_Sales_Model_Order_Item' && $item->getHasChildren()));
11
+ }
12
+
13
+ public function itemGetQty($item) {
14
+ if ($item->getParentItem()) {
15
+ $item = $item->getParentItem();
16
+ }
17
+ $qty = (get_class($item) == 'Mage_Sales_Model_Quote_Item') ? $item->getQty() : $item->getQtyOrdered();
18
+ return $qty;
19
+ }
20
+ }
app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Attribute/Validation/Mapping.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Model_Adminhtml_Attribute_Validation_Mapping
4
+ extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
5
+ {
6
+
7
+ public function save()
8
+ {
9
+ $mappingValues = $this->getValue(); //get the value from our config
10
+ $attributeCodes = [];
11
+
12
+ foreach ($mappingValues as $value) {
13
+ if (in_array($value['attribute_code'], $attributeCodes)) {
14
+ Mage::throwException(Mage::helper('mercadopago')->__("Cannot repeat Magento Product size attributes"));
15
+ }
16
+
17
+ $attributeCodes[] = $value['attribute_code'];
18
+ }
19
+
20
+ return parent::save();
21
+ }
22
+ }
app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/FreeMethod.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Model_Adminhtml_Source_Shipping_FreeMethod
4
+ extends MercadoPago_MercadoEnvios_Model_Adminhtml_Source_Shipping_Method
5
+ {
6
+
7
+ public function toOptionArray()
8
+ {
9
+ $arr = parent::toOptionArray();
10
+ array_unshift($arr, array('value'=>'', 'label'=>Mage::helper('shipping')->__('None')));
11
+ return $arr;
12
+ }
13
+
14
+ }
app/code/community/MercadoPago/MercadoEnvios/Model/Adminhtml/Source/Shipping/Method.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Model_Adminhtml_Source_Shipping_Method
4
+ {
5
+
6
+ protected $_countryOptions = [
7
+ 'mla' => [
8
+ ['value' => 73328, 'label' => 'Normal'],
9
+ ['value' => 73330, 'label' => 'Prioritario']
10
+ ],
11
+ 'mlb' => [
12
+ ['value' => 100009, 'label' => 'Normal'],
13
+ ['value' => 182, 'label' => 'Expresso'],
14
+ ],
15
+ 'mlm' => [
16
+ ['value' => 501245, 'label' => 'DHL Estándar'],
17
+ ['value' => 501345, 'label' => 'DHL Express'],
18
+ ]
19
+ ];
20
+
21
+ public function toOptionArray()
22
+ {
23
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
24
+ if ($this->_countryOptions[$country]) {
25
+ return $this->_countryOptions[$country];
26
+ }
27
+ return null;
28
+ }
29
+
30
+ }
app/code/community/MercadoPago/MercadoEnvios/Model/Observer.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Model_Observer
4
+ {
5
+
6
+ protected $_useMercadoEnvios;
7
+ const CODE = 'MercadoEnvios';
8
+
9
+ public function filterActivePaymentMethods($observer)
10
+ {
11
+ if ($this->_useMercadoEnvios()) {
12
+ $event = $observer->getEvent();
13
+ $method = $event->getMethodInstance();
14
+ $result = $event->getResult();
15
+ if ($method->getCode() != 'mercadopago_standard') {
16
+ $result->isAvailable = false;
17
+ }
18
+ }
19
+ }
20
+
21
+ protected function _useMercadoEnvios()
22
+ {
23
+ if (empty($this->_useMercadoEnvios)) {
24
+ $quote = Mage::helper('mercadopago_mercadoenvios')->getQuote();
25
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
26
+ $this->_useMercadoEnvios = Mage::helper('mercadopago_mercadoenvios')->isMercadoEnviosMethod($shippingMethod);
27
+ }
28
+
29
+ return $this->_useMercadoEnvios;
30
+ }
31
+
32
+ public function checkAndValidateData()
33
+ {
34
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
35
+ $code = Mage::getModel('mercadopago/source_country')->getCodeByValue($country);
36
+ Mage::getConfig()->saveConfig('carriers/mercadoenvios/specificcountry', $code);
37
+ }
38
+
39
+ public function addPrintButton($observer)
40
+ {
41
+ $block = $observer->getBlock();
42
+
43
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View) {
44
+ $shipmentId = Mage::app()->getRequest()->getParam('shipment_id');
45
+ $block->addButton('print_shipment_label', array(
46
+ 'label' => 'Print shipping label',
47
+ 'onclick' => 'window.open(\' ' . Mage::helper('mercadopago_mercadoenvios')->getTrackingPrintUrl($shipmentId) . '\')',
48
+ 'class' => 'go'
49
+ ));
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @param $observer
55
+ *
56
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
57
+ */
58
+ public function trackingPopup($observer)
59
+ {
60
+ $shippingInfoModel = Mage::getModel('shipping/info')->loadByHash(Mage::app()->getRequest()->getParam('hash'));
61
+
62
+ if ($url = Mage::helper('mercadopago_mercadoenvios')->getTrackingUrlByShippingInfo($shippingInfoModel)) {
63
+ $controller = $observer->getControllerAction();
64
+ $controller->getResponse()->setRedirect($url);
65
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
66
+ }
67
+ }
68
+
69
+ public function createShipment($observer)
70
+ {
71
+ $merchant_order = $observer->getMerchantOrder();
72
+ if (!count($merchant_order['shipments']) > 0) {
73
+ return;
74
+ }
75
+ $data = $observer->getPayment();
76
+ $order = Mage::getModel('sales/order')->loadByIncrementId($data["external_reference"]);
77
+
78
+ //if order has shipments, status is updated. If it doesn't the shipment is created.
79
+ if ($merchant_order['shipments'][0]['status'] == 'ready_to_ship') {
80
+ if ($order->hasShipments()) {
81
+ $shipment = Mage::getModel('sales/order_shipment')->load($order->getId(), 'order_id');
82
+ } else {
83
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment();
84
+ $shipment->register();
85
+ $order->setIsInProcess(true);
86
+ }
87
+ $shipment->setShippingLabel($merchant_order['shipments'][0]['id']);
88
+
89
+ $helper = Mage::helper('mercadopago_mercadoenvios');
90
+ $shipmentInfo = $helper->getShipmentInfo($merchant_order['shipments'][0]['id']);
91
+ Mage::helper('mercadopago')->log("Shipment Info", 'mercadopago-notification.log', $shipmentInfo);
92
+ $serviceInfo = $helper->getServiceInfo($merchant_order['shipments'][0]['service_id'], $merchant_order['site_id']);
93
+ Mage::helper('mercadopago')->log("Service Info by service id", 'mercadopago-notification.log', $serviceInfo);
94
+ if ($shipmentInfo && isset($shipmentInfo->tracking_number)) {
95
+ $tracking['number'] = $shipmentInfo->tracking_number;
96
+ $tracking['description'] = str_replace('#{trackingNumber}', $shipmentInfo->tracking_number, $serviceInfo->tracking_url);
97
+ $tracking['title'] = self::CODE;
98
+
99
+ $existingTracking = Mage::getModel('sales/order_shipment_track')->load($shipment->getOrderId(), 'order_id');
100
+ if ($existingTracking->getId()) {
101
+ $track = $shipment->getTrackById($existingTracking->getId());
102
+ $track->setNumber($tracking['number'])
103
+ ->setDescription($tracking['description'])
104
+ ->setTitle($tracking['title'])
105
+ ->save();
106
+ } else {
107
+ $track = Mage::getModel('sales/order_shipment_track')->addData($tracking);
108
+ $shipment->addTrack($track);
109
+ }
110
+
111
+ Mage::helper('mercadopago')->log("Track added", 'mercadopago-notification.log', $track);
112
+ }
113
+
114
+ Mage::getModel('core/resource_transaction')
115
+ ->addObject($shipment)
116
+ ->addObject($order)
117
+ ->save();
118
+ }
119
+ }
120
+
121
+ public function setShippingParams($observer)
122
+ {
123
+ $order = $observer->getOrder();
124
+ $method = $order->getShippingMethod();
125
+ $shippingCost = $order->getBaseShippingAmount();
126
+ if (Mage::helper('mercadopago_mercadoenvios')->isMercadoEnviosMethod($method)) {
127
+ $shippingAddress = $order->getShippingAddress();
128
+ $zipCode = $shippingAddress->getPostcode();
129
+ $defaultShippingId = substr($method, strpos($method, '_') + 1);
130
+ $paramsME = [
131
+ 'mode' => 'me2',
132
+ 'zip_code' => $zipCode,
133
+ 'default_shipping_method' => intval($defaultShippingId),
134
+ 'dimensions' => Mage::helper('mercadopago_mercadoenvios')->getDimensions($order->getAllItems())
135
+ ];
136
+ if ($shippingCost == 0) {
137
+ $paramsME['free_methods'] = [['id' => intval($defaultShippingId)]];
138
+ }
139
+ }
140
+ if (!empty($shippingCost)) {
141
+ $paramsME['cost'] = (float)$order->getBaseShippingAmount();
142
+ }
143
+ $observer->getParams()->setValues($paramsME);
144
+ Mage::helper('mercadopago_mercadoenvios')->log('REQUEST SHIPMENT ME: ', $paramsME, Zend_Log::INFO);
145
+
146
+ return $observer;
147
+ }
148
+
149
+ public function setOrderShipmentData($observer)
150
+ {
151
+ $observerData = $observer->getData();
152
+
153
+ $orderId = $observerData['orderId'];
154
+ $shipmentData = $observerData['shipmentData'];
155
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
156
+ $method = $order->getShippingMethod();
157
+ if (Mage::helper('mercadopago_mercadoenvios')->isMercadoEnviosMethod($method)) {
158
+ $methodId = $shipmentData['shipping_option']['shipping_method_id'];
159
+ $name = $shipmentData['shipping_option']['name'];
160
+ $order->setShippingMethod('mercadoenvios_' . $methodId);
161
+
162
+ $estimatedDate = Mage::helper('core')->formatDate($shipmentData['shipping_option']['estimated_delivery']['date']);
163
+ $estimatedDate = Mage::helper('mercadopago')->__('(estimated date %s)', $estimatedDate);
164
+ $shippingDescription = 'MercadoEnvíos - ' . $name . ' ' . $estimatedDate;
165
+ $order->setShippingDescription($shippingDescription);
166
+ try {
167
+ $order->save();
168
+ Mage::helper('mercadopago_mercadoenvios')->log('Order ' . $order->getIncrementId() . ' shipping data setted ',$shipmentData, Zend_Log::INFO);
169
+ } catch (Exception $e) {
170
+ Mage::helper('mercadopago')->log("error when update shipment data: " . $e, 'mercadopago.log');
171
+ Mage::helper('mercadopago_mercadoenvios')->log($e);
172
+ }
173
+ }
174
+ }
175
+
176
+ }
app/code/community/MercadoPago/MercadoEnvios/Model/Shipping/Carrier/MercadoEnvios.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_MercadoEnvios_Model_Shipping_Carrier_MercadoEnvios
4
+ extends Mage_Shipping_Model_Carrier_Abstract
5
+ implements Mage_Shipping_Model_Carrier_Interface
6
+ {
7
+
8
+ /**
9
+ * Code of the carrier
10
+ *
11
+ * @var string
12
+ */
13
+ const CODE = 'mercadoenvios';
14
+ const INVALID_METHOD = -1;
15
+
16
+ protected $_code = self::CODE;
17
+ protected $_available;
18
+ protected $_methods;
19
+ protected $_request;
20
+
21
+ /**
22
+ * Collect and get rates
23
+ *
24
+ * @param Mage_Shipping_Model_Rate_Request $request
25
+ *
26
+ * @return Mage_Shipping_Model_Rate_Result|bool|null
27
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
28
+ */
29
+
30
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
31
+ {
32
+ if (!$this->isActive()) {
33
+ return false;
34
+ }
35
+ $this->_request = $request;
36
+
37
+ /** @var Mage_Shipping_Model_Rate_Result $result */
38
+ $result = Mage::getModel('shipping/rate_result');
39
+ foreach (array_keys($this->getAllowedMethods()) as $methodId) {
40
+ $rate = $this->_getRate($methodId);
41
+ $result->append($rate);
42
+ }
43
+
44
+ return $result;
45
+ }
46
+
47
+ /**
48
+ * Get allowed shipping methods
49
+ *
50
+ * @return array
51
+ */
52
+ public function getAllowedMethods()
53
+ {
54
+ $methods = $this->getDataAllowedMethods();
55
+ $allowedMethods = [];
56
+ if (is_array($methods)) {
57
+ foreach ($methods as $method) {
58
+ if (isset($method['shipping_method_id'])) {
59
+ if ($this->_isAvailableRate($method['shipping_method_id'])) {
60
+ $allowedMethods[$method['shipping_method_id']] = $method['name'];
61
+ }
62
+ }
63
+ }
64
+ } else {
65
+ $allowedMethods[self::INVALID_METHOD] = $methods;
66
+ }
67
+
68
+ return $allowedMethods;
69
+ }
70
+
71
+ protected function getDataAllowedMethods()
72
+ {
73
+ if (empty($this->_methods)) {
74
+ $quote = Mage::helper('mercadopago_mercadoenvios')->getQuote();
75
+
76
+ $shippingAddress = $quote->getShippingAddress();
77
+ if (empty($shippingAddress)) {
78
+ return null;
79
+ }
80
+ $postcode = $shippingAddress->getPostcode();
81
+
82
+ $client_id = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_ID);
83
+ $client_secret = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_CLIENT_SECRET);
84
+ $mp = Mage::helper('mercadopago')->getApiInstance($client_id, $client_secret);
85
+
86
+ try {
87
+ $dimensions = Mage::helper('mercadopago_mercadoenvios')->getDimensions($quote->getAllItems());
88
+ } catch (Exception $e) {
89
+ $this->_methods = self::INVALID_METHOD;
90
+ return;
91
+ }
92
+
93
+ $params = [
94
+ "dimensions" => $dimensions,
95
+ "zip_code" => $postcode,
96
+ ];
97
+
98
+ $freeMethod = Mage::helper('mercadopago_mercadoenvios')->getFreeMethod($this->_request);
99
+ if (!empty($freeMethod)) {
100
+ $params['free_method'] = $freeMethod;
101
+ }
102
+ $response = $mp->get("/shipping_options", $params);
103
+ if ($response['status'] == 200) {
104
+ $this->_methods = $response['response']['options'];
105
+ } else {
106
+ $this->_methods = self::INVALID_METHOD;
107
+ Mage::helper('mercadopago_mercadoenvios')->log('Request params: ', $params);
108
+ Mage::helper('mercadopago_mercadoenvios')->log('Error response API: ', $response);
109
+ }
110
+ }
111
+
112
+ return $this->_methods;
113
+ }
114
+
115
+ public function getDataMethod($methodId)
116
+ {
117
+ $methods = $this->getDataAllowedMethods();
118
+ if (!empty($methods)) {
119
+ foreach ($methods as $method) {
120
+ if ($method['shipping_method_id'] == $methodId) {
121
+ return new Varien_Object($method);
122
+ }
123
+ }
124
+ }
125
+
126
+ return new Varien_Object();
127
+ }
128
+
129
+ protected function _getRate($methodId)
130
+ {
131
+ if ($methodId == self::INVALID_METHOD) {
132
+ return $this->_getErrorRate();
133
+ }
134
+ /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
135
+ $rate = Mage::getModel('shipping/rate_result_method');
136
+
137
+ $dataMethod = $this->getDataMethod($methodId);
138
+ $rate->setCarrier($this->_code);
139
+
140
+ $estimatedDate = $this->_getEstimatedDate($dataMethod->getEstimatedDeliveryTime());
141
+ $rate->setCarrierTitle($this->getConfigData('title'));
142
+ $rate->setMethod($methodId);
143
+ $rate->setMethodTitle($dataMethod->getName() . ' ' . Mage::helper('mercadopago')->__('(estimated date %s)', $estimatedDate));
144
+ if (!empty($this->_request) && $this->_request->getFreeShipping()) {
145
+ $rate->setPrice(0.00);
146
+ } else {
147
+ $rate->setPrice($dataMethod->getCost());
148
+ }
149
+ $rate->setCost($dataMethod->getListCost());
150
+
151
+ return $rate;
152
+ }
153
+
154
+ protected function _getErrorRate()
155
+ {
156
+ $error = Mage::getModel('shipping/rate_result_error');
157
+ $error->setCarrier($this->_code);
158
+ $error->setCarrierTitle($this->getConfigData('title'));
159
+ $msg = $this->getConfigData('specificerrmsg');
160
+ $error->setErrorMessage($msg);
161
+ return $error;
162
+ }
163
+
164
+ protected function _getEstimatedDate($dataTime)
165
+ {
166
+ $current = new Zend_Date();
167
+ $current->setTime(0);
168
+ $nextNotificationDate = $current->add($dataTime['shipping'], Zend_Date::HOUR);
169
+
170
+ return Mage::helper('core')->formatDate($nextNotificationDate);
171
+ }
172
+
173
+ protected function _isAvailableRate($rateId)
174
+ {
175
+ if (empty($this->_available)) {
176
+ $this->_available = explode(',', Mage::getStoreConfig('carriers/mercadoenvios/availablemethods'));
177
+ }
178
+
179
+ return in_array($rateId, $this->_available);
180
+ }
181
+
182
+ public function isActive() {
183
+ if (!Mage::getStoreConfigFlag('payment/mercadopago_standard/active')) {
184
+ return false;
185
+ }
186
+ if (!Mage::helper('mercadopago_mercadoenvios')->isCountryEnabled()) {
187
+ return false;
188
+ }
189
+ return parent::isActive();
190
+ }
191
+
192
+ public function isTrackingAvailable()
193
+ {
194
+ return true;
195
+ }
196
+
197
+ }
app/code/community/MercadoPago/MercadoEnvios/etc/config.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MercadoPago_MercadoEnvios>
5
+ <version>2.1.5</version>
6
+ </MercadoPago_MercadoEnvios>
7
+ </modules>
8
+ <frontend>
9
+ <events>
10
+ <controller_action_predispatch_shipping_tracking_popup>
11
+ <observers>
12
+ <mercadopago_mercadoenvios>
13
+ <type>model</type>
14
+ <class>mercadopago_mercadoenvios/observer</class>
15
+ <method>trackingPopup</method>
16
+ </mercadopago_mercadoenvios>
17
+ </observers>
18
+ </controller_action_predispatch_shipping_tracking_popup>
19
+ <mercadopago_standard_make_preference_before>
20
+ <observers>
21
+ <mercadopago_mercadoenvios>
22
+ <type>model</type>
23
+ <class>mercadopago_mercadoenvios/observer</class>
24
+ <method>setShippingParams</method>
25
+ </mercadopago_mercadoenvios>
26
+ </observers>
27
+ </mercadopago_standard_make_preference_before>
28
+ <mercadopago_standard_notification_received>
29
+ <observers>
30
+ <mercadopago_mercadoenvios>
31
+ <type>singleton</type>
32
+ <class>mercadopago_mercadoenvios/observer</class>
33
+ <method>createShipment</method>
34
+ </mercadopago_mercadoenvios>
35
+ </observers>
36
+ </mercadopago_standard_notification_received>
37
+ <mercadopago_standard_notification_before_set_status>
38
+ <observers>
39
+ <mercadopago_mercadoenvios>
40
+ <type>model</type>
41
+ <class>mercadopago_mercadoenvios/observer</class>
42
+ <method>setOrderShipmentData</method>
43
+ </mercadopago_mercadoenvios>
44
+ </observers>
45
+ </mercadopago_standard_notification_before_set_status>
46
+ </events>
47
+ </frontend>
48
+ <global>
49
+ <models>
50
+ <mercadopago_mercadoenvios>
51
+ <class>MercadoPago_MercadoEnvios_Model</class>
52
+ </mercadopago_mercadoenvios>
53
+ </models>
54
+ <sales>
55
+ <shipping>
56
+ <carriers>
57
+ <mercadopago_mercadoenvios>
58
+ <class>MercadoPago_MercadoEnvios_Model_Shipping_Carrier_MercadoEnvios</class>
59
+ </mercadopago_mercadoenvios>
60
+ </carriers>
61
+ </shipping>
62
+ </sales>
63
+ <blocks>
64
+ <mercadopago_mercadoenvios>
65
+ <class>MercadoPago_MercadoEnvios_Block</class>
66
+ </mercadopago_mercadoenvios>
67
+ </blocks>
68
+ <helpers>
69
+ <mercadopago_mercadoenvios>
70
+ <class>MercadoPago_MercadoEnvios_Helper</class>
71
+ </mercadopago_mercadoenvios>
72
+ </helpers>
73
+ <events>
74
+ <payment_method_is_active>
75
+ <observers>
76
+ <paymentfilter_payment_method_is_active>
77
+ <type>singleton</type>
78
+ <class>MercadoPago_MercadoEnvios_Model_Observer</class>
79
+ <method>filterActivePaymentMethods</method>
80
+ </paymentfilter_payment_method_is_active>
81
+ </observers>
82
+ </payment_method_is_active>
83
+ <admin_system_config_changed_section_payment>
84
+ <observers>
85
+ <payment_section_observer>
86
+ <class>MercadoPago_MercadoEnvios_Model_Observer</class>
87
+ <method>checkAndValidateData</method>
88
+ </payment_section_observer>
89
+ </observers>
90
+ </admin_system_config_changed_section_payment>
91
+ </events>
92
+
93
+ </global>
94
+
95
+ <adminhtml>
96
+ <events>
97
+ <adminhtml_widget_container_html_before>
98
+ <observers>
99
+ <mercadopago_mercadoenvios>
100
+ <type>singleton</type>
101
+ <class>MercadoPago_MercadoEnvios_Model_Observer</class>
102
+ <method>addPrintButton</method>
103
+ </mercadopago_mercadoenvios>
104
+ </observers>
105
+ </adminhtml_widget_container_html_before>
106
+
107
+ </events>
108
+ </adminhtml>
109
+
110
+ <default>
111
+ <carriers>
112
+ <mercadoenvios>
113
+ <active>1</active>
114
+ <title>MercadoEnvíos</title>
115
+ <model>MercadoPago_MercadoEnvios_Model_Shipping_Carrier_MercadoEnvios</model>
116
+ <sort_order>10</sort_order>
117
+ <sallowspecific>1</sallowspecific>
118
+ <name>MercadoEnvios</name>
119
+ <specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>
120
+ </mercadoenvios>
121
+ </carriers>
122
+ </default>
123
+ </config>
app/code/community/MercadoPago/MercadoEnvios/etc/system.xml ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+
3
+ <config>
4
+ <sections>
5
+ <carriers>
6
+ <groups>
7
+ <mercadoenvios_carrier translate="label">
8
+ <label>MercadoEnvios</label>
9
+ <sort_order>130</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <fields>
14
+ <mercadoenvios type="group" translate="label">
15
+ <label>MercadoEnvios - Configuration</label>
16
+ <frontend_type>text</frontend_type>
17
+ <frontend_model>mercadopago_mercadoenvios/adminhtml_system_config_fieldset_carrier</frontend_model>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <sort_order>0</sort_order>
22
+ <fields>
23
+ <active translate="label">
24
+ <label>Enabled</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>10</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ <comment>Enable to edit specific values</comment>
32
+ </active>
33
+ <title translate="label">
34
+ <label>Title</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>20</sort_order>
37
+ <depends><active>1</active></depends>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </title>
42
+ <attributesmapping translate="label">
43
+ <label>Product attributes mapping</label>
44
+ <frontend_model>mercadopago_mercadoenvios/adminhtml_system_config_fieldset_mapping</frontend_model>
45
+ <backend_model>mercadopago_mercadoenvios/adminhtml_attribute_validation_mapping</backend_model>
46
+ <sort_order>25</sort_order>
47
+ <depends><active>1</active></depends>
48
+ <depends><active>1</active></depends>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </attributesmapping>
53
+ <availablemethods translate="label">
54
+ <label>Available shipping methods</label>
55
+ <frontend_type>multiselect</frontend_type>
56
+ <source_model>mercadopago_mercadoenvios/adminhtml_source_shipping_method</source_model>
57
+ <sort_order>27</sort_order>
58
+ <depends><active>1</active></depends>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>0</show_in_store>
62
+ </availablemethods>
63
+ <sallowspecific translate="label">
64
+ <label>Allow Specific Country</label>
65
+ <frontend_type>select</frontend_type>
66
+ <frontend_class>shipping-applicable-country</frontend_class>
67
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
68
+ <sort_order>30</sort_order>
69
+ <depends><active>1</active></depends>
70
+ <show_in_default>0</show_in_default>
71
+ <show_in_website>0</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </sallowspecific>
74
+ <specificcountry translate="label">
75
+ <label>Specific Country</label>
76
+ <frontend_type>multiselect</frontend_type>
77
+ <source_model>mercadopago/source_country</source_model>
78
+ <sort_order>40</sort_order>
79
+ <depends><active>1</active></depends>
80
+ <show_in_default>0</show_in_default>
81
+ <show_in_website>0</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </specificcountry>
84
+ <free_method translate="label">
85
+ <label>Free Method</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>mercadopago_mercadoenvios/adminhtml_source_shipping_freeMethod</source_model>
88
+ <sort_order>45</sort_order>
89
+ <depends><active>1</active></depends>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ </free_method>
94
+ <free_shipping_enable translate="label">
95
+ <label>Free Shipping with Minimum Order Amount</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
98
+ <sort_order>46</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </free_shipping_enable>
103
+ <free_shipping_subtotal translate="label">
104
+ <label>Minimum Order Amount for Free Shipping</label>
105
+ <frontend_type>text</frontend_type>
106
+ <validate>validate-number validate-zero-or-greater</validate>
107
+ <sort_order>47</sort_order>
108
+ <depends><free_shipping_enable>1</free_shipping_enable></depends>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>0</show_in_store>
112
+ </free_shipping_subtotal>
113
+ <showmethod translate="label">
114
+ <label>Show method if not applicable</label>
115
+ <frontend_type>select</frontend_type>
116
+ <sort_order>50</sort_order>
117
+ <source_model>adminhtml/system_config_source_yesno</source_model>
118
+ <frontend_class>shipping-skip-hide</frontend_class>
119
+ <depends><active>1</active></depends>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ </showmethod>
124
+ <specificerrmsg translate="label">
125
+ <label>Displayed Error Message</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>60</sort_order>
128
+ <depends><active>1</active></depends>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>0</show_in_store>
132
+ </specificerrmsg>
133
+ <log translate="label">
134
+ <label>Log</label>
135
+ <frontend_type>select</frontend_type>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ <sort_order>65</sort_order>
138
+ <depends><active>1</active></depends>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ </log>
143
+ <debug_mode translate="label">
144
+ <label>Debug Mode</label>
145
+ <frontend_type>select</frontend_type>
146
+ <source_model>adminhtml/system_config_source_yesno</source_model>
147
+ <sort_order>70</sort_order>
148
+ <depends><active>1</active></depends>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>0</show_in_store>
152
+ </debug_mode>
153
+ <sort_order translate="label">
154
+ <label>Sort order</label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>80</sort_order>
157
+ <depends><active>1</active></depends>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>0</show_in_store>
161
+ </sort_order>
162
+ </fields>
163
+ </mercadoenvios>
164
+ </fields>
165
+ </mercadoenvios_carrier>
166
+ </groups>
167
+ </carriers>
168
+ </sections>
169
+ </config>
app/code/community/MercadoPago/Model/Core.php DELETED
@@ -1,314 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Core extends Mage_Payment_Model_Method_Abstract{
20
-
21
-
22
- protected $_code = 'mercadopago';
23
-
24
- protected $_isGateway = true;
25
- protected $_canOrder = true;
26
- protected $_canAuthorize = true;
27
- protected $_canCapture = true;
28
- protected $_canCapturePartial = true;
29
- protected $_canRefund = true;
30
- protected $_canRefundInvoicePartial = true;
31
- protected $_canVoid = true;
32
- protected $_canUseInternal = true;
33
- protected $_canUseCheckout = true;
34
- protected $_canUseForMultishipping = true;
35
- protected $_canFetchTransactionInfo = true;
36
- protected $_canCreateBillingAgreement = true;
37
- protected $_canReviewPayment = true;
38
-
39
-
40
- /**
41
- * @return Mage_Checkout_Model_Session
42
- */
43
- protected function _getCheckout() {
44
- return Mage::getSingleton('checkout/session');
45
- }
46
-
47
- /**
48
- * Get admin checkout session namespace
49
- *
50
- * @return Mage_Adminhtml_Model_Session_Quote
51
- */
52
- protected function _getAdminCheckout() {
53
- return Mage::getSingleton('adminhtml/session_quote');
54
- }
55
-
56
- /**
57
- * Retrieves Quote
58
- *
59
- * @param integer $quoteId
60
- * @return Mage_Sales_Model_Quote
61
- */
62
- protected function _getQuote($quoteId = null) {
63
- if (!empty($quoteId)) {
64
- return Mage::getModel('sales/quote')->load($quoteId);
65
- }
66
- else {
67
- if(Mage::app()->getStore()->isAdmin()) {
68
- return $this->_getAdminCheckout()->getQuote();
69
- } else {
70
- return $this->_getCheckout()->getQuote();
71
- }
72
- }
73
- }
74
-
75
- /**
76
- * Retrieves Order
77
- *
78
- * @param integer $incrementId
79
- * @return Mage_Sales_Model_Order
80
- */
81
- protected function _getOrder($incrementId) {
82
- return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
83
- }
84
-
85
- public function getInfoPaymentByOrder($order_id){
86
- $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
87
- $payment = $order->getPayment();
88
- $info_payments = array();
89
- $fields = array(
90
- array("field" => "cardholderName", "title" => "Card Holder Name: %s"),
91
- array("field" => "trunc_card", "title" => "Card Number: %s"),
92
- array("field" => "payment_method", "title" => "Payment Method: %s"),
93
- array("field" => "expiration_date", "title" => "Expiration Date: %s"),
94
- array("field" => "installments", "title" => "Installments: %s"),
95
- array("field" => "statement_descriptor", "title" => "Statement Descriptor: %s"),
96
- array("field" => "payment_id", "title" => "Payment id (MercadoPago): %s"),
97
- array("field" => "status", "title" => "Payment Status: %s"),
98
- array("field" => "status_detail", "title" => "Payment Detail: %s"),
99
- array("field" => "activation_uri", "title" => "Generate Ticket")
100
- );
101
-
102
- foreach($fields as $field):
103
- if($payment->getAdditionalInformation($field['field']) != ""):
104
- $text = Mage::helper('mercadopago')->__($field['title'], $payment->getAdditionalInformation($field['field']));
105
- $info_payments[$field['field']] = array(
106
- "text" => $text,
107
- "value" => $payment->getAdditionalInformation($field['field'])
108
- );
109
- endif;
110
- endforeach;
111
-
112
- return $info_payments;
113
- }
114
-
115
- protected function validStatusTwoPayments($status){
116
- $array_status = explode(" | ", $status);
117
- $status_verif = true;
118
- $status_final = "";
119
- foreach($array_status as $status):
120
-
121
- if($status_final == ""){
122
- $status_final = $status;
123
- }else{
124
- if($status_final != $status){
125
- $status_verif = false;
126
- }
127
- }
128
- endforeach;
129
-
130
- if($status_verif === false){
131
- $status_final = "other";
132
- }
133
-
134
- return $status_final;
135
- }
136
-
137
- public function getMessageByStatus($status, $status_detail, $payment_method, $installment, $amount){
138
- $status = $this->validStatusTwoPayments($status);
139
- $status_detail = $this->validStatusTwoPayments($status_detail);
140
-
141
- $message = array(
142
- "title" => "",
143
- "message" => ""
144
- );
145
-
146
-
147
- switch ($status){
148
- case "approved":
149
- $message['title'] = Mage::helper('mercadopago')->__('Done, your payment was accredited!');
150
- break;
151
-
152
- case "in_process":
153
- $message['title'] = Mage::helper('mercadopago')->__('We are processing the payment.');
154
- $message['message'] = Mage::helper('mercadopago')->__('In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.');
155
- break;
156
-
157
- case 'authorized':
158
- case "pending":
159
- $message['title'] = Mage::helper('mercadopago')->__('We are processing the payment.');
160
- $message['message'] = Mage::helper('mercadopago')->__('In less than an hour we will send you by e-mail the result.');
161
- break;
162
-
163
- case "rejected":
164
- $message['title'] = Mage::helper('mercadopago')->__('We could not process your payment.');
165
-
166
- switch ($status_detail){
167
- case "cc_rejected_bad_filled_card_number":
168
- $message['message'] = Mage::helper('mercadopago')->__('Check the card number.');
169
- break;
170
-
171
- case "cc_rejected_bad_filled_date":
172
- $message['message'] = Mage::helper('mercadopago')->__('Check the expiration date.');
173
- break;
174
-
175
- case "cc_rejected_bad_filled_other":
176
- $message['message'] = Mage::helper('mercadopago')->__('Check the data.');
177
- break;
178
-
179
- case "cc_rejected_bad_filled_security_code":
180
- $message['message'] = Mage::helper('mercadopago')->__('Check the security code.');
181
- break;
182
-
183
- case "cc_rejected_blacklist":
184
- $message['message'] = Mage::helper('mercadopago')->__('We could not process your payment.');
185
- break;
186
-
187
- case "cc_rejected_call_for_authorize":
188
- $message['message'] = Mage::helper('mercadopago')->__('You must authorize to %s the payment of $ %s to MercadoPago.', strtoupper($payment_method), strtoupper($amount));
189
- break;
190
-
191
- case "cc_rejected_card_disabled":
192
- $message['message'] = Mage::helper('mercadopago')->__('Call %s to activate your card.<br/>The phone is on the back of your card.', strtoupper($payment_method));
193
- break;
194
-
195
- case "cc_rejected_card_error":
196
- $message['message'] = Mage::helper('mercadopago')->__('We could not process your payment.');
197
- break;
198
-
199
- case "cc_rejected_duplicated_payment":
200
- $message['message'] = Mage::helper('mercadopago')->__('You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.');
201
- break;
202
-
203
- case "cc_rejected_high_risk":
204
- $message['message'] = Mage::helper('mercadopago')->__('Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.');
205
- break;
206
-
207
- case "cc_rejected_insufficient_amount":
208
- $message['message'] = Mage::helper('mercadopago')->__('Your %s do not have sufficient funds.', strtoupper($payment_method));
209
- break;
210
-
211
- case "cc_rejected_invalid_installments":
212
- $message['message'] = Mage::helper('mercadopago')->__('%s does not process payments in %s installments.', strtoupper($payment_method), $installment);
213
- break;
214
-
215
- case "cc_rejected_max_attempts":
216
- $message['message'] = Mage::helper('mercadopago')->__('You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.');
217
- break;
218
-
219
- case "cc_rejected_other_reason":
220
- $message['message'] = Mage::helper('mercadopago')->__('%s did not process the payment.', strtoupper($payment_method));
221
- break;
222
-
223
- }
224
-
225
- break;
226
- case "cancelled":
227
- $message['title'] = Mage::helper('mercadopago')->__('Payments were canceled.');
228
- $message['message'] = Mage::helper('mercadopago')->__('Contact for more information.');
229
- break;
230
- case "other":
231
- $message['title'] = Mage::helper('mercadopago')->__('Thank you for your purchase!');
232
- break;
233
- }
234
-
235
- return $message;
236
- }
237
-
238
- public function getPayment($payment_id){
239
- $model = $this;
240
- $this->client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
241
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
242
- $mp = new MP($this->client_id, $this->client_secret);
243
- return $mp->get_payment($payment_id);
244
- }
245
-
246
- public function getMerchantOrder($merchant_order_id){
247
- $model = $this;
248
- $this->client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
249
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
250
- $mp = new MP($this->client_id, $this->client_secret);
251
-
252
- return $mp->get("/merchant_orders/" . $merchant_order_id);
253
- }
254
-
255
- public function getPaymentMethods(){
256
- $this->client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
257
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
258
-
259
- $mp = new MP ($this->client_id, $this->client_secret);
260
-
261
- $payment_methods = $mp->get("/v1/payment_methods");
262
-
263
- return $payment_methods;
264
- }
265
-
266
- public function getEmailCustomer(){
267
- $customer = Mage::getSingleton('customer/session')->getCustomer();
268
- $email = $customer->getEmail();
269
-
270
- if($email == ""){
271
- $order = $this->_getOrder();
272
- $email = $order['customer_email'];
273
- }
274
-
275
- return $email;
276
- }
277
-
278
-
279
- public function getAmount(){
280
- $quote = $this->_getQuote();
281
- $total = $quote->getBaseGrandTotal();
282
-
283
- //caso o valor seja null setta um valor 0
284
- if(is_null($total))
285
- $total = 0;
286
-
287
- return (float) $total;
288
- }
289
-
290
- public function validCoupon($id){
291
-
292
- $this->client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
293
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
294
-
295
- $mp = new MP ($this->client_id, $this->client_secret);
296
-
297
- $params = array(
298
- "transaction_amount" => $this->getAmount(),
299
- "payer_email" => $this->getEmailCustomer(),
300
- "coupon_code" => $id
301
- );
302
-
303
- $details_discount = $mp->get("/discount_campaigns", $params);
304
-
305
- //add value on return api discount
306
- $details_discount['response']['transaction_amount'] = $params['transaction_amount'];
307
- $details_discount['response']['params'] = $params;
308
-
309
-
310
- return $details_discount;
311
-
312
- }
313
-
314
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Custom/Payment.php DELETED
@@ -1,436 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Custom_Payment extends Mage_Payment_Model_Method_Abstract{
20
-
21
- //configura o block do formulario e de informações sobre o pagamento
22
- protected $_formBlockType = 'mercadopago/custom_form';
23
- protected $_infoBlockType = 'mercadopago/custom_info';
24
-
25
- protected $_code = 'mercadopago_custom';
26
-
27
- protected $_canSaveCc = false;
28
- protected $_isGateway = true;
29
- protected $_canAuthorize = true;
30
- protected $_canCapture = true;
31
- protected $_canVoid = true;
32
- protected $_canCancelInvoice = true;
33
- protected $_isInitializeNeeded = true;
34
- protected $_canFetchTransactionInfo = true;
35
- protected $_canCreateBillingAgreement = true;
36
- protected $_canReviewPayment = true;
37
-
38
- public function initialize($paymentAction, $stateObject) {
39
-
40
- //verifica se o pagamento não é boleto, caso seja não tem card_token_id
41
- if($this->getInfoInstance()->getAdditionalInformation('payment_type_id') != "ticket" && $this->getInfoInstance()->getAdditionalInformation('card_token_id') == ""):
42
- Mage::throwException(Mage::helper('mercadopago')->__('Verify the form data or wait until the validation of the payment data'));
43
- return false;
44
- endif;
45
-
46
-
47
- //continua o processo de pagamento
48
- $response = $this->postPago();
49
-
50
- if($response !== false):
51
-
52
- $payment = $response['response'];
53
-
54
- //set order_id
55
- $order = Mage::getModel('sales/order')->loadByIncrementId($payment['external_reference']);
56
-
57
- //set status
58
- $this->getInfoInstance()->setAdditionalInformation('status', $payment['status']);
59
- $this->getInfoInstance()->setAdditionalInformation('status_detail', $payment['status_detail']);
60
-
61
- return true;
62
- endif;
63
-
64
- return false;
65
- }
66
-
67
- public function assignData($data){
68
-
69
- // route /checkout/onepage/savePayment
70
- if(!($data instanceof Varien_Object)){
71
- $data = new Varien_Object($data);
72
- }
73
-
74
- //get array info
75
- $info_form = $data->getData();
76
-
77
- $info = $this->getInfoInstance();
78
- $info->setAdditionalInformation('payment_type_id', "credit_card");
79
- $info->setAdditionalInformation('card_token_id', $info_form['card_token_id']);
80
- $info->setAdditionalInformation('payment_method', $info_form['payment_method']);
81
- $info->setAdditionalInformation('installments', $info_form['installments']);
82
- $info->setAdditionalInformation('doc_number', $info_form['doc_number']);
83
-
84
- //caso tenha banco, adiciona nas informações adicionais
85
- if(isset($info_form['issuers'])){
86
- $info->setAdditionalInformation('issuers', $info_form['issuers']);
87
- }
88
-
89
- if(isset($info_form['coupon_code'])){
90
- $info->setAdditionalInformation('coupon_code', $info_form['coupon_code']);
91
- }
92
-
93
- if($info_form['card_token_id'] != ""):
94
- $info->setAdditionalInformation('expiration_date', $info_form['cardExpirationMonth'] . "/" . $info_form['cardExpirationYear']);
95
- $info->setAdditionalInformation('cardholderName', $info_form['cardholderName']);
96
- $info->setAdditionalInformation('trunc_card', $info_form['trunc_card']);
97
- endif;
98
-
99
-
100
- //caso seja não tenha card_token_id
101
- /*if($info_form['card_token_id'] == ""):
102
- Mage::throwException(Mage::helper('mercadopago')->__('Verify the form data or wait until the validation of the payment data'));
103
- return false;
104
- endif;*/
105
-
106
-
107
- return $this;
108
- }
109
-
110
- public function getOrderPlaceRedirectUrl() {
111
- // requisicao vem da pagina de finalizacao de pedido
112
- return Mage::getUrl('mercadopago/success', array('_secure' => true));
113
- }
114
-
115
- /**
116
- * @return Mage_Checkout_Model_Session
117
- */
118
- protected function _getCheckout() {
119
- return Mage::getSingleton('checkout/session');
120
- }
121
-
122
- /**
123
- * Get admin checkout session namespace
124
- *
125
- * @return Mage_Adminhtml_Model_Session_Quote
126
- */
127
- protected function _getAdminCheckout() {
128
- return Mage::getSingleton('adminhtml/session_quote');
129
- }
130
-
131
- /**
132
- * Retrieves Quote
133
- *
134
- * @param integer $quoteId
135
- * @return Mage_Sales_Model_Quote
136
- */
137
- protected function _getQuote($quoteId = null) {
138
- if (!empty($quoteId)) {
139
- return Mage::getModel('sales/quote')->load($quoteId);
140
- }
141
- else {
142
- if(Mage::app()->getStore()->isAdmin()) {
143
- return $this->_getAdminCheckout()->getQuote();
144
- } else {
145
- return $this->_getCheckout()->getQuote();
146
- }
147
- }
148
- }
149
-
150
- /**
151
- * Retrieves Order
152
- *
153
- * @param integer $incrementId
154
- * @return Mage_Sales_Model_Order
155
- */
156
- protected function _getOrder($incrementId) {
157
- return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
158
- }
159
-
160
- public function getDiscount(){
161
- $discount = 0;
162
- $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
163
-
164
- if(isset($totals['discount']) && $totals['discount']->getValue()) {
165
- $discount = $totals['discount']->getValue();
166
- }
167
-
168
- return $discount;
169
- }
170
-
171
- public function postPago(){
172
- Mage::helper('mercadopago')->log("init post pago", 'mercadopago-custom.log');
173
- $core = Mage::getModel('mercadopago/core');
174
-
175
- //seta sdk php mercadopago
176
- $client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
177
- $client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
178
-
179
- $mp = new MP($client_id, $client_secret);
180
-
181
- //monta a preferencia
182
- $pref = $this->makePreference();
183
- Mage::helper('mercadopago')->log("make array", 'mercadopago-custom.log', $pref);
184
-
185
- //faz o post do pagamento
186
- $response = $mp->create_custon_payment($pref);
187
- Mage::helper('mercadopago')->log("post pago", 'mercadopago-custom.log', $response);
188
-
189
- if($response['status'] == 200 || $response['status'] == 201):
190
- return $response;
191
- else:
192
- $e = "";
193
- foreach($response['response']['cause'] as $error):
194
- switch ($error['code']) {
195
- case "106":
196
- $e .= Mage::helper('mercadopago')->__('You can not make payments to users in other countries.');
197
- break;
198
-
199
- case "109":
200
- $e .= Mage::helper('mercadopago')->__('Payment Method selected does not process payments in installments selected. Choose another card or another payment method.');
201
- break;
202
-
203
- case "126":
204
- $e .= Mage::helper('mercadopago')->__('We could not process your payment. Error code: 126.');
205
- break;
206
-
207
- case "129":
208
- $e .= Mage::helper('mercadopago')->__('Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.');
209
- break;
210
-
211
- case "137":
212
- $e .= Mage::helper('mercadopago')->__('The amount is required.');
213
- break;
214
-
215
- case "145":
216
- $e .= Mage::helper('mercadopago')->__('We could not process your payment. Error code: 145.');
217
- break;
218
-
219
- case "150":
220
- $e .= Mage::helper('mercadopago')->__('You can not make payments. Error code: 150.');
221
- break;
222
-
223
- case "151":
224
- $e .= Mage::helper('mercadopago')->__('You can not make payments.');
225
- break;
226
-
227
- case "160":
228
- $e .= Mage::helper('mercadopago')->__('We could not process your payment. Error code: 160.');
229
- break;
230
-
231
- case "204":
232
- $e .= Mage::helper('mercadopago')->__('Payment Method selected is not available at this time. Choose another card or another payment method.');
233
- break;
234
-
235
- case "801":
236
- $e .= Mage::helper('mercadopago')->__('You made a similar payment moments ago. Try again in a few minutes.');
237
- break;
238
-
239
- //validacao do coupon
240
- case "campaign_code_doesnt_match":
241
- $e .= Mage::helper('mercadopago')->__("Doesn't find a campaign with the given code.");
242
- break;
243
-
244
- default:
245
- $e .= Mage::helper('mercadopago')->__("We could not process your payment. %s", json_encode($response));
246
- break;
247
- }
248
-
249
- endforeach;
250
- Mage::helper('mercadopago')->log("erro post pago: " . $e, 'mercadopago-custom.log');
251
- Mage::helper('mercadopago')->log("response post pago: ", 'mercadopago-custom.log', $response);
252
- Mage::throwException($e);
253
- return false;
254
- endif;
255
-
256
- }
257
-
258
- function makePreference(){
259
-
260
- $core = Mage::getModel('mercadopago/core');
261
- $quote = $this->_getQuote();
262
- $orderId = $quote->getReservedOrderId();
263
- $order = $this->_getOrder($orderId);
264
-
265
-
266
- $customer = Mage::getSingleton('customer/session')->getCustomer();
267
- $model = Mage::getModel('catalog/product');
268
-
269
-
270
- //pega payment dentro da order para pegar as informacoes adicionadas pela funcao assignData()
271
- $payment = $order->getPayment();
272
-
273
- //pega valor total da compra
274
- $item_price = $order->getBaseGrandTotal();
275
- if (!$item_price) {
276
- $item_price = $order->getBasePrice() + $order->getBaseShippingAmount();
277
- }
278
-
279
- //pega o valor total da compra somando o frete
280
- $item_price = number_format($item_price, 2, '.', '');
281
-
282
- //setta informaçnoes
283
- $arr = array();
284
- $arr['external_reference'] = $orderId;
285
- $arr['amount'] = (float) $item_price;
286
- $arr['reason'] = Mage::helper('mercadopago')->__("Order # %s in store %s", $orderId, Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true));
287
- //não é necessario settar currency_id, pois ja identifica no backend
288
- //$arr['currency_id'] = "BRL";
289
- $arr['installments'] = (int) $payment->getAdditionalInformation("installments");
290
- $arr['payment_method_id'] = $payment->getAdditionalInformation("payment_method");
291
- $arr['payer_email'] = htmlentities($customer->getEmail());
292
-
293
- if($payment->getAdditionalInformation("card_token_id") != ""){
294
- $arr['card_token_id'] = $payment->getAdditionalInformation("card_token_id");
295
- }
296
-
297
- if($payment->getAdditionalInformation("issuers") != ""){
298
- $arr['card_issuer_id'] = (int) $payment->getAdditionalInformation("issuers");
299
- }
300
-
301
- //monta array de produtos
302
- $arr['items'] = array();
303
- foreach ($order->getAllVisibleItems() as $item) {
304
-
305
- $prod = $model->loadByAttribute('sku', $item->getSku());
306
-
307
- //get image
308
- try{
309
- $imagem = $prod->getImageUrl();
310
- }catch(Exception $e){
311
- $imagem = "";
312
- }
313
-
314
- $arr['items'][] = array(
315
- "id" => $item->getSku(),
316
- "title" => $item->getName(),
317
- "description" => $item->getName(),
318
- "picture_url" => $imagem,
319
- "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
320
- "quantity" => (int) number_format($item->getQtyOrdered(), 0, '.', ''),
321
- "unit_price" => (float) number_format($prod->getPrice(), 2, '.', '')
322
- );
323
-
324
- }
325
-
326
-
327
- //verifica se existe desconto, caso exista adiciona como um item
328
- $discount = $this->getDiscount();
329
- if($discount != 0){
330
- $arr['items'][] = array(
331
- "title" => "Discount by the Store",
332
- "description" => "Discount by the Store",
333
- "quantity" => (int) 1,
334
- "unit_price" => (float) number_format($discount, 2, '.', '')
335
- );
336
- }
337
-
338
- //pega dados de envio
339
- if(method_exists($order->getShippingAddress(), "getData")){
340
- $shipping = $order->getShippingAddress()->getData();
341
- $arr['shipments']['receiver_address'] = array(
342
- "floor" => "-",
343
- "zip_code" => $shipping['postcode'],
344
- "street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
345
- "apartment" => "-",
346
- "street_number" => "0"
347
- );
348
-
349
- $arr['customer']['phone'] = array(
350
- "area_code" => "-",
351
- "number" => $shipping['telephone']
352
- );
353
- }
354
-
355
- //formata a data do usuario para o padrao do mercado pago YYYY-MM-DDTHH:MM:SS
356
- $date_creation_user = date('Y-m-d',$customer->getCreatedAtTimestamp()) . "T" . date('H:i:s',$customer->getCreatedAtTimestamp());
357
-
358
- //$quote = Mage::getSingleton('checkout/session')->getQuote();
359
- $billing_address = $quote->getBillingAddress();
360
- $billing_address = $billing_address->getData();
361
-
362
- //set informaçoes do usuario
363
- $arr['customer']['registration_date'] = $date_creation_user;
364
- $arr['customer']['email'] = htmlentities($customer->getEmail());
365
- $arr['customer']['first_name'] = htmlentities($customer->getFirstname());
366
- $arr['customer']['last_name'] = htmlentities($customer->getLastname());
367
-
368
- //set o documento do usuario
369
- if($payment['additional_information']['doc_number'] != ""){
370
- $arr['customer']['identification'] = array(
371
- "type" => "CPF",
372
- "number" => $payment->getAdditionalInformation("doc_number")
373
- );
374
- }
375
-
376
- //set endereco do usuario
377
- $arr['customer']['address'] = array(
378
- "zip_code" => $billing_address['postcode'],
379
- "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
380
- "street_number" => "0"
381
- );
382
-
383
- //define a url de notificacao
384
- $arr['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago/notifications?checkout=custom";
385
-
386
- //pega o email e o nome do usuario guest
387
- if($arr['payer_email'] == "" && $arr['customer']['email'] == ""){
388
- $arr['payer_email'] = $order['customer_email'];
389
- $arr['customer']['email'] = $order['customer_email'];
390
- $arr['customer']['first_name'] = $order->getBillingAddress()->getFirstname();
391
- $arr['customer']['last_name'] = $order->getBillingAddress()->getLastname();
392
- }
393
-
394
-
395
- if($payment->getAdditionalInformation("coupon_code") != ""){
396
-
397
- $coupon_code = $payment->getAdditionalInformation("coupon_code");
398
- Mage::helper('mercadopago')->log("Validating coupon_code: " . $coupon_code, 'mercadopago-custom.log');
399
-
400
- $coupon = $core->validCoupon($coupon_code);
401
- Mage::helper('mercadopago')->log("Response API Coupon: " , 'mercadopago-custom.log', $coupon);
402
-
403
- if( $coupon['status'] != 200){
404
- if( $coupon['response']['error'] != "campaign-code-doesnt-match" &&
405
- $coupon['response']['error'] != "amount-doesnt-match" &&
406
- $coupon['response']['error'] != "transaction_amount_invalid"){
407
-
408
- // caso não seja os erros mapeados acima (todos são informandos no formulario no momento que aplica os desconto)
409
- // o coupon code é inserido no array para o post de pagamento
410
- // caso de erro significa que o coupon não é mais valido para utilização
411
- // pode ter ocorrido do usuario ja ter utilizado o coupon e mesmo assim prosseguir com o pagamento
412
-
413
- $arr['coupon_code'] = $coupon_code;
414
- Mage::helper('mercadopago')->log("Coupon applied. API response 400, error not mapped", 'mercadopago-custom.log');
415
- }else{
416
- Mage::helper('mercadopago')->log("Coupon invalid, not applied.", 'mercadopago-custom.log');
417
- }
418
- }else{
419
- $arr['coupon_code'] = $coupon_code;
420
- Mage::helper('mercadopago')->log("Coupon applied. API response 200.", 'mercadopago-custom.log');
421
-
422
- }
423
- }
424
-
425
- //verifico se o sponsor é diferente de null (se existe)
426
- $sponsor_id = Mage::getStoreConfig('payment/mercadopago/sponsor_id');
427
- Mage::helper('mercadopago')->log("Sponsor_id", 'mercadopago-standard.log', $sponsor_id);
428
- if($sponsor_id != null && $sponsor_id != ""){
429
- Mage::helper('mercadopago')->log("Sponsor_id identificado", 'mercadopago-standard.log', $sponsor_id);
430
- $arr['sponsor_id'] = (int) $sponsor_id;
431
- }
432
-
433
- return $arr;
434
-
435
- }
436
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/CustomTicket/Payment.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_CustomTicket_Payment extends Mage_Payment_Model_Method_Abstract{
20
-
21
- //configura o lugar do arquivo para listar meios de pagamento
22
- protected $_formBlockType = 'mercadopago/customticket_form';
23
- protected $_infoBlockType = 'mercadopago/customticket_info';
24
-
25
- protected $_code = 'mercadopago_customticket';
26
-
27
- protected $_canSaveCc = false;
28
- protected $_isGateway = true;
29
- protected $_canAuthorize = true;
30
- protected $_canCapture = true;
31
- protected $_canVoid = true;
32
- protected $_canCancelInvoice = true;
33
- protected $_isInitializeNeeded = true;
34
- protected $_canFetchTransactionInfo = true;
35
- protected $_canCreateBillingAgreement = true;
36
- protected $_canReviewPayment = true;
37
-
38
- public function initialize($paymentAction, $stateObject) {
39
- //chama model para fazer o post do pagamento
40
- $response = Mage::getModel('mercadopago/custom_payment')->postPago();
41
-
42
- if($response !== false):
43
- $this->getInfoInstance()->setAdditionalInformation('activation_uri', $response['response']['activation_uri']);
44
- return true;
45
- endif;
46
-
47
- return false;
48
-
49
- }
50
-
51
- public function assignData($data){
52
-
53
- // route /checkout/onepage/savePayment
54
- if(!($data instanceof Varien_Object)){
55
- $data = new Varien_Object($data);
56
- }
57
-
58
- //get array info
59
- $info_form = $data->getData();
60
-
61
- $info = $this->getInfoInstance();
62
- $info->setAdditionalInformation('payment_type_id', "ticket");
63
- $info->setAdditionalInformation('payment_method', $info_form['payment_method_boleto']);
64
- $info->setAdditionalInformation('card_token_id', "");
65
- $info->setAdditionalInformation('installments', 1);
66
- $info->setAdditionalInformation('doc_number', "");
67
-
68
- if(isset($info_form['coupon_code'])){
69
- $info->setAdditionalInformation('coupon_code', $info_form['coupon_code']);
70
- }
71
-
72
- return $this;
73
- }
74
-
75
- public function getOrderPlaceRedirectUrl() {
76
- // requisicao vem da pagina de finalizacao de pedido
77
- return Mage::getUrl('mercadopago/success', array('_secure' => true));
78
- }
79
-
80
- }
81
-
82
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Observer.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Observer{
20
-
21
- private $banners = array(
22
- "mercadopago_custom" => array(
23
- "mla" => "http://imgmp.mlstatic.com/org-img/banners/ar/medios/online/468X60.jpg",
24
- "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg",
25
- "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
26
- "mlm" => "http://imgmp.mlstatic.com/org-img/banners/mx/medios/MLM_468X60.JPG"
27
- ),
28
- "mercadopago_customticket" => array(
29
- "mla" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
30
- "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png",
31
- "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
32
- "mlm" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png"
33
- ),
34
- "mercadopago_standard" => array(
35
- "mla" => "http://imgmp.mlstatic.com/org-img/banners/ar/medios/online/468X60.jpg",
36
- "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg",
37
- "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
38
- "mlm" => "http://imgmp.mlstatic.com/org-img/banners/mx/medios/MLM_468X60.JPG"
39
- )
40
- );
41
-
42
- private $available_transparent_credit_cart = array('mla', 'mlb', 'mlm');
43
- private $available_transparent_ticket = array('mla', 'mlb', 'mlm');
44
-
45
- public function checkAndValidData($observer){
46
- //verifica se o usuario é de teste ou nao
47
- $this->setSponsor();
48
-
49
- //verifica se o checkout esta disponível para o pais
50
- $this->availableCheckout();
51
-
52
- //verifica se os banners estao de acordo com o pais
53
- $this->checkBanner('mercadopago_custom');
54
- $this->checkBanner('mercadopago_customticket');
55
- $this->checkBanner('mercadopago_standard');
56
- }
57
-
58
-
59
- public function availableCheckout(){
60
- //verifica se o pais selecionado possui integracao para utilizar os checkouts transparents
61
- $core = new Mage_Core_Model_Resource_Setup('core_setup');
62
- $country = Mage::getStoreConfig('payment/mercadopago/country');
63
-
64
- if(!in_array($country, $this->available_transparent_credit_cart)){
65
- $core->setConfigData('payment/mercadopago_custom/active', 0);
66
- }
67
-
68
- if(!in_array($country, $this->available_transparent_ticket)){
69
- $core->setConfigData('payment/mercadopago_customticket/active', 0);
70
- }
71
- }
72
-
73
- function checkBanner($type_checkout){
74
- //get country
75
- $country = Mage::getStoreConfig('payment/mercadopago/country');
76
- $default_banner = $this->banners[$type_checkout][$country];
77
-
78
- //pega o banner do tipo de checkout
79
- $current_banner = Mage::getStoreConfig('payment/' . $type_checkout . '/banner_checkout');
80
-
81
- Mage::helper('mercadopago')->log("Type Checkout Path: " . $type_checkout, 'mercadopago.log');
82
- Mage::helper('mercadopago')->log("Current Banner: " . $current_banner, 'mercadopago.log');
83
- Mage::helper('mercadopago')->log("Default Banner: " . $default_banner, 'mercadopago.log');
84
-
85
- //verifico se o banner esta na lista de banner default
86
- //caso esteja verifico se esta de acordo com o pais
87
- if(in_array($current_banner, $this->banners[$type_checkout])){
88
- Mage::helper('mercadopago')->log("Banner default need update...", 'mercadopago.log');
89
-
90
- if($default_banner != $current_banner){
91
- //set o novo banner atualiza o banner
92
- $core = new Mage_Core_Model_Resource_Setup('core_setup');
93
- $core->setConfigData('payment/' . $type_checkout . '/banner_checkout', $default_banner);
94
-
95
- Mage::helper('mercadopago')->log('payment/' . $type_checkout . '/banner_checkout setted ' . $default_banner, 'mercadopago.log');
96
- }
97
- }
98
- }
99
-
100
-
101
- public function setSponsor(){
102
- Mage::helper('mercadopago')->log("Sponsor_id: " . Mage::getStoreConfig('payment/mercadopago/sponsor_id'), 'mercadopago.log');
103
-
104
- $sponsor_id = "";
105
- Mage::helper('mercadopago')->log("Valid user test", 'mercadopago.log');
106
-
107
- $client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
108
- Mage::helper('mercadopago')->log("Get client id: " . $client_id, 'mercadopago.log');
109
-
110
- $client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
111
- Mage::helper('mercadopago')->log("Get client secret: " . $client_secret, 'mercadopago.log');
112
-
113
- $mp = new MP($client_id, $client_secret);
114
- $user = $mp->get("/users/me");
115
- Mage::helper('mercadopago')->log("API Users response", 'mercadopago.log', $user);
116
-
117
- //caso api retorne 403 (error no get) verifica se a mensagem e do usuario com test credentials
118
- if( $user['status'] == 200 && !in_array("test_user", $user['response']['tags']) ){
119
-
120
- $sponsor_id = 1;
121
- $country = Mage::getStoreConfig('payment/mercadopago/country');
122
-
123
- switch($user['response']['site_id']){
124
- case 'MLA':
125
- $sponsor_id = 186172525;
126
- break;
127
- case 'MLB':
128
- $sponsor_id = 186175129;
129
- break;
130
- case 'MLM':
131
- $sponsor_id = 186175064;
132
- break;
133
- default:
134
- $sponsor_id = "";
135
- break;
136
- }
137
-
138
- Mage::helper('mercadopago')->log("Sponsor id setted", 'mercadopago.log', $sponsor_id);
139
- }
140
-
141
- $core = new Mage_Core_Model_Resource_Setup('core_setup');
142
- $core->setConfigData('payment/mercadopago/sponsor_id', $sponsor_id);
143
- Mage::helper('mercadopago')->log("Sponsor saved", 'mercadopago.log', $sponsor_id);
144
- }
145
-
146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Source/CategoryId.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Source_CategoryId extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- Mage::helper('mercadopago')->log("Get Categories... ", 'mercadopago.log');
24
-
25
- $response = MPRestClient::get("/item_categories");
26
- Mage::helper('mercadopago')->log("API item_categories", 'mercadopago.log', $response);
27
-
28
- $response = $response['response'];
29
-
30
- $cat = array();
31
- $count = 0;
32
- foreach($response as $v):
33
- //force category others first
34
- if($v['id'] == "others"):
35
- $cat[0] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
36
- else:
37
- $count++;
38
- $cat[$count] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
39
- endif;
40
-
41
- endforeach;
42
-
43
- //force order by key
44
- ksort($cat);
45
- return $cat;
46
-
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Source/Country.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_Model_Source_Country extends Mage_Payment_Model_Method_Abstract{
18
-
19
- public function toOptionArray (){
20
-
21
- $country = array();
22
- $country[] = array('value' => "mla", 'label'=>Mage::helper('adminhtml')->__("Argentina"));
23
- $country[] = array('value' => "mlb", 'label'=>Mage::helper('adminhtml')->__("Brasil"));
24
- $country[] = array('value' => "mco", 'label'=>Mage::helper('adminhtml')->__("Colombia"));
25
- $country[] = array('value' => "mlm", 'label'=>Mage::helper('adminhtml')->__("Mexico"));
26
-
27
- //force order by key
28
- ksort($country);
29
- return $country;
30
-
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Source/Installments.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Source_Installments extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- $inst = array();
24
-
25
- Mage::helper('mercadopago')->log("Get Site payment methods... ", 'mercadopago.log');
26
- $response = MPRestClient::get("/sites/MLB/payment_methods/melicard?marketplace=NONE");
27
- Mage::helper('mercadopago')->log("API sites payment methods", 'mercadopago.log', $response);
28
-
29
- $response = $response['response'];
30
-
31
- foreach($response['payer_costs'] as $i){
32
-
33
- $inst[] = array(
34
- 'value' => $i['installments'],
35
- 'label'=>Mage::helper('adminhtml')->__($i['installments'] . " Parcela(s)")
36
- );
37
- }
38
-
39
- return $inst;
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Source/PaymentMethods.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Source_PaymentMethods extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- Mage::helper('mercadopago')->log("Get payment methods by country... ", 'mercadopago.log');
24
-
25
- $country = strtoupper(Mage::getStoreConfig('payment/mercadopago/country'));
26
- $methods = array();
27
- //adiciona um valor vazio caso nao queria excluir nada
28
- $methods[] = array("value" => "", "label" => "");
29
- $response = MPRestClient::get("/sites/" . $country . "/payment_methods");
30
- Mage::helper('mercadopago')->log("API payment methods", 'mercadopago.log', $response);
31
-
32
- $response = $response['response'];
33
-
34
- foreach($response as $m){
35
- if ( $m['id'] != 'account_money' ) {
36
- $methods[] = array(
37
- 'value' => $m['id'],
38
- 'label'=>Mage::helper('adminhtml')->__($m['name'])
39
- );
40
- }
41
- }
42
-
43
- return $methods;
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Source/TypeCheckout.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Source_TypeCheckout extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- $arr = array(
24
- array("value"=> "iframe", 'label'=>Mage::helper('adminhtml')->__("Iframe")),
25
- array("value"=> "redirect", 'label'=>Mage::helper('adminhtml')->__("Redirect")),
26
- array("value"=> "lightbox", 'label'=>Mage::helper('adminhtml')->__("Lightbox"))
27
- );
28
-
29
- return $arr;
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Model/Standard/Payment.php DELETED
@@ -1,298 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
-
19
- class MercadoPago_Model_Standard_Payment extends Mage_Payment_Model_Method_Abstract{
20
-
21
- //configura o lugar do arquivo para listar meios de pagamento
22
- protected $_formBlockType = 'mercadopago/standard_form';
23
- protected $_infoBlockType = 'mercadopago/standard_info';
24
-
25
- protected $_code = 'mercadopago_standard';
26
-
27
- protected $_isGateway = true;
28
- protected $_canOrder = true;
29
- protected $_canAuthorize = true;
30
- protected $_canCapture = true;
31
- protected $_canCapturePartial = true;
32
- protected $_canRefund = true;
33
- protected $_canRefundInvoicePartial = true;
34
- protected $_canVoid = true;
35
- protected $_canUseInternal = true;
36
- protected $_canUseCheckout = true;
37
- protected $_canUseForMultishipping = true;
38
- protected $_canFetchTransactionInfo = true;
39
- protected $_canCreateBillingAgreement = true;
40
- protected $_canReviewPayment = true;
41
-
42
- public function postPago(){
43
-
44
- $core = Mage::getModel('mercadopago/core');
45
-
46
- //seta sdk php mercadopago
47
- $client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
48
- $client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
49
- $mp = new MP($client_id, $client_secret);
50
-
51
- //monta a prefernecia
52
- $pref = $this->makePreference();
53
- Mage::helper('mercadopago')->log("make array", 'mercadopago-standard.log', $pref);
54
-
55
- //faz o posto do pagamento
56
- $response = $mp->create_preference($pref);
57
- Mage::helper('mercadopago')->log("create preference result", 'mercadopago-standard.log', $response);
58
-
59
- $array_assign = array();
60
-
61
- if($response['status'] == 200 || $response['status'] == 201):
62
- $payment = $response['response'];
63
- $init_point = $payment['init_point'];
64
-
65
- $array_assign = array(
66
- "init_point" => $init_point,
67
- "type_checkout" => $this->getConfigData('type_checkout'),
68
- "iframe_width" => $this->getConfigData('iframe_width'),
69
- "iframe_height" => $this->getConfigData('iframe_height'),
70
- "banner_checkout" => $this->getConfigData('banner_checkout'),
71
- "status" => 201
72
- );
73
-
74
- Mage::helper('mercadopago')->log("Array preference ok", 'mercadopago-standard.log');
75
- else:
76
- $array_assign = array(
77
- "message" => Mage::helper('mercadopago')->__('An error has occurred. Please refresh the page.'),
78
- "json" => json_encode($response),
79
- "status" => 400
80
- );
81
-
82
- Mage::helper('mercadopago')->log("Array preference error", 'mercadopago-standard.log');
83
- endif;
84
-
85
- return $array_assign;
86
- }
87
-
88
- public function getOrderPlaceRedirectUrl() {
89
- // requisicao vem da pagina de finalizacao de pedido
90
- return Mage::getUrl('mercadopago/pay', array('_secure' => true));
91
- }
92
-
93
- public function getDiscount($order){
94
- $discount = 0;
95
- $order = $order->getData();
96
-
97
- if(isset($order['base_discount_amount']) && $order['base_discount_amount'] < 0) {
98
- $discount = $order['base_discount_amount'];
99
- }
100
-
101
- return $discount;
102
- }
103
-
104
- function makePreference(){
105
-
106
- //pega a order atual
107
- $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
108
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
109
- $customer = Mage::getSingleton('customer/session')->getCustomer();
110
- $model = Mage::getModel('catalog/product');
111
-
112
- //pega payment dentro da order para pegar as informacoes adicionadas pela funcao assignData()
113
- $payment = $order->getPayment();
114
-
115
- //init array preferneces
116
- $arr = array();
117
-
118
- //seta o external_reference para conciliacao futura
119
- $arr['external_reference'] = $orderIncrementId;
120
-
121
- //monta array de produtos
122
- $arr['items'] = array();
123
-
124
- $total_item = 0;
125
- foreach ($order->getAllVisibleItems() as $item) {
126
-
127
- $prod = $model->loadByAttribute('sku', $item->getSku());
128
-
129
- //get image
130
- try{
131
- $imagem = $prod->getImageUrl();
132
- }catch(Exception $e){
133
- $imagem = "";
134
- }
135
-
136
- $arr['items'][] = array(
137
- "id" => $item->getSku(),
138
- "title" => $item->getName(),
139
- "description" => $item->getName(),
140
- "picture_url" => $imagem,
141
- "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
142
- "quantity" => (int) number_format($item->getQtyOrdered(), 0, '.', ''),
143
- "unit_price" => (float) number_format($prod->getFinalPrice(), 2, '.', '')
144
- );
145
-
146
- //faz uma soma dos itens para depois verificar com o valor total
147
- $total_item += (float) number_format($prod->getFinalPrice(), 2, '.', '');
148
- }
149
-
150
- //pega valor total da compra
151
- $order_amount = (float) $order->getBaseGrandTotal();
152
- if (!$order_amount) {
153
- $order_amount = (float) $order->getBasePrice() + $order->getBaseShippingAmount();
154
- }
155
-
156
- //adiciona o valor do frete para as variaveis bater
157
- $total_item += (float) $order->getBaseShippingAmount();
158
-
159
- // if respons�vel por verificar se existe diferen�a entre os pre�os,
160
- // tanto maior quanto menor,
161
- // calcula e adiciona como itens para ter o valor real do pedido
162
- if($total_item > $order_amount || $total_item < $order_amount){
163
- $diff_price = $order_amount - $total_item;
164
-
165
- $arr['items'][] = array(
166
- "title" => "Difference amount of the items with a total",
167
- "description" => "Difference amount of the items with a total",
168
- "category_id" => Mage::getStoreConfig('payment/mercadopago/category_id'),
169
- "quantity" => 1,
170
- "unit_price" => (float) $diff_price
171
- );
172
-
173
- Mage::helper('mercadopago')->log("Total itens: " . $total_item, 'mercadopago-standard.log');
174
- Mage::helper('mercadopago')->log("Total order: " . $order_amount, 'mercadopago-standard.log');
175
- Mage::helper('mercadopago')->log("Difference add itens: " . $diff_price, 'mercadopago-standard.log');
176
- }
177
-
178
-
179
- /*
180
- //verifica se existe desconto, caso exista adiciona como um item
181
- $discount = $this->getDiscount($order);
182
-
183
- if($discount != 0){
184
- $arr['items'][] = array(
185
- "title" => "Discount by the Store",
186
- "description" => "Discount by the Store",
187
- "quantity" => (int) 1,
188
- "unit_price" => (float) number_format($discount, 2, '.', '')
189
- );
190
- }*/
191
-
192
-
193
- //pega dados de envio
194
- if(method_exists($order->getShippingAddress(), "getData")){
195
- $shipping = $order->getShippingAddress()->getData();
196
- $arr['shipments']['receiver_address'] = array(
197
- "floor" => "-",
198
- "zip_code" => $shipping['postcode'],
199
- "street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
200
- "apartment" => "-",
201
- "street_number" => "0"
202
- );
203
- $arr['payer']['phone'] = array(
204
- "area_code" => "-",
205
- "number" => $shipping['telephone']
206
- );
207
- }
208
-
209
- //adiciona o valor do frete nas preferencias
210
- if($order->getBaseShippingAmount() != "" && $order->getBaseShippingAmount() > 0){
211
- $arr['shipments']['cost'] = (float) $order->getBaseShippingAmount();
212
- }
213
-
214
-
215
- //pega informa�oes de cadastro do usuario
216
- $billing_address = $order->getBillingAddress();
217
- $billing_address = $billing_address->getData();
218
-
219
- //formata a data do usuario para o padrao do mercado pago YYYY-MM-DDTHH:MM:SS
220
- $arr['payer']['date_created'] = date('Y-m-d',$customer->getCreatedAtTimestamp()) . "T" . date('H:i:s',$customer->getCreatedAtTimestamp());
221
-
222
- //set informa�oes do usuario
223
- $arr['payer']['email'] = htmlentities($customer->getEmail());
224
- $arr['payer']['first_name'] = htmlentities($customer->getFirstname());
225
- $arr['payer']['last_name'] = htmlentities($customer->getLastname());
226
-
227
- //set o documento do usuario
228
- if(isset($payment['additional_information']['doc_number']) && $payment['additional_information']['doc_number'] != ""){
229
- $arr['payer']['identification'] = array(
230
- "type" => "CPF",
231
- "number" => $payment['additional_information']['doc_number']
232
- );
233
- }
234
-
235
- //set endereco do usuario
236
- $arr['payer']['address'] = array(
237
- "zip_code" => $billing_address['postcode'],
238
- "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
239
- "street_number" => "0"
240
- );
241
-
242
- //setta as urls de retorno
243
- $arr['back_urls'] = array(
244
- "success" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago/success",
245
- "pending" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago/success",
246
- "failure" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago/success"
247
- );
248
-
249
- //define a url de notificacao
250
- $arr['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago/notifications?checkout=standard";
251
-
252
- //pega o email e o nome do usuario guest
253
- if($arr['payer']['email'] == ""){
254
- $arr['payer']['email'] = $order['customer_email'];
255
- $arr['payer']['first_name'] = $order->getBillingAddress()->getFirstname();
256
- $arr['payer']['last_name'] = $order->getBillingAddress()->getLastname();
257
- }
258
-
259
- // pega os meios de pagamento que ele dejexa excluir
260
- $checkout = Mage::getModel('mercadopago/standard_payment');
261
- $excluded_payment_methods = $checkout->getConfigData('excluded_payment_methods');
262
- $arr_epm = explode(",", $excluded_payment_methods);
263
- if(count($arr_epm) > 0){
264
- $arr['payment_methods']['excluded_payment_methods'] = array();
265
-
266
- foreach($arr_epm as $m):
267
- $arr['payment_methods']['excluded_payment_methods'][] = array("id" => $m);
268
- endforeach;
269
-
270
- }
271
-
272
- //seta o numero de parcelas maxima aceita pelo lojista
273
- $installments = $checkout->getConfigData('installments');
274
- $arr['payment_methods']['installments'] = (int) $installments;
275
-
276
-
277
- //define o retorno automatico ao finalizar o checkout
278
- $auto_return = $checkout->getConfigData('auto_return');
279
- if($auto_return == 1){
280
- $arr['auto_return'] = "approved";
281
- }
282
-
283
-
284
- //verifico se o sponsor � diferente de null (se existe)
285
- $sponsor_id = Mage::getStoreConfig('payment/mercadopago/sponsor_id');
286
- Mage::helper('mercadopago')->log("Sponsor_id", 'mercadopago-standard.log', $sponsor_id);
287
- if($sponsor_id != null && $sponsor_id != ""){
288
- Mage::helper('mercadopago')->log("Sponsor_id identificado", 'mercadopago-standard.log', $sponsor_id);
289
- $arr['sponsor_id'] = (int) $sponsor_id;
290
- }
291
-
292
-
293
- return $arr;
294
-
295
- }
296
- }
297
-
298
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/OneStepCheckout/Block/Custom/Form.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_OneStepCheckout_Block_Custom_Form
4
+ extends MercadoPago_Core_Block_Custom_Form
5
+ {
6
+
7
+ protected function _construct()
8
+ {
9
+ if (Mage::helper('mercadopago_onestepcheckout')->isOneStepCheckoutActive()) {
10
+ Mage_Payment_Block_Form_Cc::_construct();
11
+ $this->setTemplate('mercadopago/onestepcheckout/custom/form.phtml');
12
+ } else {
13
+ parent::_construct();
14
+ }
15
+ }
16
+
17
+ protected function _prepareLayout()
18
+ {
19
+
20
+ $public_key = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_PUBLIC_KEY);
21
+
22
+ //init js no header
23
+ $block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
24
+ if (Mage::helper('mercadopago_onestepcheckout')->isOneStepCheckoutActive()) {
25
+ $block->setText(
26
+ sprintf(
27
+ '
28
+ <script type="text/javascript">var PublicKeyMercadoPagoCustom = "' . $public_key . '";</script>
29
+ <script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script>
30
+ <script src="http://ui.mlstatic.com/chico/tiny/0.1.1/tiny.min.js"></script>
31
+ <script type="text/javascript" src="%s"></script>
32
+ <script type="text/javascript" src="%s"></script>
33
+ <script type="text/javascript" src="%s"></script>',
34
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago_osc.js',
35
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tiny.min.js',
36
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tinyJ.js'
37
+ )
38
+ );
39
+ $head = Mage::app()->getLayout()->getBlock('after_body_start');
40
+
41
+ if ($head) {
42
+ $head->append($block);
43
+ }
44
+
45
+ return Mage_Payment_Block_Form_Cc::_prepareLayout();
46
+ } else {
47
+ return parent::_prepareLayout();
48
+ }
49
+
50
+ }
51
+ }
app/code/community/MercadoPago/OneStepCheckout/Block/Customticket/Form.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_OneStepCheckout_Block_Customticket_Form
4
+ extends MercadoPago_Core_Block_Customticket_Form
5
+ {
6
+ protected function _prepareLayout()
7
+ {
8
+
9
+ //pega public key para settar no aquivo mercadopago.js
10
+ $public_key = Mage::getStoreConfig(MercadoPago_Core_Helper_Data::XML_PATH_PUBLIC_KEY);
11
+
12
+ //init js no header
13
+ $block = Mage::app()->getLayout()->createBlock('core/text', 'js_mercadopago');
14
+ if (Mage::getStoreConfigFlag(MercadoPago_OneStepCheckout_Helper_Data::XML_PATH_ONS_ACTIVE)) {
15
+ $block->setText(
16
+ sprintf(
17
+ '
18
+ <script type="text/javascript">var PublicKeyMercadoPagoCustom = "' . $public_key . '";</script>
19
+ <script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script>
20
+ <script type="text/javascript" src="%s"></script>
21
+ <script type="text/javascript" src="%s"></script>
22
+ <script type="text/javascript" src="%s"></script>',
23
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago_osc.js',
24
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tiny.min.js',
25
+ Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/tinyJ.js'
26
+ )
27
+ );
28
+
29
+ $head = Mage::app()->getLayout()->getBlock('after_body_start');
30
+
31
+ if ($head) {
32
+ $head->append($block);
33
+ }
34
+
35
+ return Mage_Payment_Block_Form_Cc::_prepareLayout();
36
+ } else {
37
+ return parent::_prepareLayout();
38
+ }
39
+
40
+ }
41
+
42
+ }
app/code/community/MercadoPago/OneStepCheckout/Helper/Data.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_OneStepCheckout_Helper_Data
4
+ extends Mage_Core_Helper_Abstract
5
+ {
6
+ const XML_PATH_ONS_ACTIVE = 'payment/mercadopago/osc_active';
7
+
8
+ public function isOneStepCheckoutActive() {
9
+ return Mage::getStoreConfigFlag(MercadoPago_OneStepCheckout_Helper_Data::XML_PATH_ONS_ACTIVE);
10
+ }
11
+
12
+ }
app/code/community/MercadoPago/OneStepCheckout/Model/Observer.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MercadoPago_OneStepCheckout_Model_Observer
4
+ {
5
+ /**
6
+ * @param $observer
7
+ *
8
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
9
+ */
10
+ public function successPredispatch($observer)
11
+ {
12
+ $session = Mage::getSingleton('checkout/session');
13
+ $session->getQuote()->setIsActive(false)->save();
14
+ $session->clear();
15
+ }
16
+ }
app/code/community/MercadoPago/OneStepCheckout/etc/config.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MercadoPago_OneStepCheckout>
5
+ <version>2.1.5</version>
6
+ </MercadoPago_OneStepCheckout>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <mercadopago_onestepcheckout>
11
+ <class>MercadoPago_OneStepCheckout_Model</class>
12
+ </mercadopago_onestepcheckout>
13
+ </models>
14
+ <helpers>
15
+ <mercadopago_onestepcheckout>
16
+ <class>MercadoPago_OneStepCheckout_Helper</class>
17
+ </mercadopago_onestepcheckout>
18
+ </helpers>
19
+ <blocks>
20
+ <mercadopago>
21
+ <rewrite>
22
+ <custom_form>MercadoPago_OneStepCheckout_Block_Custom_Form</custom_form>
23
+ <customticket_form>MercadoPago_OneStepCheckout_Block_Customticket_Form</customticket_form>
24
+ </rewrite>
25
+ <mercadopago_onestepcheckout>
26
+ <class>MercadoPago_OneStepCheckout_Block</class>
27
+ </mercadopago_onestepcheckout>
28
+ </mercadopago>
29
+ </blocks>
30
+ </global>
31
+ <frontend>
32
+ <events>
33
+ <controller_action_predispatch_mercadopago_success_index>
34
+ <observers>
35
+ <mercadopago_onestepcheckout>
36
+ <type>model</type>
37
+ <class>mercadopago_onestepcheckout/observer</class>
38
+ <method>successPredispatch</method>
39
+ </mercadopago_onestepcheckout>
40
+ </observers>
41
+ </controller_action_predispatch_mercadopago_success_index>
42
+ </events>
43
+ </frontend>
44
+
45
+ <default>
46
+ <payment>
47
+ <mercadopago>
48
+ <osc_active>0</osc_active>
49
+ </mercadopago>
50
+ </payment>
51
+ </default>
52
+ </config>
app/code/community/MercadoPago/OneStepCheckout/etc/system.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+
3
+ <config>
4
+ <sections>
5
+ <payment translate="label">
6
+ <groups>
7
+ <mercadopago type="group">
8
+ <fields>
9
+ <osc_active translate="label">
10
+ <label>Onestepcheckout Active</label>
11
+ <frontend_type>select</frontend_type>
12
+ <source_model>adminhtml/system_config_source_yesno</source_model>
13
+ <sort_order>200</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ </osc_active>
18
+ </fields>
19
+ </mercadopago>
20
+ </groups>
21
+ </payment>
22
+ </sections>
23
+ </config>
app/code/community/MercadoPago/controllers/ApiController.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_ApiController extends Mage_Core_Controller_Front_Action{
18
-
19
- // action: /mercadopago/api/amount
20
-
21
- public function amountAction(){
22
-
23
- $core = Mage::getModel('mercadopago/core');
24
-
25
- $response = array(
26
- "amount" => $core->getAmount()
27
- );
28
-
29
- header('Content-Type: application/json');
30
- echo json_encode($response);
31
- exit;
32
-
33
- }
34
-
35
- // action: /mercadopago/api/cupom?id=:cupom_id
36
-
37
- public function couponAction(){
38
- $response = array();
39
- $core = Mage::getModel('mercadopago/core');
40
-
41
- if(isset($_REQUEST['id']) && $_REQUEST['id'] != ""){
42
- $coupon_id = $_REQUEST['id'];
43
- $response = $core->validCoupon($coupon_id);
44
- }else{
45
- $response = array(
46
- "status" => 400,
47
- "response" => array(
48
- "error" => "invalid_id",
49
- "message" => "invalid id"
50
- )
51
- );
52
- }
53
-
54
- header('Content-Type: application/json');
55
- echo json_encode($response);
56
- exit;
57
- }
58
-
59
-
60
- /*
61
- *
62
- * Test Request
63
- *
64
- */
65
-
66
- public function testAction(){
67
- $core = Mage::getModel('mercadopago/core');
68
-
69
- $payment_methods = $core->getPaymentMethods();
70
-
71
- $response = array(
72
- "getPaymentMethods" => $payment_methods['status'],
73
- "public_key" => Mage::getStoreConfig('payment/mercadopago_custom/public_key')
74
- );
75
-
76
- header('Content-Type: application/json');
77
- echo json_encode($response);
78
- exit;
79
- }
80
-
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/controllers/NotificationsController.php DELETED
@@ -1,347 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_NotificationsController extends Mage_Core_Controller_Front_Action{
18
-
19
- protected $_return = null;
20
- protected $_order = null;
21
- protected $_order_id = null;
22
- protected $_mpcartid = null;
23
- protected $_sendemail = false;
24
- protected $_hash = null;
25
-
26
- public function indexAction(){
27
-
28
- $core = Mage::getModel('mercadopago/core');
29
-
30
- try {
31
- $params = $this->getRequest()->getParams();
32
-
33
- //notification received
34
- Mage::helper('mercadopago')->log("Received notification", 'mercadopago-notification.log', $params);
35
-
36
- if(isset($params['checkout']) && $params['checkout'] == "standard"){
37
- Mage::helper('mercadopago')->log("Type: Standard", 'mercadopago-notification.log');
38
- $this->standard($params);
39
- }else{
40
- Mage::helper('mercadopago')->log("Type: Custom", 'mercadopago-notification.log');
41
- $this->custom($params);
42
- }
43
- } catch (Exception $e) {
44
- Mage::helper('mercadopago')->log("error: " . $e, 'mercadopago-notification.log');
45
- echo $e;
46
-
47
- //caso erro no processo de notificação de pagamento, mercadopago ira notificar novamente.
48
- header(' ', true, 400);
49
- exit;
50
- }
51
-
52
- }
53
-
54
- public function standard($params){
55
- $core = Mage::getModel('mercadopago/core');
56
-
57
- if (isset($params['id']) && isset($params['topic']) && $params['topic'] == 'merchant_order'){
58
-
59
- $response = $core->getMerchantOrder($params['id']);
60
- Mage::helper('mercadopago')->log("Return merchant_order", 'mercadopago-notification.log', $response);
61
-
62
- if($response['status'] == 200 || $response['status'] == 201):
63
- $data = array();
64
- $merchant_order = $response['response'];
65
- $order = Mage::getModel('sales/order')->loadByIncrementId($merchant_order["external_reference"]);
66
-
67
- if(count($merchant_order['payments']) > 0):
68
-
69
- //status final para pagamento com mais de um cartão
70
- $status_final = "";
71
-
72
- foreach($merchant_order['payments'] as $payment):
73
- $response = $core->getPayment($payment['id']);
74
- $payment = $response['response']['collection'];
75
- $data = $this->formatArrayPayment($data, $payment);
76
-
77
-
78
- //caso ele não esteja settado
79
- if($status_final == ""):
80
- $status_final = $payment['status'];
81
- else:
82
-
83
- //verifica se o status inicial é igual ao atual
84
- //para alterar o status da order, todos tem que estarem iguais
85
- if($status_final != $payment['status']):
86
- $status_final = false;
87
- endif;
88
- endif;
89
- endforeach;
90
-
91
- //atualiza a order com os dados do pagamento
92
- $this->updateOrder($data);
93
-
94
-
95
- //caso seja false, eles não são iguais, logo não faz nada.
96
- if($status_final != false):
97
- $data['status_final'] = $status_final;
98
-
99
- //atualiza status da order de acordo com a notificação do pagamento
100
- $this->setStatusOrder($data);
101
- endif;
102
- endif;
103
- else:
104
- Mage::helper('mercadopago')->log("Merchant Order not found", 'mercadopago-notification.log');
105
- throw new Exception('Merchant Order not found');
106
- endif;
107
- }
108
- }
109
-
110
- public function custom($params){
111
- $core = Mage::getModel('mercadopago/core');
112
-
113
- if (isset($params['id']) && isset($params['topic']) && $params['topic'] == 'payment'){
114
-
115
- $response = $core->getPayment($params['id']);
116
- Mage::helper('mercadopago')->log("Return payment", 'mercadopago-notification.log', $response);
117
-
118
- if($response['status'] == 200 || $response['status'] == 201):
119
- $payment = $response['response']['collection'];
120
-
121
- //Atualiza informações da order
122
- $data = $this->formatArrayPayment(array(), $payment);
123
- $this->updateOrder($data);
124
-
125
- //atualiza status da order de acordo com a notificação do pagamento
126
- $this->setStatusOrder($payment);
127
-
128
- else:
129
- Mage::helper('mercadopago')->log("Payment not found", 'mercadopago-notification.log');
130
- throw new Exception('Payment not found');
131
- endif;
132
-
133
- }
134
- }
135
-
136
- /*
137
- * Funcao responsavel por adicionar informação do pagamento no pedido
138
- */
139
- function updateOrder($data){
140
- try {
141
- $core = Mage::getModel('mercadopago/core');
142
- $order = Mage::getModel('sales/order')->loadByIncrementId($data["external_reference"]);
143
-
144
- //update info de status no pagamento
145
- $payment_order = $order->getPayment();
146
- $payment_order->setAdditionalInformation('status', $data['status']);
147
- $payment_order->setAdditionalInformation('status_detail', $data['status_detail']);
148
- $payment_order->setAdditionalInformation('payment_id', $data['id']);
149
- $payment_order->setAdditionalInformation('transaction_amount', $data['transaction_amount']);
150
-
151
- if(isset($data['cardholder_name']))
152
- $payment_order->setAdditionalInformation('cardholderName', $data['cardholder_name']);
153
-
154
- if(isset($data['installments']))
155
- $payment_order->setAdditionalInformation('installments', $data['installments']);
156
-
157
- if(isset($data['payment_method_id']))
158
- $payment_order->setAdditionalInformation('payment_method', $data['payment_method_id']);
159
-
160
- if(isset($data['statement_descriptor']))
161
- $payment_order->setAdditionalInformation('statement_descriptor', $data['statement_descriptor']);
162
-
163
- if(isset($data['trunc_card']))
164
- $payment_order->setAdditionalInformation('trunc_card', $data['trunc_card']);
165
-
166
- $payment_status = $payment_order->save();
167
- Mage::helper('mercadopago')->log("Update Payment", 'mercadopago-notification.log', $payment_status->toString());
168
-
169
- //adiciona informações sobre o comprador na order
170
- if ($data['payer_first_name'])
171
- $order->setCustomerFirstname($data['payer_first_name']);
172
-
173
- if ($data['payer_last_name'])
174
- $order->setCustomerLastname($data['payer_last_name']);
175
-
176
- if ($data['payer_email'])
177
- $order->setCustomerEmail($data['payer_email']);
178
-
179
- $status_save = $order->save();
180
- Mage::helper('mercadopago')->log("Update order", 'mercadopago-notification.log', $status_save->toString());
181
-
182
- } catch (Exception $e) {
183
- Mage::helper('mercadopago')->log("erro in update order status: " . $e, 'mercadopago-notification.log');
184
- echo $e;
185
-
186
- //caso erro no processo de notificação de pagamento, mercadopago ira notificar novamente.
187
- header(' ', true, 400);
188
- exit;
189
- }
190
- }
191
-
192
-
193
- function setStatusOrder($payment){
194
- try {
195
- $core = Mage::getModel('mercadopago/core');
196
- Mage::helper('mercadopago')->log("Received Payment data", 'mercadopago-notification.log', $payment);
197
-
198
- $message = "";
199
- $status = "";
200
-
201
- // obtem a order para atualizar o status
202
- $order = Mage::getModel('sales/order')->loadByIncrementId($payment["external_reference"]);
203
-
204
- //adiciona variavel de status
205
- $status = $payment['status'];
206
-
207
- //caso exista um status_final, utiliza ele (pagamento com dois cartões)
208
- if(isset($payment['status_final'])){
209
- $status = $payment['status_final'];
210
- }
211
-
212
- switch ( $status ) {
213
- case 'approved':
214
- //add status na order
215
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment was approved.');
216
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_approved');
217
-
218
- //cria a invoice
219
- $invoice = $order->prepareInvoice();
220
- $invoice->register()->pay();
221
- Mage::getModel('core/resource_transaction')
222
- ->addObject($invoice)
223
- ->addObject($invoice->getOrder())
224
- ->save();
225
-
226
- $invoice->sendEmail(true, $message);
227
- break;
228
-
229
- case 'refunded':
230
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_refunded');
231
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment was refunded.');
232
- $order->cancel();
233
- break;
234
-
235
- case 'pending':
236
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_process');
237
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment is being processed.');
238
- break;
239
-
240
- case 'authorized':
241
- case 'in_process':
242
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_process');
243
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.');
244
- break;
245
-
246
- case 'in_mediation':
247
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_mediation');
248
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.');
249
- break;
250
-
251
- case 'cancelled':
252
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_cancelled');
253
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment was cancelled.');
254
- $order->cancel();
255
- break;
256
-
257
- case 'rejected':
258
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_rejected');
259
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: The payment was rejected.');
260
- break;
261
-
262
- case 'chargeback':
263
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_chargeback');
264
- $message = Mage::helper('mercadopago')->__('Automatic notification of the MercadoPago: One chargeback was initiated for this payment.');
265
- break;
266
-
267
- default:
268
- $status = Mage::getStoreConfig('payment/mercadopago/order_status_in_process');
269
- $message = '';
270
- }
271
-
272
- //adiciona informações do pagamento para enviar por email e salvar nos historicos
273
- $message .= Mage::helper('mercadopago')->__('<br/> Payment id: %s', $payment['id']);
274
- $message .= Mage::helper('mercadopago')->__('<br/> Status: %s', $payment['status']);
275
- $message .= Mage::helper('mercadopago')->__('<br/> Status Detail: %s', $payment['status_detail']);
276
-
277
- $order->addStatusToHistory($status,$message, true);
278
- $order->sendOrderUpdateEmail(true, $message);
279
-
280
- $status_save = $order->save();
281
- Mage::helper('mercadopago')->log("Update order", 'mercadopago-notification.log', $status_save->toString());
282
- Mage::helper('mercadopago')->log($message, 'mercadopago-notification.log');
283
-
284
- echo $message;
285
- } catch (Exception $e) {
286
- Mage::helper('mercadopago')->log("erro in set order status: " . $e, 'mercadopago-notification.log');
287
- echo $e;
288
-
289
- //caso erro no processo de notificação de pagamento, mercadopago ira notificar novamente.
290
- header(' ', true, 400);
291
- exit;
292
- }
293
- }
294
-
295
- /*
296
- * Funcao responsavel por formatar o array para atualizar informações do pedido
297
- */
298
-
299
- function formatArrayPayment($data, $payment){
300
- $fields = array(
301
- "status",
302
- "status_detail",
303
- "id",
304
- "payment_method_id",
305
- "transaction_amount",
306
- "installments"
307
- );
308
-
309
- foreach($fields as $field){
310
- if(isset($payment[$field])){
311
- if(isset($data[$field])){
312
- $data[$field] .= " | " . $payment[$field];
313
- }else{
314
- $data[$field] = $payment[$field];
315
- }
316
- }
317
- }
318
-
319
- if(isset($payment["last_four_digits"])){
320
- if(isset($data["trunc_card"])){
321
- $data["trunc_card"] .= " | " . "xxxx xxxx xxxx " . $payment["last_four_digits"];
322
- }else{
323
- $data["trunc_card"] = "xxxx xxxx xxxx " . $payment["last_four_digits"];
324
- }
325
- }
326
-
327
- if(isset($payment['cardholder']['name'])){
328
- if(isset($data["cardholder_name"])){
329
- $data["cardholder_name"] .= " | " . $payment["cardholder"]["name"];
330
- }else{
331
- $data["cardholder_name"] = $payment["cardholder"]["name"];
332
- }
333
- }
334
-
335
- if(isset($payment['statement_descriptor']))
336
- $data['statement_descriptor'] = $payment['statement_descriptor'];
337
-
338
-
339
- //esses dados não precisam concatenar pois se repetem..
340
- $data['external_reference'] = $payment['external_reference'];
341
- $data['payer_first_name'] = $payment['payer']['first_name'];
342
- $data['payer_last_name'] = $payment['payer']['last_name'];
343
- $data['payer_email'] = $payment['payer']['email'];
344
-
345
- return $data;
346
- }
347
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/controllers/PayController.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_PayController extends Mage_Core_Controller_Front_Action{
18
-
19
- public function indexAction(){
20
- $standard = Mage::getModel('mercadopago/standard_payment');
21
-
22
- //chama model para fazer o post do pagamento e obter as informacoes para mostrar o checkout
23
- $array_assign = $standard->postPago();
24
-
25
- $this->loadLayout();
26
-
27
- $block = Mage::app()->getLayout()->createBlock('mercadopago/standard_pay');
28
-
29
- //envia as informações para view
30
- $block->assign($array_assign);
31
-
32
- //insere o block
33
- $this->getLayout()->getBlock('content')->append($block);
34
- $this->_initLayoutMessages('core/session');
35
-
36
- //adiciona uma clean page
37
- $root = $this->getLayout()->getBlock('root');
38
- $root->setTemplate("mercadopago/clean.phtml");
39
-
40
- $this->renderLayout();
41
- }
42
-
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/controllers/SuccessController.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the Open Software License (OSL).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://opensource.org/licenses/osl-3.0.php
9
- *
10
- * @category Payment Gateway
11
- * @package MercadoPago
12
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
13
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
-
17
- class MercadoPago_SuccessController extends Mage_Core_Controller_Front_Action{
18
-
19
- public function indexAction(){
20
-
21
- $this->loadLayout();
22
-
23
- //instancia block de success
24
- $block = Mage::app()->getLayout()->createBlock('mercadopago/success');
25
-
26
- //insere o block
27
- $this->getLayout()->getBlock('content')->append($block);
28
- $this->_initLayoutMessages('core/session');
29
-
30
- //adiciona uma clean page
31
- $root = $this->getLayout()->getBlock('root');
32
- $root->setTemplate("mercadopago/clean.phtml");
33
-
34
- $this->renderLayout();
35
- }
36
-
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/etc/system.xml DELETED
@@ -1,403 +0,0 @@
1
- <?xml version="1.0" ?>
2
- <!--
3
- /**
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL).
8
- * It is also available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category Payment Gateway
12
- * @package MercadoPago
13
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
14
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
15
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
- */
17
- -->
18
-
19
- <config>
20
- <sections>
21
- <payment translate="label">
22
- <groups>
23
- <mercadopago>
24
- <label>MercadoPago - Configuration</label>
25
- <sort_order>99</sort_order>
26
- <show_in_default>1</show_in_default>
27
- <show_in_website>1</show_in_website>
28
- <show_in_store>0</show_in_store>
29
- <fields>
30
- <client_id translate="label">
31
- <label>Client Id</label>
32
- <frontend_type>text</frontend_type>
33
- <sort_order>3</sort_order>
34
- <show_in_default>1</show_in_default>
35
- <show_in_website>1</show_in_website>
36
- <show_in_store>0</show_in_store>
37
- </client_id>
38
-
39
- <client_secret translate="label">
40
- <label>Client Secret</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>4</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>0</show_in_store>
46
- </client_secret>
47
-
48
- <country translate="label">
49
- <label>Country</label>
50
- <frontend_type>select</frontend_type>
51
- <source_model>MercadoPago_Model_Source_Country</source_model>
52
- <sort_order>6</sort_order>
53
- <show_in_default>1</show_in_default>
54
- <show_in_website>1</show_in_website>
55
- <show_in_store>1</show_in_store>
56
- </country>
57
-
58
- <category_id translate="label">
59
- <label>Category of your store</label>
60
- <frontend_type>select</frontend_type>
61
- <source_model>MercadoPago_Model_Source_CategoryId</source_model>
62
- <sort_order>7</sort_order>
63
- <show_in_default>1</show_in_default>
64
- <show_in_website>1</show_in_website>
65
- <show_in_store>0</show_in_store>
66
- </category_id>
67
-
68
- <order_status_approved translate="label">
69
- <label>Choose the status of approved orders</label>
70
- <comment>To manage the status available go to System > Order Statuses</comment>
71
- <frontend_type>select</frontend_type>
72
- <source_model>adminhtml/system_config_source_order_status</source_model>
73
- <sort_order>8</sort_order>
74
- <show_in_default>1</show_in_default>
75
- <show_in_website>1</show_in_website>
76
- <show_in_store>1</show_in_store>
77
- </order_status_approved>
78
-
79
- <order_status_refunded translate="label">
80
- <label>Choose the status of refunded orders</label>
81
- <comment>To manage the status available go to System > Order Statuses</comment>
82
- <frontend_type>select</frontend_type>
83
- <source_model>adminhtml/system_config_source_order_status</source_model>
84
- <sort_order>9</sort_order>
85
- <show_in_default>1</show_in_default>
86
- <show_in_website>1</show_in_website>
87
- <show_in_store>1</show_in_store>
88
- </order_status_refunded>
89
-
90
- <order_status_in_process translate="label">
91
- <label>Choose the status when payment is pending</label>
92
- <comment>To manage the status available go to System > Order Statuses</comment>
93
- <frontend_type>select</frontend_type>
94
- <source_model>adminhtml/system_config_source_order_status</source_model>
95
- <sort_order>9</sort_order>
96
- <show_in_default>1</show_in_default>
97
- <show_in_website>1</show_in_website>
98
- <show_in_store>1</show_in_store>
99
- </order_status_in_process>
100
-
101
- <order_status_in_mediation translate="label">
102
- <label>Choose the status when client open a mediation</label>
103
- <comment>To manage the status available go to System > Order Statuses</comment>
104
- <frontend_type>select</frontend_type>
105
- <source_model>adminhtml/system_config_source_order_status</source_model>
106
- <sort_order>10</sort_order>
107
- <show_in_default>1</show_in_default>
108
- <show_in_website>1</show_in_website>
109
- <show_in_store>1</show_in_store>
110
- </order_status_in_mediation>
111
-
112
- <order_status_rejected translate="label">
113
- <label>Choose the status when payment was reject</label>
114
- <comment>To manage the status available go to System > Order Statuses</comment>
115
- <frontend_type>select</frontend_type>
116
- <source_model>adminhtml/system_config_source_order_status</source_model>
117
- <sort_order>11</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>1</show_in_website>
120
- <show_in_store>1</show_in_store>
121
- </order_status_rejected>
122
-
123
- <order_status_cancelled translate="label">
124
- <label>Choose the status when payment was canceled</label>
125
- <comment>To manage the status available go to System > Order Statuses</comment>
126
- <frontend_type>select</frontend_type>
127
- <source_model>adminhtml/system_config_source_order_status</source_model>
128
- <sort_order>12</sort_order>
129
- <show_in_default>1</show_in_default>
130
- <show_in_website>1</show_in_website>
131
- <show_in_store>1</show_in_store>
132
- </order_status_cancelled>
133
-
134
- <order_status_chargeback translate="label">
135
- <label>Choose the status when payment was chargeback</label>
136
- <comment>To manage the status available go to System > Order Statuses</comment>
137
- <frontend_type>select</frontend_type>
138
- <source_model>adminhtml/system_config_source_order_status</source_model>
139
- <sort_order>13</sort_order>
140
- <show_in_default>1</show_in_default>
141
- <show_in_website>1</show_in_website>
142
- <show_in_store>1</show_in_store>
143
- </order_status_chargeback>
144
-
145
- <logs translate="label">
146
- <label>Logs</label>
147
- <frontend_type>select</frontend_type>
148
- <source_model>adminhtml/system_config_source_yesno</source_model>
149
- <sort_order>14</sort_order>
150
- <show_in_default>1</show_in_default>
151
- <show_in_website>1</show_in_website>
152
- <show_in_store>0</show_in_store>
153
- <comment></comment>
154
- </logs>
155
- </fields>
156
- </mercadopago>
157
-
158
-
159
- <mercadopago_custom translate="label" module="mercadopago_custom">
160
- <label>MercadoPago Custom - Credit Card</label>
161
- <sort_order>100</sort_order>
162
- <show_in_default>1</show_in_default>
163
- <show_in_website>1</show_in_website>
164
- <show_in_store>0</show_in_store>
165
- <fields>
166
- <active translate="label">
167
- <label>Enabled</label>
168
- <frontend_type>select</frontend_type>
169
- <source_model>adminhtml/system_config_source_yesno</source_model>
170
- <sort_order>1</sort_order>
171
- <show_in_default>1</show_in_default>
172
- <show_in_website>1</show_in_website>
173
- <show_in_store>0</show_in_store>
174
- </active>
175
- <title translate="label">
176
- <label>Payment Title</label>
177
- <frontend_type>text</frontend_type>
178
- <sort_order>2</sort_order>
179
- <show_in_default>1</show_in_default>
180
- <show_in_website>1</show_in_website>
181
- <show_in_store>0</show_in_store>
182
- </title>
183
-
184
- <public_key translate="label">
185
- <label>Public Key</label>
186
- <frontend_type>text</frontend_type>
187
- <sort_order>5</sort_order>
188
- <show_in_default>1</show_in_default>
189
- <show_in_website>1</show_in_website>
190
- <show_in_store>0</show_in_store>
191
- <comment>To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento</comment>
192
- </public_key>
193
-
194
-
195
- <banner_checkout translate="label">
196
- <label>Banner Checkout</label>
197
- <frontend_type>text</frontend_type>
198
- <sort_order>13</sort_order>
199
- <show_in_default>1</show_in_default>
200
- <show_in_website>1</show_in_website>
201
- <show_in_store>0</show_in_store>
202
- </banner_checkout>
203
-
204
- <sort_order translate="label">
205
- <label>Checkout Position</label>
206
- <frontend_type>text</frontend_type>
207
- <sort_order>14</sort_order>
208
- <show_in_default>1</show_in_default>
209
- <show_in_website>1</show_in_website>
210
- <show_in_store>0</show_in_store>
211
- <frontend_class>validate-number</frontend_class>
212
- </sort_order>
213
-
214
- <coupon_mercadopago translate="label">
215
- <label>Marketing - Coupon MercadoPago</label>
216
- <frontend_type>select</frontend_type>
217
- <source_model>adminhtml/system_config_source_yesno</source_model>
218
- <sort_order>15</sort_order>
219
- <show_in_default>1</show_in_default>
220
- <show_in_website>1</show_in_website>
221
- <show_in_store>0</show_in_store>
222
- <comment></comment>
223
- </coupon_mercadopago>
224
- </fields>
225
- </mercadopago_custom>
226
-
227
- <mercadopago_customticket translate="label" module="mercadopago_customticket">
228
- <label>MercadoPago Custom - Ticket</label>
229
- <sort_order>101</sort_order>
230
- <show_in_default>1</show_in_default>
231
- <show_in_website>1</show_in_website>
232
- <show_in_store>0</show_in_store>
233
- <fields>
234
- <active translate="label">
235
- <label>Enabled</label>
236
- <frontend_type>select</frontend_type>
237
- <source_model>adminhtml/system_config_source_yesno</source_model>
238
- <sort_order>1</sort_order>
239
- <show_in_default>1</show_in_default>
240
- <show_in_website>1</show_in_website>
241
- <show_in_store>0</show_in_store>
242
- <comment>For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'</comment>
243
- </active>
244
-
245
- <title translate="label">
246
- <label>Payment Title</label>
247
- <frontend_type>text</frontend_type>
248
- <sort_order>2</sort_order>
249
- <show_in_default>1</show_in_default>
250
- <show_in_website>1</show_in_website>
251
- <show_in_store>0</show_in_store>
252
- </title>
253
-
254
-
255
- <banner_checkout translate="label">
256
- <label>Banner Checkout</label>
257
- <frontend_type>text</frontend_type>
258
- <sort_order>3</sort_order>
259
- <show_in_default>1</show_in_default>
260
- <show_in_website>1</show_in_website>
261
- <show_in_store>0</show_in_store>
262
- </banner_checkout>
263
-
264
- <sort_order translate="label">
265
- <label>Checkout Position</label>
266
- <frontend_type>text</frontend_type>
267
- <sort_order>4</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
- <frontend_class>validate-number</frontend_class>
272
- </sort_order>
273
-
274
- <coupon_mercadopago translate="label">
275
- <label>Marketing - Coupon MercadoPago</label>
276
- <frontend_type>select</frontend_type>
277
- <source_model>adminhtml/system_config_source_yesno</source_model>
278
- <sort_order>5</sort_order>
279
- <show_in_default>1</show_in_default>
280
- <show_in_website>1</show_in_website>
281
- <show_in_store>0</show_in_store>
282
- <comment></comment>
283
- </coupon_mercadopago>
284
- </fields>
285
- </mercadopago_customticket>
286
-
287
- <mercadopago_standard module="mercadopago_standard">
288
- <label>MercadoPago Standard - Credit Card, Ticket and Account Money</label>
289
- <sort_order>102</sort_order>
290
- <show_in_default>1</show_in_default>
291
- <show_in_website>1</show_in_website>
292
- <show_in_store>0</show_in_store>
293
- <fields>
294
- <active translate="label">
295
- <label>Enabled</label>
296
- <frontend_type>select</frontend_type>
297
- <source_model>adminhtml/system_config_source_yesno</source_model>
298
- <sort_order>1</sort_order>
299
- <show_in_default>1</show_in_default>
300
- <show_in_website>1</show_in_website>
301
- <show_in_store>0</show_in_store>
302
- <comment>For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'</comment>
303
- </active>
304
-
305
- <title translate="label">
306
- <label>Payment Title</label>
307
- <frontend_type>text</frontend_type>
308
- <sort_order>2</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>1</show_in_website>
311
- <show_in_store>0</show_in_store>
312
- </title>
313
-
314
-
315
- <banner_checkout translate="label">
316
- <label>Banner Checkout</label>
317
- <frontend_type>text</frontend_type>
318
- <sort_order>3</sort_order>
319
- <show_in_default>1</show_in_default>
320
- <show_in_website>1</show_in_website>
321
- <show_in_store>0</show_in_store>
322
- </banner_checkout>
323
-
324
- <sort_order translate="label">
325
- <label>Checkout Position</label>
326
- <frontend_type>text</frontend_type>
327
- <sort_order>4</sort_order>
328
- <show_in_default>1</show_in_default>
329
- <show_in_website>1</show_in_website>
330
- <show_in_store>0</show_in_store>
331
- <frontend_class>validate-number</frontend_class>
332
- </sort_order>
333
-
334
- <type_checkout>
335
- <label>Type Checkout</label>
336
- <frontend_type>select</frontend_type>
337
- <source_model>MercadoPago_Model_Source_TypeCheckout</source_model>
338
- <sort_order>5</sort_order>
339
- <show_in_default>1</show_in_default>
340
- <show_in_website>1</show_in_website>
341
- <show_in_store>1</show_in_store>
342
- </type_checkout>
343
-
344
- <auto_return translate="label">
345
- <label>Auto Redirect</label>
346
- <frontend_type>select</frontend_type>
347
- <source_model>adminhtml/system_config_source_yesno</source_model>
348
- <sort_order>6</sort_order>
349
- <show_in_default>1</show_in_default>
350
- <show_in_website>1</show_in_website>
351
- <show_in_store>0</show_in_store>
352
- <comment>Auto-redirect the buyer when finishing the payment.</comment>
353
- </auto_return>
354
-
355
- <excluded_payment_methods translate="label">
356
- <label>Exclude Payment Methods</label>
357
- <comment>Select payment methods not accepted</comment>
358
- <frontend_type>multiselect</frontend_type>
359
- <source_model>MercadoPago_Model_Source_PaymentMethods</source_model>
360
- <sort_order>8</sort_order>
361
- <show_in_default>1</show_in_default>
362
- <show_in_website>1</show_in_website>
363
- <show_in_store>1</show_in_store>
364
- <can_be_empty>1</can_be_empty>
365
- </excluded_payment_methods>
366
-
367
- <installments>
368
- <label>Maximum number of accepted installments</label>
369
- <frontend_type>select</frontend_type>
370
- <source_model>MercadoPago_Model_Source_Installments</source_model>
371
- <sort_order>9</sort_order>
372
- <show_in_default>1</show_in_default>
373
- <show_in_website>1</show_in_website>
374
- <show_in_store>1</show_in_store>
375
- </installments>
376
-
377
-
378
- <iframe_width translate="label">
379
- <label>Width Checkout Iframe</label>
380
- <frontend_type>text</frontend_type>
381
- <sort_order>10</sort_order>
382
- <show_in_default>1</show_in_default>
383
- <show_in_website>1</show_in_website>
384
- <show_in_store>0</show_in_store>
385
- <frontend_class>validate-number</frontend_class>
386
- </iframe_width>
387
-
388
- <iframe_height translate="label">
389
- <label>Height Checkout Iframe</label>
390
- <frontend_type>text</frontend_type>
391
- <sort_order>11</sort_order>
392
- <show_in_default>1</show_in_default>
393
- <show_in_website>1</show_in_website>
394
- <show_in_store>0</show_in_store>
395
- <frontend_class>validate-number</frontend_class>
396
- </iframe_height>
397
-
398
- </fields>
399
- </mercadopago_standard>
400
- </groups>
401
- </payment>
402
- </sections>
403
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/mercadopago.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout>
4
+ <default>
5
+ <reference name="head">
6
+ <action method="addCss"><name>mercadopago/styles.css</name></action>
7
+ </reference>
8
+ </default>
9
+
10
+ <mercadopago_add_order_total>
11
+ <reference name="order_totals">
12
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
13
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
14
+ </reference>
15
+ </mercadopago_add_order_total>
16
+
17
+ <mercadopago_add_invoice_total>
18
+ <reference name="invoice_totals">
19
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
20
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
21
+ </reference>
22
+ </mercadopago_add_invoice_total>
23
+
24
+ <mercadopago_add_creditmemo_total>
25
+ <reference name="creditmemo_totals">
26
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
27
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
28
+ </reference>
29
+ </mercadopago_add_creditmemo_total>
30
+
31
+ <adminhtml_sales_order_view>
32
+ <update handle="mercadopago_add_order_total" />
33
+ </adminhtml_sales_order_view>
34
+ <adminhtml_sales_order_invoice_new>
35
+ <update handle="mercadopago_add_invoice_total" />
36
+ </adminhtml_sales_order_invoice_new>
37
+ <adminhtml_sales_order_invoice_updateqty>
38
+ <update handle="mercadopago_add_invoice_total" />
39
+ </adminhtml_sales_order_invoice_updateqty>
40
+ <adminhtml_sales_order_invoice_view>
41
+ <update handle="mercadopago_add_invoice_total" />
42
+ </adminhtml_sales_order_invoice_view>
43
+ <adminhtml_sales_order_creditmemo_new>
44
+ <update handle="mercadopago_add_creditmemo_total" />
45
+ </adminhtml_sales_order_creditmemo_new>
46
+ <adminhtml_sales_order_creditmemo_updateqty>
47
+ <update handle="mercadopago_add_creditmemo_total" />
48
+ </adminhtml_sales_order_creditmemo_updateqty>
49
+ <adminhtml_sales_order_creditmemo_view>
50
+ <update handle="mercadopago_add_creditmemo_total" />
51
+ </adminhtml_sales_order_creditmemo_view>
52
+
53
+ </layout>
app/design/adminhtml/default/default/template/mercadopago/array_dropdown.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @class MercadoPago_MercadoEnvios_Block_Adminhtml_System_Config_Fieldset_Mapping
4
+ */
5
+ $_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
6
+ $productCode = $this->_getAttributes();
7
+ $sizeUnit = ['cm', 'mt'];
8
+ $weightUnit = ['kg', 'gr'];
9
+ $meCode = ['length','width','height', 'weight'];
10
+ $meLabel = $this->_getMeLabel();
11
+ $prevValues = [];
12
+ $unit = $sizeUnit;
13
+
14
+ $prevValues = $this->_getStoredMappingValues();
15
+
16
+ ?>
17
+
18
+ <div class="grid" id="grid<?php echo $_htmlId ?>">
19
+ <table cellpadding="0" cellspacing="0" class="border">
20
+ <tr class="headings" id="headings<?php echo $_htmlId ?>">
21
+ <th><?php echo $this->__('MercadoEnvios')?></th>
22
+ <th><?php echo $this->__('Product Attribute')?></th>
23
+ <th><?php echo $this->__('Product Attribute Unit')?></th>
24
+ </tr>
25
+ <?php foreach($meCode as $key => $meOption):?>
26
+ <tr id="<?php echo $meOption ?>">
27
+ <td>
28
+ <label><?php echo $meLabel[$key] ?>:</label>
29
+ </td>
30
+ <td>
31
+ <select name="groups[mercadoenvios][fields][attributesmapping][value][<?php echo $meOption ?>][attribute_code]">
32
+ <?php foreach($productCode as $option):?>
33
+ <option value="<?php echo $option->getAttributeCode() ?>"
34
+ <?php echo ( isset($prevValues[$meOption]['attribute_code']) && $prevValues[$meOption]['attribute_code'] == $option->getAttributeCode()) ? "selected='selected'" : "" ?>><?php echo $option->getFrontendLabel() ?>
35
+ </option>
36
+ <?php endforeach; ?>
37
+ </select>
38
+ </td>
39
+ <?php if ($meOption == 'weight') : $unit = $weightUnit; endif;?>
40
+ <td>
41
+ <select name="groups[mercadoenvios][fields][attributesmapping][value][<?php echo $meOption ?>][unit]">
42
+ <?php foreach($unit as $_u):?>
43
+ <option value="<?php echo $_u ?>" <?php echo (isset($prevValues[$meOption]['unit']) && $prevValues[$meOption]['unit'] == $_u) ? "selected='selected'" : '' ?>><?php echo $_u ?></option>
44
+ <?php endforeach; ?>
45
+ </select>
46
+ </td>
47
+ </tr>
48
+ <?php endforeach; ?>
49
+ </table>
50
+ </div>
app/design/adminhtml/default/default/template/mercadopago/custom/info.phtml CHANGED
File without changes
app/design/adminhtml/default/default/template/mercadopago/custom_ticket/info.phtml CHANGED
@@ -4,15 +4,15 @@
4
 
5
  <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
6
 
7
- <?php if($info_payment['payment_id']['value'] != ""): ?>
8
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $info_payment['payment_id']['value']); ?></p>
9
  <?php endif; ?>
10
 
11
- <?php if($info_payment['status']['value'] != ""): ?>
12
  <p><?php echo $this->__('Payment Status: %s', $info_payment['status']['value']); ?></p>
13
  <?php endif; ?>
14
 
15
- <?php if($info_payment['status_detail']['value'] != ""): ?>
16
  <p><?php echo $this->__('Payment Status Detail: %s', $info_payment['status_detail']['value']); ?></p>
17
  <?php endif; ?>
18
 
4
 
5
  <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
6
 
7
+ <?php if(isset($info_payment['payment_id']) && $info_payment['payment_id']['value'] != ""): ?>
8
+ <p><?php echo $this->__('Payment Id (Mercado Pago): %s', $info_payment['payment_id']['value']); ?></p>
9
  <?php endif; ?>
10
 
11
+ <?php if(isset($info_payment['status']) && $info_payment['status']['value'] != ""): ?>
12
  <p><?php echo $this->__('Payment Status: %s', $info_payment['status']['value']); ?></p>
13
  <?php endif; ?>
14
 
15
+ <?php if(isset($info_payment['status_detail']) && $info_payment['status_detail']['value'] != ""): ?>
16
  <p><?php echo $this->__('Payment Status Detail: %s', $info_payment['status_detail']['value']); ?></p>
17
  <?php endif; ?>
18
 
app/design/adminhtml/default/default/template/mercadopago/standard/info.phtml CHANGED
File without changes
app/design/frontend/base/default/layout/mercadopago.xml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <mercadopago_success_index>
5
+
6
+ <reference name="head">
7
+ <action method="addCss">
8
+ <stylesheet>mercadopago/css/style-success.css</stylesheet>
9
+ </action>
10
+ </reference>
11
+
12
+ <reference name="root">
13
+ <action method="setTemplate"><template>mercadopago/clean.phtml</template></action>
14
+ </reference>
15
+
16
+ </mercadopago_success_index>
17
+
18
+ <mercadopago_custom_success>
19
+ <reference name="content">
20
+ <block type="mercadopago/custom_success" name="mercadopago.success" as="success" />
21
+ </reference>
22
+ </mercadopago_custom_success>
23
+
24
+ <mercadopago_standard_success>
25
+ <reference name="content">
26
+ <block type="mercadopago/standard_success" name="mercadopago.success" as="success" />
27
+ </reference>
28
+ </mercadopago_standard_success>
29
+
30
+ <mercadopago_customticket_success>
31
+ <reference name="content">
32
+ <block type="mercadopago/customticket_success" name="mercadopago.success" as="success"/>
33
+ </reference>
34
+ </mercadopago_customticket_success>
35
+
36
+ <mercadopago_add_order_total>
37
+ <reference name="order_totals">
38
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
39
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
40
+ </reference>
41
+ </mercadopago_add_order_total>
42
+
43
+ <mercadopago_add_invoice_total>
44
+ <reference name="invoice_totals">
45
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
46
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
47
+ </reference>
48
+ </mercadopago_add_invoice_total>
49
+
50
+ <mercadopago_add_creditmemo_total>
51
+ <reference name="creditmemo_totals">
52
+ <block type="mercadopago/sales_order_totals_finance_cost" name="total_finance_cost" />
53
+ <block type="mercadopago/sales_order_totals_discount_coupon" name="total_discount_coupon" />
54
+ </reference>
55
+ </mercadopago_add_creditmemo_total>
56
+
57
+ <sales_order_view>
58
+ <update handle="mercadopago_add_order_total" />
59
+ </sales_order_view>
60
+ <sales_order_invoice>
61
+ <update handle="mercadopago_add_invoice_total" />
62
+ </sales_order_invoice>
63
+ <sales_order_creditmemo>
64
+ <update handle="mercadopago_add_creditmemo_total" />
65
+ </sales_order_creditmemo>
66
+ <sales_order_print>
67
+ <update handle="mercadopago_add_order_total" />
68
+ </sales_order_print>
69
+ <sales_order_printinvoice>
70
+ <update handle="mercadopago_add_invoice_total" />
71
+ </sales_order_printinvoice>
72
+ <sales_order_printcreditmemo>
73
+ <update handle="mercadopago_add_creditmemo_total" />
74
+ </sales_order_printcreditmemo>
75
+ <sales_email_order_items>
76
+ <update handle="mercadopago_add_order_total" />
77
+ </sales_email_order_items>
78
+ <sales_email_order_invoice_items>
79
+ <update handle="mercadopago_add_invoice_total" />
80
+ </sales_email_order_invoice_items>
81
+ <sales_email_order_creditmemo_items>
82
+ <update handle="mercadopago_add_creditmemo_total" />
83
+ </sales_email_order_creditmemo_items>
84
+ <sales_guest_view>
85
+ <update handle="mercadopago_add_order_total" />
86
+ </sales_guest_view>
87
+ <sales_guest_invoice>
88
+ <update handle="mercadopago_add_invoice_total" />
89
+ </sales_guest_invoice>
90
+ <sales_guest_creditmemo>
91
+ <update handle="mercadopago_add_creditmemo_total" />
92
+ </sales_guest_creditmemo>
93
+ <sales_guest_print>
94
+ <update handle="mercadopago_add_order_total" />
95
+ </sales_guest_print>
96
+ <sales_guest_printinvoice>
97
+ <update handle="mercadopago_add_invoice_total" />
98
+ </sales_guest_printinvoice>
99
+ <sales_guest_printcreditmemo>
100
+ <update handle="mercadopago_add_creditmemo_total" />
101
+ </sales_guest_printcreditmemo>
102
+
103
+ </layout>
app/design/frontend/base/default/template/mercadopago/clean.phtml CHANGED
File without changes
app/design/frontend/base/default/template/mercadopago/custom/form.phtml CHANGED
@@ -1,188 +1,193 @@
1
- <?php
2
-
3
- $country = Mage::getStoreConfig('payment/mercadopago/country');
4
-
5
- $coupon_mercadopago = Mage::getStoreConfig('payment/mercadopago_custom/coupon_mercadopago');
6
-
7
- $_code = $this->getMethodCode();
8
- $grant_total = $this->helper('checkout/cart')->getQuote()->getGrandTotal();
9
- $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true);
10
- $route = $this->getRequest()->getRequestedRouteName();
11
-
12
- ?>
13
-
14
-
15
- <fieldset class="form-list mercadopago">
16
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>?nocache=<?php echo rand();?>" />
17
-
18
- <script>
19
- //load nas actions para funcionar o js do mercadopago
20
- loadFilesMP();
21
- </script>
22
-
23
- <div id="mp-form">
24
- <ul class="form-list form-mercadopago" id="payment_form_<?php echo $_code ?>" style="display:none;" >
25
-
26
- <?php if( $country == 'mlm'):
27
- $payment_methods = $this->getCardsPaymentMethods();
28
- ?>
29
- <li>
30
- <div class="box-input">
31
- <label for="<?php echo $_code ?>_payment_method" class="required"><em>*</em><?php echo $this->__('Payment Method'); ?></label>
32
- <div class="input-box box-payment_method">
33
- <select name="payment[payment_method]" id="payment_method" data-checkout="payment_method" id="<?php echo $_code ?>_payment_method" class="input-text required-entry">
34
- <option value="-1"><?php echo $this->__('Choice'); ?>...</option>
35
- <?php foreach($payment_methods as $pm): ?>
36
- <option value="<?php echo $pm['id']; ?>"><?php echo $pm['name']; ?></option>
37
- <?php endforeach; ?>
38
- </select>
39
- </div>
40
- </div>
41
- </li>
42
- <?php else: ?>
43
- <input type="hidden" name="payment[payment_method]" type="text" value="" id="payment_method" />
44
- <?php endif; ?>
45
-
46
- <?php
47
- if($coupon_mercadopago):
48
- $block = $this->getLayout()->createBlock('MercadoPago_Block_Discount');
49
- echo $block->toHtml();
50
- endif;
51
- ?>
52
-
53
- <li>
54
- <label for="<?php echo $_code ?>_cn" class="required"><em>*</em><?php echo $this->__('Card Number'); ?></label>
55
- <div class="input-box">
56
- <input data-checkout="cardNumber" id="<?php echo $_code ?>_cn" type="text" class="input-text required-entry"/>
57
- <p class="msg-status error-E301 validation-advice"><?php echo $this->__('Card number is invalid.'); ?></p>
58
- <p class="msg-status error-132 validation-advice"><?php echo $this->__('Cannot pay this amount with this payment_method_id.'); ?></p>
59
- </div>
60
- </li>
61
-
62
- <li id="issuersOptions" style="display: none;">
63
- <label for="<?php echo $_code ?>_issuers" class="required"><em>*</em><?php echo $this->__('Banks'); ?></label>
64
- <div class="input-box">
65
- <div id="issuers">
66
- </div>
67
- </div>
68
- </li>
69
-
70
- <li>
71
- <div class="box-mes">
72
- <label for="<?php echo $_code ?>_month" class="required"><em>*</em><?php echo $this->__('Month'); ?></label>
73
- <div class="input-box mes">
74
- <select data-checkout="cardExpirationMonth" name="payment[cardExpirationMonth]" id="<?php echo $_code ?>_month" class="required-entry validate-digits">
75
- <?php foreach ($this->getCcMonths() as $m=>$v): ?>
76
- <option value="<?php echo $m?$m:'' ?>"><?php echo $v ?></option>
77
- <?php endforeach ?>
78
- </select>
79
- <p class="msg-status error-325 validation-advice"><?php echo $this->__('Month is invalid.'); ?></p>
80
- </div>
81
- </div>
82
-
83
- <div class="box-ano">
84
- <label for="<?php echo $_code ?>_year" class="required"><em>*</em><?php echo $this->__('Year'); ?></label>
85
- <div class="input-box">
86
- <select data-checkout="cardExpirationYear" name="payment[cardExpirationYear]" id="<?php echo $_code ?>_year" class="required-entry validate-digits">
87
- <?php foreach ($this->getCcYears() as $y=>$v): ?>
88
- <option value="<?php echo $y?$y:'' ?>"><?php echo $v ?></option>
89
- <?php endforeach ?>
90
- </select>
91
- <p class="msg-status error-326 validation-advice"><?php echo $this->__('Year is invalid.'); ?></p>
92
- </div>
93
- </div>
94
- </li>
95
-
96
-
97
- <li>
98
- <div class="box-input">
99
- <label for="<?php echo $_code ?>_name" class="required"><em>*</em><?php echo $this->__('Card Holder Name'); ?></label>
100
- <div class="input-box">
101
- <input data-checkout="cardholderName" name="payment[cardholderName]" id="<?php echo $_code ?>_name" type="text" class="input-text required-entry" type="text"/>
102
- <p class="msg-status error-316 validation-advice"><?php echo $this->__('Card Holder Name is invalid.'); ?></p>
103
- </div>
104
- </div>
105
- </li>
106
-
107
- <?php
108
- //mexico não possui documento no checkout
109
- if( $country != 'mlm'): ?>
110
-
111
- <li>
112
- <div class="box-input">
113
- <label for="<?php echo $_code ?>_doc" class="required"><em>*</em><?php echo $this->__('Document Number'); ?></label>
114
- <div class="input-box">
115
- <?php if( $country == 'mlb'): ?>
116
- <input type="hidden" data-checkout="docType" id="docType" type="text" value="CPF"/>
117
- <?php elseif($country == 'mla'): ?>
118
- <select optionkey="id" name="payment[docType]" id="docType" data-checkout="docType">
119
- <option value="DNI">DNI</option>
120
- <option value="CI">Cédula</option>
121
- <option value="LC">L.C.</option>
122
- <option value="LE">L.E.</option>
123
- <option value="Otro">Otro</option>
124
- </select>
125
- <?php endif; ?>
126
-
127
- <input name="payment[doc_number]" data-checkout="docNumber" id="<?php echo $_code ?>_doc" type="text" class="input-text required-entry validate-digits" type="text" maxlength="11" />
128
- <p class="msg-status error-324 validation-advice"><?php echo $this->__('Document Number is invalid.'); ?></p>
129
- <p class="msg-status error-322 validation-advice"><?php echo $this->__('Document Type is invalid.'); ?></p>
130
- </div>
131
- </div>
132
- </li>
133
- <?php endif; ?>
134
-
135
- <li>
136
- <div class="box-input">
137
- <label for="<?php echo $_code ?>_code" class="required"><em>*</em><?php echo $this->__('CVV'); ?></label>
138
- <div class="input-box">
139
- <input data-checkout="securityCode" id="<?php echo $_code ?>_code" type="text" class="input-text required-entry validate-digits" type="text" size="5"/>
140
- <p class="msg-status error-E302 validation-advice"><?php echo $this->__('CVV is invalid.'); ?></p>
141
- </div>
142
- </div>
143
- </li>
144
-
145
- <li>
146
- <div class="box-input">
147
- <label for="<?php echo $_code ?>_installments" class="required"><em>*</em><?php echo $this->__('Installments'); ?></label>
148
- <div class="input-box box-installments">
149
- <select name="payment[installments]" id="installments" data-checkout="installments" id="<?php echo $_code ?>_installments" class="required-entry validate-digits">
150
- <option><?php echo $this->__('Enter the card number'); ?></option>
151
- </select>
152
- <p class="msg-status error-installment-not-work validation-advice"><?php echo $this->__('It was not possible to calculate the installments, click here and try again.'); ?></p>
153
- <p class="msg-status error-011 validation-advice"><?php echo $this->__('An error has occurred. Please refresh the page.'); ?></p>
154
- <p class="msg-status error-other validation-advice"><?php echo $this->__('Please validate your data.'); ?></p>
155
- </div>
156
- </div>
157
-
158
- <div id="mercadopago-loading">
159
- <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif') ;?>" alt="loading" />
160
- <!--<p><?php echo $this->__('Validating Data'); ?>...</p>-->
161
- </div>
162
-
163
- <input type="hidden" name="payment[card_token_id]" type="text" value="" id="card_token_id" />
164
- <input type="hidden" name="payment[trunc_card]" type="text" value="" id="trunc_card" />
165
-
166
- <!-- -->
167
- <input type="hidden" class="amount" value="<?php echo $grant_total; ?>">
168
- <input type="hidden" class="mercadopago-discount-amount" value="0">
169
- <input type="hidden" type="text" value="<?php echo $base_url; ?>" class="mercado_base_url" />
170
- <input type="hidden" type="text" value="<?php echo $route; ?>" class="mercado_route" />
171
- <!-- -->
172
-
173
- <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
174
- <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
175
- <?php endif;?>
176
-
177
- <div style="display: none;">
178
- <span class="mercadopago-text-currency"><?php echo $this->__('$'); ?></span>
179
- <span class="mercadopago-text-choice"><?php echo $this->__('Choice'); ?></span>
180
- <span class="mercadopago-text-default-issuer"><?php echo $this->__('Default issuer'); ?></span>
181
- <span class="mercadopago-country"><?php echo $country; ?></span>
182
- </div>
183
- </li>
184
- </ul>
185
-
186
-
187
- </div>
 
 
 
 
 
188
  </fieldset>
1
+ <?php
2
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
3
+ $coupon_mercadopago = Mage::getStoreConfig('payment/mercadopago_custom/coupon_mercadopago');
4
+ $_code = $this->getMethodCode();
5
+ $grant_total = $this->helper('checkout/cart')->getQuote()->getGrandTotal();
6
+ $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true);
7
+ $logEnabled= Mage::getStoreConfigFlag('payment/mercadopago/logs');
8
+ $route = $this->getRequest()->getRequestedRouteName();
9
+ $customer = $this->getCustomerAndCards();
10
+ ?>
11
+
12
+ <script type="text/javascript">
13
+ MercadoPagoCustom.enableLog(<?php echo $logEnabled?>);
14
+ MercadoPagoCustom.getInstance().init();
15
+ </script>
16
+
17
+ <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>?nocache=<?php echo rand(); ?>"/>
18
+
19
+ <fieldset>
20
+ <div id="mercadopago_checkout_custom">
21
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
22
+
23
+
24
+ <?php
25
+ if ($coupon_mercadopago):
26
+ $block = $this->getLayout()->createBlock('mercadopago/discount')->setCode($_code);
27
+ echo $block->toHtml();
28
+ ?>
29
+ <script type="text/javascript">
30
+ MercadoPagoCustom.getInstance().initDiscount();
31
+ </script>
32
+ <?php
33
+ endif;
34
+ ?>
35
+
36
+ <?php if ($customer !== false && isset($customer['cards']) && count($customer['cards']) > 0): ?>
37
+ <li>
38
+ <ul id="mercadopago_checkout_custom_ocp">
39
+ <li id="cardId__mp">
40
+
41
+ <div><a id="use_other_card_mp" class="action_ocp"><?php echo $this->__('Use other card'); ?></a></div>
42
+
43
+ <label for="cardNumber"><?php echo $this->__('Payment Method'); ?></label>
44
+ <select id="cardId" name="payment[<?php echo $_code; ?>][cardId]" data-checkout="cardId" data-element-id="#cardId__mp">
45
+ <?php foreach ($customer['cards'] as $card) { ?>
46
+ <option value="<?php echo $card["id"]; ?>" first_six_digits="<?php echo $card["first_six_digits"]; ?>" security_code_length="<?php echo $card["security_code"]["length"]; ?>">
47
+
48
+ <?php echo $card["payment_method"]["name"].' '; ?><?php echo $this->__('ended in'); ?><?php echo ' '.$card["last_four_digits"]; ?>
49
+ </option>
50
+ <?php } ?>
51
+ </select>
52
+
53
+ <input type="hidden" name="payment[<?php echo $_code; ?>][customer_id]" value="<?php echo $customer['id']; ?>">
54
+
55
+ </li>
56
+
57
+ <li id="securityCodeOCP__mp">
58
+ <label for="securityCode"><?php echo $this->__('CVV'); ?></label>
59
+ <input type="text" id="securityCodeOCP" class="required-entry" data-checkout="securityCode" maxlength="4" data-element-id="#securityCodeOCP__mp"/>
60
+
61
+ <p class="message-error error-E302 error-224 validation-advice"><?php echo $this->__('CVV is invalid.'); ?></p>
62
+ </li>
63
+ </ul>
64
+ </li>
65
+
66
+ <script>
67
+ MercadoPagoCustom.getInstance().initOCP();
68
+ </script>
69
+ <?php endif; ?>
70
+
71
+ <li>
72
+ <ul id="mercadopago_checkout_custom_card">
73
+ <li id="paymentMethod__mp">
74
+ <label for="paymentMethod"><?php echo $this->__('Payment Method'); ?></label>
75
+ <select id="paymentMethod" data-checkout="paymentMethod" name="payment[<?php echo $_code; ?>][paymentMethod]" data-element-id="#paymentMethod__mp" class="validate-select"></select>
76
+ </li>
77
+ <li id="cardNumber__mp">
78
+ <div><a id="return_list_card_mp" class="action_ocp"><?php echo $this->__('Return to cards list'); ?></a></div>
79
+
80
+ <label for="cardNumber"><?php echo $this->__('Card Number'); ?></label>
81
+ <input type="text" id="cardNumber" data-checkout="cardNumber" data-element-id="#cardNumber__mp"/>
82
+
83
+ <p class="message-error error-payment-method-not-found error-E301 error-205 validation-advice"><?php echo $this->__('Card number is invalid.'); ?></p>
84
+
85
+ <p class="message-error error-payment-method-min-amount validation-advice"><?php echo $this->__('Cannot pay this amount with this payment_method_id.'); ?></p>
86
+
87
+ </li>
88
+
89
+ <li id="issuer__mp">
90
+ <label for="issuer"><?php echo $this->__('Banks'); ?></label>
91
+ <select id="issuer" name="payment[<?php echo $_code; ?>][issuer_id]" data-checkout="issuer" data-element-id="#issuer__mp">
92
+
93
+ </select>
94
+
95
+ <p class="message-error error-220 validation-advice"><?php echo $this->__('Select issuer'); ?></p>
96
+ </li>
97
+
98
+ <li id="expiration_date__mp">
99
+ <div id="box_month">
100
+ <label for="cardExpirationMonth"><?php echo $this->__('Month'); ?></label>
101
+ <select id="cardExpirationMonth" data-checkout="cardExpirationMonth" class="mp-validate-cc-exp" name="payment[<?php echo $_code; ?>][card_expiration_month]" data-element-id="#expiration_date__mp">
102
+ <?php foreach ($this->getCcMonths() as $m => $v): ?>
103
+ <option value="<?php echo $m ? $m : ''; ?>"><?php echo $v; ?></option>
104
+ <?php endforeach ?>
105
+ </select>
106
+
107
+ <p class="message-error error-325 error-208 validation-advice"><?php echo $this->__('Month is invalid.'); ?></p>
108
+ </div>
109
+
110
+ <div id="box_year">
111
+ <label for="cardExpirationYear"><?php echo $this->__('Year'); ?></label>
112
+ <select id="cardExpirationYear" data-checkout="cardExpirationYear" name="payment[<?php echo $_code; ?>][card_expiration_year]" data-element-id="#expiration_date__mp">
113
+ <?php foreach ($this->getCcYears() as $y => $v): ?>
114
+ <option value="<?php echo $y ? $y : ''; ?>"><?php echo $v; ?></option>
115
+ <?php endforeach ?>
116
+ </select>
117
+
118
+ <p class="message-error error-326 error-209 validation-advice"><?php echo $this->__('Year is invalid.'); ?></p>
119
+ </div>
120
+ </li>
121
+
122
+ <li id="cardholderName__mp">
123
+ <label for="cardholderName"><?php echo $this->__('Card Holder Name'); ?></label>
124
+ <input type="text" id="cardholderName" data-checkout="cardholderName" name="payment[<?php echo $_code; ?>][card_holder_name]" data-element-id="#cardholderName__mp"/>
125
+
126
+ <p class="message-error error-316 validation-advice"><?php echo $this->__('Card Holder Name is invalid.'); ?></p>
127
+ </li>
128
+
129
+ <li id="securityCode__mp">
130
+ <label for="securityCode"><?php echo $this->__('CVV'); ?></label>
131
+ <input type="text" id="securityCode" data-checkout="securityCode" maxlength="4" data-element-id="#securityCode__mp" class="required-entry"/>
132
+
133
+ <p class="message-error error-E302 error-224 validation-advice"><?php echo $this->__('CVV is invalid.'); ?></p>
134
+ </li>
135
+
136
+ <li id="doc_type__mp">
137
+ <label for="docType"><?php echo $this->__('Document Type'); ?></label>
138
+ <select id="docType" data-checkout="docType" data-element-id="#doc_type__mp" name="payment[<?php echo $_code; ?>][doc_type]"></select>
139
+
140
+ <p class="message-error error-322 error-212 validation-advice"><?php echo $this->__('Document Type is invalid.'); ?></p>
141
+ </li>
142
+
143
+ <li id="doc_number__mp">
144
+ <label for="docNumber"><?php echo $this->__('Document Number'); ?></label>
145
+ <input type="text" id="docNumber" class="mp-validate-docnumber" data-checkout="docNumber" name="payment[<?php echo $_code; ?>][doc_number]" data-element-id="#doc_number__mp"/>
146
+
147
+ <p class="message-error error-324 error-213 error-214 validation-advice"><?php echo $this->__('Document Number is invalid.'); ?></p>
148
+ </li>
149
+
150
+ </ul>
151
+ </li>
152
+
153
+ <li id="installments__mp">
154
+ <label for="installments"><?php echo $this->__('Installments'); ?></label>
155
+ <select id="installments" name="payment[<?php echo $_code; ?>][installments]" data-element-id="#installments__mp" class="validate-select"></select>
156
+
157
+ <p class="message-error error-installment-not-work validation-advice"><?php echo $this->__('It was not possible to calculate the installments, click here and try again.'); ?></p>
158
+
159
+ <p class="message-error error-011 validation-advice"><?php echo $this->__('An error has occurred. Please refresh the page.'); ?></p>
160
+
161
+ <p class="message-error error-other validation-advice"><?php echo $this->__('Please validate your data.'); ?></p>
162
+
163
+ </li>
164
+ <li>
165
+ <div id="mercadopago-loading">
166
+ <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif'); ?>" alt="loading"/>
167
+ </div>
168
+ </li>
169
+
170
+ <li>
171
+
172
+ <?php if ($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
173
+ <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
174
+ <?php endif; ?>
175
+
176
+ <input type="hidden" class="total_amount" name="total_amount" value="<?php echo $grant_total; ?>"/>
177
+ <input type="hidden" class="amount" name="amount" value="<?php echo $grant_total; ?>"/>
178
+ <input type="hidden" class="mercadopago-discount-amount" name="mercadopago-discount-amount" value="0"/>
179
+ <input type="hidden" class="site_id" name="site_id" value="<?php echo strtoupper($country); ?>"/>
180
+ <input type="hidden" class="mercadopago-text-currency" value="<?php echo $this->__('$'); ?>">
181
+ <input type="hidden" class="mercadopago-text-choice" value="<?php echo $this->__('Choice'); ?>">
182
+ <input type="hidden" class="mercadopago-text-default-issuer" value="<?php echo $this->__('Default issuer'); ?>">
183
+ <input type="hidden" class="mercadopago-text-installment" value="<?php echo $this->__('Enter the card number'); ?>">
184
+ <input type="hidden" class="mercado_base_url" value="<?php echo $base_url; ?>">
185
+ <input type="hidden" class="mercado_route" value="<?php echo $route; ?>">
186
+ <input type="hidden" name="payment[<?php echo $_code; ?>][token]" type="text" value="" class="token"/>
187
+ <input type="hidden" name="payment[<?php echo $_code; ?>][payment_method_id]" type="text" value="" class="payment_method_id"/>
188
+
189
+ <input type="hidden" id="one_click_pay_mp" name="payment[<?php echo $_code; ?>][one_click_pay]" value="<?php echo count($customer['cards']) > 0 ? 1 : 0; ?>">
190
+ </li>
191
+ </ul>
192
+ </div>
193
  </fieldset>
app/design/frontend/base/default/template/mercadopago/custom/info.phtml CHANGED
File without changes
app/design/frontend/base/default/template/mercadopago/custom/success.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $order = $this->getOrder();
3
+ $total = $this->getTotal();
4
+ $payment = $this->getPayment();
5
+
6
+ //monta link para o pedido
7
+ $link_to_order = $this->__('Your order %s has been successfully generated.', '<a href="'. Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "sales/order/view/order_id/" . $this->getEntityId() . '">' . $order->getIncrementId() .'</a>');
8
+
9
+ $payment_method = $this->getPaymentMethod();
10
+ $info_payment = $this->getInfoPayment();
11
+ ?>
12
+
13
+ <div id="box-mercadopago">
14
+
15
+ <?php if(!isset($info_payment['status']['value'])): ?>
16
+ <h2 class="mercadopago-title"><?php echo $this->__('Thank you for your purchase!'); ?></h2>
17
+ <p><?php echo $link_to_order; ?></p>
18
+ <?php else: ?>
19
+ <?php
20
+ $message_status = $this->getMessageByStatus(
21
+ $info_payment['status']['value'],
22
+ $info_payment['status_detail']['value'],
23
+ (isset($info_payment['payment_method']['value'])) ? $info_payment['payment_method']['value'] : '',
24
+ (isset($info_payment['installment']['value'])) ? $info_payment['installment']['value'] : '' ,
25
+ $this->getTotal()
26
+ );
27
+ ?>
28
+ <h2 class="mercadopago-title"><?php echo $message_status['title']; ?></h2>
29
+
30
+ <p><?php echo $message_status['message']; ?></p>
31
+
32
+ <p><?php echo $link_to_order; ?></p>
33
+
34
+ <h5 class="mercadopago-title-info-payment"><?php echo $this->__('Payment information'); ?></h5>
35
+
36
+ <?php foreach($info_payment as $info): ?>
37
+ <p><?php echo $info['text']; ?></p>
38
+ <?php endforeach; ?>
39
+
40
+ <?php endif; ?>
41
+ </div>
42
+
43
+ <div id="logo-mercadopago">
44
+ <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
45
+ </div>
app/design/frontend/base/default/template/mercadopago/custom_ticket/form.phtml CHANGED
@@ -1,61 +1,62 @@
1
- <?php
2
- $coupon_mercadopago = Mage::getStoreConfig('payment/mercadopago_customticket/coupon_mercadopago');
3
- $_code = $this->getMethodCode();
4
- $grant_total = $this->helper('checkout/cart')->getQuote()->getGrandTotal();
5
- $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true);
6
- $route = $this->getRequest()->getRequestedRouteName();
7
-
8
- ?>
9
-
10
- <fieldset class="form-list">
11
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>?nocache=<?php echo rand();?>" />
12
-
13
- <script>
14
- //load nas actions para funcionar o js do mercadopago
15
- loadFilesMP();
16
- </script>
17
-
18
- <div id="mp-form-boleto">
19
- <ul class="form-list form-mercadopago" id="payment_form_<?php echo $_code ?>" style="display:none;" >
20
- <li>
21
- <?php
22
- if($coupon_mercadopago):
23
- $block = $this->getLayout()->createBlock('MercadoPago_Block_Discount');
24
- echo $block->toHtml();
25
- endif;
26
- ?>
27
-
28
- <?php
29
- $optionsTicket = $this->getTicketsOptions();
30
- if(count($optionsTicket) == 1){ ?>
31
- <input type="hidden" name="payment[payment_method_boleto]" type="text" value="<?php echo $optionsTicket[0]['id']; ?>" id="payment_method_boleto" />
32
- <?php } else { ?>
33
-
34
- <?php
35
- foreach($optionsTicket as $ticket){ ?>
36
- <input type="radio" name="payment[payment_method_boleto]" class="optionsTicketMp" value="<?php echo $ticket['id']; ?>"> <img src="<?php echo $ticket['secure_thumbnail']; ?>"> (<?php echo $ticket['name']; ?>) <br/>
37
- <?php } ?>
38
- <?php } ?>
39
-
40
-
41
- <input type="hidden" class="amount" value="<?php echo $grant_total; ?>">
42
- <input type="hidden" class="mercadopago-discount-amount" value="0">
43
- <input type="hidden" type="text" value="<?php echo $base_url; ?>" class="mercado_base_url" />
44
- <input type="hidden" type="text" value="<?php echo $route; ?>" class="mercado_route" />
45
-
46
- <div style="display: none;">
47
- <span class="mercadopago-text-currency"><?php echo $this->__('$'); ?></span>
48
- <span class="mercadopago-text-choice"><?php echo $this->__('Choice'); ?></span>
49
- <span class="mercadopago-text-default-issuer"><?php echo $this->__('Default issuer'); ?></span>
50
- <span class="mercadopago-country"><?php // echo $country; ?></span>
51
- </div>
52
- </li>
53
-
54
- </ul>
55
- </div>
56
-
57
- <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
58
- <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
59
- <?php endif;?>
60
-
61
- </fieldset>
 
1
+ <?php
2
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
3
+ $coupon_mercadopago = Mage::getStoreConfig('payment/mercadopago_customticket/coupon_mercadopago');
4
+ $_code = $this->getMethodCode();
5
+ $grant_total = $this->helper('checkout/cart')->getQuote()->getGrandTotal();
6
+ $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true);
7
+ $route = $this->getRequest()->getRequestedRouteName();
8
+
9
+ ?>
10
+
11
+ <fieldset class="form-list">
12
+ <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>?nocache=<?php echo rand(); ?>"/>
13
+
14
+ <div id="mercadopago_checkout_custom_ticket">
15
+ <ul class="form-list form-mercadopago" id="payment_form_<?php echo $_code ?>" style="display:none;">
16
+ <li>
17
+ <?php
18
+ if ($coupon_mercadopago):
19
+ $block = $this->getLayout()->createBlock('mercadopago/discount')->setCode($_code);
20
+ echo $block->toHtml();
21
+ ?>
22
+ <script type="text/javascript">
23
+ MercadoPagoCustom.getInstance().initDiscountTicket();
24
+ </script>
25
+ <?php
26
+ endif;
27
+ ?>
28
+ </li>
29
+ <br/>
30
+ <li class="mercadopago-discount-options">
31
+ <?php $optionsTicket = $this->getTicketsOptions(); ?>
32
+ <?php if (count($optionsTicket) == 1): ?>
33
+ <input type="hidden" name="payment[<?php echo $_code; ?>][payment_method_ticket]" type="text" value="<?php echo $optionsTicket[0]['id']; ?>" id="payment_method_ticket"/>
34
+ <?php else: ?>
35
+ <?php foreach ($optionsTicket as $ticket): ?>
36
+ <br/>
37
+ <input type="radio" name="payment[<?php echo $_code; ?>][payment_method_ticket]" class="optionsTicketMp validate-one-required-by-name" value="<?php echo $ticket['id']; ?>">
38
+ <img src="<?php echo $ticket['secure_thumbnail']; ?>">
39
+ <label class="mercadopago-ticket-label"> (<?php echo $ticket['name']; ?>)</label><br/>
40
+ <?php endforeach; ?>
41
+ <?php endif; ?>
42
+
43
+ <input type="hidden" class="total_amount" name="total_amount" value="<?php echo $grant_total; ?>"/>
44
+ <input type="hidden" class="amount" name="amount" value="<?php echo $grant_total; ?>"/>
45
+ <input type="hidden" class="site_id" name="site_id" value="<?php echo strtoupper($country); ?>"/>
46
+ <input type="hidden" class="mercadopago-discount-amount" name="mercadopago-discount-amount" value="0"/>
47
+ <input type="hidden" class="mercadopago-text-currency" value="<?php echo $this->__('$'); ?>">
48
+ <input type="hidden" class="mercadopago-text-choice" value="<?php echo $this->__('Choice'); ?>">
49
+ <input type="hidden" class="mercadopago-text-default-issuer" value="<?php echo $this->__('Default issuer'); ?>">
50
+ <input type="hidden" class="mercadopago-text-installment" value="<?php echo $this->__('Enter the card number'); ?>">
51
+ <input type="hidden" class="mercado_base_url" value="<?php echo $base_url; ?>">
52
+ <input type="hidden" class="mercado_route" value="<?php echo $route; ?>">
53
+ </li>
54
+
55
+ </ul>
56
+ </div>
57
+ <br/>
58
+ <?php if ($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
59
+ <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
60
+ <?php endif; ?>
61
+
62
+ </fieldset>
app/design/frontend/base/default/template/mercadopago/custom_ticket/info.phtml CHANGED
@@ -7,15 +7,15 @@
7
  ?>
8
 
9
 
10
- <?php if($info_payment['payment_id']['value'] != ""): ?>
11
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $info_payment['payment_id']['value']); ?></p>
12
  <?php endif; ?>
13
 
14
- <?php if($info_payment['status']['value'] != ""): ?>
15
  <p><?php echo $this->__('Payment Status: %s', $info_payment['status']['value']); ?></p>
16
  <?php endif; ?>
17
 
18
- <?php if($info_payment['status_detail']['value'] != ""): ?>
19
  <p><?php echo $this->__('Payment Status Detail: %s', $info_payment['status_detail']['value']); ?></p>
20
  <?php endif; ?>
21
 
7
  ?>
8
 
9
 
10
+ <?php if(isset($info_payment['payment_id']) && $info_payment['payment_id']['value'] != ""): ?>
11
+ <p><?php echo $this->__('Payment Id (Mercado Pago): %s', $info_payment['payment_id']['value']); ?></p>
12
  <?php endif; ?>
13
 
14
+ <?php if(isset($info_payment['status']) && $info_payment['status']['value'] != ""): ?>
15
  <p><?php echo $this->__('Payment Status: %s', $info_payment['status']['value']); ?></p>
16
  <?php endif; ?>
17
 
18
+ <?php if(isset($info_payment['status_detail']) && $info_payment['status_detail']['value'] != ""): ?>
19
  <p><?php echo $this->__('Payment Status Detail: %s', $info_payment['status_detail']['value']); ?></p>
20
  <?php endif; ?>
21
 
app/design/frontend/base/default/template/mercadopago/custom_ticket/success.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $order = $this->getOrder();
3
+ $total = $this->getTotal();
4
+ $payment = $this->getPayment();
5
+
6
+ //monta link para o pedido
7
+ $link_to_order = $this->__('Your order %s has been successfully generated.', '<a href="'. Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "sales/order/view/order_id/" . $this->getEntityId() . '">' . $order->getIncrementId() .'</a>');
8
+
9
+ $payment_method = $this->getPaymentMethod();
10
+ $info_payment = $this->getInfoPayment();
11
+ ?>
12
+
13
+ <div id="box-mercadopago">
14
+
15
+ <?php if($payment_method == 'mercadopago_customticket'): ?>
16
+ <h2 class="mercadopago-title"><?php echo $this->__('Thank you for your purchase!'); ?></h2>
17
+
18
+ <p>
19
+ <?php echo $link_to_order; ?>
20
+ </p>
21
+
22
+ <p>
23
+ <?php echo $this->__('Generate the ticket and pay it wherever you want.'); ?>
24
+ </p>
25
+ <p>
26
+ <?php echo $this->__('Will be approved within 2 business days.'); ?>
27
+ </p>
28
+ <a href="<?php echo urldecode($this->htmlEscape($payment->getAdditionalInformation('activation_uri'))); ?>" target="_blank" id="btn-boleto-mercadopago">
29
+ <?php echo $this->__('Generate Ticket'); ?>
30
+ </a>
31
+
32
+ <?php endif; ?>
33
+
34
+ </div>
35
+
36
+ <div id="logo-mercadopago">
37
+ <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
38
+ </div>
app/design/frontend/base/default/template/mercadopago/discount.phtml CHANGED
@@ -1,8 +1,8 @@
1
- <li>
2
  <div class="box-input">
3
  <label for="mercadopago_coupon"><?php echo $this->__('Discount coupon'); ?></label>
4
  <div class="input-box">
5
- <input class="mercadopago_coupon" type="text" class="input-text" type="text" name="payment[coupon_code]"/>
6
  </div>
7
  </div>
8
 
@@ -19,8 +19,8 @@
19
  <li class="error amount-doesnt-match transaction_amount_invalid validation-advice">
20
  <?php echo $this->__('The coupon can not be applied to this amount.'); ?>
21
  </li>
22
-
23
- <li class="error campaign-code-doesnt-match validation-advice">
24
  <?php echo $this->__("Doesn't find a campaign with the given code."); ?>
25
  </li>
26
 
@@ -34,7 +34,7 @@
34
  </li>
35
 
36
  <li class="ok discount-ok">
37
- <p><?php echo $this->__('You save %s with the exclusive discount', '<b><span class="amount-discount"></span></b>'); ?> <span class="mercadopago-focus">MercadoPago.</span></p>
38
  <p><?php echo $this->__('Total of your purchase'); ?>: <b><span class="total-amount"></span></b>.</p>
39
  <p><?php echo $this->__('Total of your purchase discount'); ?>: <b><span class="total-amount-discount"></span>*</b>.</p>
40
  <p><i>*<?php echo $this->__('Upon approval of payment'); ?></i></p>
1
+ <li class="mercadopago-discount-options">
2
  <div class="box-input">
3
  <label for="mercadopago_coupon"><?php echo $this->__('Discount coupon'); ?></label>
4
  <div class="input-box">
5
+ <input class="mercadopago_coupon input-text validate-discount" id="input-coupon-discount" type="text" type="text" name="payment[<?php echo $this->code; ?>][coupon_code]"/>
6
  </div>
7
  </div>
8
 
19
  <li class="error amount-doesnt-match transaction_amount_invalid validation-advice">
20
  <?php echo $this->__('The coupon can not be applied to this amount.'); ?>
21
  </li>
22
+
23
+ <li class="error campaign-code-doesnt-match collector-doesnt-match validation-advice">
24
  <?php echo $this->__("Doesn't find a campaign with the given code."); ?>
25
  </li>
26
 
34
  </li>
35
 
36
  <li class="ok discount-ok">
37
+ <p><?php echo $this->__('You save %s with the exclusive discount', '<b><span class="amount-discount"></span></b>'); ?> <span class="mercadopago-focus">Mercado Pago.</span></p>
38
  <p><?php echo $this->__('Total of your purchase'); ?>: <b><span class="total-amount"></span></b>.</p>
39
  <p><?php echo $this->__('Total of your purchase discount'); ?>: <b><span class="total-amount-discount"></span>*</b>.</p>
40
  <p><i>*<?php echo $this->__('Upon approval of payment'); ?></i></p>
app/design/frontend/base/default/template/mercadopago/onestepcheckout/custom/form.phtml ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $country = Mage::getStoreConfig('payment/mercadopago/country');
3
+ $coupon_mercadopago = Mage::getStoreConfig('payment/mercadopago_custom/coupon_mercadopago');
4
+ $_code = $this->getMethodCode();
5
+ $_quote = $this->helper('checkout/cart')->getQuote();
6
+ $grant_total = $_quote->getGrandTotal();
7
+ $_totals = $_quote->getTotals();
8
+ if (isset($_totals['mercadopago'])) {
9
+ $grant_total = $grant_total - $_totals['mercadopago']->getValue();
10
+ }
11
+ $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true);
12
+ $logEnabled= Mage::getStoreConfigFlag('payment/mercadopago/logs');
13
+ $route = $this->getRequest()->getRequestedRouteName();
14
+ $customer = $this->getCustomerAndCards();
15
+ ?>
16
+
17
+ <script>
18
+ MercadoPagoCustom.enableLog(<?php echo $logEnabled?>);
19
+ try {
20
+ TinyJ('#mercadopago_checkout_custom');
21
+ MercadoPagoCustom.getInstance().init();
22
+ } catch (exception) {
23
+ document.observe("dom:loaded", function() {
24
+ MercadoPagoCustom.getInstance().init();
25
+ });
26
+ }
27
+ </script>
28
+ <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>?nocache=<?php echo rand(); ?>"/>
29
+
30
+ <fieldset>
31
+ <div id="mercadopago_checkout_custom">
32
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
33
+
34
+
35
+ <?php
36
+ if ($coupon_mercadopago):
37
+ $block = $this->getLayout()->createBlock('mercadopago/discount')->setCode($_code);
38
+ echo $block->toHtml();
39
+ ?>
40
+ <script type="text/javascript">
41
+ try {
42
+ TinyJ('#mercadopago_checkout_custom');
43
+ MercadoPagoCustom.getInstance().initDiscount();
44
+ } catch (exception) {
45
+ document.observe("dom:loaded", function() {
46
+ MercadoPagoCustom.getInstance().initDiscount();
47
+ });
48
+ }
49
+ </script>
50
+ <?php
51
+ endif;
52
+ ?>
53
+
54
+ <?php if ($customer !== false && isset($customer['cards']) && count($customer['cards']) > 0): ?>
55
+ <li>
56
+ <ul id="mercadopago_checkout_custom_ocp">
57
+ <li id="cardId__mp">
58
+
59
+ <div><a id="use_other_card_mp" class="action_ocp"><?php echo $this->__('Use other card'); ?></a></div>
60
+
61
+ <label for="cardNumber"><?php echo $this->__('Payment Method'); ?></label>
62
+ <select id="cardId" name="payment[<?php echo $_code; ?>][cardId]" data-checkout="cardId" data-element-id="#cardId__mp">
63
+ <?php foreach ($customer['cards'] as $card) { ?>
64
+ <option value="<?php echo $card["id"]; ?>" first_six_digits="<?php echo $card["first_six_digits"]; ?>" security_code_length="<?php echo $card["security_code"]["length"]; ?>">
65
+
66
+ <?php echo $card["payment_method"]["name"].' '; ?><?php echo $this->__('ended in'); ?><?php echo ' '.$card["last_four_digits"]; ?>
67
+ </option>
68
+ <?php } ?>
69
+ </select>
70
+
71
+ <input type="hidden" name="payment[<?php echo $_code; ?>][customer_id]" value="<?php echo $customer['id']; ?>">
72
+
73
+ </li>
74
+
75
+ <li id="securityCodeOCP__mp">
76
+ <label for="securityCode"><?php echo $this->__('CVV'); ?></label>
77
+ <input type="text" id="securityCodeOCP" class="required-entry" data-checkout="securityCode" maxlength="4" data-element-id="#securityCodeOCP__mp"/>
78
+
79
+ <p class="message-error error-E302 error-224 validation-advice"><?php echo $this->__('CVV is invalid.'); ?></p>
80
+ </li>
81
+ </ul>
82
+ </li>
83
+
84
+ <script>
85
+ try {
86
+ TinyJ('#use_other_card_mp');
87
+ MercadoPagoCustom.getInstance().initOCP();
88
+ } catch (exception) {
89
+ document.observe("dom:loaded", function() {
90
+ MercadoPagoCustom.getInstance().initOCP();
91
+ });
92
+ }
93
+ </script>
94
+ <?php endif; ?>
95
+
96
+ <li>
97
+ <ul id="mercadopago_checkout_custom_card">
98
+ <li id="paymentMethod__mp">
99
+ <label for="paymentMethod"><?php echo $this->__('Payment Method'); ?></label>
100
+ <select id="paymentMethod" data-checkout="paymentMethod" name="payment[<?php echo $_code; ?>][paymentMethod]" data-element-id="#paymentMethod__mp" class="validate-select"></select>
101
+ </li>
102
+ <li id="cardNumber__mp">
103
+ <div><a id="return_list_card_mp" class="action_ocp"><?php echo $this->__('Return to cards list'); ?></a></div>
104
+
105
+ <label for="cardNumber"><?php echo $this->__('Card Number'); ?></label>
106
+ <input type="text" id="cardNumber" data-checkout="cardNumber" data-element-id="#cardNumber__mp"/>
107
+
108
+ <p class="message-error error-payment-method-not-found error-E301 error-205 validation-advice"><?php echo $this->__('Card number is invalid.'); ?></p>
109
+
110
+ <p class="message-error error-payment-method-min-amount validation-advice"><?php echo $this->__('Cannot pay this amount with this payment_method_id.'); ?></p>
111
+
112
+ </li>
113
+
114
+ <li id="issuer__mp">
115
+ <label for="issuer"><?php echo $this->__('Banks'); ?></label>
116
+ <select id="issuer" name="payment[<?php echo $_code; ?>][issuer_id]" data-checkout="issuer" data-element-id="#issuer__mp">
117
+
118
+ </select>
119
+
120
+ <p class="message-error error-220 validation-advice"><?php echo $this->__('Select issuer'); ?></p>
121
+ </li>
122
+
123
+ <li id="expiration_date__mp">
124
+ <div id="box_month">
125
+ <label for="cardExpirationMonth"><?php echo $this->__('Month'); ?></label>
126
+ <select id="cardExpirationMonth" data-checkout="cardExpirationMonth" class="mp-validate-cc-exp" name="payment[<?php echo $_code; ?>][card_expiration_month]" data-element-id="#expiration_date__mp">
127
+ <?php foreach ($this->getCcMonths() as $m => $v): ?>
128
+ <option value="<?php echo $m ? $m : ''; ?>"><?php echo $v; ?></option>
129
+ <?php endforeach ?>
130
+ </select>
131
+
132
+ <p class="message-error error-325 error-208 validation-advice"><?php echo $this->__('Month is invalid.'); ?></p>
133
+ </div>
134
+
135
+ <div id="box_year">
136
+ <label for="cardExpirationYear"><?php echo $this->__('Year'); ?></label>
137
+ <select id="cardExpirationYear" data-checkout="cardExpirationYear" name="payment[<?php echo $_code; ?>][card_expiration_year]" data-element-id="#expiration_date__mp">
138
+ <?php foreach ($this->getCcYears() as $y => $v): ?>
139
+ <option value="<?php echo $y ? $y : ''; ?>"><?php echo $v; ?></option>
140
+ <?php endforeach ?>
141
+ </select>
142
+
143
+ <p class="message-error error-326 error-209 validation-advice"><?php echo $this->__('Year is invalid.'); ?></p>
144
+ </div>
145
+ </li>
146
+
147
+ <li id="cardholderName__mp">
148
+ <label for="cardholderName"><?php echo $this->__('Card Holder Name'); ?></label>
149
+ <input type="text" id="cardholderName" data-checkout="cardholderName" name="payment[<?php echo $_code; ?>][card_holder_name]" data-element-id="#cardholderName__mp"/>
150
+
151
+ <p class="message-error error-316 validation-advice"><?php echo $this->__('Card Holder Name is invalid.'); ?></p>
152
+ </li>
153
+
154
+ <li id="securityCode__mp">
155
+ <label for="securityCode"><?php echo $this->__('CVV'); ?></label>
156
+ <input type="text" id="securityCode" data-checkout="securityCode" maxlength="4" data-element-id="#securityCode__mp" class="required-entry"/>
157
+
158
+ <p class="message-error error-E302 error-224 validation-advice"><?php echo $this->__('CVV is invalid.'); ?></p>
159
+ </li>
160
+
161
+ <li id="doc_type__mp">
162
+ <label for="docType"><?php echo $this->__('Document Type'); ?></label>
163
+ <select id="docType" data-checkout="docType" data-element-id="#doc_type__mp" name="payment[<?php echo $_code; ?>][doc_type]"></select>
164
+
165
+ <p class="message-error error-322 error-212 validation-advice"><?php echo $this->__('Document Type is invalid.'); ?></p>
166
+ </li>
167
+
168
+ <li id="doc_number__mp">
169
+ <label for="docNumber"><?php echo $this->__('Document Number'); ?></label>
170
+ <input type="text" id="docNumber" class="mp-validate-docnumber" data-checkout="docNumber" name="payment[<?php echo $_code; ?>][doc_number]" data-element-id="#doc_number__mp"/>
171
+
172
+ <p class="message-error error-324 error-213 error-214 validation-advice"><?php echo $this->__('Document Number is invalid.'); ?></p>
173
+ </li>
174
+
175
+ </ul>
176
+ </li>
177
+
178
+ <li id="installments__mp">
179
+ <label for="installments"><?php echo $this->__('Installments'); ?></label>
180
+ <select id="installments" name="payment[<?php echo $_code; ?>][installments]" data-element-id="#installments__mp" class="validate-select"></select>
181
+
182
+ <p class="message-error error-installment-not-work validation-advice"><?php echo $this->__('It was not possible to calculate the installments, click here and try again.'); ?></p>
183
+
184
+ <p class="message-error error-011 validation-advice"><?php echo $this->__('An error has occurred. Please refresh the page.'); ?></p>
185
+
186
+ <p class="message-error error-other validation-advice"><?php echo $this->__('Please validate your data.'); ?></p>
187
+
188
+ </li>
189
+ <li>
190
+ <div id="mercadopago-loading">
191
+ <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif'); ?>" alt="loading"/>
192
+ </div>
193
+ </li>
194
+
195
+ <li>
196
+
197
+ <?php if ($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
198
+ <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
199
+ <?php endif; ?>
200
+
201
+ <input type="hidden" class="total_amount" name="total_amount" value="<?php echo $grant_total; ?>"/>
202
+ <input type="hidden" class="amount" name="amount" value="<?php echo $grant_total; ?>"/>
203
+ <input type="hidden" class="mercadopago-discount-amount" name="mercadopago-discount-amount" value="0"/>
204
+ <input type="hidden" class="site_id" name="site_id" value="<?php echo strtoupper($country); ?>"/>
205
+ <input type="hidden" class="mercadopago-text-currency" value="<?php echo $this->__('$'); ?>">
206
+ <input type="hidden" class="mercadopago-text-choice" value="<?php echo $this->__('Choice'); ?>">
207
+ <input type="hidden" class="mercadopago-text-default-issuer" value="<?php echo $this->__('Default issuer'); ?>">
208
+ <input type="hidden" class="mercadopago-text-installment" value="<?php echo $this->__('Enter the card number'); ?>">
209
+ <input type="hidden" class="mercado_base_url" value="<?php echo $base_url; ?>">
210
+ <input type="hidden" class="mercado_route" value="<?php echo $route; ?>">
211
+ <input type="hidden" name="payment[<?php echo $_code; ?>][token]" type="text" value="" class="token"/>
212
+ <input type="hidden" name="payment[<?php echo $_code; ?>][payment_method_id]" type="text" value="" class="payment_method_id"/>
213
+
214
+ <input type="hidden" id="one_click_pay_mp" name="payment[<?php echo $_code; ?>][one_click_pay]" value="<?php echo count($customer['cards']) > 0 ? 1 : 0; ?>">
215
+ </li>
216
+ </ul>
217
+ </div>
218
+ </fieldset>
app/design/frontend/base/default/template/mercadopago/standard/form.phtml CHANGED
@@ -1,12 +1,12 @@
1
-
2
- <fieldset class="form-list">
3
- <!--<link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" /> -->
4
-
5
- <?php $_code = $this->getMethodCode(); ?>
6
- <?php $_country = $this->getMethodCountry(); ?>
7
-
8
- <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
9
- <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
10
- <?php endif;?>
11
-
12
- </fieldset>
1
+
2
+ <fieldset class="form-list">
3
+ <!--<link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" /> -->
4
+
5
+ <?php $_code = $this->getMethodCode(); ?>
6
+ <?php $_country = $this->getMethodCountry(); ?>
7
+
8
+ <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
9
+ <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
10
+ <?php endif;?>
11
+
12
+ </fieldset>
app/design/frontend/base/default/template/mercadopago/standard/info.phtml CHANGED
File without changes
app/design/frontend/base/default/template/mercadopago/standard/pay.phtml CHANGED
File without changes
app/design/frontend/base/default/template/mercadopago/standard/success.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $order = $this->getOrder();
3
+ $total = $this->getTotal();
4
+ $payment = $this->getPayment();
5
+
6
+ //monta link para o pedido
7
+ $link_to_order = $this->__('Your order %s has been successfully generated.', '<a href="'. Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "sales/order/view/order_id/" . $this->getEntityId() . '">' . $order->getIncrementId() .'</a>');
8
+
9
+ $payment_method = $this->getPaymentMethod();
10
+ $info_payment = $this->getInfoPayment();
11
+ ?>
12
+
13
+ <div id="box-mercadopago">
14
+
15
+ <?php if(!isset($info_payment['status']['value'])): ?>
16
+ <h2 class="mercadopago-title"><?php echo $this->__('Thank you for your purchase!'); ?></h2>
17
+ <p><?php echo $link_to_order; ?></p>
18
+ <?php else: ?>
19
+ <?php
20
+ $message_status = $this->getMessageByStatus(
21
+ $info_payment['status']['value'],
22
+ $info_payment['status_detail']['value'],
23
+ (isset($info_payment['payment_method']['value'])) ? $info_payment['payment_method']['value'] : '',
24
+ (isset($info_payment['installment']['value'])) ? $info_payment['installment']['value'] : '' ,
25
+ $this->getTotal()
26
+ );
27
+
28
+ ?>
29
+ <h2 class="mercadopago-title"><?php echo $message_status['title']; ?></h2>
30
+
31
+ <p><?php echo $message_status['message']; ?></p>
32
+
33
+ <p><?php echo $link_to_order; ?></p>
34
+
35
+ <h5 class="mercadopago-title-info-payment"><?php echo $this->__('Payment information'); ?></h5>
36
+
37
+ <?php foreach($info_payment as $info): ?>
38
+ <p><?php echo $info['text']; ?></p>
39
+ <?php endforeach; ?>
40
+ <?php endif ?>
41
+ </div>
42
+
43
+ <div id="logo-mercadopago">
44
+ <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
45
+ </div>
app/design/frontend/base/default/template/mercadopago/success.phtml DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- $order = $this->getOrder();
3
- $total = $this->getTotal();
4
- $payment = $this->getPayment();
5
-
6
- //monta link para o pedido
7
- $link_to_order = $this->__('Your order %s has been successfully generated.', '<a href="'. Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "sales/order/view/order_id/" . $this->getEntityId() . '">' . $order->getIncrementId() .'</a>');
8
-
9
- $payment_method = $this->getPaymentMethod();
10
- $info_payment = $this->getInfoPayment();
11
- ?>
12
-
13
- <div id="box-mercadopago">
14
-
15
- <?php if($payment_method == 'mercadopago_customticket'): ?>
16
- <h2 class="mercadopago-title"><?php echo $this->__('Thank you for your purchase!'); ?></h2>
17
-
18
- <p>
19
- <?php echo $link_to_order; ?>
20
- </p>
21
-
22
- <p>
23
- <?php echo $this->__('Generate the ticket and pay it wherever you want.'); ?>
24
- </p>
25
- <p>
26
- <?php echo $this->__('Will be approved within 2 business days.'); ?>
27
- </p>
28
- <a href="<?php echo urldecode($this->htmlEscape($payment->getAdditionalInformation('activation_uri'))); ?>" target="_blank" id="btn-boleto-mercadopago">
29
- <?php echo $this->__('Generate Ticket'); ?>
30
- </a>
31
-
32
- <?php endif; ?>
33
-
34
-
35
- <?php
36
- if($payment_method == 'mercadopago_standard' || $payment_method == 'mercadopago_custom'):
37
-
38
- if(!isset($info_payment['status']['value'])){
39
- //caso não exista informações sobre o pagamento
40
- ?>
41
- <h2 class="mercadopago-title"><?php echo $this->__('Thank you for your purchase!'); ?></h2>
42
- <p><?php echo $link_to_order; ?></p>
43
- <?php
44
- }else{
45
- //caso exista informações sobre o pagamento
46
- $message_status = $this->getMessageByStatus(
47
- $info_payment['status']['value'],
48
- $info_payment['status_detail']['value'],
49
- $info_payment['payment_method']['value'],
50
- $info_payment['installment']['value'],
51
- $this->getTotal()
52
- );
53
-
54
- ?>
55
- <h2 class="mercadopago-title"><?php echo $message_status['title']; ?></h2>
56
-
57
- <p><?php echo $message_status['message']; ?></p>
58
-
59
- <p><?php echo $link_to_order; ?></p>
60
-
61
- <h5 class="mercadopago-title-info-payment"><?php echo $this->__('Payment information'); ?></h5>
62
-
63
- <?php foreach($info_payment as $info): ?>
64
- <p><?php echo $info['text']; ?></p>
65
- <?php endforeach; ?>
66
-
67
- <?php
68
- } //end if exist informações do pagamento
69
- ?>
70
-
71
- <?php endif; ?>
72
-
73
-
74
- </div>
75
-
76
- <div id="logo-mercadopago">
77
- <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
78
- </div>
79
-
80
- <style>
81
- .mercadopago-title{
82
- margin: 0 0 10px 0;
83
- font-weight:bold;
84
- }
85
- .mercadopago-title-info-payment{
86
- margin: 20px 0 10px 0;
87
- }
88
-
89
- #btn-boleto-mercadopago{
90
- font-size: 1.25em;
91
- text-align: center;
92
- line-height: 1.25em;
93
- padding: 6px 12px;
94
- font-family: 'Lato',sans-serif;
95
- font-weight: 400;
96
- background-color: #36A1F1;
97
- background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#36A1F1),color-stop(100%,#0F79C9));
98
- background-image: -webkit-linear-gradient(#36A1F1,#0F79C9);
99
- background-image: -moz-linear-gradient(#36A1F1,#0F79C9);
100
- background-image: -o-linear-gradient(#36A1F1,#0F79C9);
101
- background-image: linear-gradient(#36A1F1,#0F79C9);
102
- -webkit-box-shadow: inset 0 1px #97DCFF;
103
- box-shadow: 0 1px #97DCFF inset;
104
- color: #FFF!important;
105
- border: 1px solid #0D6FB9;
106
- border-radius: 4px 4px 4px 4px;
107
- cursor: pointer;
108
- display: inline-block;
109
- text-decoration:none;
110
- }
111
- #btn-boleto-mercadopago:hover{
112
- background-color:#4CBFF8;
113
- background-image:linear-gradient(#4CBFF8,#1699DF);
114
- box-shadow:0 1px #B6EBFF inset;
115
- background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#4CBFF8),color-stop(100%,#1699DF));
116
- background-image:-webkit-linear-gradient(#4CBFF8,#1699DF);
117
- background-image:-moz-linear-gradient(#4CBFF8,#1699DF);
118
- background-image:-o-linear-gradient(#4CBFF8,#1699DF);
119
- background-image:linear-gradient(#4CBFF8,#1699DF);-webkit-box-shadow:inset 0 1px #B6EBFF;
120
- border:1px solid #1890D3;
121
- color:#FFF;
122
- text-decoration:none;
123
- }
124
-
125
- #logo-mercadopago{
126
- width: 100px;
127
- margin: 20px 0;
128
- float: left;
129
- }
130
-
131
- #logo-mercadopago img{
132
- float: left;
133
- width: 100%;
134
- }
135
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/{MercadoPago.xml → MercadoPago_Core.xml} RENAMED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <MercadoPago>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- </MercadoPago>
8
  </modules>
9
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <MercadoPago_Core>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ </MercadoPago_Core>
8
  </modules>
9
  </config>
app/etc/modules/MercadoPago_MercadoEnvios.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MercadoPago_MercadoEnvios>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <MercadoPago_Core />
9
+ </depends>
10
+ </MercadoPago_MercadoEnvios>
11
+ </modules>
12
+ </config>
app/etc/modules/MercadoPago_OneStepCheckout.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MercadoPago_OneStepCheckout>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <MercadoPago_Core />
9
+ </depends>
10
+ </MercadoPago_OneStepCheckout>
11
+ </modules>
12
+ </config>
app/locale/en_US/MercadoPago_Core.csv ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Enabled"
2
+
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuration"
4
+ "Credit Card - Mercado Pago","Credit Card - Mercado Pago"
5
+
6
+ "Mercado Pago Custom - Credit Card","Mercado Pago Custom - Credit Card"
7
+ "Payment Title","Payment Title"
8
+ "Category of your store","Category of your store"
9
+ "Choose the status of approved orders","Choose the status of approved orders"
10
+ "Choose the status of refunded orders","Choose the status of refunded orders"
11
+ "Choose the status when payment is pending","Choose the status when payment is pending"
12
+ "Choose the status when client open a mediation","Choose the status when client open a mediation"
13
+ "Choose the status when payment was reject","Choose the status when payment was reject"
14
+ "Choose the status when payment was canceled","Choose the status when payment was canceled"
15
+ "Checkout Position","Checkout Position"
16
+ "To manage the status available go to System > Order Statuses","To manage the status available go to System > Order Statuses"
17
+
18
+ "Mercado Pago Custom - Ticket","Mercado Pago Custom - Ticket"
19
+
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Credit Card, Ticket and Account Money"
21
+ "Country","Country"
22
+ "Type Checkout","Type Checkout"
23
+ "Auto Redirect","Auto Redirect"
24
+ "Exclude Payment Methods","Exclude Payment Methods"
25
+ "Maximum number of accepted installments","Maximum number of accepted installments"
26
+ "Width Checkout Iframe","Width Checkout Iframe"
27
+ "Height Checkout Iframe","Height Checkout Iframe"
28
+ "Auto-redirect the buyer when finishing the payment.","Auto-redirect the buyer when finishing the payment."
29
+ "Select payment methods not accepted","Select payment methods not accepted"
30
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'"
32
+
33
+ "Card Number","Card Number"
34
+ "Month","Month"
35
+ "Year","Year"
36
+ "Card Holder Name","Card Holder Name"
37
+ "Document Number","Document Number"
38
+ "CVV","CVV"
39
+ "Installments","Installments"
40
+ "Banks","Banks"
41
+
42
+ "Enter the card number","Enter the card number"
43
+ "Validating Data","Validating Data"
44
+ "An error has occurred. Please refresh the page.","An error has occurred. Please refresh the page."
45
+ "Card number is invalid.","Card number is invalid."
46
+ "CVV is invalid.","CVV is invalid."
47
+ "Card Holder Name is invalid.","Card Holder Name is invalid."
48
+ "Document Number is invalid.","Document Number is invalid."
49
+ "Document Type is invalid.","Document Type is invalid."
50
+ "Year is invalid.","Year is invalid."
51
+ "Month is invalid.","Month is invalid."
52
+ "Please validate your data.","Please validate your data."
53
+ "Cannot pay this amount with this payment_method_id.","Cannot pay this amount with this payment_method_id."
54
+
55
+ "Card Number: %s","Card Number: %s"
56
+ "Card Holder Name: %s","Card Holder Name: %s"
57
+ "Payment Method: %s","Payment Method: %s"
58
+ "Expiration Date: %s","Expiration Date: %s"
59
+ "Installments: %s","Installments: %s"
60
+ "Statement Descriptor: %s","Statement Descriptor: %s"
61
+ "Payment Id (Mercado Pago): %s","Payment Id (Mercado Pago): %s"
62
+ "Payment Status: %s (%s)","Payment Status: %s (%s)"
63
+
64
+ "Click on the link to generate the ticket","Click on the link to generate the ticket"
65
+ "Generate Ticket","Generate Ticket"
66
+
67
+ "Payment Method","Payment Method"
68
+
69
+ "Generate the ticket and pay it wherever you want.","Generate the ticket and pay it wherever you want."
70
+ "Will be approved within 2 business days.","Will be approved within 2 business days."
71
+
72
+
73
+
74
+ "Thank you for your purchase!","Thank you for your purchase!"
75
+ "Your order %s has been successfully generated.","Your order %s has been successfully generated."
76
+ "Done, your payment was accredited!","Done, your payment was accredited!"
77
+ "We are processing the payment.","We are processing the payment."
78
+ "In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.","In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information."
79
+ "In less than an hour we will send you by e-mail the result.","In less than an hour we will send you by e-mail the result."
80
+
81
+ "Check the card number.","Check the card number."
82
+ "Check the expiration date.","Check the expiration date."
83
+ "Check the data.","Check the data."
84
+ "Check the security code.","Check the security code."
85
+ "We could not process your payment.","We could not process your payment."
86
+
87
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","You must authorize to %s the payment of $ %s to Mercado Pago."
88
+ "Call %s to activate your card.<br/>The phone is on the back of your card.","Call %s to activate your card.<br/>The phone is on the back of your card."
89
+ "We could not process your payment.","We could not process your payment."
90
+ "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","You already made a payment by that value.<br/>If you need to repay, use another card or other payment method."
91
+ "Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.","Your payment was rejected.<br/>Choose another payment method, we recommend cash methods."
92
+ "Your %s do not have sufficient funds.","Your %s do not have sufficient funds."
93
+ "%s does not process payments in %s installments.","%s does not process payments in %s installments."
94
+ "You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.","You have got to the limit of allowed attempts.<br/>Choose another card or another payment method."
95
+ "%s did not process the payment.","%s did not process the payment."
96
+
97
+ "You can not make payments to users in other countries.","You can not make payments to users in other countries."
98
+ "Payment Method selected does not process payments in installments selected. Choose another card or another payment method.","Payment Method selected does not process payments in installments selected. Choose another card or another payment method."
99
+ "We could not process your payment. Error code: 126.","We could not process your payment. Error code: 126."
100
+ "Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.","Payment Method selected does not process payments for the selected amount. Choose another card or another payment method."
101
+ "We could not process your payment. Error code: 145.","We could not process your payment. Error code: 145."
102
+ "You can not make payments. Error code: 150.","You can not make payments. Error code: 150."
103
+ "You can not make payments.","You can not make payments."
104
+ "We could not process your payment. Error code: 160.","We could not process your payment. Error code: 160."
105
+ "Payment Method selected is not available at this time. Choose another card or another payment method.","Payment Method selected is not available at this time. Choose another card or another payment method."
106
+ "You made a similar payment moments ago. Try again in a few minutes.","You made a similar payment moments ago. Try again in a few minutes."
107
+ "We could not process your payment. %s","We could not process your payment. %s"
108
+
109
+ "Verify the form data or wait until the validation of the payment data","Verify the form data or wait until the validation of the payment data"
110
+
111
+ "Automatic notification of the Mercado Pago: The payment was approved.","Automatic notification of the Mercado Pago: The payment was approved."
112
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Automatic notification of the Mercado Pago: The payment was refunded."
113
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Automatic notification of the Mercado Pago: The payment is being processed."
114
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days."
115
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information."
116
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Automatic notification of the Mercado Pago: The payment was cancelled."
117
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Automatic notification of the Mercado Pago: The payment was rejected."
118
+ "<br/> Payment id: %s","<br/> Payment id: %s"
119
+ "<br/> Status: %s","<br/> Status: %s"
120
+ "<br/> Status Detail: %s","<br/> Status Detail: %s"
121
+
122
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials"
123
+ "Choose the status when payment was chargeback", "Choose the status when payment was chargeback"
124
+
125
+ "Cannot operate between users from different countries.","Cannot operate between users from different countries."
126
+ "Payment method does not process installments.","Payment method does not process installments. Choose another credit card or payment method."
127
+ "Cannot pay this amount with this paymentMethod.","Cannot pay this amount with this paymentMethod. Choose another credit card or payment method."
128
+ "You user cannot do payments currently","You user cannot do payments currently."
129
+ "You user cannot do payments currently with this payment method.","You user cannot do payments currently with this payment method."
130
+ "Unavailable paymentmethod currently.","Unavailable paymentmethod currently."
131
+ "Already posted the same request in the last minute.","Already posted the same request in the last minute. Retry later."
132
+ "Doesn't find a campaign with the given code.", "Doesn't find a campaign with the given code."
133
+ "We could not process your payment in this moment. Please check the form data and retry later","We could not process your payment in this moment. Please check the form data and retry later"
134
+
135
+ "The items Quantity has exceeded the limits. We could not process your payment.", "The items Quantity has exceeded the limits. We could not process your payment."
136
+ "Already posted the same request in the last minute.", "Already posted the same request in the last minute."
137
+ "The transaction amount is invalid. We could not process your payment.", "The transaction amount is invalid. We could not process your payment."
138
+ "You user cannot do payments currently", "You user cannot do payments currently"
139
+ "You have exceeded the max number of refunds for this payment.", "You have exceeded the max number of refunds for this payment."
140
+ "Payment too old to be refunded", "Payment too old to be refunded"
141
+ "Coupon code is invalid", "Coupon code is invalid"
142
+ "Your user e-mail does not exist. Please check data and retry later", "Your user e-mail does not exist. Please check data and retry later"
143
+ "You must provide your cardholder name with your card data", "You must provide your cardholder name with your card data"
144
+ "Not found payment method or credit card. Please check the form data and retry.", "Not found payment method or credit card. Please check the form data and retry."
145
+ "Security code is invalid. Please check the form data and retry.", "Security code is invalid. Please check the form data and retry."
146
+ "Security code is a required field. Please check the form data and retry.", "Security code is a required field. Please check the form data and retry."
147
+ "Payment method or credit card invalid. Please check the form data and retry.", "Payment method or credit card invalid. Please check the form data and retry."
148
+ "Credit card number is invalid. Please check the form data and retry.", "Credit card number is invalid. Please check the form data and retry."
149
+ "Expiration month can not be empty. Please check the form data and retry.", "Expiration month can not be empty. Please check the form data and retry."
150
+ "Expiration year can not be empty. Please check the form data and retry.", "Expiration year can not be empty. Please check the form data and retry."
151
+ "Cardholder name can not empty. Please check the form data and retry.", "Cardholder name can not empty. Please check the form data and retry."
152
+ "Cardholder document number can not be empty. Please check the form data and retry.", "Cardholder document number can not be empty. Please check the form data and retry."
153
+ "Cardholder document type can not be empty. Please check the form data and retry.", "Cardholder document type can not be empty. Please check the form data and retry."
154
+ "Cardholder document subtype can not be empty. Please check the form data and retry.", "Cardholder document subtype can not be empty. Please check the form data and retry."
155
+ "Expiration month is invalid. Please check the form data and retry.", "Expiration month is invalid. Please check the form data and retry."
156
+ "Expiration year is invalid. Please check the form data and retry.", "Expiration year is invalid. Please check the form data and retry."
157
+ "Installments attribute can not be empty. Please check the form data and retry.", "Installments attribute can not be empty Please check the form data and retry."
158
+ "Coupon amount is invalid. Please check the form data and retry.", "Coupon amount is invalid. Please check the form data and retry."
159
+ "Doesn't find a campaign to amount given", "Doesn't find a campaign to amount given"
160
+ "Amount discount is invalid", "Amount discount is invalid"
161
+
162
+ "Mercado Pago - Classic Checkout: Invalid client id or client secret","Mercado Pago - Classic Checkout: Invalid client id or client secret"
163
+ "Mercado Pago - Custom Checkout: Invalid access token","Mercado Pago - Custom Checkout: Invalid access token"
164
+ "(estimated date %s)","(estimated date %s)"
165
+ "MercadoEnvios is not enabled in the country where Mercado Pago is configured", "MercadoEnvios is not enabled in the country where Mercado Pago is configured"
166
+ "Discount Mercado Pago","Discount Mercado Pago"
app/locale/es_AR/MercadoPago_Core.csv ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Activo"
2
+
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuración"
4
+ "Credit Card - Mercado Pago","Tarjetas de crédito - Mercado Pago"
5
+
6
+ "Mercado Pago Custom - Credit Card","Mercado Pago Custom - Tarjeta de Crédito"
7
+ "Payment Title","Título"
8
+ "Category of your store","Categoria de la tienda"
9
+ "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
10
+ "Choose the status of refunded orders","Elija el estado de los pedidos para pagos Devueltos"
11
+ "Choose the status when payment is pending","Elija el estado de los pedidos para pagos Pendientes"
12
+ "Choose the status when client open a mediation","Elija el estado de los pedidos para pagos en Disputa"
13
+ "Choose the status when payment was reject","Elija el estado de los pedidos para pagos Rechazados"
14
+ "Choose the status when payment was canceled","Elija el estado de los pedidos para pagos Cancelados"
15
+ "Checkout Position","Posición en el Checkout"
16
+ "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
+
18
+ "Mercado Pago Custom - Ticket","Mercado Pago Custom - Tickets de pago"
19
+
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
+ "Country","País"
22
+ "Type Checkout","Tipo de Checkout"
23
+ "Auto Redirect","Auto-Redireccionar"
24
+ "Exclude Payment Methods","Excluir Medios de Pago"
25
+ "Maximum number of accepted installments","Numero maximo de cuotas"
26
+ "Width Checkout Iframe","Ancho de la zona del Checkout (Iframe)"
27
+ "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
+ "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
+ "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
32
+
33
+ "Card Number","Número de Tarjeta"
34
+ "Month","Mes"
35
+ "Year","Año"
36
+ "Card Holder Name","Titular de la Tarjeta"
37
+ "Document Number","Número de Documento"
38
+ "CVV","Código de Seguridad"
39
+ "Installments","Cuotas"
40
+ "Banks","Bancos"
41
+
42
+ "Enter the card number","Digite el número de tarjeta"
43
+ "Validating Data","Validando datos"
44
+ "An error has occurred. Please refresh the page.","Ocurrio un error. Por favor, actualice la página."
45
+ "Card number is invalid.","Número de Tarjeta inválido."
46
+ "CVV is invalid.","Código de Seguridad inválido."
47
+ "Card Holder Name is invalid.","Nombre de titular de tarjeta inválido."
48
+ "Document Number is invalid.","Número de Documento inválido."
49
+ "Document Type is invalid.","Tipo de Documento inválido."
50
+ "Year is invalid.","Año inválido."
51
+ "Month is invalid.","Mes inválido."
52
+ "Please validate your data.","Por favor, valide los datos"
53
+ "Cannot pay this amount with this payment_method_id.","No se puede pagar esta monto con este medio de pago."
54
+
55
+ "Card Number: %s","Número de Tarjeta: %s"
56
+ "Card Holder Name: %s","Titular de la Tarjeta: %s"
57
+ "Payment Method: %s","Medio de pago: %s"
58
+ "Expiration Date: %s","Fecha de Expiración: %s"
59
+ "Installments: %s","Cuotas: %s"
60
+ "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
+ "Payment Id (Mercado Pago): %s","Número de Pago (Mercado Pago): %s"
62
+ "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
+
64
+ "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
65
+ "Generate Ticket","Generar ticket de pago"
66
+
67
+ "Payment Method","Medio de pago"
68
+
69
+ "Generate the ticket and pay it wherever you want.","Genere el ticket de pago y pague"
70
+ "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
71
+
72
+
73
+
74
+ "Thank you for your purchase!","Gracias por su compra!"
75
+ "Your order %s has been successfully generated.","Su pedido con el numero %s fué generado con éxito."
76
+ "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
77
+ "We are processing the payment.","Estamos procesando el pago."
78
+ "In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.","Estamos procesando el pago. En menos de 2 días hábiles te avisaremos por e-mail si se acreditó o si necesitamos más información."
79
+ "In less than an hour we will send you by e-mail the result.","Estamos procesando el pago. En menos de una hora te avisaremos por e-mail el resultado."
80
+
81
+ "Check the card number.","Revisa el número de la tarjeta."
82
+ "Check the expiration date.","Revisa la fecha de vencimiento."
83
+ "Check the data.","Revisa los datos."
84
+ "Check the security code.","Revisa el código de seguridad."
85
+ "We could not process your payment.","No pudimos procesar tu pago."
86
+
87
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","Debes llamar y autorizar ante %s el pago de $ %s a Mercado Pago"
88
+ "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
89
+ "We could not process your payment.","No pudimos procesar tu pago."
90
+ "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
91
+ "Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.","Tu pago fue rechazado.<br/>Elige otro de los medios de pago, te recomendamos con medios de pago en efectivo."
92
+ "Your %s do not have sufficient funds.","Tu %s no tiene fondos suficientes."
93
+ "%s does not process payments in %s installments.","%s no procesa pagos en %s cuotas."
94
+ "You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.","Llegaste al límite de intentos permitidos.<br/>Elige otra tarjeta u otro medio de pago."
95
+ "%s did not process the payment.","%s no procesó el pago."
96
+
97
+ "You can not make payments to users in other countries.","No puedes realizar pagos a usuarios de otros países."
98
+ "Payment Method selected does not process payments in installments selected. Choose another card or another payment method.","El medio de pago seleccionado no procesa pagos en la cuota seleccionada. Elige otra tarjeta u otro medio de pago."
99
+ "We could not process your payment. Error code: 126.","No pudimos procesar tu pago. Código de error: 126."
100
+ "Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.","El medio de pago seleccionado no procesa pagos del monto seleccionado. Elige otro medio de pago."
101
+ "We could not process your payment. Error code: 145.","No pudimos procesar tu pago. Código de error: 145"
102
+ "You can not make payments. Error code: 150.","No puedes realizar pagos. Código de error: 150."
103
+ "You can not make payments.","No puedes realizar pagos."
104
+ "We could not process your payment. Error code: 160.","No pudimos procesar tu pago. Código de error: 160."
105
+ "Payment Method selected is not available at this time. Choose another card or another payment method.","El medio de pago seleccionado no está disponible en este momento. Elige otra tarjeta u otro medio de pago."
106
+ "You made a similar payment moments ago. Try again in a few minutes.","Realizaste un pago similar hace instantes. Intenta nuevamente en unos minutos."
107
+ "We could not process your payment. %s","No pudimos procesar tu pago. %s"
108
+
109
+ "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
110
+
111
+ "Automatic notification of the Mercado Pago: The payment was approved.","Notificación automática de Mercado Pago: El pago fué aprobado."
112
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Notificación automática de Mercado Pago: El pago fué devuelto."
113
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Notificación automática de Mercado Pago: El pago esta siendo procesado."
114
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de Mercado Pago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
115
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Notificación automática de Mercado Pago: El pago está en un proceso de disputa, chequea tu cuenta de Mercado Pago para mayor información."
116
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Notificación automática de Mercado Pago: El pago fué cancelado."
117
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Notificación automática de Mercado Pago: El pago fué rechazado."
118
+ "<br/> Payment id: %s","<br/> Número de Pago: %s"
119
+ "<br/> Status: %s","<br/> Estado: %s"
120
+ "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
121
+
122
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtén tu public_key en la siguiente dirección: https://www.mercadopago.com/mla/account/credentials"
123
+ "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
124
+
125
+ "Cannot operate between users from different countries.","No es posible realizar pagos a usuarios de otros países."
126
+ "Payment method does not process installments.","El medio de pago no procesa pagos en cuotas. Elige otra tarjeta u otro medio de pago."
127
+ "Cannot pay this amount with this paymentMethod.","El medio de pago no procesa pagos del monto seleccionado. Elige otra tarjeta u otro medio de pago."
128
+ "You user cannot do payments currently","No puedes realizar pagos en este momento."
129
+ "You user cannot do payments currently with this payment method.","No puedes realizar pagos con este medio de pago en este momento."
130
+ "Unavailable paymentmethod currently.","El medio de pago no está disponible en este momento, elige otra tarjeta o medio de pago."
131
+ "Already posted the same request in the last minute.","Realizaste un pago similar hace instantes. Intenta nuevamente en unos minutos."
132
+ "Doesn't find a campaign with the given code.", "No se ha encontrado una campaña de descuento con el código indicado."
133
+ "We could not process your payment in this moment. Please check the form data and retry later","No es posible procesar su pago en este momento. Por favor verifique los datos ingresados y vuelva a intentarlo."
134
+
135
+ "The items Quantity has exceeded the limits. We could not process your payment.", "La cantidad de ítems ha excedido el límite. No es posible procesar su pago."
136
+ "Already posted the same request in the last minute.", "Realizaste un pago similar hace instantes. Intenta nuevamente en unos minutos."
137
+ "The transaction amount is invalid. We could not process your payment.", "El monto de la transacción es inválido. No es posible procesar su pago."
138
+ "You user cannot do payments currently", "No puedes realizar pagos en este momento."
139
+ "You have exceeded the max number of refunds for this payment.", "Has excedido el máximo número de devoluciones para este pago"
140
+ "Payment too old to be refunded", "El pago es demasiado antiguo para ser devuelto"
141
+ "Coupon code is invalid", "Código de cupón inválido"
142
+ "Your user e-mail does not exist. Please check data and retry later", "Tu dirección de e-mail no existe. Por favor verifique los datos ingresados y vuelva a intentarlo."
143
+ "You must provide your cardholder name with your card data", "Debes ingresar el titular de la tarjeta"
144
+ "Not found payment method or credit card. Please check the form data and retry.", "No se encontró el método de pago o tarjeta de crédito. Por favor verifique los datos ingresados y vuelva a intentarlo."
145
+ "Security code is invalid. Please check the form data and retry.", "El código de seguridad de la tarjeta no es válido. Por favor verifique los datos ingresados y vuelva a intentarlo."
146
+ "Security code is a required field. Please check the form data and retry.", "Debe ingresar el código de seguridad de la tarjeta. Por favor verifique los datos ingresados y vuelva a intentarlo."
147
+ "Payment method or credit card invalid. Please check the form data and retry.", "El método de pago o tarjeta de crédito son inválidos. Por favor verifique los datos ingresados y vuelva a intentarlo."
148
+ "Credit card number is invalid. Please check the form data and retry.", "El número de la tarjeta de crédito es inválido. Por favor verifique los datos ingresados y vuelva a intentarlo."
149
+ "Expiration month can not be empty. Please check the form data and retry.", "El mes de expiración de la tarjeta no puede estar vacío. Por favor verifique los datos ingresados y vuelva a intentarlo."
150
+ "Expiration year can not be empty. Please check the form data and retry.", "El año de expiración de la tarjeta no puede estar vacío. Por favor verifique los datos ingresados y vuelva a intentarlo."
151
+ "Cardholder name can not empty. Please check the form data and retry.", "El titular de la tarjeta no puede estar vacío. Por favor verifique los datos ingresados y vuelva a intentarlo."
152
+ "Cardholder document number can not be empty. Please check the form data and retry.", "Cardholder document number can not be empty. Por favor verifique los datos ingresados y vuelva a intentarlo."
153
+ "Cardholder document type can not be empty. Please check the form data and retry.", "El tipo de documento no puede estar vacío. Por favor verifique los datos ingresados y vuelva a intentarlo."
154
+ "Cardholder document subtype can not be empty. Please check the form data and retry.", "El subtipo de documento no puede estar vacío. Por favor verifique los datos ingresados y vuelva a intentarlo."
155
+ "Expiration month is invalid. Please check the form data and retry.", "El mes de expiración de la tarjeta es inválido. Por favor verifique los datos ingresados y vuelva a intentarlo."
156
+ "Expiration year is invalid. Please check the form data and retry.", "El año de expiración de la tarjeta es inválido. Por favor verifique los datos ingresados y vuelva a intentarlo."
157
+ "Installments attribute can not be empty. Please check the form data and retry.", "Debe ingresar la cantidad de cuotas del pago. Por favor verifique los datos ingresados y vuelva a intentarlo."
158
+ "Coupon amount is invalid. Please check the form data and retry.", "El monto de descuento es inválido. Por favor verifique los datos ingresados y vuelva a intentarlo."
159
+ "Doesn't find a campaign to amount given", "No se ha encontrado una campaña que coicida con el monto de la orden"
160
+ "Amount discount is invalid", "El monto de descuento no es válido"
161
+
162
+ "Use other card","Utilizar otra tarjeta"
163
+ "Return to cards list","Volver a lista de tarjetas"
164
+ "Mercado Pago - Classic Checkout: Invalid client id or client secret","Mercado Pago - Classic Checkout: El id de cliente o la clave secreta, son inválidas"
165
+ "Mercado Pago - Custom Checkout: Invalid access token", "Mercado Pago - Custom Checkout: El token de acceso es inválido"
166
+ "(estimated date %s)","(fecha estimada %s)"
167
+
168
+ "Cannot repeat Magento Product size attributes","No puede repetir los atributos de tamaño de producto de magento"
169
+ "Cannot repeat MercadoEnvios Product size attributes","No puede repetir los atributos de tamaño de producto de MercadoEnvios"
170
+ "Checkout Classic Method must be enabled","El método de pago Checkout Classic debe estar habilitado"
171
+ "MercadoEnvios is not enabled in the country where Mercado Pago is configured", "MercadoEnvios no está disponible en el país configurado para Mercado Pago"
172
+ "Discount Mercado Pago","Descuento de Mercado Pago"
app/locale/es_CL/MercadoPago_Core.csv ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Enabled","Activo"
2
+
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuración"
4
+ "Credit Card - Mercado Pago","Tarjetas de crédito - Mercado Pago"
5
+
6
+ "Mercado Pago Transparent - Credit Card","Mercado Pago Transparente - Tarjeta de Crédito"
7
+ "Payment Title","Título"
8
+ "Category of your store","Categoria de la tienda"
9
+ "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
10
+ "Choose the status of refunded orders","Elija el estado de los pedidos para pagos Devueltos"
11
+ "Choose the status when payment is pending","Elija el estado de los pedidos para pagos Pendientes"
12
+ "Choose the status when client open a mediation","Elija el estado de los pedidos para pagos en Disputa"
13
+ "Choose the status when payment was reject","Elija el estado de los pedidos para pagos Rechazados"
14
+ "Choose the status when payment was canceled","Elija el estado de los pedidos para pagos Cancelados"
15
+ "Checkout Position","Posición en el Checkout"
16
+ "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
+
18
+ "Mercado Pago Transparent - Ticket","Mercado Pago Transparente - Tickets de pago"
19
+
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
+ "Country","País"
22
+ "Type Checkout","Tipo de Checkout"
23
+ "Auto Redirect","Auto-Redireccionar"
24
+ "Exclude Payment Methods","Excluir Medios de Pago"
25
+ "Maximum number of accepted installments","Numero maximo de cuotas"
26
+ "Width Checkout Iframe","Ancho de la zona del Checkout (Iframe)"
27
+ "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
+ "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
+ "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
+ "For the operation of the Checkout Transparent Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Transparente - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
32
+
33
+ "Card Number","Número de Tarjeta"
34
+ "Month","Mes"
35
+ "Year","Año"
36
+ "Card Holder Name","Titular de la Tarjeta"
37
+ "Document Number","Número de Documento"
38
+ "CVV","Código de Seguridad"
39
+ "Installments","Cuotas"
40
+ "Banks","Bancos"
41
+
42
+ "Enter the card number","Digite el número de tarjeta"
43
+ "Validating Data","Validando datos"
44
+ "An error has occurred. Please refresh the page.","Ocurrio un error. Por favor, actualice la página."
45
+ "Card number is invalid.","Número de Tarjeta inválido."
46
+ "CVV is invalid.","Código de Seguridad inválido."
47
+ "Card Holder Name is invalid.","Nombre de titular de tarjeta inválido."
48
+ "Document Number is invalid.","Número de Documento inválido."
49
+ "Year is invalid.","Año inválido."
50
+ "Month is invalid.","Mes inválido."
51
+ "Please validate your data.","Por favor, valide los datos"
52
+ "Cannot pay this amount with this payment_method_id.","No se puede pagar esta monto con este medio de pago."
53
+
54
+ "Card Number: %s","Número de Tarjeta: %s"
55
+ "Card Holder Name: %s","Titular de la Tarjeta: %s"
56
+ "Payment Method: %s","Medio de pago: %s"
57
+ "Expiration Date: %s","Fecha de Expiración: %s"
58
+ "Installments: %s","Cuotas: %s"
59
+ "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
60
+ "Payment Id (Mercado Pago): %s","Número de Pago (Mercado Pago): %s"
61
+ "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
62
+
63
+ "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
64
+ "Generate Ticket","Generar ticket de pago"
65
+
66
+ "Payment Method","Medio de pago"
67
+
68
+ "Generate the ticket and pay it wherever you want.","Genere el ticket de pago y pague"
69
+ "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
70
+
71
+ "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
72
+ "We are processing the payment.","Estamos procesando el pago."
73
+ "In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.","Estamos procesando el pago. En menos de 2 días hábiles te avisaremos por e-mail si se acreditó o si necesitamos más información."
74
+ "In less than an hour we will send you by e-mail the result.","Estamos procesando el pago. En menos de una hora te avisaremos por e-mail el resultado."
75
+
76
+ "Check the card number.","Revisa el número de la tarjeta."
77
+ "Check the expiration date.","Revisa la fecha de vencimiento."
78
+ "Check the data.","Revisa los datos."
79
+ "Check the security code.","Revisa el código de seguridad."
80
+ "We could not process your payment.","No pudimos procesar tu pago."
81
+
82
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","Debes llamar y autorizar ante %s el pago de $ %s a Mercado Pago"
83
+ "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
84
+ "We could not process your payment.","No pudimos procesar tu pago."
85
+ "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
86
+ "Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.","Tu pago fue rechazado.<br/>Elige otro de los medios de pago, te recomendamos con medios de pago en efectivo."
87
+ "Your %s do not have sufficient funds.","Tu %s no tiene fondos suficientes."
88
+ "%s does not process payments in %s installments.","%s no procesa pagos en %s cuotas."
89
+ "You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.","Llegaste al límite de intentos permitidos.<br/>Elige otra tarjeta u otro medio de pago."
90
+ "%s did not process the payment.","%s no procesó el pago."
91
+
92
+ "You can not make payments to users in other countries.","No puedes realizar pagos a usuarios de otros países."
93
+ "Payment Method selected does not process payments in installments selected. Choose another card or another payment method.","El medio de pago seleccionado no procesa pagos en la cuota seleccionada. Elige otra tarjeta u otro medio de pago."
94
+ "We could not process your payment. Error code: 126.","No pudimos procesar tu pago. Código de error: 126."
95
+ "Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.","El medio de pago seleccionado no procesa pagos del monto seleccionado. Elige otro medio de pago."
96
+ "We could not process your payment. Error code: 145.","No pudimos procesar tu pago. Código de error: 145"
97
+ "You can not make payments. Error code: 150.","No puedes realizar pagos. Código de error: 150."
98
+ "You can not make payments.","No puedes realizar pagos."
99
+ "We could not process your payment. Error code: 160.","No pudimos procesar tu pago. Código de error: 160."
100
+ "Payment Method selected is not available at this time. Choose another card or another payment method.","El medio de pago seleccionado no está disponible en este momento. Elige otra tarjeta u otro medio de pago."
101
+ "You made a similar payment moments ago. Try again in a few minutes.","Realizaste un pago similar hace instantes. Intenta nuevamente en unos minutos."
102
+ "We could not process your payment. %s","No pudimos procesar tu pago. %s"
103
+
104
+ "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
105
+
106
+ "Automatic notification of the Mercado Pago: The payment was approved.","Notificación automática de Mercado Pago: El pago fué aprobado."
107
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Notificación automática de Mercado Pago: El pago fué devuelto."
108
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Notificación automática de Mercado Pago: El pago esta siendo procesado."
109
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de Mercado Pago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
110
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Notificación automática de Mercado Pago: El pago está en un proceso de disputa, chequea tu cuenta de Mercado Pago para mayor información."
111
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Notificación automática de Mercado Pago: El pago fué cancelado."
112
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Notificación automática de Mercado Pago: El pago fué rechazado."
113
+ "<br/> Payment id: %s","<br/> Número de Pago: %s"
114
+ "<br/> Status: %s","<br/> Estado: %s"
115
+ "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
app/locale/es_CO/{mercadopago.csv → MercadoPago_Core.csv} RENAMED
@@ -1,9 +1,9 @@
1
  "Enabled","Activo"
2
 
3
- "MercadoPago - Configuration", "MercadoPago - Configuración"
4
- "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Custom - Credit Card","MercadoPago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
@@ -15,9 +15,9 @@
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
- "MercadoPago Custom - Ticket","MercadoPago Custom - Tickets de pago"
19
 
20
- "MercadoPago Standard - Credit Card, Ticket and Account Money","MercadoPago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
@@ -27,8 +27,8 @@
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
- "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
31
- "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
32
 
33
  "Card Number","Número de Tarjeta"
34
  "Month","Mes"
@@ -58,7 +58,7 @@
58
  "Expiration Date: %s","Fecha de Expiración: %s"
59
  "Installments: %s","Cuotas: %s"
60
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
- "Payment Id (MercadoPago): %s","Número de Pago (MercadoPago): %s"
62
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
 
64
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
@@ -83,7 +83,7 @@
83
  "Check the security code.","Revisa el código de seguridad."
84
  "We could not process your payment.","No pudimos procesar tu pago."
85
 
86
- "You must authorize to %s the payment of $ %s to MercadoPago.","Debes llamar y autorizar ante %s el pago de $ %s a MercadoPago"
87
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
88
  "We could not process your payment.","No pudimos procesar tu pago."
89
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
@@ -107,13 +107,13 @@
107
 
108
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
109
 
110
- "Automatic notification of the MercadoPago: The payment was approved.","Notificación automática de MercadoPago: El pago fué aprobado."
111
- "Automatic notification of the MercadoPago: The payment was refunded.","Notificación automática de MercadoPago: El pago fué devuelto."
112
- "Automatic notification of the MercadoPago: The payment is being processed.","Notificación automática de MercadoPago: El pago esta siendo procesado."
113
- "Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de MercadoPago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
114
- "Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.","Notificación automática de MercadoPago: El pago está en un proceso de disputa, chequea tu cuenta de MercadoPago para mayor información."
115
- "Automatic notification of the MercadoPago: The payment was cancelled.","Notificación automática de MercadoPago: El pago fué cancelado."
116
- "Automatic notification of the MercadoPago: The payment was rejected.","Notificación automática de MercadoPago: El pago fué rechazado."
117
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
118
  "<br/> Status: %s","<br/> Estado: %s"
119
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
@@ -123,5 +123,5 @@
123
  "Choice", "Elige"
124
  "Default issuer", "Cualquier otro banco"
125
 
126
- "To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento","Para generar una public_key envíe un email para developers@mercadopago.com informando su CLIENT_ID y la url de su tienda con el asunto public_key para Magento"
127
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
1
  "Enabled","Activo"
2
 
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuración"
4
+ "Credit Card - Mercado Pago","Tarjetas de crédito - Mercado Pago"
5
 
6
+ "Mercado Pago Custom - Credit Card","Mercado Pago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
+ "Mercado Pago Custom - Ticket","Mercado Pago Custom - Tickets de pago"
19
 
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
32
 
33
  "Card Number","Número de Tarjeta"
34
  "Month","Mes"
58
  "Expiration Date: %s","Fecha de Expiración: %s"
59
  "Installments: %s","Cuotas: %s"
60
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
+ "Payment Id (Mercado Pago): %s","Número de Pago (Mercado Pago): %s"
62
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
 
64
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
83
  "Check the security code.","Revisa el código de seguridad."
84
  "We could not process your payment.","No pudimos procesar tu pago."
85
 
86
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","Debes llamar y autorizar ante %s el pago de $ %s a Mercado Pago"
87
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
88
  "We could not process your payment.","No pudimos procesar tu pago."
89
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
107
 
108
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
109
 
110
+ "Automatic notification of the Mercado Pago: The payment was approved.","Notificación automática de Mercado Pago: El pago fué aprobado."
111
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Notificación automática de Mercado Pago: El pago fué devuelto."
112
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Notificación automática de Mercado Pago: El pago esta siendo procesado."
113
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de Mercado Pago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
114
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Notificación automática de Mercado Pago: El pago está en un proceso de disputa, chequea tu cuenta de Mercado Pago para mayor información."
115
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Notificación automática de Mercado Pago: El pago fué cancelado."
116
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Notificación automática de Mercado Pago: El pago fué rechazado."
117
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
118
  "<br/> Status: %s","<br/> Estado: %s"
119
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
123
  "Choice", "Elige"
124
  "Default issuer", "Cualquier otro banco"
125
 
126
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtén tu public_key en la siguiente dirección: https://www.mercadopago.com/mco/account/credentials"
127
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
app/locale/es_ES/{mercadopago.csv → MercadoPago_Core.csv} RENAMED
@@ -1,9 +1,9 @@
1
  "Enabled","Activo"
2
 
3
- "MercadoPago - Configuration", "MercadoPago - Configuración"
4
- "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Custom - Credit Card","MercadoPago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
@@ -15,9 +15,9 @@
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
- "MercadoPago Custom - Ticket","MercadoPago Custom - Tickets de pago"
19
 
20
- "MercadoPago Standard - Credit Card, Ticket and Account Money","MercadoPago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
@@ -27,8 +27,8 @@
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
- "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
31
- "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
32
 
33
  "Card Number","Número de Tarjeta"
34
  "Month","Mes"
@@ -58,7 +58,7 @@
58
  "Expiration Date: %s","Fecha de Expiración: %s"
59
  "Installments: %s","Cuotas: %s"
60
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
- "Payment Id (MercadoPago): %s","Número de Pago (MercadoPago): %s"
62
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
 
64
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
@@ -83,7 +83,7 @@
83
  "Check the security code.","Revisa el código de seguridad."
84
  "We could not process your payment.","No pudimos procesar tu pago."
85
 
86
- "You must authorize to %s the payment of $ %s to MercadoPago.","Debes llamar y autorizar ante %s el pago de $ %s a MercadoPago"
87
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
88
  "We could not process your payment.","No pudimos procesar tu pago."
89
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
@@ -107,16 +107,16 @@
107
 
108
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
109
 
110
- "Automatic notification of the MercadoPago: The payment was approved.","Notificación automática de MercadoPago: El pago fué aprobado."
111
- "Automatic notification of the MercadoPago: The payment was refunded.","Notificación automática de MercadoPago: El pago fué devuelto."
112
- "Automatic notification of the MercadoPago: The payment is being processed.","Notificación automática de MercadoPago: El pago esta siendo procesado."
113
- "Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de MercadoPago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
114
- "Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.","Notificación automática de MercadoPago: El pago está en un proceso de disputa, chequea tu cuenta de MercadoPago para mayor información."
115
- "Automatic notification of the MercadoPago: The payment was cancelled.","Notificación automática de MercadoPago: El pago fué cancelado."
116
- "Automatic notification of the MercadoPago: The payment was rejected.","Notificación automática de MercadoPago: El pago fué rechazado."
117
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
118
  "<br/> Status: %s","<br/> Estado: %s"
119
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
120
 
121
- "To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento","Para generar una public_key envíe un email para developers@mercadopago.com informando su CLIENT_ID y la url de su tienda con el asunto public_key para Magento"
122
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
1
  "Enabled","Activo"
2
 
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuración"
4
+ "Credit Card - Mercado Pago","Tarjetas de crédito - Mercado Pago"
5
 
6
+ "Mercado Pago Custom - Credit Card","Mercado Pago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
+ "Mercado Pago Custom - Ticket","Mercado Pago Custom - Tickets de pago"
19
 
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
32
 
33
  "Card Number","Número de Tarjeta"
34
  "Month","Mes"
58
  "Expiration Date: %s","Fecha de Expiración: %s"
59
  "Installments: %s","Cuotas: %s"
60
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
+ "Payment Id (Mercado Pago): %s","Número de Pago (Mercado Pago): %s"
62
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
 
64
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
83
  "Check the security code.","Revisa el código de seguridad."
84
  "We could not process your payment.","No pudimos procesar tu pago."
85
 
86
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","Debes llamar y autorizar ante %s el pago de $ %s a Mercado Pago"
87
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
88
  "We could not process your payment.","No pudimos procesar tu pago."
89
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
107
 
108
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
109
 
110
+ "Automatic notification of the Mercado Pago: The payment was approved.","Notificación automática de Mercado Pago: El pago fué aprobado."
111
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Notificación automática de Mercado Pago: El pago fué devuelto."
112
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Notificación automática de Mercado Pago: El pago esta siendo procesado."
113
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de Mercado Pago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
114
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Notificación automática de Mercado Pago: El pago está en un proceso de disputa, chequea tu cuenta de Mercado Pago para mayor información."
115
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Notificación automática de Mercado Pago: El pago fué cancelado."
116
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Notificación automática de Mercado Pago: El pago fué rechazado."
117
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
118
  "<br/> Status: %s","<br/> Estado: %s"
119
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
120
 
121
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtén tu public_key en la siguiente dirección: https://www.mercadopago.com/mla/account/credentials"
122
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
app/locale/{es_AR/mercadopago.csv → es_MX/MercadoPago_Core.csv} RENAMED
@@ -1,9 +1,9 @@
1
  "Enabled","Activo"
2
 
3
- "MercadoPago - Configuration", "MercadoPago - Configuración"
4
- "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Custom - Credit Card","MercadoPago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
@@ -15,9 +15,9 @@
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
- "MercadoPago Custom - Ticket","MercadoPago Custom - Tickets de pago"
19
 
20
- "MercadoPago Standard - Credit Card, Ticket and Account Money","MercadoPago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
@@ -27,9 +27,10 @@
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
- "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
31
- "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
32
 
 
33
  "Card Number","Número de Tarjeta"
34
  "Month","Mes"
35
  "Year","Año"
@@ -58,7 +59,7 @@
58
  "Expiration Date: %s","Fecha de Expiración: %s"
59
  "Installments: %s","Cuotas: %s"
60
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
61
- "Payment Id (MercadoPago): %s","Número de Pago (MercadoPago): %s"
62
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
63
 
64
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
@@ -70,7 +71,6 @@
70
  "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
71
 
72
 
73
-
74
  "Thank you for your purchase!","Gracias por su compra!"
75
  "Your order %s has been successfully generated.","Su pedido con el numero %s fué generado con éxito."
76
  "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
@@ -84,7 +84,7 @@
84
  "Check the security code.","Revisa el código de seguridad."
85
  "We could not process your payment.","No pudimos procesar tu pago."
86
 
87
- "You must authorize to %s the payment of $ %s to MercadoPago.","Debes llamar y autorizar ante %s el pago de $ %s a MercadoPago"
88
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
89
  "We could not process your payment.","No pudimos procesar tu pago."
90
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
@@ -108,16 +108,21 @@
108
 
109
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
110
 
111
- "Automatic notification of the MercadoPago: The payment was approved.","Notificación automática de MercadoPago: El pago fué aprobado."
112
- "Automatic notification of the MercadoPago: The payment was refunded.","Notificación automática de MercadoPago: El pago fué devuelto."
113
- "Automatic notification of the MercadoPago: The payment is being processed.","Notificación automática de MercadoPago: El pago esta siendo procesado."
114
- "Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de MercadoPago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
115
- "Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.","Notificación automática de MercadoPago: El pago está en un proceso de disputa, chequea tu cuenta de MercadoPago para mayor información."
116
- "Automatic notification of the MercadoPago: The payment was cancelled.","Notificación automática de MercadoPago: El pago fué cancelado."
117
- "Automatic notification of the MercadoPago: The payment was rejected.","Notificación automática de MercadoPago: El pago fué rechazado."
118
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
119
  "<br/> Status: %s","<br/> Estado: %s"
120
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
 
 
 
 
 
121
 
122
- "To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento","Para generar una public_key envíe un email para developers@mercadopago.com informando su CLIENT_ID y la url de su tienda con el asunto public_key para Magento"
123
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
1
  "Enabled","Activo"
2
 
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configuración"
4
+ "Credit Card - Mercado Pago","Tarjetas de crédito - Mercado Pago"
5
 
6
+ "Mercado Pago Custom - Credit Card","Mercado Pago Custom - Tarjeta de Crédito"
7
  "Payment Title","Título"
8
  "Category of your store","Categoria de la tienda"
9
  "Choose the status of approved orders","Elija el estado de los pedidos para pagos Aprobados"
15
  "Checkout Position","Posición en el Checkout"
16
  "To manage the status available go to System > Order Statuses","Para gerenciar los estados disponibles vaya a 'System > Order Statuses'"
17
 
18
+ "Mercado Pago Custom - Ticket","Mercado Pago Custom - Tickets de pago"
19
 
20
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money","Mercado Pago Standard - Tarjetas, Tickets y Dinero en Cuenta"
21
  "Country","País"
22
  "Type Checkout","Tipo de Checkout"
23
  "Auto Redirect","Auto-Redireccionar"
27
  "Height Checkout Iframe","Alto de la zona del Checkout (Iframe)"
28
  "Auto-redirect the buyer when finishing the payment.","Auto-Redireccionar al comprador al finalizar el pago."
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
31
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'Mercado Pago - Configuración'"
32
 
33
+ "Payment Method", "Medio de pago"
34
  "Card Number","Número de Tarjeta"
35
  "Month","Mes"
36
  "Year","Año"
59
  "Expiration Date: %s","Fecha de Expiración: %s"
60
  "Installments: %s","Cuotas: %s"
61
  "Statement Descriptor: %s","Identificación en la Factura de la Tarjeta de Crédito: %s"
62
+ "Payment Id (Mercado Pago): %s","Número de Pago (Mercado Pago): %s"
63
  "Payment Status: %s (%s)","Estado del Pago: %s (%s)"
64
 
65
  "Click on the link to generate the ticket","Clique en el link para mostrar el ticket de pago"
71
  "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
72
 
73
 
 
74
  "Thank you for your purchase!","Gracias por su compra!"
75
  "Your order %s has been successfully generated.","Su pedido con el numero %s fué generado con éxito."
76
  "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
84
  "Check the security code.","Revisa el código de seguridad."
85
  "We could not process your payment.","No pudimos procesar tu pago."
86
 
87
+ "You must authorize to %s the payment of $ %s to Mercado Pago.","Debes llamar y autorizar ante %s el pago de $ %s a Mercado Pago"
88
  "Call %s to activate your card.<br/>The phone is on the back of your card.","Llama a %s para que active tu tarjeta.<br/>El teléfono está al dorso de tu tarjeta."
89
  "We could not process your payment.","No pudimos procesar tu pago."
90
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.","Ya hiciste un pago por ese valor.<br/>Si necesitas volver a pagar usa otra tarjeta u otro medio de pago."
108
 
109
  "Verify the form data or wait until the validation of the payment data","Verifique los datos del formulario o aguarde la validación de los datos del pago."
110
 
111
+ "Automatic notification of the Mercado Pago: The payment was approved.","Notificación automática de Mercado Pago: El pago fué aprobado."
112
+ "Automatic notification of the Mercado Pago: The payment was refunded.","Notificación automática de Mercado Pago: El pago fué devuelto."
113
+ "Automatic notification of the Mercado Pago: The payment is being processed.","Notificación automática de Mercado Pago: El pago esta siendo procesado."
114
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.","Notificación automática de Mercado Pago: El pago esta siendo procesado. Será aprobado en hasta 2 días hábiles."
115
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.","Notificación automática de Mercado Pago: El pago está en un proceso de disputa, chequea tu cuenta de Mercado Pago para mayor información."
116
+ "Automatic notification of the Mercado Pago: The payment was cancelled.","Notificación automática de Mercado Pago: El pago fué cancelado."
117
+ "Automatic notification of the Mercado Pago: The payment was rejected.","Notificación automática de Mercado Pago: El pago fué rechazado."
118
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
119
  "<br/> Status: %s","<br/> Estado: %s"
120
  "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
121
+ "Order # %s in store %s","Orden # %s realizada en %s"
122
+
123
+ "$", "$"
124
+ "Choice", "Elige"
125
+ "Default issuer", "Cualquier otro banco"
126
 
127
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtén tu public_key en la siguiente dirección: https://www.mercadopago.com/mlm/account/credentials"
128
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
app/locale/{es_MX/mercadopago.csv → es_VE/MercadoPago_Core.csv} RENAMED
@@ -29,6 +29,7 @@
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
  "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
31
  "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
 
32
 
33
  "Payment Method", "Medio de pago"
34
  "Card Number","Número de Tarjeta"
@@ -124,5 +125,5 @@
124
  "Choice", "Elige"
125
  "Default issuer", "Cualquier otro banco"
126
 
127
- "To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento","Para generar una public_key envíe un email para developers@mercadopago.com informando su CLIENT_ID y la url de su tienda con el asunto public_key para Magento"
128
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
29
  "Select payment methods not accepted","Seleccione los medios de pago no aceptados"
30
  "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Custom - Tickets de pago, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
31
  "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para el funcionamento del Checkout Standard, es necesario configurar las Credenciales 'CLIENT_ID' y 'CLIENT_SECRET' en 'MercadoPago - Configuración'"
32
+ "Sandbox Mode", "Modo Sandbox"
33
 
34
  "Payment Method", "Medio de pago"
35
  "Card Number","Número de Tarjeta"
125
  "Choice", "Elige"
126
  "Default issuer", "Cualquier otro banco"
127
 
128
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtén tu public_key en la siguiente dirección: https://www.mercadopago.com/mlm/account/credentials"
129
  "Choose the status when payment was chargeback", "Elija el estado de los pedidos para pagos con status Chargeback"
app/locale/pt_BR/{mercadopago.csv → MercadoPago_Core.csv} RENAMED
@@ -1,9 +1,9 @@
1
  "Enabled", "Ativo"
2
 
3
- "MercadoPago - Configuration", "MercadoPago - Configurações"
4
- "Credit Card - MercadoPago", "Cartões de Credito - MercadoPago"
5
 
6
- "MercadoPago Custom - Credit Card", "MercadoPago Transparente - Cartão de Crédito"
7
  "Payment Title", "Titulo"
8
  "Category of your store", "Categoria da Loja"
9
  "Choose the status of approved orders", "Escolha o status dos pedidos para pagamentos Aprovados"
@@ -16,9 +16,9 @@
16
  "Checkout Position", "Posição no Checkout"
17
  "To manage the status available go to System > Order Statuses", "Para gerenciar os status disponíveis vá até System > Order Statuses"
18
 
19
- "MercadoPago Custom - Ticket", "MercadoPago Transparente - Boleto"
20
 
21
- "MercadoPago Standard - Credit Card, Ticket and Account Money", "MercadoPago Standard - Cartão, Boleto e Dinheiro em Conta"
22
  "Country", "País"
23
  "Type Checkout", "Tipo de Checkout"
24
  "Auto Redirect","Auto-Redirecionar"
@@ -28,8 +28,8 @@
28
  "Height Checkout Iframe","Altura do Checkout Iframe (Height)"
29
  "Auto-redirect the buyer when finishing the payment.","Auto-Redirecionar o comprador ao finalizar o pagamento."
30
  "Select payment methods not accepted","Selecione os meios de pagamento não aceitos"
31
- "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para o funcionamento do Checkout Transparente Boleto é necessário configurar as Credenciais 'CLIENT_ID' e 'CLIENT_SECRET' em 'MercadoPago - Configurações'"
32
- "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'","Para o funcionamento do Checkout Standard é necessário configurar as Credenciais 'CLIENT_ID' e 'CLIENT_SECRET' em 'MercadoPago - Configurações'"
33
 
34
  "Card Number", "Número do cartão"
35
  "Month", "Mês de vencimento"
@@ -79,7 +79,7 @@
79
  "Expiration Date: %s", "Data de expiração: %s"
80
  "Installments: %s", "Parcelas: %s"
81
  "Statement Descriptor: %s", "Identificação na Fatura: %s"
82
- "Payment Id (MercadoPago): %s", "Numero de Pagamento (MercadoPago): %s"
83
  "Payment Status: %s (%s)", "Status de Pagamento: %s (%s)"
84
 
85
  "Click on the link to generate the ticket", "Clique no link para gerar o boleto"
@@ -100,7 +100,7 @@
100
  "Check the data.", "Verifique os dados."
101
  "Check the security code.", "Verifique o código de segurança."
102
  "We could not process your payment.", "Não foi possível processar o pagamento."
103
- "You must authorize to %s the payment of $ %s to MercadoPago.", "Você precisa autorizar com a %s o pagamento de R$ %s ao MercadoPago."
104
  "Call %s to activate your card.<br/>The phone is on the back of your card.", "Ligue para %s e ative o seu cartão.<br/>O telefone está no verso do seu cartão de crédito."
105
  "We could not process your payment.", "Não foi possível processar o pagamento."
106
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.", "Você já fez o pagamento deste valor.<br/>Se você precisa pagar novamente use outro cartão ou outro meio de pagamento."
@@ -129,13 +129,13 @@
129
  "Contact for more information.","Entre em contato para mais informações."
130
 
131
 
132
- "Automatic notification of the MercadoPago: The payment was approved.", "Notificação automática do MercadoPago: O pagamento foi aprovado."
133
- "Automatic notification of the MercadoPago: The payment was refunded.", "Notificação automática do MercadoPago: O pagamento foi devolvido."
134
- "Automatic notification of the MercadoPago: The payment is being processed.", "Notificação automática do MercadoPago: O pagamento está sendo processado."
135
- "Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.", "Notificação automática do MercadoPago: O pagamento está sendo processado. Em até 2 dias úteis o pagamento será analisado."
136
- "Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.", "Notificação automática do MercadoPago: O pagamento está em processo de Disputa, verifique a conta gráfica do MercadoPago para maiores informações."
137
- "Automatic notification of the MercadoPago: The payment was cancelled.", "Notificação automática do MercadoPago: O pagamento foi cancelado."
138
- "Automatic notification of the MercadoPago: The payment was rejected.", "Notificação automática do MercadoPago: O pagamento foi rejeitado."
139
  "<br/> Payment id: %s", "<br/> Numero do Pagamento: %s"
140
  "<br/> Status: %s", "<br/> Status: %s"
141
  "<br/> Status Detail: %s", "<br/> Detalhe do Status: %s"
@@ -146,5 +146,51 @@
146
  "Choice", "Escolha"
147
  "Default issuer", "Qualquer Banco"
148
 
149
- "To generate a public_key send an email to developers@mercadopago.com passing your CLIENT_ID and link your online store asking for a PUBLIC_KEY for Magento","Para gerar a public_key envie um email para developers@mercadopago.com.br informando o seu CLIENT_ID e a url da sua loja virtual com o assunto PUBLIC_KEY para Magento"
150
- "Choose the status when payment was chargeback", "Escolha o status dos pedidos para pagamentos com status Chargeback"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  "Enabled", "Ativo"
2
 
3
+ "Mercado Pago - Configuration", "Mercado Pago - Configurações"
4
+ "Credit Card - Mercado Pago", "Cartões de Credito - Mercado Pago"
5
 
6
+ "Mercado Pago Custom - Credit Card", "Mercado Pago Transparente - Cartão de Crédito"
7
  "Payment Title", "Titulo"
8
  "Category of your store", "Categoria da Loja"
9
  "Choose the status of approved orders", "Escolha o status dos pedidos para pagamentos Aprovados"
16
  "Checkout Position", "Posição no Checkout"
17
  "To manage the status available go to System > Order Statuses", "Para gerenciar os status disponíveis vá até System > Order Statuses"
18
 
19
+ "Mercado Pago Custom - Ticket", "Mercado Pago Transparente - Boleto"
20
 
21
+ "Mercado Pago Standard - Credit Card, Ticket and Account Money", "Mercado Pago Standard - Cartão, Boleto e Dinheiro em Conta"
22
  "Country", "País"
23
  "Type Checkout", "Tipo de Checkout"
24
  "Auto Redirect","Auto-Redirecionar"
28
  "Height Checkout Iframe","Altura do Checkout Iframe (Height)"
29
  "Auto-redirect the buyer when finishing the payment.","Auto-Redirecionar o comprador ao finalizar o pagamento."
30
  "Select payment methods not accepted","Selecione os meios de pagamento não aceitos"
31
+ "For the operation of the Checkout Custom Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para o funcionamento do Checkout Transparente Boleto é necessário configurar as Credenciais 'CLIENT_ID' e 'CLIENT_SECRET' em 'Mercado Pago - Configurações'"
32
+ "For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'Mercado Pago - Configuration'","Para o funcionamento do Checkout Standard é necessário configurar as Credenciais 'CLIENT_ID' e 'CLIENT_SECRET' em 'Mercado Pago - Configurações'"
33
 
34
  "Card Number", "Número do cartão"
35
  "Month", "Mês de vencimento"
79
  "Expiration Date: %s", "Data de expiração: %s"
80
  "Installments: %s", "Parcelas: %s"
81
  "Statement Descriptor: %s", "Identificação na Fatura: %s"
82
+ "Payment Id (Mercado Pago): %s", "Numero de Pagamento (Mercado Pago): %s"
83
  "Payment Status: %s (%s)", "Status de Pagamento: %s (%s)"
84
 
85
  "Click on the link to generate the ticket", "Clique no link para gerar o boleto"
100
  "Check the data.", "Verifique os dados."
101
  "Check the security code.", "Verifique o código de segurança."
102
  "We could not process your payment.", "Não foi possível processar o pagamento."
103
+ "You must authorize to %s the payment of $ %s to Mercado Pago.", "Você precisa autorizar com a %s o pagamento de R$ %s ao Mercado Pago."
104
  "Call %s to activate your card.<br/>The phone is on the back of your card.", "Ligue para %s e ative o seu cartão.<br/>O telefone está no verso do seu cartão de crédito."
105
  "We could not process your payment.", "Não foi possível processar o pagamento."
106
  "You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.", "Você já fez o pagamento deste valor.<br/>Se você precisa pagar novamente use outro cartão ou outro meio de pagamento."
129
  "Contact for more information.","Entre em contato para mais informações."
130
 
131
 
132
+ "Automatic notification of the Mercado Pago: The payment was approved.", "Notificação automática do Mercado Pago: O pagamento foi aprovado."
133
+ "Automatic notification of the Mercado Pago: The payment was refunded.", "Notificação automática do Mercado Pago: O pagamento foi devolvido."
134
+ "Automatic notification of the Mercado Pago: The payment is being processed.", "Notificação automática do Mercado Pago: O pagamento está sendo processado."
135
+ "Automatic notification of the Mercado Pago: The payment is being processed. Will be approved within 2 business days.", "Notificação automática do Mercado Pago: O pagamento está sendo processado. Em até 2 dias úteis o pagamento será analisado."
136
+ "Automatic notification of the Mercado Pago: The payment is in the process of Dispute, check the graphic account of the Mercado Pago for more information.", "Notificação automática do Mercado Pago: O pagamento está em processo de Disputa, verifique a conta gráfica do Mercado Pago para maiores informações."
137
+ "Automatic notification of the Mercado Pago: The payment was cancelled.", "Notificação automática do Mercado Pago: O pagamento foi cancelado."
138
+ "Automatic notification of the Mercado Pago: The payment was rejected.", "Notificação automática do Mercado Pago: O pagamento foi rejeitado."
139
  "<br/> Payment id: %s", "<br/> Numero do Pagamento: %s"
140
  "<br/> Status: %s", "<br/> Status: %s"
141
  "<br/> Status Detail: %s", "<br/> Detalhe do Status: %s"
146
  "Choice", "Escolha"
147
  "Default issuer", "Qualquer Banco"
148
 
149
+ "Get your public_key in the following address: https://www.mercadopago.com/mlb/account/credentials","Obtenha seu public_key no seguinte endereço: https://www.mercadopago.com/mlb/account/credentials"
150
+ "Choose the status when payment was chargeback", "Escolha o status dos pedidos para pagamentos com status Chargeback"
151
+
152
+ "Cannot operate between users from different countries.","Não é possível operar entre usuários de diferentes países."
153
+ "Payment method does not process installments.","Payment method does not process installments. Choose another credit card or payment method."
154
+ "Cannot pay this amount with this paymentMethod.","Forma de pagamento não processa parcelas. Escolha um outro cartão de crédito ou método de pagamento."
155
+ "You user cannot do payments currently","Você usuário não pode fazer pagamentos atualmente."
156
+ "You user cannot do payments currently with this payment method.","Você usuário não pode fazer pagamentos actualmente com este método de pagamento ."
157
+ "Unavailable paymentmethod currently.","Método de pagamento actualmente indisponíveis."
158
+ "Already posted the same request in the last minute.","Já postou o mesmo pedido no último minuto . Tente novamente mais tarde."
159
+ "Doesn't find a campaign with the given code.", "Não encontrar uma campanha com o código dado."
160
+ "We could not process your payment in this moment. Please check the form data and retry later","Não foi possível processar seu pagamento , neste momento . Por favor verifique os dados do formulário e tente novamente mais tarde"
161
+
162
+ "The items Quantity has exceeded the limits. We could not process your payment.", "O itens Quantidade ultrapassou os limites . Não foi possível processar o seu pagamento."
163
+ "Already posted the same request in the last minute.", "Já postou o mesmo pedido no último minuto."
164
+ "The transaction amount is invalid. We could not process your payment.", "O valor da transação é inválido. Não foi possível processar o seu pagamento."
165
+ "You user cannot do payments currently", "Você usuário não pode fazer pagamentos atualmente"
166
+ "You have exceeded the max number of refunds for this payment.", "Você excedeu o número máximo de reembolso para este pagamento."
167
+ "Payment too old to be refunded", "O pagamento velho demais para ser reembolsado"
168
+ "Coupon code is invalid", "Código de cupom é inválido"
169
+ "Your user e-mail does not exist. Please check data and retry later", "Seu e-mail do usuário não existe. Verifique os dados e tente novamente mais tarde"
170
+ "You must provide your cardholder name with your card data", "Você deve fornecer seu nome do titular do cartão com seus dados de cartão"
171
+ "Not found payment method or credit card. Please check the form data and retry.", "Não encontrou forma de pagamento ou do cartão de crédito . Por favor verifique os dados do formulário e tente novamente."
172
+ "Security code is invalid. Please check the form data and retry.", "Código de segurança inválido. Por favor verifique os dados do formulário e tente novamente."
173
+ "Security code is a required field. Please check the form data and retry.", "O código de segurança é um campo obrigatório . Por favor verifique os dados do formulário e tente novamente."
174
+ "Payment method or credit card invalid. Please check the form data and retry.", "Forma de pagamento ou do cartão de crédito inválido. Por favor verifique os dados do formulário e tente novamente."
175
+ "Credit card number is invalid. Please check the form data and retry.", "Número do cartão de crédito é inválido. Por favor verifique os dados do formulário e tente novamente."
176
+ "Expiration month can not be empty. Please check the form data and retry.", "Mês de expiração não pode estar vazio . Por favor verifique os dados do formulário e tente novamente."
177
+ "Expiration year can not be empty. Please check the form data and retry.", "Ano de expiração não pode estar vazio . Por favor verifique os dados do formulário e tente novamente."
178
+ "Cardholder name can not empty. Please check the form data and retry.", "Nome do titular do cartão não pode vazio. Por favor verifique os dados do formulário e tente novamente."
179
+ "Cardholder document number can not be empty. Please check the form data and retry.", "Número do documento do titular do cartão não pode ser vazio . Por favor verifique os dados do formulário e tente novamente."
180
+ "Cardholder document type can not be empty. Please check the form data and retry.", "Titular do cartão tipo de documento não pode estar vazio . Por favor verifique os dados do formulário e tente novamente."
181
+ "Cardholder document subtype can not be empty. Please check the form data and retry.", "Documento do titular do cartão subtipo não pode estar vazio . Por favor verifique os dados do formulário e tente novamente."
182
+ "Expiration month is invalid. Please check the form data and retry.", "Mês de expiração é inválido. Por favor verifique os dados do formulário e tente novamente."
183
+ "Expiration year is invalid. Please check the form data and retry.", "Ano de expiração é inválido. Por favor verifique os dados do formulário e tente novamente."
184
+ "Installments attribute can not be empty. Please check the form data and retry.", "Atributo parcelas não pode estar vazio . Por favor verifique os dados do formulário e tente novamente."
185
+ "Coupon amount is invalid. Please check the form data and retry.", "Valor do cupom é válido. Por favor verifique os dados do formulário e tente novamente."
186
+ "Doesn't find a campaign to amount given", "Não Encontrado um coicida campanha para o montante da ordem"
187
+ "Amount discount is invalid", "Valor do desconto é inválido"
188
+
189
+ "Use other card","Utilizar outro cartão"
190
+ "Return to cards list","Voltar para lista de Cartões"
191
+
192
+ "Mercado Pago - Classic Checkout: Invalid client id or client secret","Mercado Pago - Classic Checkout: ID de cliente ou secreta cliente inválido"
193
+ "Mercado Pago - Custom Checkout: Invalid access token","Mercado Pago - Custom Checkout: Token de acesso inválido"
194
+ "(estimated date %s)","(data estimada %s)"
195
+ "MercadoEnvios is not enabled in the country where Mercado Pago is configured","MercadoEnvios não está habilitado no país onde Mercado Pago está configurado"
196
+ "Discount Mercado Pago","Desconto de Mercado Pago"
js/mercadopago/jquery-1.11.0.min.js CHANGED
File without changes
js/mercadopago/mercadopago.js CHANGED
@@ -1,563 +1,1065 @@
1
- //load dinamico de js externo
2
- function loadJsAsync(url, callback) {
3
- var head = document.getElementsByTagName('head')[0];
4
- var script = document.createElement('script');
5
- script.type = 'text/javascript';
6
- script.src = url;
7
- script.onreadystatechange = callback;
8
- script.onload = callback;
9
- head.appendChild(script);
10
- }
11
-
12
- var mercadopago_log = false;
13
- function showLogMercadoPago(message) {
14
- if (mercadopago_log) {
15
- console.debug(message);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
- }
18
-
19
- loadJsAsync("//code.jquery.com/jquery-1.11.0.min.js", function () {
20
- showLogMercadoPago("jQuery Running ...");
21
- $.noConflict();
22
-
23
- loadJsAsync("https://secure.mlstatic.com/org-img/checkout/custom/1.0/checkout.js?nocache=" + Math.random() * 10, function () {
24
- showLogMercadoPago("MercadoPago Running ...");
25
- Checkout.setPublishableKey(PublicKeyMercadoPagoTransparent);
26
-
27
- });//end load mp
28
-
29
- });//end load js
30
-
31
-
32
- function loadFilesMP() {
33
- (function($){
34
- $.noConflict();
35
- jQuery(document).ready(function ($) {
36
- showLogMercadoPago("jquery ready...");
37
-
38
- // form custom payment
39
- var $form_custom_payment = $("#payment_form_mercadopago_custom");
40
-
41
- //variables translates
42
- var currency_text_mercadopago = $form_custom_payment.find(".mercadopago-text-currency").html();
43
- var choice_text_mercadopago = $form_custom_payment.find(".mercadopago-text-choice").html();
44
- var default_issuer_text_mercadopago = $form_custom_payment.find(".mercadopago-text-default-issuer").html();
45
-
46
-
47
- //hide loading and msg-status
48
- $form_custom_payment.find(".msg-status").hide();
49
-
50
- //caso tenha alteração no campo de banco
51
- $("#issuers").change(function(){
52
-
53
- //pega o bin
54
- var card = $("input[data-checkout='cardNumber']").val().replace(/ /g, '').replace(/-/g, '').replace(/\./g, '');
55
- var bin = card.substr(0,6);
56
-
57
- //verifica installments para o banco, pode ocorrer de ter desconto
58
- Checkout.getInstallmentsByIssuerId(
59
- bin,
60
- this.value,
61
- parseFloat($form_custom_payment.find(".amount").val()),
62
- setInstallmentInfo
63
- );
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  });
66
-
67
- //caso o cartão copie e cole
68
- $("input[data-checkout='cardNumber']").focusout(function () {
69
- getBin();
70
  });
71
-
72
- //pega o bin enquanto digita
73
- $("input[data-checkout='cardNumber']").bind("keyup", function () {
74
- getBin();
 
 
 
 
 
 
 
75
  });
76
-
77
- function getBin(){
78
- var card = $("input[data-checkout='cardNumber']").val()
79
-
80
- if (card != undefined && card != "") {
81
- card = card.replace(/ /g, '').replace(/-/g, '').replace(/\./g, '');
82
- var bin = card.substr(0,6);
83
-
84
- if (bin.length == 6) {
85
- if ($("#mercadopago-country").html() == 'mlm') {
86
- Checkout.getPaymentMethod(bin, parseFloat($form_custom_payment.find(".amount").val()), setPaymentMethodInfo, $('#payment_method option:checked').val());
87
- }else{
88
- Checkout.getPaymentMethod(bin, setPaymentMethodInfo);
89
- }
90
- }
91
- }else{
92
- showLogMercadoPago("Cartão invalido ou não foi preenchido");
 
 
 
93
  }
94
-
95
- }
96
-
97
- function setPaymentMethodInfo(status, result){
98
- showLogMercadoPago("Get Payment Method: ");
99
- showLogMercadoPago({status, result});
100
-
101
- if (status == 200) {
102
- var method_payment = result[0];
103
-
104
- $("input[data-checkout='cardNumber']").css(
105
- "background",
106
- "url(" + method_payment.secure_thumbnail + ") 98% 50% no-repeat #fff"
107
- );
108
-
109
- //setta o meio de pagamento
110
- $("#payment_method").val(method_payment.id);
111
-
112
- //lista parcelas
113
- getInstallments(method_payment.id);
114
- if(method_payment.exceptions_by_card_issuer.length > 0){
115
- showIssuers(method_payment.exceptions_by_card_issuer)
116
- }else{
117
- setOneIssuer(method_payment.card_issuer);
118
- }
119
-
120
- //Checkout.getCardIssuers(method_payment.id, showIssuers);
121
- }else{
122
- //show errors
123
- if (result.error == "bad_request") {
124
- $.each(result.cause, function(p, e){
125
- $form_custom_payment.find(".msg-status").hide();
126
- $(".error-" + e.code).show();
127
- });
128
- }
129
- }
130
  }
131
-
132
- $("#mp-form input").focusout(function () {
133
- validCreateToken();
134
- });
135
-
136
- $("#mp-form select").change(function () {
137
- validCreateToken();
138
- });
139
-
140
- function validCreateToken(){
141
-
142
- var valid = true;
143
-
144
- //verifica os elementos "input"
145
- $("#mp-form input[data-checkout]").each(function () {
146
-
147
- if ($(this).val() == "") {
148
- valid = false
149
- }else if($(this).attr('data-checkout') == 'docNumber'){
150
-
151
- //caso o documento seja CPF, faz a validação em um função especifica
152
- if($("#docType").val() == "CPF"){
153
-
154
- //forca todas as mensagens sumirem
155
- $form_custom_payment.find(".msg-status").hide();
156
-
157
- if(validCpf($(this).val())){
158
- //hide msg
159
- $(".error-324").hide();
160
- }else{
161
- showLogMercadoPago("Erro validation: 324 - doc number invalid");
162
-
163
- valid = false;
164
- //show msg cpf
165
- $(".error-324").show();
166
  }
167
  }
168
- }
 
 
 
 
169
 
170
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
- //verifica os elementos "select"
173
- $("#mp-form select[data-checkout]").each(function () {
174
- if ($(this).find("option:selected").val() == "") {
175
- valid = false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
- });
178
-
179
- if (valid) {
180
- showLogMercadoPago("Request created card_token...");
181
-
182
- //hide all msg status
183
- $form_custom_payment.find(".msg-status").hide();
184
-
185
- //show loading
186
- $("#mercadopago-loading").show();
187
-
188
- //show form
189
- var $form = $("#mp-form");
190
-
191
- Checkout.createToken($form, function (status, response) {
192
- showLogMercadoPago("Card_token created: ");
193
- showLogMercadoPago({status, response});
194
-
195
- var html = ""
196
- if (status == 200 || status == 201) {
197
- showLogMercadoPago("card_token_id: " + response.id);
198
-
199
- $("#card_token_id").val(response.id);
200
- $("#trunc_card").val(response.trunc_card_number);
201
- }else{
202
-
203
- $.each(response.cause, function(p, e){
204
- showLogMercadoPago("Erro validation: " + e.code + " - " + e.description);
205
-
206
- //mapea os erros
207
- switch (e.code) {
208
- case "011":
209
- case "E301":
210
- case "E302":
211
- case "316":
212
- case "322":
213
- case "324":
214
- case "325":
215
- case "326":
216
- $form_custom_payment.find(".error-" + e.code).show();
217
- break;
218
- default:
219
- $form_custom_payment.find(".error-other").show();
220
- }
221
-
222
- // remove card_token_id - ele é invalido!
223
- $("#card_token_id").val("");
224
- });
225
-
226
- }
227
-
228
- //hide loading
229
- $("#mercadopago-loading").hide();
230
-
231
- });
232
  }
233
  }
234
 
235
-
236
- function validCpf(cpf){
237
- var soma;
238
- var resto;
239
- soma = 0;
240
- if (cpf == "00000000000")
241
- return false;
242
-
243
- for (i=1; i<=9; i++){
244
- soma = soma + parseInt(cpf.substring(i-1, i)) * (11 - i);
245
- resto = (soma * 10) % 11;
 
 
 
 
 
 
 
 
 
 
246
  }
247
-
248
- if ((resto == 10) || (resto == 11))
249
- resto = 0;
250
-
251
- if (resto != parseInt(cpf.substring(9, 10)) )
252
- return false;
253
-
254
- soma = 0;
255
-
256
- for (i = 1; i <= 10; i++){
257
- soma = soma + parseInt(cpf.substring(i-1, i)) * (12 - i);
258
- resto = (soma * 10) % 11;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
-
261
- if ((resto == 10) || (resto == 11))
262
- resto = 0;
263
-
264
- if (resto != parseInt(cpf.substring(10, 11))){
265
- return false;
266
- }else{
267
- return true;
 
 
 
 
 
268
  }
 
 
 
 
 
 
269
  }
270
-
271
-
272
- /*
273
- *
274
- * Installments
275
- *
276
- */
277
-
278
-
279
-
280
- $(".error-installment-not-work").click(function(){
281
- //caso retorne erro na consulta do amount, disponibiliza a opção do usuario tentar novamente
282
- getBin();
283
-
284
- //esconde erro
285
- $(this).hide();
286
- });
287
-
288
- function getInstallments(payment_method) {
289
-
290
- //set loading
291
- $("#mercadopago-loading").show();
292
-
293
- //get route
294
- var route = $form_custom_payment.find(".mercado_route").val();
295
-
296
- var discount_amount = parseFloat($form_custom_payment.find(".mercadopago-discount-amount").val());
297
-
298
- // caso seja diferente do standard
299
- // é feito uma consulta em um controller interno
300
- // para pegar informações do pedido atualizado
301
- // com isso, o box de installments sempre estará atualizado
302
-
303
- if (route != "checkout") {
304
- //caso seja OSC forca atualização do valor
305
- var base_url = $form_custom_payment.find(".mercado_base_url").val();
306
-
307
- showLogMercadoPago("get api internal (magento) - amount");
308
- $.ajax({
309
- type: "GET",
310
- url: base_url + "mercadopago/api/amount",
311
- success: function(response){
312
- showLogMercadoPago("Response amount: ");
313
- showLogMercadoPago(response);
314
-
315
- //atualiza valor no input
316
- $form_custom_payment.find(".amount").attr("value", response.amount);
317
-
318
- //obtem o valor real a ser pago a partir do valor total menos o valor de desconto
319
- var total = parseFloat(response.amount) - discount_amount;
320
-
321
- showLogMercadoPago("Valores para calculo da parcela: ");
322
- showLogMercadoPago({total: total, amount: response.amount, discount: discount_amount});
323
-
324
- //busca installment na API do MercadoPago passando valor atualizado
325
- Checkout.getInstallments(payment_method, total, setInstallmentInfo);
326
- },
327
- error: function(){
328
- //hide loading
329
- $("#mercadopago-loading").hide();
330
-
331
- showLogMercadoPago("Error request - get amount!!");
332
-
333
- //caso ocorra um erro na consulta do magento
334
- $form_custom_payment.find(".error-installment-not-work").show();
335
- }
336
- });
337
- }else{
338
-
339
- //obtem o valor real a ser pago a partir do valor total menos o valor de desconto
340
- var total = parseFloat($form_custom_payment.find(".amount").val()) - discount_amount;
341
-
342
- showLogMercadoPago("Valores para calculo da parcela: ");
343
- showLogMercadoPago({total: total, amount: parseFloat($form_custom_payment.find(".amount").val()), discount: discount_amount});
344
-
345
- //caso não seja OSC faz a requisição usando o valor do input
346
- Checkout.getInstallments(payment_method, total, setInstallmentInfo);
347
  }
348
-
349
- }
350
-
351
-
352
- //setta parcelas
353
- function setInstallmentInfo(status, installments){
354
- //hide loading
355
- $("#mercadopago-loading").hide();
356
-
357
- showLogMercadoPago("Set installment: ");
358
- showLogMercadoPago({status, installments});
359
-
360
- var html_options = '<option value="">' + choice_text_mercadopago + '... </option>';
361
- for(i=0; installments && i<installments.length; i++){
362
- if (installments[i] != undefined) {
363
- html_options += "<option value='"+installments[i].installments+"'>"+installments[i].installments +" de " + currency_text_mercadopago + " " + installments[i].share_amount+" ("+ currency_text_mercadopago + " "+ installments[i].total_amount+")</option>";
364
  }
365
- };
366
- $("#installments").html(html_options);
367
- }
368
-
369
-
370
- /**
371
- *
372
- *
373
- * Issuers
374
- *
375
- */
376
-
377
- function setOneIssuer(issuer) {
378
- showLogMercadoPago("Issuer set payment method.");
379
-
380
- var input_issuer = '<input type="text" name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off" value="' + issuer.id + '">';
381
- $("#issuers").html(input_issuer);
382
- $("#issuersOptions").hide();
383
- }
384
-
385
- function showIssuers(issuers) {
386
- showLogMercadoPago("Issuer set exceptions by card issuer.");
387
-
388
- var options = '<select name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off">'
389
- options += '<option value="-1">' + choice_text_mercadopago + '...</option>';
390
-
391
- for(i=0; issuers && i<issuers.length;i++){
392
- var issuer = issuers[i].card_issuer
393
- if (issuer.name == "default") {
394
- issuer.name = default_issuer_text_mercadopago;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  }
396
-
397
- options+="<option value='"+issuer.id+"'>"+issuer.name +" </option>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  }
399
-
400
- options += "</select>";
401
-
402
- $("#issuers").html(options);
403
- }
404
-
405
- //para listar todas as issuer
406
- /*function showIssuers(status, issuers){
407
- showLogMercadoPago("Set Issuer: ");
408
- showLogMercadoPago({status, issuers});
409
-
410
- //caso tenha apenas um registro, pega o valor dele e setta em um input escondido
411
- if (issuers.length == 1) {
412
- showLogMercadoPago("Issuer set by payment.");
413
- var input_issuers = '<input type="text" name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off" value="' + issuers[0].id + '">';
414
- $("#issuers").html(input_issuers);
415
- $("#issuersOptions").hide();
416
- } else{
417
-
418
- var options = '<select name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off">'
419
- options += '<option value="-1">' + choice_text_mercadopago + '...</option>';
420
-
421
- for(i=0; issuers && i<issuers.length;i++){
422
-
423
- if (issuers[i].name == "default") {
424
- issuers[i].name = default_issuer_text_mercadopago;
425
  }
426
-
427
- options+="<option value='"+issuers[i].id+"'>"+issuers[i].name +" </option>";
428
- }
429
-
430
- options += "</select>";
431
-
432
- if(issuers.length > 1){
433
- $("#issuers").html(options);
434
- $("#issuersOptions").show();
435
- }else{
436
- $("#issuers").html("");
437
- $("#issuersOptions").hide();
438
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  }
440
- }*/
441
-
442
- /*
443
- *
444
- * COUPON
445
- *
446
- */
447
-
448
- //hide all info
449
- $(".mercadopago-message-coupon li").hide();
450
-
451
- //action apply
452
- $(".mercadopago-coupon-action-apply").click(function(){
453
-
454
- // obtem de qual formulario esta vindo a requisição
455
- // a partir do formulario ele trabalha as variaveis e as informações que serão
456
- // mostradas ao comprador
457
- var $form_payment = $(this).parent().parent();
458
-
459
- showLogMercadoPago("Form action:");
460
- showLogMercadoPago($form_payment);
461
- showLogMercadoPago("Validating coupon...");
462
-
463
- //Esconde todas as mensagens
464
- $form_payment.find(".mercadopago-message-coupon li").hide();
465
-
466
- //show loading
467
- $form_payment.find(".mercadopago-message-coupon .loading").show();
468
-
469
-
470
- //obtem algumas informações para montar o request
471
- var base_url = $form_payment.find(".mercado_base_url").val();
472
- var coupon = $form_payment.find(".mercadopago_coupon").val();
473
-
474
-
475
- showLogMercadoPago("get api internal (magento) - coupon");
476
- //verifica se o coupon de desconto é valida
477
- $.ajax({
478
- type: "GET",
479
- url: base_url + "mercadopago/api/coupon?id=" + coupon,
480
- success: function(r){
481
-
482
- showLogMercadoPago("Response validating coupon: ");
483
- showLogMercadoPago(r);
484
-
485
- //hide loading
486
- $form_payment.find(".mercadopago-message-coupon .loading").hide();
487
-
488
- if(r.status == 200){
489
- //caso o coupon seja valido, mostra uma mensagem + termos e condições
490
- //obtem informações sobre o coupon
491
- var coupon_amount = (r.response.coupon_amount).toFixed(2)
492
- var transaction_amount = (r.response.transaction_amount).toFixed(2)
493
- var id_coupon = r.response.id;
494
- var currency = $form_payment.find(".mercadopago-text-currency").html();
495
- var url_term = "https://api.mercadolibre.com/campaigns/" + id_coupon + "/terms_and_conditions?format_type=html"
496
-
497
- $form_payment.find(".mercadopago-message-coupon .discount-ok .amount-discount").html(currency + coupon_amount);
498
- $form_payment.find(".mercadopago-message-coupon .discount-ok .total-amount").html(currency + transaction_amount);
499
- $form_payment.find(".mercadopago-message-coupon .discount-ok .total-amount-discount").html(currency + (transaction_amount - coupon_amount));
500
-
501
-
502
- $form_payment.find(".mercadopago-message-coupon .discount-ok .mercadopago-coupon-terms").attr("href", url_term);
503
- $form_payment.find(".mercadopago-discount-amount").attr("value", coupon_amount);
504
-
505
- //show mensagem ok
506
- $form_payment.find(".mercadopago-message-coupon .discount-ok").show();
507
- $form_payment.find(".mercadopago-coupon-action-apply").hide();
508
- $form_payment.find(".mercadopago-coupon-action-remove").show();
509
- }else{
510
-
511
- //reset input amount
512
- $form_payment.find(".mercadopago-discount-amount").attr("value", "0");
513
-
514
- //caso não seja mostra a mensagem de validação
515
- $form_payment.find(".mercadopago-message-coupon").find("." + r.response.error).show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  }
517
-
518
- //forca atualização do bin/installment para atualizar os valores de installment
519
- getBin();
520
- },
521
- error: function(){
522
-
523
- //hide loading
524
- $form_payment.find(".mercadopago-message-coupon .loading").hide();
525
-
526
- showLogMercadoPago("Error request - get coupon!!");
527
-
528
  //reset input amount
529
- $form_payment.find(".mercadopago-discount-amount").attr("value", "0");
530
-
531
- //caso ocorra um erro na consulta do magento
532
- $form_payment.find(".mercadopago-message-coupon .error-get").show();
533
-
534
- //forca atualização do bin/installment para atualizar os valores de installment
535
- getBin();
536
-
537
  }
538
- });
539
- });
540
-
541
-
542
- //caso o usuario não deseja usar coupon de desconto
543
- $(".mercadopago-coupon-action-remove").click(function(){
544
- var $form_payment = $(this).parent().parent();
545
-
546
- //hide all info
547
- $form_payment.find(".mercadopago-message-coupon li").hide();
548
- $form_payment.find(".mercadopago-coupon-action-apply").show();
549
- $form_payment.find(".mercadopago-coupon-action-remove").hide();
550
- $form_payment.find(".mercadopago_coupon").val("");
551
- $form_payment.find(".mercadopago-discount-amount").attr("value", "0");
552
-
553
- //forca atualização do bin/installment para atualizar os valores de installment
554
- getBin();
555
-
556
- showLogMercadoPago("Remove coupon!");
557
  });
558
-
559
- });
560
- //end load js
561
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
 
563
- }
 
 
 
 
 
 
 
 
 
 
 
1
+ var MercadoPagoCustom = (function () {
2
+
3
+ var instance = null;
4
+ var http = {
5
+ status: {
6
+ OK: 200,
7
+ CREATED: 201
8
+ },
9
+ method: {
10
+ GET: 'GET'
11
+ }
12
+ };
13
+ var self = {
14
+ messages: {
15
+ init: 'Init Mercado Pago JS',
16
+ initOCP: 'Init Mercado Pago OCP',
17
+ initDiscount: 'Init Mercado Pago Custom Discount',
18
+ initTicket: 'Init Mercado Pago Custom Ticket',
19
+ mpIncorrectlyConfigured: 'Mercado Pago was not configured correctly. Public Key not found.',
20
+ publicKey: 'Public Key: {0}',
21
+ siteId: 'SITE_ID: {0}',
22
+ invalidDocument: 'Document Number is invalid.',
23
+ incorrectExpDate: 'Incorrect credit card expiration date.',
24
+ defineInputs: 'Define Inputs',
25
+ ocpUser: 'Action One Click Pay User',
26
+ clearOpts: 'Clear Option',
27
+ getBin: 'Get bin',
28
+ guessingPayment: 'Guessing Payment',
29
+ setPaymentInfo: 'Set payment method info: ',
30
+ issuerMandatory: 'Issuer is mandatory? {0}',
31
+ setIssuer: 'Set Issuer...',
32
+ setInstallment: 'Set install by issuer id',
33
+ getInstallment: 'Get Installments',
34
+ usingMagentoCustomCheckout: 'Using checkout customized Magento...',
35
+ usingMagentoStdCheckout: 'Using checkout standard Magento...',
36
+ getAmountSuccess: 'Success in get amount: ',
37
+ installmentAmount: 'Valor para calculo da parcela: {0}',
38
+ customDiscountAmount: 'Valor do desconto: {0}',
39
+ finalAmount: 'Valor final: {0}',
40
+ getAmountError: 'Error getting amount: ',
41
+ setInstallmentInfo: 'Set Installment info',
42
+ issuerSet: 'Issuer set: {0}',
43
+ releasecardTokenEvent: 'Release event create card token',
44
+ checkCreateCardToken: 'Check create card token',
45
+ responseCardToken: 'Response create/update card_token: ',
46
+ hideErrors: 'Hiding all errors...',
47
+ showingError: 'Show Message Error Form',
48
+ showLoading: 'Show loading...',
49
+ hideLoading: 'Hide loading...',
50
+ validateDiscount: 'Valid Discount',
51
+ validateCouponResponse: 'Validating coupon response : ',
52
+ removeDiscount: 'Remove Discount',
53
+ removeCoupon: 'Remove coupon!',
54
+ hideCouponMessages: 'Hide all coupon messages...',
55
+ ocpActivatedFormat: 'OCP? {0}',
56
+ cardHandler: 'card Handler'
57
+ },
58
+ constants: {
59
+ option: 'option',
60
+ undefined: 'undefined',
61
+ default: 'default',
62
+ checkout: 'checkout',
63
+ mexico: 'MLM',
64
+ colombia: 'MCO',
65
+ brazil: 'MLB',
66
+ mercadopagoCustom: 'mercadopago_custom',
67
+ validateDiscount: 'validate-discount',
68
+ validateDocNumber: 'mp-validate-docnumber',
69
+ validateCC: 'mp-validate-cc-exp',
70
+ invalidCoupon: 'invalid_coupon',
71
+ cost: 'cost',
72
+ dataElementId: 'data-element-id',
73
+ style: 'style',
74
+ requireEntry: 'required-entry',
75
+ validateSelect: 'validate-select',
76
+ keyup: 'keyup',
77
+ firstSixDigits: 'first_six_digits',
78
+ backgroundUrlFormat: 'url({0}) no-repeat'
79
+ },
80
+ selectors: {
81
+ checkoutCustom: '#mercadopago_checkout_custom',
82
+ checkoutTicket: '#mercadopago_checkout_custom_ticket',
83
+ siteId: '#mercadopago_checkout_custom .site_id',
84
+ cardNumberInput: 'input[data-checkout="cardNumber"]',
85
+ installmentsDontWork: '.error-installment-not-work',
86
+ mercadopagoCustomOpt: '#p_method_mercadopago_custom',
87
+ cardExpYear: '#cardExpirationYear',
88
+ docType: '#docType',
89
+ cardId: '#cardId',
90
+ returnToCardList: '#return_list_card_mp',
91
+ useOtherCard: '#use_other_card_mp',
92
+ installments: '#installments',
93
+ totalAmount: '.total_amount',
94
+ amount: '.amount',
95
+ cardNumber: '#cardNumber',
96
+ issuer: '#issuer',
97
+ issuerMp: '#issuer__mp',
98
+ issuerMpLabel: '#issuer__mp label',
99
+ issuerId: 'issuer_id',
100
+ cardExpirationMonth: '#cardExpirationMonth',
101
+ cardHolder: '#cardholderName',
102
+ docNumber: '#docNumber',
103
+ securityCode: '#securityCode',
104
+ securityCodeOCP: '#securityCodeOCP',
105
+ dataCheckout: '[data-checkout]',
106
+ oneClickPayment: '#mercadopago_checkout_custom #one_click_pay_mp',
107
+ installmentText: '#mercadopago_checkout_custom .mercadopago-text-installment',
108
+ paymentMethod: '#paymentMethod',
109
+ paymentMethodSelect: 'select[data-checkout="paymentMethod"]',
110
+ paymentMethodId: '#mercadopago_checkout_custom .payment_method_id',
111
+ paymenMethodNotFound: '.error-payment-method-not-found',
112
+ mercadoPagoTextChoice: '#mercadopago_checkout_custom .mercadopago-text-choice',
113
+ errorMethodMinAmount: '.error-payment-method-min-amount',
114
+ textDefaultIssuer: '#mercadopago_checkout_custom .mercadopago-text-default-issuer',
115
+ customCard: '#mercadopago_checkout_custom_card',
116
+ ocp: '#mercadopago_checkout_custom_ocp',
117
+ mercadoRoute: '#mercadopago_checkout_custom .mercado_route',
118
+ baseUrl: '.mercado_base_url',
119
+ loading: '#mercadopago-loading',
120
+ messageError: '.message-error',
121
+ customDiscountAmount: '#mercadopago_checkout_custom .mercadopago-discount-amount',
122
+ discountAmount: '.mercadopago-discount-amount',
123
+ token: '#mercadopago_checkout_custom .token',
124
+ errorFormat: '.error-{0}',
125
+ couponActionApply: '.mercadopago-coupon-action-apply',
126
+ couponActionRemove: '.mercadopago-coupon-action-remove',
127
+ ticketActionApply: '#mercadopago_checkout_custom_ticket .mercadopago-coupon-action-apply',
128
+ ticketActionRemove: '#mercadopago_checkout_custom_ticket .mercadopago-coupon-action-remove',
129
+ coupon: '.mercadopago_coupon',
130
+ couponLoading: '.mercadopago-message-coupon .loading',
131
+ couponList: '.mercadopago-message-coupon li',
132
+ textCurrency: '.mercadopago-text-currency',
133
+ discountOk: '.mercadopago-message-coupon .discount-ok',
134
+ messageCoupon: '.mercadopago-message-coupon',
135
+ discountOkAmountDiscount: '.mercadopago-message-coupon .discount-ok .amount-discount',
136
+ discountOkTotalAmount: '.mercadopago-message-coupon .discount-ok .total-amount',
137
+ discountOkTotalAmountDiscount: '.mercadopago-message-coupon .discount-ok .total-amount-discount',
138
+ discountOkTerms: '.mercadopago-message-coupon .discount-ok .mercadopago-coupon-terms',
139
+ inputCouponDiscount: '#input-coupon-discount'
140
+
141
+ },
142
+ url: {
143
+ amount: 'mercadopago/api/amount',
144
+ couponUrlFormat: 'mercadopago/api/coupon?id={0}',
145
+ termsUrlFormat: "https://api.mercadolibre.com/campaigns/{0}/terms_and_conditions?format_type=html"
146
+ },
147
+ enableLog: true
148
+ };
149
+
150
+ function getMessages() {
151
+ return self.messages;
152
+ }
153
+
154
+ function getConstants() {
155
+ return self.constants;
156
+ }
157
+
158
+ function getSelectors() {
159
+ return self.selectors;
160
+ }
161
+
162
+ function getUrls() {
163
+ return self.url;
164
+ }
165
+
166
+ function setMessages(messages) {
167
+ self.messages = messages;
168
+ }
169
+
170
+ function setConstants(constants) {
171
+ self.constants = constants;
172
+ }
173
+
174
+ function setSelectors(selectors) {
175
+ self.selectors = selectors;
176
+ }
177
+
178
+ function setUrls(urls) {
179
+ self.url = urls;
180
+ }
181
+
182
+ function isLogEnabled() {
183
+ return self.enableLog;
184
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+ // MERCADO LOG
187
+ function enableLog(val) {
188
+ self.enableLog = val;
189
+ }
190
+
191
+ function InitializeNewModule() {
192
+
193
+ var issuerMandatory = false;
194
+
195
+
196
+ function showLogMercadoPago(message) {
197
+ if (self.enableLog) {
198
+ console.debug(message);
199
+ }
200
+ }
201
+
202
+ if (typeof PublicKeyMercadoPagoCustom != self.constants.undefined) {
203
+ Mercadopago.setPublishableKey(PublicKeyMercadoPagoCustom);
204
+ }
205
+
206
+
207
+ function initMercadoPagoJs() {
208
+ showLogMercadoPago(self.messages.init);
209
+
210
+ var siteId = TinyJ(self.selectors.siteId).val();
211
+
212
+ if (typeof PublicKeyMercadoPagoCustom == self.constants.undefined) {
213
+ alert(self.messages.mpIncorrectlyConfigured);
214
+ }
215
+
216
+ //Show public key
217
+ showLogMercadoPago(String.format(self.messages.publicKey, PublicKeyMercadoPagoCustom));
218
+ //Show site
219
+ showLogMercadoPago(String.format(self.messages.siteId, siteId));
220
+
221
+ if (siteId != self.constants.mexico) {
222
+ Mercadopago.getIdentificationTypes();
223
+ } else {
224
+ setTimeout(function () {
225
+ setPaymentMethods()
226
+ }, 1000);
227
+ }
228
+
229
+ defineInputs();
230
+
231
+ TinyJ(self.selectors.cardNumberInput).keyup(guessingPaymentMethod);
232
+ TinyJ(self.selectors.cardNumberInput).keyup(clearOptions);
233
+ TinyJ(self.selectors.cardNumberInput).change(guessingPaymentMethod);
234
+ TinyJ(self.selectors.installmentsDontWork).click(guessingPaymentMethod);
235
+ TinyJ(self.selectors.installments).change(setTotalAmount);
236
+
237
+ releaseEventCreateCardToken();
238
+
239
+ cardsHandler();
240
+
241
+ if (TinyJ(self.selectors.mercadopagoCustomOpt).isChecked()) {
242
+ payment.switchMethod(self.constants.mercadopagoCustom);
243
+ }
244
+
245
+ Validation.add(self.constants.validateDiscount, ' ', function (v, element) {
246
+ return (!element.hasClassName(self.constants.invalidCoupon));
247
  });
248
+
249
+ Validation.add(self.constants.validateDocNumber, self.messages.invalidDocument, function (v, element) {
250
+ return checkDocNumber(v);
 
251
  });
252
+
253
+ Validation.add(self.constants.validateCC, self.messages.incorrectExpDate, function (v, element) {
254
+ var ccExpMonth = v;
255
+ var ccExpYear = TinyJ(self.selectors.cardExpYear).val();
256
+ var currentTime = new Date();
257
+ var currentMonth = currentTime.getMonth() + 1;
258
+ var currentYear = currentTime.getFullYear();
259
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
260
+ return false;
261
+ }
262
+ return true;
263
  });
264
+
265
+ }
266
+
267
+ function setPaymentMethodId(event) {
268
+ var paymentMethodSelector = TinyJ(self.selectors.paymentMethodSelect);
269
+ var paymentMethodId = paymentMethodSelector.val();
270
+ if (paymentMethodId != '') {
271
+ var payment_method_id = TinyJ(self.selectors.paymentMethodId);
272
+ payment_method_id.val(paymentMethodId);
273
+ }
274
+ }
275
+
276
+ function getPaymentMethods() {
277
+ var allMethods = Mercadopago.getPaymentMethods();
278
+ var allowedMethods = [];
279
+ for (var key in allMethods) {
280
+ var method = allMethods[key];
281
+ var typeId = method.payment_type_id;
282
+ if (typeId == 'debit_card' || typeId == 'credit_card' || typeId == 'prepaid_card') {
283
+ allowedMethods.push(method);
284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
+
287
+ return allowedMethods;
288
+
289
+ }
290
+
291
+ function setPaymentMethods() {
292
+ var methods = getPaymentMethods();
293
+ setPaymentMethodsInfo(methods);
294
+ TinyJ(self.selectors.paymentMethodSelect).change(setPaymentMethodId);
295
+ }
296
+
297
+ function checkDocNumber(v) {
298
+ var flagReturn = true;
299
+ Mercadopago.getIdentificationTypes(function (status, identificationsTypes) {
300
+ if (status == http.status.OK) {
301
+ var type = TinyJ(self.selectors.docType).val();
302
+ identificationsTypes.each(function (dataType) {
303
+ if (dataType.id == type) {
304
+ if (v.length > dataType.max_length || v.length < dataType.min_length) {
305
+ flagReturn = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
  }
308
+ });
309
+ }
310
+ });
311
+ return flagReturn;
312
+ }
313
 
314
+ //init one click pay
315
+ function initMercadoPagoOCP() {
316
+ showLogMercadoPago(self.messages.initOCP);
317
+ TinyJ(self.selectors.cardId).change(cardsHandler);
318
+
319
+ var returnListCard = TinyJ(self.selectors.returnToCardList);
320
+ TinyJ(self.selectors.useOtherCard).click(actionUseOneClickPayOrNo);
321
+ returnListCard.click(actionUseOneClickPayOrNo);
322
+
323
+ TinyJ(self.selectors.installments).change(setTotalAmount);
324
+
325
+ returnListCard.show();
326
+ }
327
+
328
+ function setTotalAmount() {
329
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.totalAmount).val(TinyJ(this).getSelectedOption().attribute(self.constants.cost));
330
+ }
331
+
332
+ function defineInputs() {
333
+ showLogMercadoPago(self.messages.defineInputs);
334
+
335
+ var siteId = TinyJ(self.selectors.siteId).val();
336
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
337
+ var dataCheckout = TinyJ(self.selectors.dataCheckout);
338
+ var excludeInputs = [self.selectors.cardId, self.selectors.securityCodeOCP, self.selectors.paymentMethod];
339
+ var dataInputs = [];
340
+ var disabledInputs = [];
341
+
342
+ if (oneClickPay == true) {
343
+
344
+ excludeInputs = [
345
+ self.selectors.cardNumber, self.selectors.issuer, self.selectors.cardExpirationMonth, self.selectors.cardExpYear,
346
+ self.selectors.cardHolder, self.selectors.docType, self.selectors.docNumber, self.selectors.securityCode, self.selectors.paymentMethod
347
+ ];
348
+
349
+ } else if (siteId == self.constants.brazil) {
350
+
351
+ excludeInputs.push(self.selectors.issuer);
352
+ excludeInputs.push(self.selectors.docType)
353
 
354
+ } else if (siteId == self.constants.mexico) {
355
+
356
+ excludeInputs.push(self.selectors.docType);
357
+ excludeInputs.push(self.selectors.docNumber);
358
+ disabledInputs.push(self.selectors.issuer);
359
+
360
+ var index = excludeInputs.indexOf(self.selectors.paymentMethod);
361
+ if (index > -1) {
362
+ excludeInputs.splice(index, 1);
363
+ }
364
+
365
+ } else if (siteId == self.constants.colombia) {
366
+ var indexColombia = excludeInputs.indexOf(self.selectors.paymentMethod);
367
+ if (indexColombia > -1) {
368
+ excludeInputs.splice(indexColombia, 1);
369
+ }
370
+ }
371
+ if (!this.issuerMandatory) {
372
+ excludeInputs.push(self.selectors.issuer);
373
+ }
374
+
375
+ for (var x = 0; x < dataCheckout.length; x++) {
376
+ var $id = "#" + dataCheckout[x].id();
377
+
378
+ var elPai = dataCheckout[x].attribute(self.constants.dataElementId);
379
+
380
+
381
+ if (excludeInputs.indexOf($id) == -1) {
382
+ TinyJ(elPai).removeAttribute(self.constants.style);
383
+ dataInputs.push($id);
384
+ if (disabledInputs.indexOf($id) != -1) {
385
+ TinyJ(self.selectors.checkoutCustom).getElem($id).disabled = "disabled";
386
  }
387
+ } else {
388
+ TinyJ(elPai).hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  }
390
  }
391
 
392
+
393
+ //Show inputs
394
+ showLogMercadoPago(dataInputs);
395
+
396
+ return dataInputs;
397
+
398
+ }
399
+
400
+ function setPaymentMethodsInfo(methods) {
401
+ hideLoading();
402
+
403
+ var selectorPaymentMethods = TinyJ(self.selectors.paymentMethod);
404
+
405
+ selectorPaymentMethods.empty();
406
+ var message_choose = document.querySelector(".mercadopago-text-choice").value;
407
+ var option = new Option(message_choose + "... ", '');
408
+ selectorPaymentMethods.appendChild(option);
409
+ if (methods.length > 0) {
410
+ for (var i = 0; i < methods.length; i++) {
411
+ option = new Option(methods[i].name, methods[i].id);
412
+ selectorPaymentMethods.appendChild(option);
413
  }
414
+ }
415
+ }
416
+
417
+
418
+ function setRequiredFields(required) {
419
+ if (required) {
420
+ TinyJ(self.selectors.cardNumber).addClass(self.constants.requireEntry);
421
+ TinyJ(self.selectors.cardHolder).addClass(self.constants.requireEntry);
422
+ TinyJ(self.selectors.docNumber).addClass(self.constants.requireEntry);
423
+ TinyJ(self.selectors.cardExpirationMonth).addClass(self.constants.validateSelect);
424
+ TinyJ(self.selectors.cardExpYear).addClass(self.constants.validateSelect);
425
+ TinyJ(self.selectors.docType).addClass(self.constants.validateSelect);
426
+ TinyJ(self.selectors.securityCodeOCP).removeClass(self.constants.requireEntry);
427
+ TinyJ(self.selectors.securityCode).addClass(self.constants.requireEntry);
428
+ } else {
429
+ TinyJ(self.selectors.cardNumber).removeClass(self.constants.requireEntry);
430
+ TinyJ(self.selectors.cardHolder).removeClass(self.constants.requireEntry);
431
+ TinyJ(self.selectors.docNumber).removeClass(self.constants.requireEntry);
432
+ TinyJ(self.selectors.securityCode).removeClass(self.constants.requireEntry);
433
+ TinyJ(self.selectors.securityCodeOCP).addClass(self.constants.requireEntry);
434
+ TinyJ(self.selectors.cardExpirationMonth).removeClass(self.constants.validateSelect);
435
+ TinyJ(self.selectors.cardExpYear).removeClass(self.constants.validateSelect);
436
+ TinyJ(self.selectors.docType).removeClass(self.constants.validateSelect);
437
+ }
438
+ }
439
+
440
+ function actionUseOneClickPayOrNo() {
441
+ showLogMercadoPago(self.messages.ocpUser);
442
+
443
+ var ocp = TinyJ(self.selectors.oneClickPayment).val();
444
+
445
+ showLogMercadoPago(String.format(self.messages.ocpActivatedFormat, ocp));
446
+
447
+ if (ocp == true) {
448
+ TinyJ(self.selectors.oneClickPayment).val(0);
449
+ TinyJ(self.selectors.cardId).disable();
450
+ setRequiredFields(true);
451
+ } else {
452
+ TinyJ(self.selectors.oneClickPayment).val(1);
453
+ TinyJ(self.selectors.cardId).enable();
454
+ setRequiredFields(false);
455
+ }
456
+
457
+ defineInputs();
458
+ clearOptions();
459
+ Mercadopago.clearSession();
460
+
461
+ hideMessageError();
462
+
463
+ checkCreateCardToken();
464
+
465
+ //update payment_id
466
+ guessingPaymentMethod(event.type = self.constants.keyup);
467
+
468
+
469
+ }
470
+
471
+ function clearOptions() {
472
+ showLogMercadoPago(self.messages.clearOpts);
473
+
474
+ var bin = getBin();
475
+ if (bin != undefined && (bin.length == 0 || TinyJ(self.selectors.cardNumberInput).val() == '')) {
476
+ var messageInstallment = TinyJ(self.selectors.installmentText).val();
477
+
478
+ var issuer = TinyJ(self.selectors.issuer);
479
+ issuer.hide();
480
+ issuer.empty();
481
+
482
+ TinyJ(self.selectors.issuerMp).hide();
483
+ TinyJ(self.selectors.issuerMpLabel).hide();
484
+
485
+ var selectorInstallments = TinyJ(self.selectors.installments);
486
+ var fragment = document.createDocumentFragment();
487
+ option = new Option(messageInstallment, '');
488
+
489
+ selectorInstallments.empty();
490
+ fragment.appendChild(option);
491
+ selectorInstallments.appendChild(fragment);
492
+ selectorInstallments.disable();
493
+ }
494
+ }
495
+
496
+ function cardsHandler() {
497
+ showLogMercadoPago(self.messages.cardHandler);
498
+ clearOptions();
499
+ var cardSelector;
500
+ try {
501
+ cardSelector = TinyJ(self.selectors.cardId);
502
+ }
503
+ catch (err) {
504
+ return;
505
+ }
506
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
507
+
508
+ if (oneClickPay == true) {
509
+ var selectedCard = cardSelector.getSelectedOption();
510
+ if (selectedCard.val() != "-1") {
511
+ var _bin = selectedCard.attribute(self.constants.firstSixDigits);
512
+ Mercadopago.getPaymentMethod({"bin": _bin}, setPaymentMethodInfo);
513
+ TinyJ(self.selectors.issuer).val('');
514
  }
515
+ }
516
+ }
517
+
518
+ function getBin() {
519
+ showLogMercadoPago(self.messages.getBin);
520
+
521
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
522
+ if (oneClickPay == true) {
523
+ try {
524
+ var cardSelector = TinyJ(self.selectors.cardId).getSelectedOption();
525
+ }
526
+ catch (err) {
527
+ return;
528
  }
529
+ if (cardSelector.val() != "-1") {
530
+ return cardSelector.attribute(self.constants.firstSixDigits);
531
+ }
532
+ } else {
533
+ var ccNumber = TinyJ(self.selectors.cardNumberInput).val();
534
+ return ccNumber.replace(/[ .-]/g, '').slice(0, 6);
535
  }
536
+ return;
537
+ }
538
+
539
+
540
+ function guessingPaymentMethod(event) {
541
+ showLogMercadoPago(self.messages.guessingPayment);
542
+
543
+ //hide all errors
544
+ hideMessageError();
545
+
546
+ var bin = getBin();
547
+ try {
548
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
549
+ } catch (e) {
550
+ var amount = TinyJ(self.selectors.checkoutTicket).getElem(self.selectors.amount).val();
551
+ }
552
+
553
+ if (event.type == self.constants.keyup) {
554
+ if (bin != undefined && bin.length == 6) {
555
+ Mercadopago.getPaymentMethod({
556
+ "bin": bin,
557
+ "amount": amount
558
+ }, setPaymentMethodInfo);
559
+ }
560
+ } else {
561
+ setTimeout(function () {
562
+ if (bin != undefined && bin.length >= 6) {
563
+ Mercadopago.getPaymentMethod({
564
+ "bin": bin,
565
+ "amount": amount
566
+ }, setPaymentMethodInfo);
567
+ }
568
+ }, 100);
569
+ }
570
+ };
571
+
572
+ function setPaymentMethodInfo(status, response) {
573
+ showLogMercadoPago(self.messages.setPaymentInfo);
574
+ showLogMercadoPago(status);
575
+ showLogMercadoPago(response);
576
+
577
+ var siteId = TinyJ(self.selectors.siteId).val();
578
+ if (siteId == self.constants.colombia) {
579
+ setPaymentMethods()
580
+ }
581
+ //hide loading
582
+ hideLoading();
583
+
584
+ if (status == http.status.OK) {
585
+ if (response.length == 1) {
586
+ var paymentMethodId = response[0].id;
587
+ TinyJ(self.selectors.paymentMethodId).val(paymentMethodId);
588
+ }
589
+
590
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
591
+ var selector = oneClickPay == true ? self.selectors.cardId : self.selectors.cardNumberInput;
592
+ if (response.length == 1) {
593
+ TinyJ(selector).getElem().style.background = String.format(self.constants.backgroundUrlFormat, response[0].secure_thumbnail);
594
+ }
595
+
596
+ var bin = getBin();
597
+ try {
598
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
599
+ } catch (e) {
600
+ var amount = TinyJ(self.selectors.checkoutTicket).getElem(self.selectors.amount).val();
 
 
 
 
 
 
 
 
 
 
 
 
601
  }
602
+
603
+ //get installments
604
+ getInstallments({
605
+ "bin": bin,
606
+ "amount": amount
607
+ });
608
+
609
+ // check if the issuer is necessary to pay
610
+ this.issuerMandatory;
611
+ this.issuerMandatory = false;
612
+ var additionalInfo = response[0].additional_info_needed;
613
+
614
+ for (var i = 0; i < additionalInfo.length; i++) {
615
+ if (additionalInfo[i] == self.selectors.issuerId) {
616
+ this.issuerMandatory = true;
 
617
  }
618
+ }
619
+
620
+ showLogMercadoPago(String.format(self.messages.issuerMandatory, this.issuerMandatory));
621
+
622
+ var issuer = TinyJ(self.selectors.issuer);
623
+
624
+ if (this.issuerMandatory) {
625
+ Mercadopago.getIssuers(response[0].id, showCardIssuers);
626
+ issuer.change(setInstallmentsByIssuerId);
627
+ } else {
628
+ TinyJ(self.selectors.issuerMp).hide();
629
+ issuer.hide();
630
+ issuer.getElem().options.length = 0;
631
+ }
632
+
633
+ } else {
634
+
635
+ showMessageErrorForm(self.selectors.paymenMethodNotFound);
636
+
637
+ }
638
+
639
+ defineInputs();
640
+ };
641
+
642
+ function showCardIssuers(status, issuers) {
643
+ showLogMercadoPago(self.messages.setIssuer);
644
+ showLogMercadoPago(status);
645
+ showLogMercadoPago(issuers);
646
+
647
+ var messageChoose = TinyJ(self.selectors.mercadoPagoTextChoice).val();
648
+ var messageDefaultIssuer = TinyJ(self.selectors.textDefaultIssuer).val();
649
+
650
+ fragment = document.createDocumentFragment();
651
+
652
+ var option = new Option(messageChoose + "...", '');
653
+ fragment.appendChild(option);
654
+
655
+ for (var i = 0; i < issuers.length; i++) {
656
+ if (issuers[i].name != self.constants.default) {
657
+ option = new Option(issuers[i].name, issuers[i].id);
658
+ } else {
659
+ option = new Option(messageDefaultIssuer, issuers[i].id);
660
+ }
661
+ fragment.appendChild(option);
662
+ }
663
+
664
+ TinyJ(self.selectors.issuer).empty().appendChild(fragment).enable().removeAttribute(self.constants.style);
665
+ TinyJ(self.selectors.issuerMp).removeAttribute(self.constants.style);
666
+ TinyJ(self.selectors.issuerMpLabel).removeAttribute(self.constants.style);
667
+ defineInputs();
668
+ };
669
+
670
+ function setInstallmentsByIssuerId(status, response) {
671
+ showLogMercadoPago(self.messages.setInstallment);
672
+
673
+ var issuerId = TinyJ(self.selectors.issuer).val();
674
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
675
+
676
+ if (issuerId === '-1') {
677
+ return;
678
+ }
679
+
680
+ getInstallments({
681
+ "bin": getBin(),
682
+ "amount": amount,
683
+ "issuer_id": issuerId
684
+ });
685
+
686
+ }
687
+
688
+ function getInstallments(options) {
689
+
690
+
691
+ showLogMercadoPago(self.messages.getInstallment);
692
+
693
+ hideMessageError();
694
+ showLoading();
695
+
696
+ var route = TinyJ(self.selectors.mercadoRoute).val();
697
+ var baseUrl = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.baseUrl).val();
698
+ var discountAmount = parseFloat(TinyJ(self.selectors.customDiscountAmount).val());
699
+
700
+ if (route != self.constants.checkout) {
701
+ showLogMercadoPago(self.messages.usingMagentoCustomCheckout);
702
+
703
+ tiny.ajax(baseUrl + self.url.amount, {
704
+ method: http.method.GET,
705
+ timeout: 5000,
706
+ success: function (response, status, xhr) {
707
+ showLogMercadoPago(self.messages.getAmountSuccess);
708
+ showLogMercadoPago(status);
709
+ showLogMercadoPago(response);
710
+
711
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val(response.amount);
712
+
713
+ options.amount = parseFloat(response.amount) - discountAmount;
714
+
715
+ showLogMercadoPago(String.format(self.messages.installmentAmount, response.amount));
716
+ showLogMercadoPago(String.format(self.messages.customDiscountAmount, discountAmount));
717
+ showLogMercadoPago(String.format(self.messages.finalAmount, options.amount));
718
+
719
+ Mercadopago.getInstallments(options, setInstallmentInfo);
720
+ },
721
+ error: function (status, response) {
722
+ showLogMercadoPago(self.messages.getAmountError);
723
+ showLogMercadoPago(status);
724
+ showLogMercadoPago(response);
725
+
726
+ //hide loading
727
+ hideLoading();
728
+
729
+ showMessageErrorForm(self.selectors.installmentsDontWork);
730
  }
731
+ });
732
+ }
733
+ else {
734
+
735
+ showLogMercadoPago(self.messages.usingMagentoStdCheckout);
736
+
737
+ options.amount = parseFloat(options.amount) - discountAmount;
738
+
739
+ showLogMercadoPago(String.format(self.messages.installmentAmount, options.amount));
740
+ showLogMercadoPago(String.format(self.messages.customDiscountAmount, discountAmount));
741
+ showLogMercadoPago(String.format(self.messages.finalAmount, options.amount));
742
+
743
+ Mercadopago.getInstallments(options, setInstallmentInfo);
744
+ }
745
+
746
+ }
747
+
748
+ function setInstallmentInfo(status, response) {
749
+ showLogMercadoPago(self.messages.setInstallmentInfo);
750
+ showLogMercadoPago(status);
751
+ showLogMercadoPago(response);
752
+ hideLoading();
753
+
754
+ var selectorInstallments = TinyJ(self.selectors.installments);
755
+
756
+ selectorInstallments.empty();
757
+
758
+ if (response.length > 0) {
759
+ var messageChoose = TinyJ(self.selectors.mercadoPagoTextChoice).val();
760
+
761
+ var option = new Option(messageChoose + "... ", ''),
762
+ payerCosts = response[0].payer_costs;
763
+
764
+ selectorInstallments.appendChild(option);
765
+ for (var i = 0; i < payerCosts.length; i++) {
766
+ option = new Option(payerCosts[i].recommended_message || payerCosts[i].installments, payerCosts[i].installments);
767
+ selectorInstallments.appendChild(option);
768
+ TinyJ(option).attribute(self.constants.cost, payerCosts[i].total_amount);
769
  }
770
+ selectorInstallments.enable();
771
+
772
+
773
+ setTimeout(function () {
774
+ var siteId = TinyJ(self.selectors.siteId).val();
775
+ if (siteId == self.constants.mexico) {
776
+
777
+ var issuers = TinyJ(self.selectors.issuer);
778
+ var issuerExist = false;
779
+ try {
780
+ issuersOptions = issuers.getElem(self.constants.option);
781
+ for (i = 0; i < issuersOptions.length; ++i) {
782
+ if (issuersOptions[i].val() == response[0].issuer.id) {
783
+ issuers.val(response[0].issuer.id);
784
+ issuerExist = true;
785
+ }
786
+ }
 
 
 
 
 
 
 
 
 
787
  }
788
+ catch (err) {
789
+ //nothing is needed here right now
790
+ }
791
+
792
+ if (issuerExist === false) {
793
+ var option = new Option(response[0].issuer.name, response[0].issuer.id);
794
+ issuers.appendChild(option);
795
+ }
796
+
797
+ showLogMercadoPago(String.format(self.messages.issuerSet, response[0].issuer));
 
 
798
  }
799
+ }, 100);
800
+ } else {
801
+ showMessageErrorForm(self.selectors.errorMethodMinAmount);
802
+ }
803
+ }
804
+
805
+
806
+ function releaseEventCreateCardToken() {
807
+ showLogMercadoPago(self.messages.releaseCardTokenEvent);
808
+
809
+ var dataCheckout = TinyJ(self.selectors.dataCheckout);
810
+
811
+ if (Array.isArray(dataCheckout)) {
812
+ for (var x = 0; x < dataCheckout.length; x++) {
813
+ dataCheckout[x].focusout(checkCreateCardToken);
814
+ dataCheckout[x].change(checkCreateCardToken);
815
  }
816
+ } else {
817
+ dataCheckout.focusout(checkCreateCardToken);
818
+ dataCheckout.change(checkCreateCardToken);
819
+ }
820
+
821
+ }
822
+
823
+ function checkCreateCardToken() {
824
+ showLogMercadoPago(self.messages.checkCreateCardToken);
825
+
826
+ var submit = true;
827
+ var dataInputs = defineInputs();
828
+
829
+ for (var x = 0; x < dataInputs.length; x++) {
830
+ if (TinyJ(dataInputs[x]).val() == "" || TinyJ(dataInputs[x]).val() == -1) {
831
+ submit = false;
832
+ }
833
+ }
834
+
835
+ var docNumber = TinyJ(self.selectors.docNumber).val();
836
+ if (docNumber != '' && !checkDocNumber(docNumber)) {
837
+ submit = false;
838
+ }
839
+
840
+ if (submit) {
841
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
842
+ var selector = TinyJ(self.selectors.oneClickPayment).val() == true ? self.selectors.ocp : self.selectors.customCard;
843
+ showLoading();
844
+ Mercadopago.createToken(TinyJ(selector).getElem(), sdkResponseHandler);
845
+ }
846
+ }
847
+
848
+ function sdkResponseHandler(status, response) {
849
+ showLogMercadoPago(self.messages.responseCardToken);
850
+ showLogMercadoPago(status);
851
+ showLogMercadoPago(response);
852
+
853
+ //hide all errors
854
+ hideMessageError();
855
+ hideLoading();
856
+
857
+ if (status == http.status.OK || status == http.status.CREATED) {
858
+ var form = TinyJ(self.selectors.token).val(response.id);
859
+ showLogMercadoPago(response);
860
+
861
+ } else {
862
+
863
+ for (var x = 0; x < Object.keys(response.cause).length; x++) {
864
+ var error = response.cause[x];
865
+ showMessageErrorForm(String.format(self.selectors.errorFormat, error.code));
866
+ }
867
+
868
+ }
869
+ };
870
+
871
+
872
+ function hideMessageError() {
873
+ showLogMercadoPago(self.messages.hideErrors);
874
+ var allMessageErrors = TinyJ(self.selectors.messageError);
875
+ if (Array.isArray(allMessageErrors)) {
876
+ for (var x = 0; x < allMessageErrors.length; x++) {
877
+ allMessageErrors[x].hide();
878
+ }
879
+ } else {
880
+ allMessageErrors.hide();
881
+ }
882
+ }
883
+
884
+ function showMessageErrorForm(elError) {
885
+ showLogMercadoPago(self.messages.showingError);
886
+ showLogMercadoPago(elError);
887
+
888
+ var elMessage = TinyJ(elError);
889
+ if (Array.isArray(elMessage)) {
890
+ for (var x = 0; x < elMessage.length; x++) {
891
+ elMessage[x].show();
892
+ }
893
+ } else {
894
+ elMessage.show();
895
+ }
896
+
897
+ }
898
+
899
+ function showLoading() {
900
+ showLogMercadoPago(self.messages.showLoading);
901
+ TinyJ(self.selectors.loading).show();
902
+ }
903
+
904
+ function hideLoading() {
905
+ showLogMercadoPago(self.messages.hideLoading);
906
+ TinyJ(self.selectors.loading).hide();
907
+ }
908
+
909
+ /*
910
+ *
911
+ * Discount
912
+ *
913
+ */
914
+
915
+ function initDiscountMercadoPagoCustom() {
916
+ showLogMercadoPago(self.messages.initDiscount);
917
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.couponActionApply).click(applyDiscountCustom);
918
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.couponActionRemove).click(removeDiscountCustom);
919
+ }
920
+
921
+ function initDiscountMercadoPagoCustomTicket() {
922
+ showLogMercadoPago(self.messages.initTicket);
923
+ TinyJ(self.selectors.ticketActionApply).click(applyDiscountCustomTicket);
924
+ TinyJ(self.selectors.ticketActionRemove).click(removeDiscountCustomTicket);
925
+ }
926
+
927
+ function applyDiscountCustom() {
928
+ validDiscount(self.selectors.checkoutCustom);
929
+ }
930
+
931
+ function applyDiscountCustomTicket() {
932
+ validDiscount(self.selectors.checkoutTicket);
933
+ }
934
+
935
+ function validDiscount(formPaymentMethod) {
936
+ showLogMercadoPago(self.messages.validateDiscount);
937
+
938
+ var $formPayment = TinyJ(formPaymentMethod);
939
+ var couponCode = $formPayment.getElem(self.selectors.coupon).val();
940
+ var baseUrl = $formPayment.getElem(self.selectors.baseUrl).val();
941
+
942
+
943
+ hideMessageCoupon($formPayment);
944
+
945
+ //show loading
946
+ $formPayment.getElem(self.selectors.couponLoading).show();
947
+
948
+ tiny.ajax({
949
+ method: http.method.GET,
950
+ url: baseUrl + String.format(self.url.couponUrlFormat, couponCode),
951
+ timeout: 5000,
952
+ success: function (r, status, xhr) {
953
+ console.log(r);
954
+ showLogMercadoPago(self.messages.validateCouponResponse);
955
+ showLogMercadoPago({status: status, response: r});
956
+
957
+ $formPayment.getElem(self.selectors.couponLoading).hide();
958
+
959
+ if (r.status == http.status.OK) {
960
+ var couponAmount = (r.response.coupon_amount).toFixed(2)
961
+ var transactionAmount = (r.response.transaction_amount).toFixed(2)
962
+ var idCoupon = r.response.id;
963
+ var currency = $formPayment.getElem(self.selectors.textCurrency).val();
964
+ var urlTerm = String.format(self.url.termsUrlFormat, idCoupon);
965
+
966
+ $formPayment.getElem(self.selectors.discountOkAmountDiscount).html(currency + couponAmount);
967
+ $formPayment.getElem(self.selectors.discountOkTotalAmount).html(currency + transactionAmount);
968
+ $formPayment.getElem(self.selectors.discountOkTotalAmountDiscount).html(currency + (transactionAmount - couponAmount).toFixed(2));
969
+ $formPayment.getElem(self.selectors.totalAmount).val(transactionAmount - couponAmount);
970
+
971
+ $formPayment.getElem(self.selectors.discountOkTerms).attribute("href", urlTerm);
972
+ $formPayment.getElem(self.selectors.discountAmount).val(couponAmount);
973
+
974
+ //show mensagem ok
975
+ $formPayment.getElem(self.selectors.discountOk).show();
976
+ $formPayment.getElem(self.selectors.couponActionRemove).show();
977
+ $formPayment.getElem(self.selectors.couponActionApply).hide();
978
+
979
+ $formPayment.getElem(self.selectors.inputCouponDiscount).removeClass(self.constants.invalidCoupon);
980
+ if (formPaymentMethod == self.selectors.checkoutCustom) {
981
+ var event = {};
982
+ guessingPaymentMethod(event.type = self.constants.keyup);
983
  }
984
+ } else {
985
+
 
 
 
 
 
 
 
 
 
986
  //reset input amount
987
+ $formPayment.getElem(self.selectors.discountAmount).val(0);
988
+ $formPayment.getElem(self.selectors.couponActionRemove).show();
989
+
990
+ console.log(r.response.error);
991
+ $formPayment.getElem(self.selectors.messageCoupon + " ." + r.response.error).show();
992
+ $formPayment.getElem(self.selectors.inputCouponDiscount).addClass(self.constants.invalidCoupon);
 
 
993
  }
994
+ },
995
+ error: function (status, response) {
996
+ console.log(status, response);
997
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
998
  });
999
+ }
1000
+
1001
+ function removeDiscountCustom() {
1002
+ removeDiscount(self.selectors.checkoutCustom);
1003
+ }
1004
+
1005
+ function removeDiscountCustomTicket() {
1006
+ removeDiscount(self.selectors.checkoutTicket);
1007
+ }
1008
+
1009
+ function removeDiscount(formPaymentMethod) {
1010
+ showLogMercadoPago(self.messages.removeDiscount);
1011
+ var $formPayment = TinyJ(formPaymentMethod);
1012
+
1013
+ //hide all info
1014
+ hideMessageCoupon($formPayment);
1015
+ $formPayment.getElem(self.selectors.couponActionApply).show();
1016
+ $formPayment.getElem(self.selectors.couponActionRemove).hide();
1017
+ $formPayment.getElem(self.selectors.coupon).val("");
1018
+ $formPayment.getElem(self.selectors.discountAmount).val(0);
1019
+ $formPayment.getElem(self.selectors.discountOk).hide();
1020
+
1021
+ if (formPaymentMethod == self.selectors.checkoutCustom) {
1022
+ var event = {};
1023
+ guessingPaymentMethod(event.type = self.constants.keyup);
1024
+ }
1025
+ $formPayment.getElem(self.selectors.inputCouponDiscount).removeClass(self.constants.invalidCoupon);
1026
+ showLogMercadoPago(self.messages.removeCoupon);
1027
+ }
1028
+
1029
+ function hideMessageCoupon($formPayment) {
1030
+ showLogMercadoPago(self.messages.hideCouponMessages);
1031
+
1032
+ var messageCoupon = $formPayment.getElem().querySelectorAll(self.selectors.couponList);
1033
+
1034
+ for (var x = 0; x < messageCoupon.length; x++) {
1035
+ messageCoupon[x].hide();
1036
+ }
1037
+ }
1038
+
1039
+ return {
1040
+ init: initMercadoPagoJs,
1041
+ initDiscount: initDiscountMercadoPagoCustom,
1042
+ initOCP: initMercadoPagoOCP,
1043
+ initDiscountTicket: initDiscountMercadoPagoCustomTicket
1044
+ };
1045
+ }
1046
+
1047
+ function getInstance() {
1048
+ if (!instance) {
1049
+ instance = new InitializeNewModule();
1050
+ }
1051
+ return instance;
1052
+ }
1053
 
1054
+ return {
1055
+ getInstance: getInstance,
1056
+ getSelectors: getSelectors,
1057
+ getUrls: getUrls,
1058
+ getMessages: getMessages,
1059
+ setMessages: setMessages,
1060
+ setSelectors: setSelectors,
1061
+ setUrls: setUrls,
1062
+ enableLog: enableLog,
1063
+ isLogEnabled: isLogEnabled
1064
+ };
1065
+ })();
js/mercadopago/mercadopago_osc.js ADDED
@@ -0,0 +1,1179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var MercadoPagoCustom = (function () {
2
+
3
+ var instance = null;
4
+ var http = {
5
+ status: {
6
+ OK: 200,
7
+ CREATED: 201
8
+ },
9
+ method: {
10
+ GET: 'GET'
11
+ }
12
+ };
13
+ var self = {
14
+ messages: {
15
+ init: 'Init Mercado Pago JS',
16
+ initOCP: 'Init Mercado Pago OCP',
17
+ initDiscount: 'Init Mercado Pago Custom Discount',
18
+ initTicket: 'Init Mercado Pago Custom Ticket',
19
+ mpIncorrectlyConfigured: 'Mercado Pago was not configured correctly. Public Key not found.',
20
+ publicKey: 'Public Key: {0}',
21
+ siteId: 'SITE_ID: {0}',
22
+ invalidDocument: 'Document Number is invalid.',
23
+ incorrectExpDate: 'Incorrect credit card expiration date.',
24
+ defineInputs: 'Define Inputs',
25
+ ocpUser: 'Action One Click Pay User',
26
+ clearOpts: 'Clear Option',
27
+ getBin: 'Get bin',
28
+ guessingPayment: 'Guessing Payment',
29
+ setPaymentInfo: 'Set payment method info: ',
30
+ issuerMandatory: 'Issuer is mandatory? {0}',
31
+ setIssuer: 'Set Issuer...',
32
+ setInstallment: 'Set install by issuer id',
33
+ getInstallment: 'Get Installments',
34
+ usingMagentoCustomCheckout: 'Using checkout customized Magento...',
35
+ usingMagentoStdCheckout: 'Using checkout standard Magento...',
36
+ getAmountSuccess: 'Success in get amount: ',
37
+ installmentAmount: 'Valor para calculo da parcela: {0}',
38
+ customDiscountAmount: 'Valor do desconto: {0}',
39
+ finalAmount: 'Valor final: {0}',
40
+ getAmountError: 'Error getting amount: ',
41
+ setInstallmentInfo: 'Set Installment info',
42
+ issuerSet: 'Issuer set: {0}',
43
+ releasecardTokenEvent: 'Release event create card token',
44
+ checkCreateCardToken: 'Check create card token',
45
+ responseCardToken: 'Response create/update card_token: ',
46
+ hideErrors: 'Hiding all errors...',
47
+ showingError: 'Show Message Error Form',
48
+ showLoading: 'Show loading...',
49
+ hideLoading: 'Hide loading...',
50
+ validateDiscount: 'Valid Discount',
51
+ validateCouponResponse: 'Validating coupon response : ',
52
+ removeDiscount: 'Remove Discount',
53
+ removeCoupon: 'Remove coupon!',
54
+ hideCouponMessages: 'Hide all coupon messages...',
55
+ ocpActivatedFormat: 'OCP? {0}',
56
+ cardHandler: 'card Handler'
57
+ },
58
+ constants: {
59
+ option: 'option',
60
+ undefined: 'undefined',
61
+ default: 'default',
62
+ checkout: 'onestepcheckout',
63
+ mexico: 'MLM',
64
+ brazil: 'MLB',
65
+ colombia: 'MCO',
66
+ mercadopagoCustom: 'mercadopago_custom',
67
+ validateDiscount: 'validate-discount',
68
+ validateDocNumber: 'mp-validate-docnumber',
69
+ validateCC: 'mp-validate-cc-exp',
70
+ invalidCoupon: 'invalid_coupon',
71
+ cost: 'cost',
72
+ dataElementId: 'data-element-id',
73
+ style: 'style',
74
+ requireEntry: 'required-entry',
75
+ validateSelect: 'validate-select',
76
+ keyup: 'keyup',
77
+ firstSixDigits: 'first_six_digits',
78
+ backgroundUrlFormat: 'url({0}) no-repeat'
79
+ },
80
+ selectors: {
81
+ checkoutCustom: '#mercadopago_checkout_custom',
82
+ checkoutTicket: '#mercadopago_checkout_custom_ticket',
83
+ siteId: '#mercadopago_checkout_custom .site_id',
84
+ cardNumberInput: 'input[data-checkout="cardNumber"]',
85
+ installmentsDontWork: '.error-installment-not-work',
86
+ mercadopagoCustomOpt: '#p_method_mercadopago_custom',
87
+ cardExpYear: '#cardExpirationYear',
88
+ docType: '#docType',
89
+ cardId: '#cardId',
90
+ returnToCardList: '#return_list_card_mp',
91
+ useOtherCard: '#use_other_card_mp',
92
+ installments: '#installments',
93
+ totalAmount: '.total_amount',
94
+ amount: '.amount',
95
+ cardNumber: '#cardNumber',
96
+ issuer: '#issuer',
97
+ issuerMp: '#issuer__mp',
98
+ issuerMpLabel: '#issuer__mp label',
99
+ issuerId: 'issuer_id',
100
+ cardExpirationMonth: '#cardExpirationMonth',
101
+ cardHolder: '#cardholderName',
102
+ docNumber: '#docNumber',
103
+ securityCode: '#securityCode',
104
+ securityCodeOCP: '#securityCodeOCP',
105
+ dataCheckout: '[data-checkout]',
106
+ oneClickPayment: '#mercadopago_checkout_custom #one_click_pay_mp',
107
+ installmentText: '#mercadopago_checkout_custom .mercadopago-text-installment',
108
+ paymentMethodId: '#mercadopago_checkout_custom .payment_method_id',
109
+ paymenMethodNotFound: '.error-payment-method-not-found',
110
+ paymentMethod: '#paymentMethod',
111
+ paymentMethodSelect: 'select[data-checkout="paymentMethod"]',
112
+ mercadoPagoTextChoice: '#mercadopago_checkout_custom .mercadopago-text-choice',
113
+ errorMethodMinAmount: '.error-payment-method-min-amount',
114
+ textDefaultIssuer: '#mercadopago_checkout_custom .mercadopago-text-default-issuer',
115
+ customCard: '#mercadopago_checkout_custom_card',
116
+ ocp: '#mercadopago_checkout_custom_ocp',
117
+ mercadoRoute: '#mercadopago_checkout_custom .mercado_route',
118
+ baseUrl: '.mercado_base_url',
119
+ loading: '#mercadopago-loading',
120
+ messageError: '.message-error',
121
+ customDiscountAmount: '#mercadopago_checkout_custom .mercadopago-discount-amount',
122
+ discountAmount: '.mercadopago-discount-amount',
123
+ token: '#mercadopago_checkout_custom .token',
124
+ errorFormat: '.error-{0}',
125
+ couponActionApply: '.mercadopago-coupon-action-apply',
126
+ couponActionRemove: '.mercadopago-coupon-action-remove',
127
+ ticketActionApply: '#mercadopago_checkout_custom_ticket .mercadopago-coupon-action-apply',
128
+ ticketActionRemove: '#mercadopago_checkout_custom_ticket .mercadopago-coupon-action-remove',
129
+ coupon: '.mercadopago_coupon',
130
+ couponLoading: '.mercadopago-message-coupon .loading',
131
+ couponList: '.mercadopago-message-coupon li',
132
+ textCurrency: '.mercadopago-text-currency',
133
+ discountOk: '.mercadopago-message-coupon .discount-ok',
134
+ messageCoupon: '.mercadopago-message-coupon',
135
+ discountOkAmountDiscount: '.mercadopago-message-coupon .discount-ok .amount-discount',
136
+ discountOkTotalAmount: '.mercadopago-message-coupon .discount-ok .total-amount',
137
+ discountOkTotalAmountDiscount: '.mercadopago-message-coupon .discount-ok .total-amount-discount',
138
+ discountOkTerms: '.mercadopago-message-coupon .discount-ok .mercadopago-coupon-terms',
139
+ inputCouponDiscount: '#input-coupon-discount'
140
+
141
+ },
142
+ url: {
143
+ amount: 'mercadopago/api/amount',
144
+ couponUrlFormat: 'mercadopago/api/coupon?id={0}',
145
+ termsUrlFormat: "https://api.mercadolibre.com/campaigns/{0}/terms_and_conditions?format_type=html"
146
+ },
147
+ enableLog: true
148
+ };
149
+
150
+ function getMessages() {
151
+ return self.messages;
152
+ }
153
+
154
+ function getConstants() {
155
+ return self.constants;
156
+ }
157
+
158
+ function getSelectors() {
159
+ return self.selectors;
160
+ }
161
+
162
+ function getUrls() {
163
+ return self.url;
164
+ }
165
+
166
+ function setMessages(messages) {
167
+ self.messages = messages;
168
+ }
169
+
170
+ function setConstants(constants) {
171
+ self.constants = constants;
172
+ }
173
+
174
+ function setSelectors(selectors) {
175
+ self.selectors = selectors;
176
+ }
177
+
178
+ function setUrls(urls) {
179
+ self.url = urls;
180
+ }
181
+
182
+ function isLogEnabled() {
183
+ return self.enableLog;
184
+ }
185
+
186
+ // MERCADO LOG
187
+ function enableLog(val) {
188
+ self.enableLog = val;
189
+ }
190
+
191
+ function InitializeNewModule() {
192
+
193
+ var installmentOption = '';
194
+
195
+ function showLogMercadoPago(message) {
196
+ if (self.enableLog) {
197
+ console.debug(message);
198
+ }
199
+ }
200
+
201
+ if (typeof PublicKeyMercadoPagoCustom != self.constants.undefined) {
202
+ Mercadopago.setPublishableKey(PublicKeyMercadoPagoCustom);
203
+ }
204
+
205
+
206
+ function initMercadoPagoJs() {
207
+ showLogMercadoPago(self.messages.init);
208
+
209
+ var siteId = TinyJ(self.selectors.siteId).val();
210
+
211
+ if (typeof PublicKeyMercadoPagoCustom == self.constants.undefined) {
212
+ alert(self.messages.mpIncorrectlyConfigured);
213
+ }
214
+
215
+ if (isOsc()) {
216
+ //inovarti onestepcheckout
217
+ self.constants.checkout = 'onestepcheckout';
218
+ } else if (isIdeasa()) {
219
+ //ideasa onestepcheckout
220
+ self.constants.checkout = 'idecheckoutvm';
221
+ payment.changeVisible('mercadopago_customticket', true);
222
+ }
223
+
224
+ //Show public key
225
+ showLogMercadoPago(String.format(self.messages.publicKey, PublicKeyMercadoPagoCustom));
226
+ //Show site
227
+ showLogMercadoPago(String.format(self.messages.siteId, siteId));
228
+
229
+ if (siteId != self.constants.mexico) {
230
+ Mercadopago.getIdentificationTypes();
231
+ } else {
232
+ var methods = getPaymentMethods();
233
+ setPaymentMethodsInfo(methods);
234
+ TinyJ(self.selectors.paymentMethodSelect).change(setPaymentMethodId);
235
+ }
236
+ if (siteId == self.constants.colombia) {
237
+ setTimeout(function () {
238
+ setPaymentMethods()
239
+ }, 5000);
240
+ }
241
+
242
+ defineInputs();
243
+
244
+ TinyJ(self.selectors.cardNumberInput).keyup(guessingPaymentMethod);
245
+ TinyJ(self.selectors.cardNumberInput).keyup(clearOptions);
246
+ TinyJ(self.selectors.cardNumberInput).change(guessingPaymentMethod);
247
+ TinyJ(self.selectors.installmentsDontWork).click(guessingPaymentMethod);
248
+
249
+ releaseEventCreateCardToken();
250
+
251
+ cardsHandler();
252
+
253
+ TinyJ(self.selectors.installments).getElem().stopObserving();
254
+ TinyJ(self.selectors.installments).change(setTotalAmount);
255
+
256
+ if (isOsc()) {
257
+ registerAjaxObervers();
258
+ }
259
+
260
+ if (TinyJ(self.selectors.mercadopagoCustomOpt).isChecked()) {
261
+ payment.switchMethod(self.constants.mercadopagoCustom);
262
+ }
263
+
264
+ Validation.add(self.constants.validateDiscount, ' ', function (v, element) {
265
+ return (!element.hasClassName(self.constants.invalidCoupon));
266
+ });
267
+
268
+ Validation.add(self.constants.validateDocNumber, self.messages.invalidDocument, function (v, element) {
269
+ return checkDocNumber(v);
270
+ });
271
+
272
+ Validation.add(self.constants.validateCC, self.messages.incorrectExpDate, function (v, element) {
273
+ var ccExpMonth = v;
274
+ var ccExpYear = TinyJ(self.selectors.cardExpYear).val();
275
+ var currentTime = new Date();
276
+ var currentMonth = currentTime.getMonth() + 1;
277
+ var currentYear = currentTime.getFullYear();
278
+ if (ccExpMonth < currentMonth && ccExpYear == currentYear) {
279
+ return false;
280
+ }
281
+ return true;
282
+ });
283
+ }
284
+
285
+ function setPaymentMethodId(event) {
286
+ var paymentMethodSelector = TinyJ(self.selectors.paymentMethodSelect);
287
+ var paymentMethodId = paymentMethodSelector.val();
288
+ if (paymentMethodId != '') {
289
+ var payment_method_id = TinyJ(self.selectors.paymentMethodId);
290
+ payment_method_id.val(paymentMethodId);
291
+ }
292
+ }
293
+
294
+ function getPaymentMethods() {
295
+ var allMethods = Mercadopago.getPaymentMethods();
296
+ var allowedMethods = [];
297
+ for (var key in allMethods) {
298
+ var method = allMethods[key];
299
+ var typeId = method.payment_type_id;
300
+ if (typeId == 'debit_card' || typeId == 'credit_card' || typeId == 'prepaid_card') {
301
+ allowedMethods.push(method);
302
+ }
303
+ }
304
+
305
+ return allowedMethods;
306
+
307
+ }
308
+
309
+ function checkDocNumber(v) {
310
+ var flagReturn = true;
311
+ Mercadopago.getIdentificationTypes(function (status, identificationsTypes) {
312
+ if (status == http.status.OK) {
313
+ var type = TinyJ(self.selectors.docType).val();
314
+ identificationsTypes.each(function (dataType) {
315
+ if (dataType.id == type) {
316
+ if (v.length > dataType.max_length || v.length < dataType.min_length) {
317
+ flagReturn = false;
318
+ }
319
+ }
320
+ });
321
+ }
322
+ });
323
+ return flagReturn;
324
+ }
325
+
326
+ //init one click pay
327
+ function initMercadoPagoOCP() {
328
+ showLogMercadoPago(self.messages.initOCP);
329
+ TinyJ(self.selectors.cardId).change(cardsHandler);
330
+ TinyJ(self.selectors.installments).getElem().stopObserving();
331
+
332
+ var returnListCard = TinyJ(self.selectors.returnToCardList);
333
+ TinyJ(self.selectors.useOtherCard).click(actionUseOneClickPayOrNo);
334
+ returnListCard.click(actionUseOneClickPayOrNo);
335
+
336
+ TinyJ(self.selectors.installments).change(setTotalAmount);
337
+ var _cardNumber = TinyJ(self.selectors.cardNumber);
338
+ if (_cardNumber.val() != '') {
339
+ var _event = new Event('change');
340
+ _cardNumber.getElem().dispatchEvent(_event);
341
+ }
342
+
343
+ if (isOsc()) {
344
+ registerAjaxObervers();
345
+ }
346
+
347
+ returnListCard.show();
348
+ }
349
+
350
+ function setTotalAmount() {
351
+ var _installments = TinyJ(self.selectors.installments);
352
+ var _cost = '';
353
+ try {
354
+ _cost = _installments.getSelectedOption().attribute(self.constants.cost);
355
+ if (installmentOption != _installments.getSelectedOption().val()) {
356
+ installmentOption = _installments.getSelectedOption().val();
357
+ }
358
+ } catch (Exception) {
359
+ _cost = '';
360
+ }
361
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.totalAmount).val(_cost);
362
+
363
+ if (isOsc()) {
364
+ //inovarti onestepcheckout
365
+ OSCPayment.savePayment();
366
+ } else if (isIdeasa()) {
367
+ //ideasa onestepcheckout
368
+ payment.update();
369
+ }
370
+
371
+ }
372
+
373
+ function isOsc() {
374
+ return (typeof OSCPayment !== self.constants.undefined);
375
+ }
376
+
377
+ function isIdeasa() {
378
+ return (typeof payment !== self.constants.undefined);
379
+ }
380
+
381
+ function registerAjaxObervers() {
382
+ Ajax.Responders.register({
383
+ onCreate: function () {
384
+ try {
385
+ TinyJ(self.selectors.installments).disable();
386
+ } catch (Exception) {
387
+ showLogMercadoPago(Exception);
388
+ }
389
+
390
+ },
391
+ onComplete: function () {
392
+ try {
393
+ TinyJ(self.selectors.installments).enable();
394
+ } catch (Exception) {
395
+ showLogMercadoPago(Exception);
396
+ }
397
+ }
398
+ });
399
+ }
400
+
401
+ function defineInputs() {
402
+ showLogMercadoPago(self.messages.defineInputs);
403
+
404
+ var siteId = TinyJ(self.selectors.siteId).val();
405
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
406
+ var dataCheckout = TinyJ(self.selectors.dataCheckout);
407
+ var excludeInputs = [self.selectors.cardId, self.selectors.securityCodeOCP, self.selectors.paymentMethod];
408
+ var dataInputs = [];
409
+ var disabledInputs = [];
410
+
411
+ if (oneClickPay == true) {
412
+
413
+ excludeInputs = [
414
+ self.selectors.cardNumber, self.selectors.issuer, self.selectors.cardExpirationMonth, self.selectors.cardExpYear,
415
+ self.selectors.cardHolder, self.selectors.docType, self.selectors.docNumber, self.selectors.securityCode, self.selectors.paymentMethod
416
+ ];
417
+
418
+ } else if (siteId == self.constants.brazil) {
419
+
420
+ excludeInputs.push(self.selectors.issuer);
421
+ excludeInputs.push(self.selectors.docType);
422
+
423
+ } else if (siteId == self.constants.mexico) {
424
+
425
+ excludeInputs.push(self.selectors.docType)
426
+ excludeInputs.push(self.selectors.docNumber);
427
+ disabledInputs.push(self.selectors.issuer);
428
+ var index = excludeInputs.indexOf(self.selectors.paymentMethod);
429
+ if (index > -1) {
430
+ excludeInputs.splice(index, 1);
431
+ }
432
+
433
+ } else if (siteId == self.constants.colombia) {
434
+ var indexColombia = excludeInputs.indexOf(self.selectors.paymentMethod);
435
+ if (indexColombia > -1) {
436
+ excludeInputs.splice(indexColombia, 1);
437
+ }
438
+ }
439
+ if (!this.issuerMandatory) {
440
+ excludeInputs.push(self.selectors.issuer);
441
+ }
442
+
443
+ for (var x = 0; x < dataCheckout.length; x++) {
444
+ var $id = "#" + dataCheckout[x].id();
445
+
446
+ var elPai = dataCheckout[x].attribute(self.constants.dataElementId);
447
+
448
+
449
+ if (excludeInputs.indexOf($id) == -1) {
450
+ TinyJ(elPai).removeAttribute(self.constants.style);
451
+ dataInputs.push($id);
452
+ if (disabledInputs.indexOf($id) != -1) {
453
+ TinyJ(self.selectors.checkoutCustom).getElem($id).disabled = "disabled";
454
+ }
455
+ } else {
456
+ TinyJ(elPai).hide();
457
+ }
458
+ }
459
+
460
+
461
+ //Show inputs
462
+ showLogMercadoPago(dataInputs);
463
+
464
+ return dataInputs;
465
+
466
+ }
467
+
468
+ function setPaymentMethodsInfo(methods) {
469
+ //hide loaging
470
+ hideLoading();
471
+
472
+ var selectorPaymentMethods = TinyJ(self.selectors.paymentMethod);
473
+
474
+ selectorPaymentMethods.empty();
475
+
476
+ var message_choose = document.querySelector(".mercadopago-text-choice").value;
477
+ var option = new Option(message_choose + "... ", '');
478
+ selectorPaymentMethods.appendChild(option);
479
+ if (methods.length > 0) {
480
+ for (var i = 0; i < methods.length; i++) {
481
+ option = new Option(methods[i].name, methods[i].id);
482
+ selectorPaymentMethods.appendChild(option);
483
+ }
484
+ }
485
+ }
486
+
487
+ function setRequiredFields(required) {
488
+ if (required) {
489
+ TinyJ(self.selectors.cardNumber).addClass(self.constants.requireEntry);
490
+ TinyJ(self.selectors.cardHolder).addClass(self.constants.requireEntry);
491
+ TinyJ(self.selectors.docNumber).addClass(self.constants.requireEntry);
492
+ TinyJ(self.selectors.cardExpirationMonth).addClass(self.constants.validateSelect);
493
+ TinyJ(self.selectors.cardExpYear).addClass(self.constants.validateSelect);
494
+ TinyJ(self.selectors.docType).addClass(self.constants.validateSelect);
495
+ TinyJ(self.selectors.securityCodeOCP).removeClass(self.constants.requireEntry);
496
+ TinyJ(self.selectors.securityCode).addClass(self.constants.requireEntry);
497
+ } else {
498
+ TinyJ(self.selectors.cardNumber).removeClass(self.constants.requireEntry);
499
+ TinyJ(self.selectors.cardHolder).removeClass(self.constants.requireEntry);
500
+ TinyJ(self.selectors.docNumber).removeClass(self.constants.requireEntry);
501
+ TinyJ(self.selectors.securityCode).removeClass(self.constants.requireEntry);
502
+ TinyJ(self.selectors.securityCodeOCP).addClass(self.constants.requireEntry);
503
+ TinyJ(self.selectors.cardExpirationMonth).removeClass(self.constants.validateSelect);
504
+ TinyJ(self.selectors.cardExpYear).removeClass(self.constants.validateSelect);
505
+ TinyJ(self.selectors.docType).removeClass(self.constants.validateSelect);
506
+ }
507
+ }
508
+
509
+ function actionUseOneClickPayOrNo() {
510
+ showLogMercadoPago(self.messages.ocpUser);
511
+
512
+ var ocp = TinyJ(self.selectors.oneClickPayment).val();
513
+
514
+ showLogMercadoPago(String.format(self.messages.ocpActivatedFormat, ocp));
515
+
516
+ if (ocp == true) {
517
+ TinyJ(self.selectors.oneClickPayment).val(0);
518
+ TinyJ(self.selectors.cardId).disable();
519
+ setRequiredFields(true);
520
+ } else {
521
+ TinyJ(self.selectors.oneClickPayment).val(1);
522
+ TinyJ(self.selectors.cardId).enable();
523
+ setRequiredFields(false);
524
+ }
525
+
526
+ defineInputs();
527
+ clearOptions();
528
+ Mercadopago.clearSession();
529
+
530
+ hideMessageError();
531
+
532
+ checkCreateCardToken();
533
+
534
+ //update payment_id
535
+ guessingPaymentMethod(event.type = self.constants.keyup);
536
+
537
+
538
+ }
539
+
540
+ function clearOptions() {
541
+ showLogMercadoPago(self.messages.clearOpts);
542
+
543
+ var bin = getBin();
544
+ if (bin != undefined && (bin.length == 0 || TinyJ(self.selectors.cardNumberInput).val() == '')) {
545
+ var messageInstallment = TinyJ(self.selectors.installmentText).val();
546
+
547
+ var issuer = TinyJ(self.selectors.issuer);
548
+ issuer.hide();
549
+ issuer.empty();
550
+
551
+ TinyJ(self.selectors.issuerMp).hide();
552
+ TinyJ(self.selectors.issuerMpLabel).hide();
553
+
554
+ var selectorInstallments = TinyJ(self.selectors.installments);
555
+ var fragment = document.createDocumentFragment();
556
+ option = new Option(messageInstallment, '');
557
+
558
+ selectorInstallments.empty();
559
+ fragment.appendChild(option);
560
+ selectorInstallments.appendChild(fragment);
561
+ selectorInstallments.disable();
562
+ }
563
+ }
564
+
565
+ function cardsHandler() {
566
+ showLogMercadoPago(self.messages.cardHandler);
567
+ clearOptions();
568
+ var cardSelector;
569
+ try {
570
+ cardSelector = TinyJ(self.selectors.cardId);
571
+ }
572
+ catch (err) {
573
+ return;
574
+ }
575
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
576
+
577
+ if (oneClickPay == true) {
578
+ var selectedCard = cardSelector.getSelectedOption();
579
+ if (selectedCard.val() != "-1") {
580
+ var _bin = selectedCard.attribute(self.constants.firstSixDigits);
581
+ Mercadopago.getPaymentMethod({"bin": _bin}, setPaymentMethodInfo);
582
+ TinyJ(self.selectors.issuer).val('');
583
+ }
584
+ }
585
+ }
586
+
587
+ function getBin() {
588
+ showLogMercadoPago(self.messages.getBin);
589
+
590
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
591
+ if (oneClickPay == true) {
592
+ try {
593
+ var cardSelector = TinyJ(self.selectors.cardId).getSelectedOption();
594
+ }
595
+ catch (err) {
596
+ return;
597
+ }
598
+ if (cardSelector.val() != "-1") {
599
+ return cardSelector.attribute(self.constants.firstSixDigits);
600
+ }
601
+ } else {
602
+ var ccNumber = TinyJ(self.selectors.cardNumberInput).val();
603
+ return ccNumber.replace(/[ .-]/g, '').slice(0, 6);
604
+ }
605
+ return;
606
+ }
607
+
608
+
609
+ function guessingPaymentMethod(event) {
610
+ showLogMercadoPago(self.messages.guessingPayment);
611
+
612
+ //hide all errors
613
+ hideMessageError();
614
+
615
+ var bin = getBin();
616
+ try {
617
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
618
+ } catch (e) {
619
+ var amount = TinyJ(self.selectors.checkoutTicket).getElem(self.selectors.amount).val();
620
+ }
621
+
622
+ if (event.type == self.constants.keyup) {
623
+ if (bin != undefined && bin.length == 6) {
624
+ Mercadopago.getPaymentMethod({
625
+ "bin": bin,
626
+ "amount": amount
627
+ }, setPaymentMethodInfo);
628
+ }
629
+ } else {
630
+ setTimeout(function () {
631
+ if (bin != undefined && bin.length >= 6) {
632
+ Mercadopago.getPaymentMethod({
633
+ "bin": bin,
634
+ "amount": amount
635
+ }, setPaymentMethodInfo);
636
+ }
637
+ }, 100);
638
+ }
639
+ };
640
+
641
+ function setPaymentMethodInfo(status, response) {
642
+ showLogMercadoPago(self.messages.setPaymentInfo);
643
+ showLogMercadoPago(status);
644
+ showLogMercadoPago(response);
645
+
646
+ //hide loading
647
+ hideLoading();
648
+
649
+ if (status == http.status.OK) {
650
+ if (response.length == 1) {
651
+ var paymentMethodId = response[0].id;
652
+ TinyJ(self.selectors.paymentMethodId).val(paymentMethodId);
653
+ }
654
+
655
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
656
+ var selector = oneClickPay == true ? self.selectors.cardId : self.selectors.cardNumberInput;
657
+ if (response.length == 1) {
658
+ TinyJ(selector).getElem().style.background = String.format(self.constants.backgroundUrlFormat, response[0].secure_thumbnail);
659
+ }
660
+
661
+ var bin = getBin();
662
+ try {
663
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
664
+ } catch (e) {
665
+ var amount = TinyJ(self.selectors.checkoutTicket).getElem(self.selectors.amount).val();
666
+ }
667
+
668
+
669
+ //get installments
670
+ getInstallments({
671
+ "bin": bin,
672
+ "amount": amount
673
+ });
674
+
675
+ // check if the issuer is necessary to pay
676
+ this.issuerMandatory;
677
+ this.issuerMandatory = false;
678
+ var additionalInfo = response[0].additional_info_needed;
679
+
680
+ for (var i = 0; i < additionalInfo.length; i++) {
681
+ if (additionalInfo[i] == self.selectors.issuerId) {
682
+ this.issuerMandatory = true;
683
+ }
684
+ }
685
+ ;
686
+
687
+ showLogMercadoPago(String.format(self.messages.issuerMandatory, this.issuerMandatory));
688
+
689
+ var issuer = TinyJ(self.selectors.issuer);
690
+
691
+ if (this.issuerMandatory) {
692
+ Mercadopago.getIssuers(response[0].id, showCardIssuers);
693
+ issuer.change(setInstallmentsByIssuerId);
694
+ } else {
695
+ TinyJ(self.selectors.issuerMp).hide();
696
+ issuer.hide();
697
+ issuer.getElem().options.length = 0;
698
+ }
699
+
700
+ } else {
701
+
702
+ showMessageErrorForm(self.selectors.paymenMethodNotFound);
703
+
704
+ }
705
+
706
+ defineInputs();
707
+ };
708
+
709
+ function showCardIssuers(status, issuers) {
710
+ showLogMercadoPago(self.messages.setIssuer);
711
+ showLogMercadoPago(status);
712
+ showLogMercadoPago(issuers);
713
+
714
+ var messageChoose = TinyJ(self.selectors.mercadoPagoTextChoice).val();
715
+ var messageDefaultIssuer = TinyJ(self.selectors.textDefaultIssuer).val();
716
+
717
+ fragment = document.createDocumentFragment();
718
+
719
+ var option = new Option(messageChoose + "...", '');
720
+ fragment.appendChild(option);
721
+
722
+ for (var i = 0; i < issuers.length; i++) {
723
+ if (issuers[i].name != self.constants.default) {
724
+ option = new Option(issuers[i].name, issuers[i].id);
725
+ } else {
726
+ option = new Option(messageDefaultIssuer, issuers[i].id);
727
+ }
728
+ fragment.appendChild(option);
729
+ }
730
+
731
+ TinyJ(self.selectors.issuer).empty().appendChild(fragment).enable().removeAttribute(self.constants.style);
732
+ TinyJ(self.selectors.issuerMp).removeAttribute(self.constants.style);
733
+ TinyJ(self.selectors.issuerMpLabel).removeAttribute(self.constants.style);
734
+ defineInputs();
735
+ };
736
+
737
+ function setInstallmentsByIssuerId(status, response) {
738
+ showLogMercadoPago(self.messages.setInstallment);
739
+
740
+ var issuerId = TinyJ(self.selectors.issuer).val();
741
+ var amount = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val();
742
+
743
+ if (issuerId === '-1') {
744
+ return;
745
+ }
746
+
747
+ getInstallments({
748
+ "bin": getBin(),
749
+ "amount": amount,
750
+ "issuer_id": issuerId
751
+ });
752
+
753
+ }
754
+
755
+ function getInstallments(options) {
756
+
757
+
758
+ showLogMercadoPago(self.messages.getInstallment);
759
+
760
+ hideMessageError();
761
+ showLoading();
762
+
763
+ var route = TinyJ(self.selectors.mercadoRoute).val();
764
+ var baseUrl = TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.baseUrl).val();
765
+ var discountAmount = parseFloat(TinyJ(self.selectors.customDiscountAmount).val());
766
+
767
+ if (route != self.constants.checkout) {
768
+ showLogMercadoPago(self.messages.usingMagentoCustomCheckout);
769
+
770
+ tiny.ajax(baseUrl + self.url.amount, {
771
+ method: http.method.GET,
772
+ timeout: 5000,
773
+ success: function (response, status, xhr) {
774
+ showLogMercadoPago(self.messages.getAmountSuccess);
775
+ showLogMercadoPago(status);
776
+ showLogMercadoPago(response);
777
+
778
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.amount).val(response.amount);
779
+
780
+ options.amount = parseFloat(response.amount) - discountAmount;
781
+
782
+ showLogMercadoPago(String.format(self.messages.installmentAmount, response.amount));
783
+ showLogMercadoPago(String.format(self.messages.customDiscountAmount, discountAmount));
784
+ showLogMercadoPago(String.format(self.messages.finalAmount, options.amount));
785
+
786
+ Mercadopago.getInstallments(options, setInstallmentInfo);
787
+ },
788
+ error: function (status, response) {
789
+ showLogMercadoPago(self.messages.getAmountError);
790
+ showLogMercadoPago(status);
791
+ showLogMercadoPago(response);
792
+
793
+ //hide loaging
794
+ hideLoading();
795
+
796
+ showMessageErrorForm(self.selectors.installmentsDontWork);
797
+ }
798
+ });
799
+ }
800
+ else {
801
+
802
+ showLogMercadoPago(self.messages.usingMagentoStdCheckout);
803
+
804
+ options.amount = parseFloat(options.amount) - discountAmount;
805
+
806
+ showLogMercadoPago(String.format(self.messages.installmentAmount, options.amount));
807
+ showLogMercadoPago(String.format(self.messages.customDiscountAmount, discountAmount));
808
+ showLogMercadoPago(String.format(self.messages.finalAmount, options.amount));
809
+
810
+ Mercadopago.getInstallments(options, setInstallmentInfo);
811
+ }
812
+
813
+ }
814
+
815
+ function setInstallmentInfo(status, response) {
816
+ showLogMercadoPago(self.messages.setInstallmentInfo);
817
+ showLogMercadoPago(status);
818
+ showLogMercadoPago(response);
819
+ //hide loaging
820
+ hideLoading();
821
+
822
+ var selectorInstallments = TinyJ(self.selectors.installments);
823
+
824
+ selectorInstallments.empty();
825
+
826
+ if (response.length > 0) {
827
+ var messageChoose = TinyJ(self.selectors.mercadoPagoTextChoice).val();
828
+
829
+ var option = new Option(messageChoose + "... ", ''),
830
+ payerCosts = response[0].payer_costs;
831
+
832
+ selectorInstallments.appendChild(option);
833
+ for (var i = 0; i < payerCosts.length; i++) {
834
+ option = new Option(payerCosts[i].recommended_message || payerCosts[i].installments, payerCosts[i].installments);
835
+ selectorInstallments.appendChild(option);
836
+ TinyJ(option).attribute(self.constants.cost, payerCosts[i].total_amount);
837
+ }
838
+ selectorInstallments.enable();
839
+
840
+ selectorInstallments.val(installmentOption);
841
+
842
+ if (installmentOption) {
843
+ setTotalAmount();
844
+ }
845
+
846
+ checkCreateCardToken();
847
+
848
+ setTimeout(function () {
849
+ var siteId = TinyJ(self.selectors.siteId).val();
850
+ if (siteId == self.constants.mexico) {
851
+
852
+ var issuers = TinyJ(self.selectors.issuer);
853
+ var issuerExist = false;
854
+ try {
855
+ issuersOptions = issuers.getElem(self.constants.option);
856
+ for (i = 0; i < issuersOptions.length; ++i) {
857
+ if (issuersOptions[i].val() == response[0].issuer.id) {
858
+ issuers.val(response[0].issuer.id);
859
+ issuerExist = true;
860
+ }
861
+ }
862
+ }
863
+ catch (err) {
864
+ //nothing is needed here right now
865
+ }
866
+
867
+ if (issuerExist === false) {
868
+ var option = new Option(response[0].issuer.name, response[0].issuer.id);
869
+ issuers.appendChild(option);
870
+ }
871
+
872
+ showLogMercadoPago(String.format(self.messages.issuerSet, response[0].issuer));
873
+ }
874
+ }, 100);
875
+ } else {
876
+ showMessageErrorForm(self.selectors.errorMethodMinAmount);
877
+ }
878
+ }
879
+
880
+ /*
881
+ *
882
+ * Função de validações / POST final
883
+ *
884
+ */
885
+
886
+
887
+ function releaseEventCreateCardToken() {
888
+ showLogMercadoPago(self.messages.releaseCardTokenEvent);
889
+
890
+ var dataCheckout = TinyJ(self.selectors.dataCheckout);
891
+
892
+ if (Array.isArray(dataCheckout)) {
893
+ for (var x = 0; x < dataCheckout.length; x++) {
894
+ dataCheckout[x].focusout(checkCreateCardToken);
895
+ dataCheckout[x].change(checkCreateCardToken);
896
+ }
897
+ } else {
898
+ dataCheckout.focusout(checkCreateCardToken);
899
+ dataCheckout.change(checkCreateCardToken);
900
+ }
901
+
902
+ }
903
+
904
+ function checkCreateCardToken() {
905
+ showLogMercadoPago(self.messages.checkCreateCardToken);
906
+
907
+ var submit = true;
908
+ var dataInputs = defineInputs();
909
+
910
+ for (var x = 0; x < dataInputs.length; x++) {
911
+ if (TinyJ(dataInputs[x]).val() == "" || TinyJ(dataInputs[x]).val() == -1) {
912
+ submit = false;
913
+ }
914
+ }
915
+
916
+ var docNumber = TinyJ(self.selectors.docNumber).val();
917
+ if (docNumber != '' && !checkDocNumber(docNumber)) {
918
+ submit = false;
919
+ }
920
+
921
+ if (submit) {
922
+ var oneClickPay = TinyJ(self.selectors.oneClickPayment).val();
923
+ var selector = TinyJ(self.selectors.oneClickPayment).val() == true ? self.selectors.ocp : self.selectors.customCard;
924
+ showLoading();
925
+ Mercadopago.createToken(TinyJ(selector).getElem(), sdkResponseHandler);
926
+ }
927
+ }
928
+
929
+ function sdkResponseHandler(status, response) {
930
+ showLogMercadoPago(self.messages.responseCardToken);
931
+ showLogMercadoPago(status);
932
+ showLogMercadoPago(response);
933
+
934
+ //hide all errors
935
+ hideMessageError();
936
+ hideLoading();
937
+
938
+ if (status == http.status.OK || status == http.status.CREATED) {
939
+ var form = TinyJ(self.selectors.token).val(response.id);
940
+ setTotalAmount();
941
+ showLogMercadoPago(response);
942
+
943
+ } else {
944
+
945
+ for (var x = 0; x < Object.keys(response.cause).length; x++) {
946
+ var error = response.cause[x];
947
+ showMessageErrorForm(String.format(self.selectors.errorFormat, error.code));
948
+ }
949
+
950
+ }
951
+ };
952
+
953
+
954
+ /*
955
+ * Functions de error & loading
956
+ */
957
+
958
+
959
+ function hideMessageError() {
960
+ showLogMercadoPago(self.messages.hideErrors);
961
+ var allMessageErrors = TinyJ(self.selectors.messageError);
962
+ if (Array.isArray(allMessageErrors)) {
963
+ for (var x = 0; x < allMessageErrors.length; x++) {
964
+ allMessageErrors[x].hide();
965
+ }
966
+ } else {
967
+ allMessageErrors.hide();
968
+ }
969
+ }
970
+
971
+ function showMessageErrorForm(elError) {
972
+ showLogMercadoPago(self.messages.showingError);
973
+ showLogMercadoPago(elError);
974
+
975
+ var elMessage = TinyJ(elError);
976
+ if (Array.isArray(elMessage)) {
977
+ for (var x = 0; x < elMessage.length; x++) {
978
+ elMessage[x].show();
979
+ }
980
+ } else {
981
+ elMessage.show();
982
+ }
983
+
984
+ }
985
+
986
+ function showLoading() {
987
+ showLogMercadoPago(self.messages.showLoading);
988
+ TinyJ(self.selectors.loading).show();
989
+ }
990
+
991
+ function hideLoading() {
992
+ showLogMercadoPago(self.messages.hideLoading);
993
+ TinyJ(self.selectors.loading).hide();
994
+ }
995
+
996
+ /*
997
+ *
998
+ * Discount
999
+ *
1000
+ */
1001
+
1002
+ function initDiscountMercadoPagoCustom() {
1003
+ showLogMercadoPago(self.messages.initDiscount);
1004
+ //inicia o objeto
1005
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.couponActionApply).click(applyDiscountCustom);
1006
+ TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.couponActionRemove).click(removeDiscountCustom);
1007
+ if (TinyJ(self.selectors.checkoutCustom).getElem(self.selectors.inputCouponDiscount).val() != '') {
1008
+ applyDiscountCustom();
1009
+ }
1010
+ }
1011
+
1012
+ function initDiscountMercadoPagoCustomTicket() {
1013
+ showLogMercadoPago(self.messages.initTicket);
1014
+ //inicia o objeto
1015
+ TinyJ(self.selectors.ticketActionApply).click(applyDiscountCustomTicket);
1016
+ TinyJ(self.selectors.ticketActionRemove).click(removeDiscountCustomTicket);
1017
+ if (TinyJ(self.selectors.checkoutTicket).getElem(self.selectors.inputCouponDiscount).val() != '') {
1018
+ applyDiscountCustomTicket();
1019
+ }
1020
+
1021
+ }
1022
+
1023
+ function applyDiscountCustom() {
1024
+ validDiscount(self.selectors.checkoutCustom);
1025
+ }
1026
+
1027
+ function applyDiscountCustomTicket() {
1028
+ validDiscount(self.selectors.checkoutTicket);
1029
+ }
1030
+
1031
+ function validDiscount(formPaymentMethod) {
1032
+ showLogMercadoPago(self.messages.validateDiscount);
1033
+
1034
+ var $formPayment = TinyJ(formPaymentMethod);
1035
+ var couponCode = $formPayment.getElem(self.selectors.coupon).val();
1036
+ var baseUrl = $formPayment.getElem(self.selectors.baseUrl).val();
1037
+
1038
+
1039
+ hideMessageCoupon($formPayment);
1040
+
1041
+ //show loading
1042
+ $formPayment.getElem(self.selectors.couponLoading).show();
1043
+
1044
+ tiny.ajax({
1045
+ method: http.method.GET,
1046
+ url: baseUrl + String.format(self.url.couponUrlFormat, couponCode),
1047
+ timeout: 5000,
1048
+ success: function (r, status, xhr) {
1049
+ console.log(r);
1050
+ showLogMercadoPago(self.messages.validateCouponResponse);
1051
+ showLogMercadoPago({status: status, response: r});
1052
+
1053
+ $formPayment.getElem(self.selectors.couponLoading).hide();
1054
+
1055
+ if (r.status == http.status.OK) {
1056
+ var couponAmount = (r.response.coupon_amount).toFixed(2)
1057
+ var transactionAmount = (r.response.transaction_amount).toFixed(2)
1058
+ var idCoupon = r.response.id;
1059
+ var currency = $formPayment.getElem(self.selectors.textCurrency).val();
1060
+ var urlTerm = String.format(self.url.termsUrlFormat, idCoupon);
1061
+
1062
+ $formPayment.getElem(self.selectors.discountOkAmountDiscount).html(currency + couponAmount);
1063
+ $formPayment.getElem(self.selectors.discountOkTotalAmount).html(currency + transactionAmount);
1064
+ $formPayment.getElem(self.selectors.discountOkTotalAmountDiscount).html(currency + (transactionAmount - couponAmount).toFixed(2));
1065
+ $formPayment.getElem(self.selectors.totalAmount).val(transactionAmount - couponAmount);
1066
+
1067
+ $formPayment.getElem(self.selectors.discountOkTerms).attribute("href", urlTerm);
1068
+ $formPayment.getElem(self.selectors.discountAmount).val(couponAmount);
1069
+
1070
+ //show mensagem ok
1071
+ $formPayment.getElem(self.selectors.discountOk).show();
1072
+ $formPayment.getElem(self.selectors.couponActionRemove).show();
1073
+ $formPayment.getElem(self.selectors.couponActionApply).hide();
1074
+
1075
+ $formPayment.getElem(self.selectors.inputCouponDiscount).removeClass(self.constants.invalidCoupon);
1076
+ if (formPaymentMethod == self.selectors.checkoutCustom) {
1077
+ guessingPaymentMethod(event.type = self.constants.keyup);
1078
+ } else {
1079
+ if (isOsc()) {
1080
+ //inovarti onestepcheckout
1081
+ OSCPayment.savePayment();
1082
+ } else if (isIdeasa()) {
1083
+ //ideasa onestepcheckout
1084
+ payment.update();
1085
+ }
1086
+ }
1087
+ } else {
1088
+
1089
+ //reset input amount
1090
+ $formPayment.getElem(self.selectors.discountAmount).val(0);
1091
+ $formPayment.getElem(self.selectors.couponActionRemove).show();
1092
+
1093
+ console.log(r.response.error);
1094
+ $formPayment.getElem(self.selectors.messageCoupon + " ." + r.response.error).show();
1095
+ $formPayment.getElem(self.selectors.inputCouponDiscount).addClass(self.constants.invalidCoupon);
1096
+ }
1097
+ },
1098
+ error: function (status, response) {
1099
+ console.log(status, response);
1100
+ }
1101
+ });
1102
+ }
1103
+
1104
+ function removeDiscountCustom() {
1105
+ removeDiscount(self.selectors.checkoutCustom);
1106
+ }
1107
+
1108
+ function removeDiscountCustomTicket() {
1109
+ removeDiscount(self.selectors.checkoutTicket);
1110
+ }
1111
+
1112
+ function removeDiscount(formPaymentMethod) {
1113
+ showLogMercadoPago(self.messages.removeDiscount);
1114
+ var $formPayment = TinyJ(formPaymentMethod);
1115
+ var discount = $formPayment.getElem(self.selectors.discountAmount).val();
1116
+
1117
+ //hide all info
1118
+ hideMessageCoupon($formPayment);
1119
+ $formPayment.getElem(self.selectors.couponActionApply).show();
1120
+ $formPayment.getElem(self.selectors.couponActionRemove).hide();
1121
+ $formPayment.getElem(self.selectors.coupon).val("");
1122
+
1123
+ $formPayment.getElem(self.selectors.discountAmount).val(0);
1124
+ $formPayment.getElem(self.selectors.discountOk).hide();
1125
+
1126
+ if (formPaymentMethod == self.selectors.checkoutCustom) {
1127
+ guessingPaymentMethod(event.type = self.constants.keyup);
1128
+ } else {
1129
+ amount = $formPayment.getElem(self.selectors.amount).val();
1130
+ $formPayment.getElem(self.selectors.totalAmount).val(amount);
1131
+ if (isOsc()) {
1132
+ //inovarti onestepcheckout
1133
+ OSCPayment.savePayment();
1134
+ } else if (isIdeasa()) {
1135
+ //ideasa onestepcheckout
1136
+ payment.update();
1137
+ }
1138
+ }
1139
+ $formPayment.getElem(self.selectors.inputCouponDiscount).removeClass(self.constants.invalidCoupon);
1140
+ showLogMercadoPago(self.messages.removeCoupon);
1141
+ }
1142
+
1143
+ function hideMessageCoupon($formPayment) {
1144
+ showLogMercadoPago(self.messages.hideCouponMessages);
1145
+
1146
+ var messageCoupon = $formPayment.getElem().querySelectorAll(self.selectors.couponList);
1147
+
1148
+ for (var x = 0; x < messageCoupon.length; x++) {
1149
+ messageCoupon[x].hide();
1150
+ }
1151
+ }
1152
+
1153
+ return {
1154
+ init: initMercadoPagoJs,
1155
+ initDiscount: initDiscountMercadoPagoCustom,
1156
+ initOCP: initMercadoPagoOCP,
1157
+ initDiscountTicket: initDiscountMercadoPagoCustomTicket
1158
+ };
1159
+ }
1160
+
1161
+ function getInstance() {
1162
+ if (!instance) {
1163
+ instance = new InitializeNewModule();
1164
+ }
1165
+ return instance;
1166
+ }
1167
+
1168
+ return {
1169
+ getInstance: getInstance,
1170
+ getSelectors: getSelectors,
1171
+ getUrls: getUrls,
1172
+ getMessages: getMessages,
1173
+ setMessages: setMessages,
1174
+ setSelectors: setSelectors,
1175
+ setUrls: setUrls,
1176
+ enableLog: enableLog,
1177
+ isLogEnabled: isLogEnabled
1178
+ };
1179
+ })();
js/mercadopago/tiny.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n=arguments,r=void 0;t=1===n.length?n[0]:n[1];var o=function(){},i={url:2===n.length&&"string"==typeof e?e:".",cache:!0,data:{},headers:{},context:null,dataType:"text",method:"GET",success:o,error:o,complete:o};r=s["default"](i,t||{});var a={"application/json":"json","text/html":"html","text/plain":"text"},u={};for(var l in a)a.hasOwnProperty(l)&&(u[a[l]]=l);r.cache||(r.url=r.url+(~r.url.indexOf("?")?"&":"?")+"nc="+Math.floor(9e9*Math.random()));var c=function(e,t){r.complete.call(r.context,t,e)},d=function(e,t){var n="success";r.success.call(r.context,e,n,t),c(n,t)},f=function(e,t,n){r.error.call(r.context,n,t,e),c(t,n)},p=new XMLHttpRequest;p.onreadystatechange=function(){if(4!==p.readyState);else{var e=void 0,t=1223===p.status?204:p.status;if(t>=200&&300>t||304===t){var n=/([\/a-z]+)(;|\s|$)/.exec(p.getResponseHeader("content-type")),o=n&&a[n[1]]?a[n[1]].toLowerCase():"text";if(e=p.responseText,"json"===o)try{e=JSON.parse(e)}catch(i){e=p.responseText}d(e,p,r)}else f(new Error(p.statusText),"error",p,r)}},p.onerror=function(){f(new Error(p.statusText||"Network request failed"),"error",p,r)},p.open(r.method,r.url),r.dataType&&u[r.dataType.toLowerCase()]&&(r.headers.Accept=u[r.dataType.toLowerCase()]+", */*; q=0.01"),"POST"===r.method&&(r.headers=s["default"](r.headers,{"X-Requested-With":"XMLHttpRequest","Content-type":"application/x-www-form-urlencoded"}));for(var v in r.headers)p.setRequestHeader(v,r.headers[v]);return p.send(r.data),this}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var i=e("./extend"),s=r(i);t.exports=n["default"]},{"./extend":9}],2:[function(e,t,n){"use strict";function r(e,t){s?e.classList.add(t):e.setAttribute("class",e.getAttribute("class")+" "+t)}function o(e,t){s?e.classList.remove(t):e.setAttribute("class",e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," "))}function i(e,t){var n;return n=s?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}Object.defineProperty(n,"__esModule",{value:!0}),n.addClass=r,n.removeClass=o,n.hasClass=i;var s=!!document.body.classList,a={addClass:r,removeClass:o,hasClass:i};n["default"]=a},{}],3:[function(e,t,n){"use strict";function r(e){if(void 0===e||"object"!=typeof e)throw new Error('The "obj" parameter is required and must be an object.');var t={},n=void 0;for(n in e)void 0!==e[n]&&(t[n]=e[n]);return t}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],4:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=document.cookie.split("; "),n=null,r=t.length;if(!r)return n;for(var o=0;r>o;o++){var i=t[o].split("="),s=decodeURIComponent(i.shift());if(e===s){n=decodeURIComponent(i.join("="));break}}return n}function i(e,t,n){n="object"==typeof n?n:{expires:n};var r=null!=n.expires?n.expires:d.expires;"string"==typeof r&&""!==r?r=new Date(r):"number"==typeof r&&(r=new Date(+new Date+1e3*f*r)),r&&"toGMTString"in r&&(r=";expires="+r.toGMTString());var o=";path="+(n.path||d.path),i=n.domain||d.domain;i=i?";domain="+i:"";var s=n.secure||d.secure?";secure":"";"object"==typeof t&&(t=Array.isArray(t)||c["default"](t)?JSON.stringify(t):""),document.cookie=u(e)+"="+u(t)+r+o+i+s}function s(e){i(e,"",-1)}function a(){if(navigator.cookieEnabled)return!0;i("__","_");var e="_"===o("__");return s("__"),e}function u(e){return String(e).replace(/[,;"\\=\s%]/g,function(e){return encodeURIComponent(e)})}Object.defineProperty(n,"__esModule",{value:!0});var l=e("./isPlainObject"),c=r(l),d={expires:"",path:"/",secure:!1,domain:""},f=86400,p={get:o,set:i,remove:s,isEnabled:a};n["default"]=p,t.exports=n["default"]},{"./isPlainObject":11}],5:[function(e,t,n){"use strict";function r(e,t,n){var r,s=arguments,a=i(e),u=a.length;if("string"==typeof t&&2===s.length)return 0===u?"":o(a[0],t);3===s.length?r=function(e){e.style[t]=n}:"object"==typeof t&&(r=function(e){Object.keys(t).forEach(function(n){e.style[n]=t[n]})});for(var l=0;u>l;l++)r(a[l])}function o(e,t){return window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(t):(t=t.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()}),e.currentStyle[t])}function i(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):"object"==typeof e&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&Object.prototype.hasOwnProperty.call(e,"length")&&e.length>0&&e[0].nodeType>0?[].slice.call(e):[e]}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],6:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):"object"==typeof e&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&Object.prototype.hasOwnProperty.call(e,"length")&&e.length>0&&e[0].nodeType>0?[].slice.call(e):[e]}function i(e,t){"string"!=typeof e&&(t=e,e=t.type);var n=void 0,r=-1!==m.indexOf(e),o=r&&-1!==h.indexOf(e),i=f["default"]({bubbles:r,cancelable:r,detail:void 0},t);return document.createEvent?(n=document.createEvent(o&&window.MouseEvent?"MouseEvents":"Events"),n.initEvent(e,i.bubbles,i.cancelable,i.detail)):document.createEventObject&&(n=document.createEventObject(window.event),o&&(n.button=1),i.bubbles||(n.cancelBubble=!0)),n}function s(e){return"on"===e.substr(0,2)?y?e.substr(2):e:y?e:"on"+e}function a(e,t,n,r){o(e).forEach(function(e){e[g](s(t),n,r||!1)})}function u(e,t,n,r){o(e).forEach(function(e){var o=n;n=function(t){return l(e,t.type,n),o.apply(e,arguments)},e[g](s(t),n,r||!1)})}function l(e,t,n){o(e).forEach(function(e){e[_](s(t),n)})}function c(e,t,n){var r=this,a="string"==typeof t?t:t.type;t="string"==typeof t||v["default"](t)?i(t,n):t,o(e).forEach(function(e){t.type in focus&&"function"==typeof r[t.type]?r[t.type]():y?e[E](t):e[E](s(a),t)})}Object.defineProperty(n,"__esModule",{value:!0}),n.initEvent=i,n.on=a,n.once=u,n.off=l,n.trigger=c;var d=e("./extend"),f=r(d),p=e("./isPlainObject"),v=r(p),m=function(){var e=[];for(var t in document)if("on"===t.substring(0,2)){var n=t.replace("on","");e.push(n)}return e}(),h=m.filter(function(e){return/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/.test(e)}),y=document.addEventListener?!0:!1,g=y?"addEventListener":"attachEvent",_=y?"removeEventListener":"detachEvent",E=y?"dispatchEvent":"fireEvent",w={on:a,once:u,off:l,trigger:c};n["default"]=w},{"./extend":9,"./isPlainObject":11}],7:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("events"),i=r(o);n["default"]=i["default"],t.exports=n["default"]},{events:20}],8:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("./support"),i=r(o);e("./pointerEvents");var s=!!window.MouseEvent,a="layoutchange";n.onlayoutchange=a;var u="resize";n.onresize=u;var l="scroll";n.onscroll=l;var c=s?"pointerdown":"mousedown";n.onpointerdown=c;var d=s?"pointerup":"mouseup";n.onpointerup=d;var f=s?"pointermove":"mousemove";n.onpointermove=f;var p=i["default"].touch&&s?"pointertap":"click";n.onpointertap=p;var v=s?"pointerenter":"mouseenter";n.onpointerenter=v;var m=s?"pointerleave":"mouseleave";n.onpointerleave=m;var h="oninput"in document.createElement("input")?"input":"keydown";n.onkeyinput=h},{"./pointerEvents":17,"./support":19}],9:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=void 0,t=void 0,n=void 0,r=void 0,i=void 0,a=void 0,u=arguments[0]||{},l=1,c=arguments.length,d=!1;if("boolean"==typeof u&&(d=u,u=arguments[l]||{},l++),l>=c)return u;for(;c>l;l++)if(null!=(e=arguments[l]))for(t in e)n=u[t],r=e[t],u!==r&&(d&&r&&(s["default"](r)||(i=Array.isArray(r)))?(i?(i=!1,a=n&&Array.isArray(n)?n:[]):a=n&&s["default"](n)?n:{},u[t]=o(d,a,r)):void 0!==r&&(u[t]=r));return u}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var i=e("./isPlainObject"),s=r(i);t.exports=n["default"]},{"./isPlainObject":11}],10:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("inherits"),i=r(o);n["default"]=i["default"],t.exports=n["default"]},{inherits:21}],11:[function(e,t,n){"use strict";function r(e){return null==e?!1:"object"!=typeof e||e.nodeType||e===e.window?!1:e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf")?!1:!0}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],12:[function(e,t,n){"use strict";function r(e){if("string"==typeof e){var t=f.cloneNode(!1);t.text=e,p.parentNode.insertBefore(t,p)}else e.apply(window)}function o(e,t){v[e]=t}function i(e){o(e,null),m=e+1}function s(){for(var e=!0,t=void 0,n=m,o=v.length;o>n&&e;)t=v[n],void 0!==t&&null!==t?(r(t),i(n),n+=1):e=!1}function a(){v.length&&!function(){var e=v.pop(),t=void 0;"string"==typeof e?(t=f.cloneNode(!0),t.type="text/javascript",t.async=!0,t.src=e,t.onload=t.onreadystatechange=function(){(!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t=void 0,a())},p.parentNode.insertBefore(t,p)):(e.apply(window),a())}()}function u(e,t){return function(){o(t,e.responseText),s(),e=void 0}}function l(){var e,t,n=arguments.length;for(e=0;n>e;e+=1)"string"==typeof arguments[e]?(t=h(arguments[e]),t.onload=u(t,v.length),o(v.length,null),t.send()):(o(v.length,arguments[e]),s())}function c(){v.push(Array.prototype.slice.call(arguments,0).reverse()),a()}Object.defineProperty(n,"__esModule",{value:!0});var d=window.document,f=d.createElement("script"),p=d.getElementsByTagName("script")[0],v=[],m=0,h=function(){var e=void 0,t=void 0;return window.XMLHttpRequest&&(e=new window.XMLHttpRequest,"withCredentials"in e?t=function(t){return e=new window.XMLHttpRequest,e.open("get",t,!0),e}:window.XDomainRequest&&(t=function(t){return e=new window.XDomainRequest,e.open("get",t),e})),t}(),y=h?l:c;n["default"]=y,t.exports=n["default"]},{}],13:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n=void 0,r=void 0,o=void 0,i=void 0,c=void 0,d=s["default"]({prefix:"__jsonp",param:"callback",timeout:15e3,success:a,error:a},t);return l++,n=d.name?"function"==typeof d.name?d.name(d.prefix,l):d.name:d.prefix+l++,i=function(){r&&r.parentNode&&r.parentNode.removeChild(r),window[n]=a,o&&clearTimeout(o)},d.timeout&&(o=setTimeout(function(){i(),d.error(new Error("Script loading timeout"))},d.timeout)),window[n]=function(e){i(),d.success(e)},e+=(~e.indexOf("?")?"&":"?")+d.param+"="+encodeURIComponent(n),e=e.replace("?&","?"),r=document.createElement("script"),r.type="text/javascript",r.src=e,r.onerror=function(e){i(),d.error(new Error(e.message||"Script Error"))},u.appendChild(r),c=function(){window[n]&&i()}}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var i=e("./extend"),s=r(i),a=function(){},u=document.getElementsByTagName("head")[0],l=0;t.exports=n["default"]},{"./extend":9}],14:[function(e,t,n){"use strict";function r(e){function t(e){do e=e.nextSibling;while(e&&1!==e.nodeType);return e}return e.nextElementSibling||t(e)}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],15:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=e.getBoundingClientRect(),n=i(e),r=l["default"](),o={left:t.left,top:t.top};return"fixed"!==a["default"](e,"position")&&null===n&&(o.left+=r.left,o.top+=r.top),o}function i(e){for(var t=e.offsetParent,n=void 0;void 0===n;){if(null===t){n=null;break}"fixed"!==a["default"](t,"position")?t=t.offsetParent:n=t}return n}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=o;var s=e("./css"),a=r(s),u=e("./scroll"),l=r(u);t.exports=n["default"]},{"./css":5,"./scroll":18}],16:[function(e,t,n){"use strict";function r(e,t){for(var n=!0;n;){var r=e,o=t;i=s=void 0,n=!1;var i=r.parentNode,s=o?o.toUpperCase():o;if(null===i)return i;if(1===i.nodeType){if(void 0!==o&&i.tagName===s)return i;if(void 0===o||i.tagName===s){if(void 0===o)return i}else e=i,t=s,n=!0}else e=i,t=s,n=!0}}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],17:[function(e,t,n){"use strict";!function(e){function t(){M=!0,clearTimeout(O),O=setTimeout(function(){M=!1},700)}function n(e,t){for(;e;){if(e.contains(t))return e;e=e.parentNode}return null}function r(e,t,r){for(var o=n(e,t),i=e,s=[];i&&i!==o;)y(i,"pointerenter")&&s.push(i),i=i.parentNode;for(;s.length>0;)r(s.pop())}function o(e,t,r){for(var o=n(e,t),i=e;i&&i!==o;)y(i,"pointerleave")&&r(i),i=i.parentNode}function i(t,n){["pointerdown","pointermove","pointerup","pointerover","pointerout"].forEach(function(r){e.addEventListener(t(r),function(e){!M&&g(e.target,r)&&n(e,r,!0)})}),void 0===e["on"+t("pointerenter").toLowerCase()]&&e.addEventListener(t("pointerover"),function(t){if(!M){var o=g(t.target,"pointerenter");o&&o!==e&&(o.contains(t.relatedTarget)||r(o,t.relatedTarget,function(e){n(t,"pointerenter",!1,e,t.relatedTarget)}))}}),void 0===e["on"+t("pointerleave").toLowerCase()]&&e.addEventListener(t("pointerout"),function(t){if(!M){var r=g(t.target,"pointerleave");r&&r!==e&&(r.contains(t.relatedTarget)||o(r,t.relatedTarget,function(e){n(t,"pointerleave",!1,e,t.relatedTarget)}))}})}var s="touch",a="pen",u="mouse";if(!e.PointerEvent){var l=!!e.MouseEvent,c=["PointerDown","PointerUp","PointerMove","PointerOver","PointerOut","PointerCancel","PointerEnter","PointerLeave"],d=c.map(function(e){return e.toLowerCase()}),f={},p=function(t){for(;t&&!t.ch_forcePreventDefault;)t=t.parentNode;return!!t||e.ch_forcePreventDefault},v=function(t,n,r,o,i){var c;if(document.createEvent&&l?(c=document.createEvent("MouseEvents"),c.initMouseEvent(n,r,!0,e,1,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,i||t.relatedTarget)):(c=document.createEventObject(),c.screenX=t.screenX,c.screenY=t.screenY,c.clientX=t.clientX,c.clientY=t.clientY,c.ctrlKey=t.ctrlKey,c.altKey=t.altKey,c.shiftKey=t.shiftKey,c.metaKey=t.metaKey,c.button=t.button,c.relatedTarget=i||t.relatedTarget),void 0===c.offsetX&&(void 0!==t.offsetX?(Object&&void 0!==Object.defineProperty&&(Object.defineProperty(c,"offsetX",{writable:!0}),Object.defineProperty(c,"offsetY",{writable:!0})),c.offsetX=t.offsetX,c.offsetY=t.offsetY):Object&&void 0!==Object.defineProperty?(Object.defineProperty(c,"offsetX",{get:function(){return this.currentTarget&&this.currentTarget.offsetLeft?t.clientX-this.currentTarget.offsetLeft:t.clientX}}),Object.defineProperty(c,"offsetY",{get:function(){return this.currentTarget&&this.currentTarget.offsetTop?t.clientY-this.currentTarget.offsetTop:t.clientY}})):void 0!==t.layerX&&(c.offsetX=t.layerX-t.currentTarget.offsetLeft,c.offsetY=t.layerY-t.currentTarget.offsetTop)),void 0!==t.isPrimary?c.isPrimary=t.isPrimary:c.isPrimary=!0,t.pressure)c.pressure=t.pressure;else{var d=0;void 0!==t.which?d=t.which:void 0!==t.button&&(d=t.button),c.pressure=0===d?0:.5}if(t.rotation?c.rotation=t.rotation:c.rotation=0,t.hwTimestamp?c.hwTimestamp=t.hwTimestamp:c.hwTimestamp=0,t.tiltX?c.tiltX=t.tiltX:c.tiltX=0,t.tiltY?c.tiltY=t.tiltY:c.tiltY=0,t.height?c.height=t.height:c.height=0,t.width?c.width=t.width:c.width=0,c.preventDefault=function(){void 0!==t.preventDefault&&t.preventDefault()},void 0!==c.stopPropagation){var f=c.stopPropagation;c.stopPropagation=function(){void 0!==t.stopPropagation&&t.stopPropagation(),f.call(this)}}switch(c.pointerId=t.pointerId,c.pointerType=t.pointerType,c.pointerType){case 2:c.pointerType=s;break;case 3:c.pointerType=a;break;case 4:c.pointerType=u}o?o.dispatchEvent(c):t.target&&l?t.target.dispatchEvent(c):t.srcElement.fireEvent("on"+E(n),c)},m=function(e,t,n,r,o){e.pointerId=1,e.pointerType=u,v(e,t,n,r,o)},h=function(e,t,n,r,o,i){var a=t.identifier+2;t.pointerId=a,t.pointerType=s,t.currentTarget=n,void 0!==r.preventDefault&&(t.preventDefault=function(){r.preventDefault()}),v(t,e,o,n,i)},y=function(e,t){return e.__chGlobalRegisteredEvents&&e.__chGlobalRegisteredEvents[t]},g=function(t,n){for(;t&&!y(t,n);)t=t.parentNode;return t?t:y(e,n)?e:void 0},_=function(e,t,n,r,o,i){g(n,e)&&h(e,t,n,r,o,i)},E=function(e){return e.toLowerCase().replace("pointer","mouse")},w=function(e,t){var n=d.indexOf(t),r=e+c[n];return r},b=function(e,t,n,r){if(void 0===e.__chRegisteredEvents&&(e.__chRegisteredEvents=[]),r){if(void 0!==e.__chRegisteredEvents[t])return void e.__chRegisteredEvents[t]++;e.__chRegisteredEvents[t]=1,e.addEventListener(t,n,!1)}else{if(-1!==e.__chRegisteredEvents.indexOf(t)&&(e.__chRegisteredEvents[t]--,0!==e.__chRegisteredEvents[t]))return;e.removeEventListener(t,n),e.__chRegisteredEvents[t]=0}},T=function(t,n,r){if(t.__chGlobalRegisteredEvents||(t.__chGlobalRegisteredEvents=[]),r){if(void 0!==t.__chGlobalRegisteredEvents[n])return void t.__chGlobalRegisteredEvents[n]++;t.__chGlobalRegisteredEvents[n]=1}else void 0!==t.__chGlobalRegisteredEvents[n]&&(t.__chGlobalRegisteredEvents[n]--,t.__chGlobalRegisteredEvents[n]<0&&(t.__chGlobalRegisteredEvents[n]=0));var o,i;switch(e.MSPointerEvent?(o=function(e){return w("MS",e)},i=v):(o=E,i=m),n){case"pointerenter":case"pointerleave":var s=o(n);void 0!==t["on"+s.toLowerCase()]&&b(t,s,function(e){i(e,n)},r)}},L=function(e){var t=e.prototype?e.prototype.addEventListener:e.addEventListener,n=function(e,n,r){-1!==d.indexOf(e)&&T(this,e,!0),void 0===t?this.attachEvent("on"+E(e),n):t.call(this,e,n,r)};e.prototype?e.prototype.addEventListener=n:e.addEventListener=n},x=function(e){var t=e.prototype?e.prototype.removeEventListener:e.removeEventListener,n=function(e,n,r){-1!==d.indexOf(e)&&T(this,e,!1),void 0===t?this.detachEvent(E(e),n):t.call(this,e,n,r)};e.prototype?e.prototype.removeEventListener=n:e.removeEventListener=n};L(e),L(e.HTMLElement||e.Element),L(document),L(HTMLBodyElement),L(HTMLDivElement),L(HTMLImageElement),L(HTMLUListElement),L(HTMLAnchorElement),L(HTMLLIElement),L(HTMLTableElement),e.HTMLSpanElement&&L(HTMLSpanElement),e.HTMLCanvasElement&&L(HTMLCanvasElement),e.SVGElement&&L(SVGElement),x(e),x(e.HTMLElement||e.Element),x(document),x(HTMLBodyElement),x(HTMLDivElement),x(HTMLImageElement),x(HTMLUListElement),x(HTMLAnchorElement),x(HTMLLIElement),x(HTMLTableElement),e.HTMLSpanElement&&x(HTMLSpanElement),e.HTMLCanvasElement&&x(HTMLCanvasElement),e.SVGElement&&x(SVGElement);var M=!1,O=-1;!function(){e.MSPointerEvent?i(function(e){return w("MS",e)},v):(i(E,m),void 0!==e.ontouchstart&&(e.addEventListener("touchstart",function(e){for(var n=0;n<e.changedTouches.length;++n){var o=e.changedTouches[n];f[o.identifier]=o.target,_("pointerover",o,o.target,e,!0),r(o.target,null,function(t){h("pointerenter",o,t,e,!1)}),_("pointerdown",o,o.target,e,!0)}t()}),e.addEventListener("touchend",function(e){for(var n=0;n<e.changedTouches.length;++n){var r=e.changedTouches[n],i=f[r.identifier];_("pointerup",r,i,e,!0),_("pointerout",r,i,e,!0),o(i,null,function(t){h("pointerleave",r,t,e,!1)})}t()}),e.addEventListener("touchmove",function(e){for(var n=0;n<e.changedTouches.length;++n){var i=e.changedTouches[n],s=document.elementFromPoint(i.clientX,i.clientY),a=f[i.identifier];a&&p(a)===!0&&e.preventDefault(),_("pointermove",i,a,e,!0),a!==s&&(a&&(_("pointerout",i,a,e,!0,s),a.contains(s)||o(a,s,function(t){h("pointerleave",i,t,e,!1,s)})),s&&(_("pointerover",i,s,e,!0,a),s.contains(a)||r(s,a,function(t){h("pointerenter",i,t,e,!1,a)})),f[i.identifier]=s)}t()}),e.addEventListener("touchcancel",function(e){for(var t=0;t<e.changedTouches.length;++t){var n=e.changedTouches[t];_("pointercancel",n,f[n.identifier],e,!0)}})))}(),void 0===navigator.pointerEnabled&&(navigator.pointerEnabled=!0,navigator.msPointerEnabled&&(navigator.maxTouchPoints=navigator.msMaxTouchPoints))}}(window),function(){function e(e){var t=e.pointerType===a||e.pointerType===s||e.pointerType===i&&e.isPrimary;!u&&t&&(o={id:e.pointerId,clientX:e.clientX,clientY:e.clientY,x:e.x||e.pageX,y:e.y||e.pageY,type:e.pointerType})}function t(){o=null}function n(e){o&&o.id===e.pointerId&&Math.abs(o.x-(e.x||e.pageX))<5&&Math.abs(o.y-(e.y||e.pageY))<5&&(!u||Math.abs(c-window.pageXOffset)<5&&Math.abs(d-window.pageYOffset)<5)&&r(e),o=null}function r(e){var t=document.createEvent("MouseEvents"),n=document.elementFromPoint(e.clientX,e.clientY);return t.initMouseEvent("pointertap",!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,n),t.maskedEvent=e,n.dispatchEvent(t),t}if(window.MouseEvent){var o,i="touch",s="pen",a="mouse",u=!1,l=!1,c=0,d=0;window.addEventListener("scroll",function(){u||(c=window.pageXOffset,d=window.pageYOffset),u=!0,clearTimeout(l),l=setTimeout(function(){u=!1,c=0,d=0},100)}),window.addEventListener("pointerdown",e),window.addEventListener("pointerup",n),window.addEventListener("pointerleave",t),window.addEventListener("pointermove",function(){})}}()},{}],18:[function(e,t,n){"use strict";function r(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r,t.exports=n["default"]},{}],19:[function(e,t,n){"use strict";function r(){var e=document.createElement("tiny"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return{end:t[n]};return!1}function o(){var e=document.createElement("tiny"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return{end:t[n]};return!1}Object.defineProperty(n,"__esModule",{value:!0});var i={transition:r(),animation:o(),touch:"ontouchend"in document,customEvent:function(){try{return new CustomEvent(name,{detail:{}}),!0}catch(e){return!1}}()};n["default"]=i,t.exports=n["default"]},{}],20:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function i(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,i,u,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(r=arguments.length,i=new Array(r-1),u=1;r>u;u++)i[u-1]=arguments[u];n.apply(this,i)}else if(s(n)){for(r=arguments.length,i=new Array(r-1),u=1;r>u;u++)i[u-1]=arguments[u];for(l=n.slice(),r=l.length,u=0;r>u;u++)l[u].apply(this,i)}return!0},r.prototype.addListener=function(e,t){var n;if(!o(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned){var n;n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,i,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?o(e._events[t])?1:e._events[t].length:0}},{}],21:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],22:[function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./modules/clone"),s=o(i),a=e("./modules/extend"),u=o(a),l=e("./modules/inherits"),c=o(l),d=e("./modules/eventEmitter"),f=o(d),p=e("./modules/ajax"),v=o(p),m=e("./modules/jsonp"),h=o(m),y=e("./modules/jcors"),g=o(y),_=e("./modules/isPlainObject"),E=o(_),w=e("./modules/support"),b=o(w),T=e("./modules/classList"),L=o(T),x=e("./modules/parent"),M=o(x),O=e("./modules/next"),j=o(O),P=e("./modules/css"),C=o(P),X=e("./modules/offset"),R=o(X),H=e("./modules/scroll"),S=o(H),Y=e("./modules/cookies"),k=o(Y),N=e("./modules/domEvents"),A=o(N),D=e("./modules/events"),q=r(D),G={clone:s["default"],extend:u["default"],inherits:c["default"],EventEmitter:f["default"],ajax:v["default"],jsonp:h["default"],jcors:g["default"],isPlainObject:E["default"],support:b["default"],addClass:L["default"].addClass,removeClass:L["default"].removeClass,hasClass:L["default"].hasClass,parent:M["default"],next:j["default"],css:C["default"],offset:R["default"],scroll:S["default"],cookies:k["default"],on:A["default"].on,bind:A["default"].on,one:A["default"].once,once:A["default"].once,off:A["default"].off,trigger:A["default"].trigger};for(var K in q)G[K]=q[K];"undefined"!=typeof window&&(window.tiny=G),n["default"]=G,t.exports=n["default"]},{"./modules/ajax":1,"./modules/classList":2,"./modules/clone":3,"./modules/cookies":4,"./modules/css":5,"./modules/domEvents":6,"./modules/eventEmitter":7,"./modules/events":8,"./modules/extend":9,"./modules/inherits":10,"./modules/isPlainObject":11,"./modules/jcors":12,"./modules/jsonp":13,"./modules/next":14,"./modules/offset":15,"./modules/parent":16,"./modules/scroll":18,"./modules/support":19}]},{},[22]);
js/mercadopago/tinyJ.js ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function ElemContainer(elem){
2
+ if(!elem){
3
+ throw "Invalid element";
4
+ }
5
+ this.elem = elem;
6
+ this.displayConfig = {
7
+ hide : 'none',
8
+ show : 'block'
9
+ };
10
+
11
+ this.eventNames = {
12
+ click : 'click',
13
+ blur : 'blur',
14
+ change : 'change',
15
+ focus : 'focus',
16
+ focusout: 'focusout',
17
+ keyup: 'keyup'
18
+ };
19
+
20
+ this.getElem = function(query){
21
+ if(!isEmptyValue(query)){
22
+ return TinyJ(query, this.elem);
23
+ }
24
+ return this.elem;
25
+ };
26
+
27
+ this.isChecked = function(selector){
28
+ return this.getElem().checked;
29
+ };
30
+
31
+
32
+ this.getSelectedOption = function(){
33
+ return TinyJ(this.getElem()[this.getElem().options.selectedIndex]);
34
+ };
35
+
36
+ this.id = function(id){
37
+ if(isEmptyValue(id)){
38
+ return this.getElem().id;
39
+ }
40
+ this.getElem().id = String(id);
41
+ return this;
42
+ };
43
+
44
+ this.attribute = function(name, value){
45
+ if(isEmptyValue(value)){
46
+ return this.getElem().getAttribute(name);
47
+ }
48
+ this.getElem().setAttribute(name, String(value));
49
+ return this;
50
+ };
51
+
52
+ this.html = function(value){
53
+ if(isEmptyValue(value)){
54
+ return this.getElem().innerHTML;
55
+ }
56
+ this.getElem().innerHTML = String(value);
57
+ return this;
58
+ };
59
+
60
+ this.empty = function(){
61
+ return this.html("");
62
+ };
63
+
64
+ this.val = function (val){
65
+ if(isEmptyValue(val)){
66
+ return this.getElem().value;
67
+ }
68
+ this.getElem().value = String(val);
69
+ return this;
70
+ };
71
+
72
+ this.removeAttribute = function(name, value){
73
+ this.getElem().removeAttribute(name, value);
74
+ return this;
75
+ };
76
+
77
+ this.hide = function (){
78
+ this.getElem().style.display = this.displayConfig.hide;
79
+ return this;
80
+ };
81
+
82
+ this.show = function (){
83
+ this.getElem().style.display = this.displayConfig.show;
84
+ return this;
85
+ };
86
+
87
+ this.click = function(handler){
88
+ this.on(this.eventNames.click, handler);
89
+ return this;
90
+ };
91
+
92
+ this.focusout = function(handler){
93
+ this.on(this.eventNames.focusout, handler);
94
+ return this;
95
+ };
96
+
97
+ this.keyup = function(handler){
98
+ this.on(this.eventNames.keyup, handler);
99
+ return this;
100
+ };
101
+
102
+ this.blur = function(handler){
103
+ this.on(this.eventNames.blur, handler);
104
+ return this;
105
+ };
106
+
107
+ this.change = function(handler){
108
+ this.on(this.eventNames.change, handler);
109
+ return this;
110
+ };
111
+
112
+ this.focus = function(handler){
113
+ this.on(this.eventNames.focus, handler);
114
+ return this;
115
+ };
116
+
117
+ this.addClass = function(name){
118
+ this.getElem().className = (this.getElem().className + " " + name).trim();
119
+ return this;
120
+ };
121
+
122
+ this.removeClass = function(name){
123
+ this.getElem().className = (this.getElem().className.replace(new RegExp(name.trim(), 'g'), '')).trim();
124
+ return this;
125
+ };
126
+
127
+ this.disable = function(){
128
+ this.getElem().disabled = true;
129
+ return this;
130
+ };
131
+
132
+ this.enable = function(){
133
+ this.removeAttribute('disabled');
134
+ return this;
135
+ };
136
+
137
+ this.on = function(eventName, handler){
138
+ addEvent(this.getElem(), eventName, handler);
139
+ return this;
140
+ };
141
+
142
+ this.appendChild = function(child){
143
+ this.getElem().appendChild(child);
144
+ return this;
145
+ };
146
+
147
+ function isEmptyValue(value){
148
+ return (value === undefined || value === null);
149
+ }
150
+
151
+ function addEvent(el, eventName, handler){
152
+ if (el.addEventListener) {
153
+ el.addEventListener(eventName, handler);
154
+ } else {
155
+ el.attachEvent('on' + eventName, function(){
156
+ handler.call(el);
157
+ });
158
+ }
159
+ }
160
+ }
161
+
162
+ var TinyJ = function(elemDescriptor, parentElem){
163
+ if(parentElem){
164
+ return getElems(elemDescriptor, parentElem);
165
+ }
166
+ if(elemDescriptor){
167
+ if(typeof elemDescriptor === 'object'){
168
+ return new ElemContainer(elemDescriptor);
169
+ }
170
+ return getElems(elemDescriptor);
171
+ }
172
+
173
+ function getElems(elemDescriptor, parentElem){
174
+ var parent = parentElem ? parentElem : document;
175
+ var elements = parent.querySelectorAll(elemDescriptor);
176
+ if(elements.length === 0){
177
+ throw "Invalid element";
178
+ }
179
+ if(elements.length === 1){
180
+ return new ElemContainer(elements[0]);
181
+ }
182
+ result = [];
183
+ Array.prototype.forEach.call(elements, function(element, index, array){result.push(new ElemContainer(element));})
184
+ return result;
185
+ }
186
+ };
187
+
188
+ if (!String.format) {
189
+ String.format = function(format) {
190
+ var args = Array.prototype.slice.call(arguments, 1);
191
+ return format.replace(/{(\d+)}/g, function(match, number) {
192
+ return typeof args[number] != 'undefined'
193
+ ? args[number]
194
+ : match
195
+ ;
196
+ });
197
+ };
198
+ }
lib/{mercadopago/mercadopago.php → MercadoPago/Lib/Api.php} RENAMED
@@ -1,13 +1,15 @@
1
  <?php
 
2
  /**
3
  * MercadoPago Integration Library
4
  * Access MercadoPago for payments integration
5
- *
6
  * @author hcasatti
7
  *
8
  */
9
 
10
- class MP {
 
11
 
12
  const version = "0.3.3";
13
 
@@ -17,8 +19,13 @@ class MP {
17
  private $access_data;
18
  private $sandbox = FALSE;
19
 
20
- function __construct() {
21
- $i = func_num_args();
 
 
 
 
 
22
 
23
  if ($i > 2 || $i < 1) {
24
  throw new Exception("Invalid arguments. Use CLIENT_ID and CLIENT SECRET, or ACCESS_TOKEN");
@@ -56,7 +63,7 @@ class MP {
56
  'grant_type' => 'client_credentials'
57
  ));
58
 
59
- $access_data = MPRestClient::post("/oauth/token", $app_client_values, "application/x-www-form-urlencoded");
60
 
61
  if ($access_data["status"] != 200) {
62
  throw new Exception ($access_data['response']['message'], $access_data['status']);
@@ -76,8 +83,8 @@ class MP {
76
  $access_token = $this->get_access_token();
77
 
78
  $uri_prefix = $this->sandbox ? "/sandbox" : "";
79
-
80
- $payment_info = MPRestClient::get($uri_prefix."/collections/notifications/" . $id . "?access_token=" . $access_token);
81
  return $payment_info;
82
  }
83
  public function get_payment_info($id) {
@@ -88,11 +95,11 @@ class MP {
88
  * Get information for specific authorized payment
89
  * @param id
90
  * @return array(json)
91
- */
92
  public function get_authorized_payment($id) {
93
  $access_token = $this->get_access_token();
94
 
95
- $authorized_payment_info = MPRestClient::get("/authorized_payments/" . $id . "?access_token=" . $access_token);
96
  return $authorized_payment_info;
97
  }
98
 
@@ -108,7 +115,7 @@ class MP {
108
  "status" => "refunded"
109
  );
110
 
111
- $response = MPRestClient::put("/collections/" . $id . "?access_token=" . $access_token, $refund_status);
112
  return $response;
113
  }
114
 
@@ -124,7 +131,7 @@ class MP {
124
  "status" => "cancelled"
125
  );
126
 
127
- $response = MPRestClient::put("/collections/" . $id . "?access_token=" . $access_token, $cancel_status);
128
  return $response;
129
  }
130
 
@@ -140,7 +147,7 @@ class MP {
140
  "status" => "cancelled"
141
  );
142
 
143
- $response = MPRestClient::put("/preapproval/" . $id . "?access_token=" . $access_token, $cancel_status);
144
  return $response;
145
  }
146
 
@@ -160,8 +167,8 @@ class MP {
160
  $filters = $this->build_query($filters);
161
 
162
  $uri_prefix = $this->sandbox ? "/sandbox" : "";
163
-
164
- $collection_result = MPRestClient::get($uri_prefix."/collections/search?" . $filters . "&access_token=" . $access_token);
165
  return $collection_result;
166
  }
167
 
@@ -173,7 +180,8 @@ class MP {
173
  public function create_preference($preference) {
174
  $access_token = $this->get_access_token();
175
 
176
- $preference_result = MPRestClient::post("/checkout/preferences?access_token=" . $access_token, $preference);
 
177
  return $preference_result;
178
  }
179
 
@@ -186,7 +194,7 @@ class MP {
186
  public function update_preference($id, $preference) {
187
  $access_token = $this->get_access_token();
188
 
189
- $preference_result = MPRestClient::put("/checkout/preferences/{$id}?access_token=" . $access_token, $preference);
190
  return $preference_result;
191
  }
192
 
@@ -198,7 +206,7 @@ class MP {
198
  public function get_preference($id) {
199
  $access_token = $this->get_access_token();
200
 
201
- $preference_result = MPRestClient::get("/checkout/preferences/{$id}?access_token=" . $access_token);
202
  return $preference_result;
203
  }
204
 
@@ -210,7 +218,7 @@ class MP {
210
  public function create_preapproval_payment($preapproval_payment) {
211
  $access_token = $this->get_access_token();
212
 
213
- $preapproval_payment_result = MPRestClient::post("/preapproval?access_token=" . $access_token, $preapproval_payment);
214
  return $preapproval_payment_result;
215
  }
216
 
@@ -222,7 +230,7 @@ class MP {
222
  public function get_preapproval_payment($id) {
223
  $access_token = $this->get_access_token();
224
 
225
- $preapproval_payment_result = MPRestClient::get("/preapproval/{$id}?access_token=" . $access_token);
226
  return $preapproval_payment_result;
227
  }
228
 
@@ -230,16 +238,16 @@ class MP {
230
  * Update a preapproval payment
231
  * @param string $preapproval_payment, $id
232
  * @return array(json)
233
- */
234
-
235
  public function update_preapproval_payment($id, $preapproval_payment) {
236
  $access_token = $this->get_access_token();
237
 
238
- $preapproval_payment_result = MPRestClient::put("/preapproval/" . $id . "?access_token=" . $access_token, $preapproval_payment);
239
  return $preapproval_payment_result;
240
  }
241
-
242
- /**
243
  * Create a custon payment
244
  * @param array $preference
245
  * @return array(json)
@@ -247,18 +255,18 @@ class MP {
247
  public function create_custon_payment($info) {
248
  $access_token = $this->get_access_token();
249
 
250
- $preference_result = MPRestClient::post("/checkout/custom/create_payment?access_token=" . $access_token, $info);
251
  return $preference_result;
252
  }
253
 
254
  /* Generic resource call methods */
255
 
256
  /**
257
- * Generic resource get
258
- * @param uri
259
- * @param params
260
- * @param authenticate = true
261
- */
262
  public function get($uri, $params = null, $authenticate = true) {
263
  $params = is_array ($params) ? $params : array();
264
 
@@ -270,19 +278,19 @@ class MP {
270
 
271
  if (count($params) > 0) {
272
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
273
- $uri .= $this->build_query($params);
274
  }
275
 
276
- $result = MPRestClient::get($uri);
277
  return $result;
278
  }
279
 
280
  /**
281
- * Generic resource post
282
- * @param uri
283
- * @param data
284
- * @param params
285
- */
286
  public function post($uri, $data, $params = null) {
287
  $params = is_array ($params) ? $params : array();
288
 
@@ -291,19 +299,20 @@ class MP {
291
 
292
  if (count($params) > 0) {
293
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
294
- $uri .= $this->build_query($params);
295
  }
296
 
297
- $result = MPRestClient::post($uri, $data);
 
298
  return $result;
299
  }
300
 
301
  /**
302
- * Generic resource put
303
- * @param uri
304
- * @param data
305
- * @param params
306
- */
307
  public function put($uri, $data, $params = null) {
308
  $params = is_array ($params) ? $params : array();
309
 
@@ -312,19 +321,19 @@ class MP {
312
 
313
  if (count($params) > 0) {
314
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
315
- $uri .= $this->build_query($params);
316
  }
317
 
318
- $result = MPRestClient::put($uri, $data);
319
  return $result;
320
  }
321
 
322
  /**
323
- * Generic resource delete
324
- * @param uri
325
- * @param data
326
- * @param params
327
- */
328
  public function delete($uri, $params = null) {
329
  $params = is_array ($params) ? $params : array();
330
 
@@ -336,7 +345,7 @@ class MP {
336
  $uri .= $this->build_query($params);
337
  }
338
 
339
- $result = MPRestClient::delete($uri);
340
  return $result;
341
  }
342
 
@@ -346,6 +355,7 @@ class MP {
346
  if (function_exists("http_build_query")) {
347
  return http_build_query($params, "", "&");
348
  } else {
 
349
  foreach ($params as $name => $value) {
350
  $elements[] = "{$name}=" . urlencode($value);
351
  }
@@ -354,100 +364,29 @@ class MP {
354
  }
355
  }
356
 
357
- }
358
-
359
- /**
360
- * MercadoPago cURL RestClient
361
- */
362
- class MPRestClient {
363
-
364
- const API_BASE_URL = "https://api.mercadopago.com";
365
-
366
- private static function get_connect($uri, $method, $content_type) {
367
- if (!extension_loaded ("curl")) {
368
- throw new Exception("cURL extension not found. You need to enable cURL in your php.ini or another configuration you have.");
369
- }
370
-
371
- $connect = curl_init(self::API_BASE_URL . $uri);
372
-
373
- curl_setopt($connect, CURLOPT_USERAGENT, "MercadoPago Magento-1.9.x-transparent Cart v1.0.2");
374
- curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
375
- curl_setopt($connect, CURLOPT_CUSTOMREQUEST, $method);
376
- curl_setopt($connect, CURLOPT_HTTPHEADER, array("Accept: application/json", "Content-Type: " . $content_type));
377
-
378
- return $connect;
379
- }
380
-
381
- private static function set_data(&$connect, $data, $content_type) {
382
- if ($content_type == "application/json") {
383
- if (gettype($data) == "string") {
384
- json_decode($data, true);
385
- } else {
386
- $data = json_encode($data);
387
- }
388
-
389
- if(function_exists('json_last_error')) {
390
- $json_error = json_last_error();
391
- if ($json_error != JSON_ERROR_NONE) {
392
- throw new Exception("JSON Error [{$json_error}] - Data: {$data}");
393
- }
394
- }
395
- }
396
-
397
- curl_setopt($connect, CURLOPT_POSTFIELDS, $data);
398
- }
399
-
400
- private static function exec($method, $uri, $data, $content_type) {
401
- $connect = self::get_connect($uri, $method, $content_type);
402
- if ($data) {
403
- self::set_data($connect, $data, $content_type);
404
- }
405
-
406
- $api_result = curl_exec($connect);
407
- $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
408
-
409
- if ($api_result === FALSE) {
410
- throw new Exception (curl_error ($connect));
411
- }
412
-
413
- $response = array(
414
- "status" => $api_http_code,
415
- "response" => json_decode($api_result, true)
416
- );
417
-
418
- /*if ($response['status'] >= 400) {
419
- $message = $response['response']['message'];
420
- if (isset ($response['response']['cause'])) {
421
- if (isset ($response['response']['cause']['code']) && isset ($response['response']['cause']['description'])) {
422
- $message .= " - ".$response['response']['cause']['code'].': '.$response['response']['cause']['description'];
423
- } else if (is_array ($response['response']['cause'])) {
424
- foreach ($response['response']['cause'] as $cause) {
425
- $message .= " - ".$cause['code'].': '.$cause['description'];
426
- }
427
- }
428
- }
429
-
430
- throw new Exception ($message, $response['status']);
431
- }*/
432
-
433
- curl_close($connect);
434
-
435
- return $response;
436
- }
437
-
438
- public static function get($uri, $content_type = "application/json") {
439
- return self::exec("GET", $uri, null, $content_type);
440
  }
441
 
442
- public static function post($uri, $data, $content_type = "application/json") {
443
- return self::exec("POST", $uri, $data, $content_type);
 
 
 
 
444
  }
445
 
446
- public static function put($uri, $data, $content_type = "application/json") {
447
- return self::exec("PUT", $uri, $data, $content_type);
 
 
 
 
448
  }
449
 
450
- public static function delete($uri, $content_type = "application/json") {
451
- return self::exec("DELETE", $uri, $null, $content_type);
452
- }
453
  }
 
1
  <?php
2
+
3
  /**
4
  * MercadoPago Integration Library
5
  * Access MercadoPago for payments integration
6
+ *
7
  * @author hcasatti
8
  *
9
  */
10
 
11
+
12
+ class MercadoPago_Lib_Api {
13
 
14
  const version = "0.3.3";
15
 
19
  private $access_data;
20
  private $sandbox = FALSE;
21
 
22
+ private $_platform = null;
23
+ private $_so = null;
24
+ private $_type = null;
25
+
26
+
27
+ public function __construct() {
28
+ $i = func_num_args();
29
 
30
  if ($i > 2 || $i < 1) {
31
  throw new Exception("Invalid arguments. Use CLIENT_ID and CLIENT SECRET, or ACCESS_TOKEN");
63
  'grant_type' => 'client_credentials'
64
  ));
65
 
66
+ $access_data = MercadoPago_Lib_RestClient::post("/oauth/token", $app_client_values, "application/x-www-form-urlencoded");
67
 
68
  if ($access_data["status"] != 200) {
69
  throw new Exception ($access_data['response']['message'], $access_data['status']);
83
  $access_token = $this->get_access_token();
84
 
85
  $uri_prefix = $this->sandbox ? "/sandbox" : "";
86
+
87
+ $payment_info = MercadoPago_Lib_RestClient::get($uri_prefix."/collections/notifications/" . $id . "?access_token=" . $access_token);
88
  return $payment_info;
89
  }
90
  public function get_payment_info($id) {
95
  * Get information for specific authorized payment
96
  * @param id
97
  * @return array(json)
98
+ */
99
  public function get_authorized_payment($id) {
100
  $access_token = $this->get_access_token();
101
 
102
+ $authorized_payment_info = MercadoPago_Lib_RestClient::get("/authorized_payments/" . $id . "?access_token=" . $access_token);
103
  return $authorized_payment_info;
104
  }
105
 
115
  "status" => "refunded"
116
  );
117
 
118
+ $response = MercadoPago_Lib_RestClient::put("/collections/" . $id . "?access_token=" . $access_token, $refund_status);
119
  return $response;
120
  }
121
 
131
  "status" => "cancelled"
132
  );
133
 
134
+ $response = MercadoPago_Lib_RestClient::put("/collections/" . $id . "?access_token=" . $access_token, $cancel_status);
135
  return $response;
136
  }
137
 
147
  "status" => "cancelled"
148
  );
149
 
150
+ $response = MercadoPago_Lib_RestClient::put("/preapproval/" . $id . "?access_token=" . $access_token, $cancel_status);
151
  return $response;
152
  }
153
 
167
  $filters = $this->build_query($filters);
168
 
169
  $uri_prefix = $this->sandbox ? "/sandbox" : "";
170
+
171
+ $collection_result = MercadoPago_Lib_RestClient::get($uri_prefix."/collections/search?" . $filters . "&access_token=" . $access_token);
172
  return $collection_result;
173
  }
174
 
180
  public function create_preference($preference) {
181
  $access_token = $this->get_access_token();
182
 
183
+ $extra_params = array('platform: ' . $this->_platform, 'so;', 'type: ' . $this->_type);
184
+ $preference_result = MercadoPago_Lib_RestClient::post("/checkout/preferences?access_token=" . $access_token, $preference, "application/json", $extra_params);
185
  return $preference_result;
186
  }
187
 
194
  public function update_preference($id, $preference) {
195
  $access_token = $this->get_access_token();
196
 
197
+ $preference_result = MercadoPago_Lib_RestClient::put("/checkout/preferences/{$id}?access_token=" . $access_token, $preference);
198
  return $preference_result;
199
  }
200
 
206
  public function get_preference($id) {
207
  $access_token = $this->get_access_token();
208
 
209
+ $preference_result = MercadoPago_Lib_RestClient::get("/checkout/preferences/{$id}?access_token=" . $access_token);
210
  return $preference_result;
211
  }
212
 
218
  public function create_preapproval_payment($preapproval_payment) {
219
  $access_token = $this->get_access_token();
220
 
221
+ $preapproval_payment_result = MercadoPago_Lib_RestClient::post("/preapproval?access_token=" . $access_token, $preapproval_payment);
222
  return $preapproval_payment_result;
223
  }
224
 
230
  public function get_preapproval_payment($id) {
231
  $access_token = $this->get_access_token();
232
 
233
+ $preapproval_payment_result = MercadoPago_Lib_RestClient::get("/preapproval/{$id}?access_token=" . $access_token);
234
  return $preapproval_payment_result;
235
  }
236
 
238
  * Update a preapproval payment
239
  * @param string $preapproval_payment, $id
240
  * @return array(json)
241
+ */
242
+
243
  public function update_preapproval_payment($id, $preapproval_payment) {
244
  $access_token = $this->get_access_token();
245
 
246
+ $preapproval_payment_result = MercadoPago_Lib_RestClient::put("/preapproval/" . $id . "?access_token=" . $access_token, $preapproval_payment);
247
  return $preapproval_payment_result;
248
  }
249
+
250
+ /**
251
  * Create a custon payment
252
  * @param array $preference
253
  * @return array(json)
255
  public function create_custon_payment($info) {
256
  $access_token = $this->get_access_token();
257
 
258
+ $preference_result = MercadoPago_Lib_RestClient::post("/checkout/custom/create_payment?access_token=" . $access_token, $info);
259
  return $preference_result;
260
  }
261
 
262
  /* Generic resource call methods */
263
 
264
  /**
265
+ * Generic resource get
266
+ * @param uri
267
+ * @param params
268
+ * @param authenticate = true
269
+ */
270
  public function get($uri, $params = null, $authenticate = true) {
271
  $params = is_array ($params) ? $params : array();
272
 
278
 
279
  if (count($params) > 0) {
280
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
281
+ $uri .= $this->build_query($params);
282
  }
283
 
284
+ $result = MercadoPago_Lib_RestClient::get($uri);
285
  return $result;
286
  }
287
 
288
  /**
289
+ * Generic resource post
290
+ * @param uri
291
+ * @param data
292
+ * @param params
293
+ */
294
  public function post($uri, $data, $params = null) {
295
  $params = is_array ($params) ? $params : array();
296
 
299
 
300
  if (count($params) > 0) {
301
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
302
+ $uri .= $this->build_query($params);
303
  }
304
 
305
+ $extra_params = array('platform: ' . $this->_platform, 'so;', 'type: ' . $this->_type);
306
+ $result = MercadoPago_Lib_RestClient::post($uri, $data, "application/json", $extra_params);
307
  return $result;
308
  }
309
 
310
  /**
311
+ * Generic resource put
312
+ * @param uri
313
+ * @param data
314
+ * @param params
315
+ */
316
  public function put($uri, $data, $params = null) {
317
  $params = is_array ($params) ? $params : array();
318
 
321
 
322
  if (count($params) > 0) {
323
  $uri .= (strpos($uri, "?") === false) ? "?" : "&";
324
+ $uri .= $this->build_query($params);
325
  }
326
 
327
+ $result = MercadoPago_Lib_RestClient::put($uri, $data);
328
  return $result;
329
  }
330
 
331
  /**
332
+ * Generic resource delete
333
+ * @param uri
334
+ * @param data
335
+ * @param params
336
+ */
337
  public function delete($uri, $params = null) {
338
  $params = is_array ($params) ? $params : array();
339
 
345
  $uri .= $this->build_query($params);
346
  }
347
 
348
+ $result = MercadoPago_Lib_RestClient::delete($uri);
349
  return $result;
350
  }
351
 
355
  if (function_exists("http_build_query")) {
356
  return http_build_query($params, "", "&");
357
  } else {
358
+ $elements = [];
359
  foreach ($params as $name => $value) {
360
  $elements[] = "{$name}=" . urlencode($value);
361
  }
364
  }
365
  }
366
 
367
+ /**
368
+ * @param null $platform
369
+ */
370
+ public function set_platform($platform)
371
+ {
372
+ $this->_platform = $platform;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  }
374
 
375
+ /**
376
+ * @param null $so
377
+ */
378
+ public function set_so($so = '')
379
+ {
380
+ $this->_so = $so;
381
  }
382
 
383
+ /**
384
+ * @param null $type
385
+ */
386
+ public function set_type($type)
387
+ {
388
+ $this->_type = $type;
389
  }
390
 
 
 
 
391
  }
392
+
lib/MercadoPago/Lib/RestClient.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MercadoPago cURL RestClient
5
+ */
6
+
7
+
8
+ class MercadoPago_Lib_RestClient {
9
+
10
+ const API_BASE_URL = "https://api.mercadopago.com";
11
+
12
+ private static function get_connect($uri, $method, $content_type, $extra_params = array()) {
13
+ if (!extension_loaded ("curl")) {
14
+ throw new Exception("cURL extension not found. You need to enable cURL in your php.ini or another configuration you have.");
15
+ }
16
+
17
+ $connect = curl_init(self::API_BASE_URL . $uri);
18
+
19
+ curl_setopt($connect, CURLOPT_USERAGENT, "MercadoPago Magento-1.9.x-transparent Cart v1.0.2");
20
+ curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
21
+ curl_setopt($connect, CURLOPT_CUSTOMREQUEST, $method);
22
+
23
+ $header_opt = array("Accept: application/json", "Content-Type: " . $content_type);
24
+ if (count($extra_params) > 0) {
25
+ $header_opt = array_merge($header_opt, $extra_params);
26
+ }
27
+
28
+ curl_setopt($connect, CURLOPT_HTTPHEADER, $header_opt);
29
+
30
+ return $connect;
31
+ }
32
+
33
+ private static function set_data(&$connect, $data, $content_type) {
34
+ if ($content_type == "application/json") {
35
+ if (gettype($data) == "string") {
36
+ json_decode($data, true);
37
+ } else {
38
+ $data = json_encode($data);
39
+ }
40
+
41
+ if(function_exists('json_last_error')) {
42
+ $json_error = json_last_error();
43
+ if ($json_error != JSON_ERROR_NONE) {
44
+ throw new Exception("JSON Error [{$json_error}] - Data: {$data}");
45
+ }
46
+ }
47
+ }
48
+
49
+ curl_setopt($connect, CURLOPT_POSTFIELDS, $data);
50
+ }
51
+
52
+ private static function exec($method, $uri, $data, $content_type, $extra_params) {
53
+ $connect = self::get_connect($uri, $method, $content_type, $extra_params);
54
+ if ($data) {
55
+ self::set_data($connect, $data, $content_type);
56
+ }
57
+
58
+ $api_result = curl_exec($connect);
59
+ $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
60
+
61
+ if ($api_result === FALSE) {
62
+ throw new Exception (curl_error ($connect));
63
+ }
64
+
65
+ $response = array(
66
+ "status" => $api_http_code,
67
+ "response" => json_decode($api_result, true)
68
+ );
69
+
70
+ /*if ($response['status'] >= 400) {
71
+ $message = $response['response']['message'];
72
+ if (isset ($response['response']['cause'])) {
73
+ if (isset ($response['response']['cause']['code']) && isset ($response['response']['cause']['description'])) {
74
+ $message .= " - ".$response['response']['cause']['code'].': '.$response['response']['cause']['description'];
75
+ } else if (is_array ($response['response']['cause'])) {
76
+ foreach ($response['response']['cause'] as $cause) {
77
+ $message .= " - ".$cause['code'].': '.$cause['description'];
78
+ }
79
+ }
80
+ }
81
+
82
+ throw new Exception ($message, $response['status']);
83
+ }*/
84
+
85
+ curl_close($connect);
86
+
87
+ return $response;
88
+ }
89
+
90
+ public static function get($uri, $content_type = "application/json", $extra_params = array()) {
91
+ return self::exec("GET", $uri, null, $content_type, $extra_params);
92
+ }
93
+
94
+ public static function post($uri, $data, $content_type = "application/json", $extra_params = array()) {
95
+ return self::exec("POST", $uri, $data, $content_type, $extra_params);
96
+ }
97
+
98
+ public static function put($uri, $data, $content_type = "application/json", $extra_params = array()) {
99
+ return self::exec("PUT", $uri, $data, $content_type, $extra_params);
100
+ }
101
+
102
+ public static function delete($uri, $content_type = "application/json", $extra_params = array()) {
103
+ return self::exec("DELETE", $uri, null, $content_type, $extra_params);
104
+ }
105
+ }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MercadoPagoTransparent</name>
4
- <version>0.0.3</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
@@ -10,20 +10,57 @@
10
  <description>"Credit Card Customized Checkout&#xD;
11
  This feature will allow merchants to have a customized checkout for credit card payment. Thus, it will be possible to customize its look and feel, customers won&#x2019;t be redirected away to complete the payment, and it will also reduce the checkout steps improving conversion rates.&#xD;
12
  &#xD;
 
 
13
  Customized Bar Code Payment&#xD;
14
- This feature will allow merchants to have a customized bar code payment. It reduces the checkout steps improving conversion rates. The bar code payment will have merchant's logo.&#xD;
15
- &#xD;
16
- Standard checkout&#xD;
17
- This feature will allow merchants to have a standard checkout. It includes all payment methods (i.e. all credit cards, bar code payment, account money) and all window types (i.e. redirect, iframe and modal). Customization is not allowed."</description>
18
- <notes>- Code improvements&#xD;
19
- - Improvements in javascript&#xD;
20
- - Successful page specific to MercadoPago&#xD;
21
- - API Cupom&#xD;
22
- - LOGS (Backend and Javascript)</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  <authors><author><name>Developers MercadoPago Brasil</name><user>developers_mercadopago</user><email>developers@mercadopago.com.br</email></author></authors>
24
- <date>2015-06-30</date>
25
- <time>12:36:18</time>
26
- <contents><target name="magecommunity"><dir name="MercadoPago"><dir name="Block"><dir name="Custom"><file name="Form.php" hash="c990be90ff8d95f8dd4e02cf022a8652"/><file name="Info.php" hash="564f561fa722cead62e8e3f9f89df651"/></dir><dir name="Customticket"><file name="Form.php" hash="6847bc3716033c79c089905c6d205baf"/><file name="Info.php" hash="60179872b000387eeb85e72321f8b194"/></dir><file name="Discount.php" hash="1320a1f21596fcf3ffc5659713cd4736"/><dir name="Standard"><file name="Form.php" hash="109940801cd2bb15cdabf9c6a6787fe9"/><file name="Info.php" hash="05864e448c87668c433c8e741c92cb8f"/><file name="Pay.php" hash="e68a3660cc6a308433dec01aec927da9"/></dir><file name="Success.php" hash="281336fdd6a6db4c55ee411630e0bcef"/></dir><dir name="Helper"><file name="Data.php" hash="1c8fb37ed943d0d7362e6191099006db"/></dir><dir name="Model"><file name="Core.php" hash="ef7918d563da2fb81d40b38cbdd22c54"/><dir name="Custom"><file name="Payment.php" hash="ec1ddc3057d42318eddab95d0c262aba"/></dir><dir name="CustomTicket"><file name="Payment.php" hash="16453cd2d58220b2f14ec506da4ad12b"/></dir><file name="Observer.php" hash="4afb8cc40b51e34873a5fa2fe8b8265d"/><dir name="Source"><file name="CategoryId.php" hash="6164c82faaff5707711488c42662ecb4"/><file name="Country.php" hash="76bd0fd5773c8f18b6e0cf180c17ccbb"/><file name="Installments.php" hash="28d9570b185649b9efc1286a08449031"/><file name="PaymentMethods.php" hash="3360046d616a1b5601dec10e7680577a"/><file name="TypeCheckout.php" hash="c139d40fc81c7bb46f7c987e8c7ee73d"/></dir><dir name="Standard"><file name="Payment.php" hash="595e36054f143836709d0ec6f6f90e26"/></dir></dir><dir name="controllers"><file name="ApiController.php" hash="c7274c6229f2106e2eb2962cd9a378c6"/><file name="NotificationsController.php" hash="1a9225844c332b6f866cbcfa321826d7"/><file name="PayController.php" hash="44150ea66cef265e485002fffb645e7c"/><file name="SuccessController.php" hash="adf588cad64ff072fc256aae7cdf614d"/></dir><dir name="etc"><file name="config.xml" hash="2c5f6f349cf917b46b1ee2eb0c46aef5"/><file name="system.xml" hash="e8c1932cc8c34c9d33ccc84f867b4529"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mercadopago"><dir name="custom"><file name="info.phtml" hash="c1a6c2f8725f5e3c49acefdce87d6ba3"/></dir><dir name="custom_ticket"><file name="info.phtml" hash="79c76a31877ebbcab44bfd6ea9bc0c26"/></dir><dir name="standard"><file name="info.phtml" hash="c1a6c2f8725f5e3c49acefdce87d6ba3"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="mercadopago"><file name="clean.phtml" hash="fc92035839e69f52192eb9c3063a6864"/><dir name="custom"><file name="form.phtml" hash="63236f8e2180ec546af4e7b269a27522"/><file name="info.phtml" hash="70a72da32d8d0a952bb6bf3e21df1100"/></dir><dir name="custom_ticket"><file name="form.phtml" hash="54c1324ecc0aff732a2309a8e3989211"/><file name="info.phtml" hash="88580f9ef51978f6df334e13b5f715da"/></dir><file name="discount.phtml" hash="6f7c3a791dacdc33d12219bc017ded85"/><dir name="standard"><file name="form.phtml" hash="ae0427cde39fed3291df88412b0109f9"/><file name="info.phtml" hash="70a72da32d8d0a952bb6bf3e21df1100"/><file name="pay.phtml" hash="3e3b83363e355778b98908847a56ab28"/></dir><file name="success.phtml" hash="54a85f66a9480faba376c1998b9ea42b"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="mercadopago"><file name="mercadopago.php" hash="af486ed4aed3fab1ecbd99514609f962"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="mercadopago"><dir name="css"><file name="style.css" hash="a73e47291f6be0e6cb9e7c4f27eac35b"/></dir><dir name="images"><file name="loading.gif" hash="5c43434f066c2fbc4714c768b8f83853"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MercadoPago.xml" hash="e96ce344ffe3e8aa47a76db62182cd9c"/></dir></target><target name="mageweb"><dir name="js"><dir name="mercadopago"><file name="jquery-1.11.0.min.js" hash="52d16e147b5346147d0f3269cd4d0f80"/><file name="mercadopago.js" hash="f3e69052d5cb9550e280464d5552e0aa"/></dir></dir></target><target name="magelocale"><dir name="es_AR"><file name="mercadopago.csv" hash="142157f664156a71869d48137faa7b8a"/></dir><dir name="es_CO"><file name="mercadopago.csv" hash="f84e38b3bd34942258609060d199b98c"/></dir><dir name="es_ES"><file name="mercadopago.csv" hash="7afe76cc1054bfa60c82b812721b4335"/></dir><dir name="es_MX"><file name="mercadopago.csv" hash="8abb2cc9a5c3bf1340de7509974f1e14"/></dir><dir name="pt_BR"><file name="mercadopago.csv" hash="e03275834475ddc0482d65b5a2568bca"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
29
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MercadoPagoTransparent</name>
4
+ <version>0.0.4</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
10
  <description>"Credit Card Customized Checkout&#xD;
11
  This feature will allow merchants to have a customized checkout for credit card payment. Thus, it will be possible to customize its look and feel, customers won&#x2019;t be redirected away to complete the payment, and it will also reduce the checkout steps improving conversion rates.&#xD;
12
  &#xD;
13
+ Available for Argentina, Brazil, Colombia, Mexico and Venezuela&#xD;
14
+ &#xD;
15
  Customized Bar Code Payment&#xD;
16
+ This feature allows merchants to have a customized bar code payment. It reduces the checkout steps improving conversion rates. The bar code payment will have merchant's logo.&#xD;
17
+ &#xD;
18
+ Available for Argentina, Brazil, Colombia, Mexico and Venezuela&#xD;
19
+ &#xD;
20
+ Standard Checkout&#xD;
21
+ This feature allows merchants to have a standard checkout. It includes all payment methods (i.e. all credit cards, bar code payment, account money) and all window types (i.e. redirect, iframe, modal, blank and popup). Customization is not allowed.&#xD;
22
+ &#xD;
23
+ Available for Argentina, Brazil, Chile, Colombia, Mexico and Venezuela&#xD;
24
+ &#xD;
25
+ OneClick Pay &#xD;
26
+ This feature allows to store credit card information for the customer, so that the next time there is no need to enter all the card details. Customers will just need to re-enter the security code of the credit card they want to use."</description>
27
+ <notes>"MercadoPago v2.1.2&#xD;
28
+ &#xD;
29
+ New internal module file structure&#xD;
30
+ &#xD;
31
+ - Javascript code refactored&#xD;
32
+ &#xD;
33
+ - New plugin configuration layout&#xD;
34
+ &#xD;
35
+ - Added Customers &amp; Cards feature&#xD;
36
+ &#xD;
37
+ - Magento orders now contain subtotals related to MP coupons and financing cost.&#xD;
38
+ &#xD;
39
+ - Document type and card token validation on checkout&#xD;
40
+ &#xD;
41
+ - Venezuela added as available country.&#xD;
42
+ &#xD;
43
+ - Compatibility with OSC extensions innovarti and ideasa&#xD;
44
+ &#xD;
45
+ MercadoEnvios 0.1.0&#xD;
46
+ &#xD;
47
+ - New module available for Argentina, Brazil and Mexico only with Standard Checkout&#xD;
48
+ &#xD;
49
+ - Package size and weight attributes can be mapped with magento attributes, and its units can be converted through admin panel.&#xD;
50
+ &#xD;
51
+ - Different shipping methods per country can be enabled/disabled.&#xD;
52
+ &#xD;
53
+ - Shipping cost is calculated and shown in cart page and checkout.&#xD;
54
+ &#xD;
55
+ - Free shipping option is available.&#xD;
56
+ &#xD;
57
+ - Tracking information order can be accessed through order details admin section or my account.&#xD;
58
+ &#xD;
59
+ - Shipping label can be printed through order details admin section."</notes>
60
  <authors><author><name>Developers MercadoPago Brasil</name><user>developers_mercadopago</user><email>developers@mercadopago.com.br</email></author></authors>
61
+ <date>2016-03-31</date>
62
+ <time>21:27:23</time>
63
+ <contents><target name="magecommunity"><dir name="MercadoPago"><dir name="Core"><dir name="Block"><file name="AbstractForm.php" hash="37bbd650b14574dee9f1296bf67ffd10"/><file name="AbstractSuccess.php" hash="6aa920d8b886d22410f50b9625847699"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="af39cd4e8086b008f00bc987303e907a"/></dir></dir></dir></dir><dir name="Custom"><file name="Form.php" hash="733c5dccf752493b9fe24938433ff9fd"/><file name="Info.php" hash="51771218b04b7a41d83adec76e393311"/><file name="Success.php" hash="2ab918e6b2415018d780b1a58d5b6d04"/></dir><dir name="Customticket"><file name="Form.php" hash="6580496bc71be11e4c572e1e143557cf"/><file name="Info.php" hash="f23e8a204e431e95a7bb0e9b409c1df4"/><file name="Success.php" hash="325fc24f1c0d220a95abe238ec583ee5"/></dir><file name="Discount.php" hash="a17b7f08dd57c31d27e57b3acbe03188"/><dir name="Sales"><dir name="Order"><dir name="Totals"><dir name="Discount"><file name="Coupon.php" hash="4bd99d8954d154971b8b51b4318b5b1c"/></dir><dir name="Finance"><file name="Cost.php" hash="750c3c7ca6465439eff098f6ae912b6c"/></dir></dir></dir></dir><dir name="Standard"><file name="Form.php" hash="e6845e293d0c0ca1a6ac04acf79edd1e"/><file name="Info.php" hash="db81d01579b66fbd8251883967768320"/><file name="Pay.php" hash="8ebb3cd8ef5df082343cfe33eadf17e0"/><file name="Success.php" hash="409dd3e16db4ebd5bd22599b7271062c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ad91fcd07914aa07844303d8fb058b8d"/><dir name="Message"><file name="Abstract.php" hash="1f4f37e4a2cd0d1a18dff6f3e96ca84d"/></dir><file name="Response.php" hash="f247edf929e2d3c3fcfe7e7ea62629de"/><file name="StatusDetailMessage.php" hash="f56549a427452d4e67351274032885db"/><file name="StatusMessage.php" hash="3a7860b8dc843f8f9620852113fc5093"/><file name="StatusOrderMessage.php" hash="f17c394be7b8a795ee05342109c93fe4"/></dir><dir name="Model"><dir name="Api"><file name="Exception.php" hash="8093747fa6e2244c3f59a188911d47c3"/><dir name="V0"><file name="Exception.php" hash="026642775cab4873176aaf28493a9159"/></dir><dir name="V1"><file name="Exception.php" hash="022c7e5ff52d04a91990bdb230f97e73"/></dir></dir><file name="Core.php" hash="6c1e1a0b5f1c45d434a29b4d41de9e9d"/><dir name="Custom"><dir name="Finance"><dir name="Cost"><file name="Creditmemo.php" hash="4e75bb8d2c34e9758a27d9e9db3f6b36"/><file name="Invoice.php" hash="d8123b798f25c119739b9ac16817619c"/></dir><file name="Cost.php" hash="9fab08c5253d19b4106ef9070580f42e"/></dir><file name="Payment.php" hash="d6ffc621ce27ec6e96b3145bdd0d669c"/></dir><file name="CustomPayment.php" hash="d624d2b5bb16232be4c48dacd07b5d11"/><dir name="CustomTicket"><file name="Payment.php" hash="15a619e31be96f0cff76de029fc94c52"/></dir><dir name="Discount"><dir name="Coupon"><file name="Creditmemo.php" hash="87dc7aaac390633ddf87c27e3d097130"/><file name="Invoice.php" hash="a586d210a2b8b57a8dffe9fdb69b5363"/></dir><file name="Coupon.php" hash="54d8cbfb2fd73db87fbe3f93e483a8d8"/></dir><file name="Observer.php" hash="4cdf23a05a1652b8e67c92e8e59557f7"/><dir name="Source"><file name="CategoryId.php" hash="5728ee8c2bb1f41e10103c4ff4b939cb"/><file name="Country.php" hash="93b2efcbefc6e5ea925ca74a88af93f4"/><file name="Installments.php" hash="7c7efe8ef187ff1e2ab00bf7dbcc8cab"/><dir name="Order"><file name="Status.php" hash="4b0b5fadd551b0bc360ae53d99768cda"/></dir><file name="PaymentMethods.php" hash="c92ef487943fadd611ecad44d4d6c083"/><file name="TypeCheckout.php" hash="36496d11ce7fbb1d87f27eb705525b61"/></dir><dir name="Standard"><file name="Payment.php" hash="fe42f97ad53bf14db164350fd08617af"/></dir></dir><dir name="controllers"><file name="ApiController.php" hash="2901e45bb90b472bc81b0353c4acb824"/><file name="NotificationsController.php" hash="7b949c4c48081479db1e65882bd217c7"/><file name="PayController.php" hash="bfa751fb97ffd2d81bbffcc564d7cd0c"/><file name="SuccessController.php" hash="59da945d27a8b8b0ae102bd374415e9b"/></dir><dir name="etc"><file name="config.xml" hash="ec4c7f03e4e1dda852a46ec258913709"/><file name="system.xml" hash="0c474b71b67510d172753d3ba7703bc5"/></dir><dir name="sql"><dir name="mercadopago_setup"><file name="install-2.1.0.php" hash="12ecf80fa3ceaf2e4065bda76cf07a4d"/><file name="upgrade-2.1.0-2.1.1.php" hash="abf330b2171e90fc25f0cfe668bd051d"/><file name="upgrade-2.1.1-2.1.2.php" hash="805656e780e56feb6567c6c310bd9b7b"/></dir></dir></dir><dir name="MercadoEnvios"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Carrier.php" hash="f8a32cf354e44f90e7ce9e64017438f9"/><file name="Mapping.php" hash="b00a1ff552b99b744d29365570b33257"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7733f94af70fe579cf15a9b9820cb83d"/><file name="ItemData.php" hash="ec05bfdc7839e3d1af6089fd0ec17e83"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Attribute"><dir name="Validation"><file name="Mapping.php" hash="9cfa77a4c45541a7dc2034ac7624ec01"/></dir></dir><dir name="Source"><dir name="Shipping"><file name="FreeMethod.php" hash="e8740f8d1b3a67c8cee79b77e40cf7db"/><file name="Method.php" hash="ca97b54ee9883c302ef871a8d3ce5fd0"/></dir></dir></dir><file name="Observer.php" hash="5957f95082a0e266799042b1ee1802bd"/><dir name="Shipping"><dir name="Carrier"><file name="MercadoEnvios.php" hash="508cb199e8b98b0dbbae6fd27923b26b"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0b87ade9a5cf02b276c571d0e585b138"/><file name="system.xml" hash="17b5096fb89d95e8c05345ee96cc4e7d"/></dir></dir><dir name="OneStepCheckout"><dir name="Block"><dir name="Custom"><file name="Form.php" hash="c3c4d2230eddeca0e49098161b5d5617"/></dir><dir name="Customticket"><file name="Form.php" hash="9deffc44f4ae97765ba02a4885dbe7e5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c0a0af8a83dc71a0ccf1a5f1a3235c8a"/></dir><dir name="Model"><file name="Observer.php" hash="2cfb65eada297e55f59cc490507bd4e3"/></dir><dir name="etc"><file name="config.xml" hash="9e77435b615d9a66379102527a85287f"/><file name="system.xml" hash="0285d96e5edfd8c65773f1d395734a5c"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mercadopago"><file name="array_dropdown.phtml" hash="84c83c98f33de9530517adeb391011ab"/><dir name="custom"><file name="info.phtml" hash="c1a6c2f8725f5e3c49acefdce87d6ba3"/></dir><dir name="custom_ticket"><file name="info.phtml" hash="1c9a896cbd7d2539c2d142fa579f2d90"/></dir><dir name="standard"><file name="info.phtml" hash="c1a6c2f8725f5e3c49acefdce87d6ba3"/></dir></dir></dir><dir name="layout"><file name="mercadopago.xml" hash="3c49e00ad8174bde8e10eb7ac4a72348"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="mercadopago"><file name="clean.phtml" hash="fc92035839e69f52192eb9c3063a6864"/><dir name="custom"><file name="form.phtml" hash="b659c97b38dc9b5b9f7ed20c615225b6"/><file name="info.phtml" hash="70a72da32d8d0a952bb6bf3e21df1100"/><file name="success.phtml" hash="614035e4ff43696920090860c42de887"/></dir><dir name="custom_ticket"><file name="form.phtml" hash="763c1c6ef5f86a6c1cfffc62de5779d4"/><file name="info.phtml" hash="ab580075fca55962463cbb17628b736d"/><file name="success.phtml" hash="6f2e63745368af0e0b6987274022d14a"/></dir><file name="discount.phtml" hash="310ed2fcc7620c97002e4af155c5aecc"/><dir name="onestepcheckout"><dir name="custom"><file name="form.phtml" hash="179df6e2db3765c254f080dfd2d39646"/></dir></dir><dir name="standard"><file name="form.phtml" hash="089687bb6550b9cd36dbb8b15b6cb493"/><file name="info.phtml" hash="70a72da32d8d0a952bb6bf3e21df1100"/><file name="pay.phtml" hash="3e3b83363e355778b98908847a56ab28"/><file name="success.phtml" hash="1cf80826a9c896ff3d4abf68ab579d34"/></dir></dir></dir><dir name="layout"><file name="mercadopago.xml" hash="473e1f06bf5cf3d1793819d9ab72064f"/></dir></dir></dir></dir></target><target name="magelib"><dir name="MercadoPago"><dir name="Lib"><file name="Api.php" hash="83c779aded928366abe82ea54a3fab6c"/><file name="RestClient.php" hash="13d49937d6ba8b7e245179c74a762940"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="mercadopago"><dir name="images"><file name="cards.jpg" hash="53b06cbec7b20d95cdcaaf3b49bd2aa5"/><file name="logo.png" hash="460a0815c67a23da265f42c8bab0842a"/><file name="mercadoenvios.png" hash="006cd6ddfa8e5a19354942f79b659b5e"/></dir><file name="styles.css" hash="cac25e698c010f73dc3af01ef3377320"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="mercadopago"><dir name="css"><file name="style-success.css" hash="2780801704d278d22aff40cf333f4cf4"/><file name="style.css" hash="5d034d69a742236f658e969c1a1a7e07"/></dir><dir name="images"><file name="loading.gif" hash="5c43434f066c2fbc4714c768b8f83853"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="mercadopago"><file name="jquery-1.11.0.min.js" hash="52d16e147b5346147d0f3269cd4d0f80"/><file name="mercadopago.js" hash="5e0ac973773787c704add38fce02d582"/><file name="mercadopago_osc.js" hash="12c556d552612e3706dcbe22ff96bf5b"/><file name="tiny.min.js" hash="71bce92ef942b0ac15683f94e1f3e3a5"/><file name="tinyJ.js" hash="3318ec214b9a21fe954ce5675de013f3"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MercadoPago_Core.xml" hash="0770f2e1dd0110c2c13a330d3411fd68"/><file name="MercadoPago_MercadoEnvios.xml" hash="f7e8607c78d8b39075eb8f7700691a44"/><file name="MercadoPago_OneStepCheckout.xml" hash="9e05c392d8f00c9604ac9ad748977489"/></dir></target><target name="magelocale"><dir name="en_US"><file name="MercadoPago_Core.csv" hash="35cb0e856ef1af496e3ebf068f53d248"/></dir><dir name="es_AR"><file name="MercadoPago_Core.csv" hash="c0364c2897611efa166269adc440de77"/></dir><dir name="es_CL"><file name="MercadoPago_Core.csv" hash="ddfb3f0ff551fbf3350e1321d6d0bd3e"/></dir><dir name="es_CO"><file name="MercadoPago_Core.csv" hash="7057e0579c38432fa14f2446742f650a"/></dir><dir name="es_ES"><file name="MercadoPago_Core.csv" hash="11251df16d82efb3490bbc14a7d97c35"/></dir><dir name="es_MX"><file name="MercadoPago_Core.csv" hash="dcfd9c8d0573a15ecaeb52fca9518883"/></dir><dir name="es_VE"><file name="MercadoPago_Core.csv" hash="5586a0b0fe01d82e3a55ece73d09ff13"/></dir><dir name="pt_BR"><file name="MercadoPago_Core.csv" hash="77bd45ae846221de01c0cda4c8fe5b3c"/></dir></target></contents>
64
  <compatible/>
65
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
66
  </package>
skin/adminhtml/default/default/mercadopago/images/cards.jpg ADDED
Binary file
skin/adminhtml/default/default/mercadopago/images/logo.png ADDED
Binary file
skin/adminhtml/default/default/mercadopago/images/mercadoenvios.png ADDED
Binary file
skin/adminhtml/default/default/mercadopago/styles.css ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #meli-logo {
2
+ padding-left: 85px;
3
+ background: url(images/logo.png) no-repeat 0 0px;
4
+ height: 21px;
5
+ }
6
+
7
+ #meen-logo {
8
+ padding-left: 85px;
9
+ background: url(images/mercadoenvios.png) no-repeat 0 0px;
10
+ height: 47px;
11
+ }
12
+
13
+ .meli-cards {
14
+ padding-left: 100px;
15
+ height: 60px;
16
+ width: 468px;
17
+ }
18
+
19
+ .meli {
20
+ min-width: 100%;
21
+ box-sizing: border-box;
22
+ }
23
+
24
+ .meli-legend {
25
+ margin-top: 18px;
26
+ }
27
+
28
+ .meli-btn {
29
+ margin-top: 17%;
30
+ }
31
+
32
+ .meli-payment-btn {
33
+ margin-top: 4%;
34
+ }
35
+
36
+ .config-heading.meli .heading {
37
+ margin-top: 18px;
38
+ }
39
+
40
+ .disabled-legend {
41
+ float: right;
42
+ margin-top: 18px;
43
+ margin-right: 15px;
44
+ }
45
+
46
+ fieldset[id^="payment_mercadopago"] table {
47
+ width: 100% !important;
48
+ }
49
+
50
+ fieldset[id^="carriers_mercadoenvios"] table {
51
+ width: 100% !important;
52
+ }
skin/frontend/base/default/mercadopago/css/style-success.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Styles for success page */
2
+
3
+ .mercadopago-title{
4
+ margin: 0 0 10px 0;
5
+ font-weight:bold;
6
+ }
7
+ .mercadopago-title-info-payment{
8
+ margin: 20px 0 10px 0;
9
+ }
10
+
11
+ #btn-boleto-mercadopago{
12
+ font-size: 1.25em;
13
+ text-align: center;
14
+ line-height: 1.25em;
15
+ padding: 6px 12px;
16
+ font-family: 'Lato',sans-serif;
17
+ font-weight: 400;
18
+ background-color: #36A1F1;
19
+ background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#36A1F1),color-stop(100%,#0F79C9));
20
+ background-image: -webkit-linear-gradient(#36A1F1,#0F79C9);
21
+ background-image: -moz-linear-gradient(#36A1F1,#0F79C9);
22
+ background-image: -o-linear-gradient(#36A1F1,#0F79C9);
23
+ background-image: linear-gradient(#36A1F1,#0F79C9);
24
+ -webkit-box-shadow: inset 0 1px #97DCFF;
25
+ box-shadow: 0 1px #97DCFF inset;
26
+ color: #FFF!important;
27
+ border: 1px solid #0D6FB9;
28
+ border-radius: 4px 4px 4px 4px;
29
+ cursor: pointer;
30
+ display: inline-block;
31
+ text-decoration:none;
32
+ }
33
+ #btn-boleto-mercadopago:hover{
34
+ background-color:#4CBFF8;
35
+ background-image:linear-gradient(#4CBFF8,#1699DF);
36
+ box-shadow:0 1px #B6EBFF inset;
37
+ background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#4CBFF8),color-stop(100%,#1699DF));
38
+ background-image:-webkit-linear-gradient(#4CBFF8,#1699DF);
39
+ background-image:-moz-linear-gradient(#4CBFF8,#1699DF);
40
+ background-image:-o-linear-gradient(#4CBFF8,#1699DF);
41
+ background-image:linear-gradient(#4CBFF8,#1699DF);-webkit-box-shadow:inset 0 1px #B6EBFF;
42
+ border:1px solid #1890D3;
43
+ color:#FFF;
44
+ text-decoration:none;
45
+ }
46
+
47
+ #logo-mercadopago{
48
+ width: 100px;
49
+ margin: 20px 0;
50
+ float: left;
51
+ }
52
+
53
+ #logo-mercadopago img{
54
+ float: left;
55
+ width: 100%;
56
+ }
skin/frontend/base/default/mercadopago/css/style.css CHANGED
@@ -4,121 +4,78 @@
4
  *
5
  */
6
 
7
- #mercadopago_custom_code{
8
- width: 60px !important;
9
- }
10
-
11
- #mercadopago_custom_doc{
12
- width: 190px !important;
13
- }
14
-
15
- .sp-methods .form-list.mercadopago{
16
- padding:0 !important;
17
- }
18
- .sp-methods .form-list.form-mercadopago{
19
- padding:0 !important;
20
- }
21
-
22
- .banner_checkout_mp{
23
-
24
- }
25
-
26
- #img_payment_method{
27
  float: left;
28
  width: 100%;
29
- margin: 5px 0 0 0;
30
  }
31
 
32
- .box-mes{
33
- width: 160px;
34
  float: left;
35
- margin: 0 10px 0 0;
36
  }
37
 
38
- .box-mes select{
39
- width: 150px;
40
- }
41
- .box-ano{
42
- width: 135px;
43
- float: left;
44
  }
45
 
46
- .box-ano select{
47
- width: 90px;
 
 
48
  }
49
 
50
- .box-input{
51
- float: left;
52
- width: 100%;
53
- margin: 10px 0 0 0;
54
  }
55
 
56
- .input-box.box-installments{
57
- margin: 0 0 10px 0;
58
  }
59
 
60
-
61
-
62
- #docType{
63
- width: 60px;
64
  }
65
 
66
-
67
- #installments{
68
- margin: 0 0 5px 0;
69
- }
70
- #status{
71
- float: left;
72
- margin: 10px 0 10px 0;
73
- width: 100%;
74
- border: 1px solid transparent;
75
- border-radius: 4px;
76
- display: none;
77
  }
78
 
79
- #status.msg-alert{
80
- color: #31708f;
81
- background-color: #d9edf7;
82
- border-color: #bce8f1;
83
  }
84
 
85
- #status.msg-success{
86
- color: #3c763d;
87
- background-color: #dff0d8;
88
- border-color: #d6e9c6;
89
  }
90
 
91
- #status.msg-error{
92
- color: #a94442;
93
- background-color: #f2dede;
94
- border-color: #ebccd1;
95
  }
96
 
97
- #status .box{
98
- float: left;
99
- width: 100%;
100
- padding: 15px;
101
  }
102
 
103
- #status .loading-mp{
104
- float: left;
105
- margin: 0 10px 0 0;
106
- }
107
 
108
- #status .text-mp{
109
- float: left;
110
  }
111
 
112
- p.msg-status{
113
- margin: 0 0 !important;
 
114
  }
115
 
116
- #mercadopago_transparent_doc{
117
- width: 120px;
 
118
  }
119
 
120
- #mercadopago_transparent_code{
121
- width: 50px;
122
  }
123
 
124
  /*
@@ -190,16 +147,16 @@ p.msg-status{
190
  width: 100%;
191
  margin: 0 0 5px 0;
192
  }
193
-
194
  .box-mes {
195
  width: 100%;
196
  }
197
-
198
  .box-ano{
199
  width: 100%;
200
  margin: 10px 0 0 0;
201
  }
202
-
203
  .box-mes select{
204
  width: 50%;
205
  }
@@ -210,16 +167,16 @@ p.msg-status{
210
  #mercadopago_transparent_doc {
211
  width: 50%;
212
  }
213
-
214
  #status{
215
  margin: 0 0 10px 0;
216
  }
217
-
218
  iframe#checkout_mercadopago{
219
  float: left;
220
  width: 100% !important;
221
  }
222
-
223
  .form-list.mercadopago{
224
  float: left;
225
  min-width: 100%;
@@ -241,9 +198,9 @@ p.msg-status{
241
  }
242
 
243
  .mercadopago-message-coupon{
244
- margin: 5px 0 0 0px;
245
  float: left;
246
- width: 100%;
247
  }
248
 
249
  .mercadopago-message-coupon li{
@@ -254,7 +211,12 @@ p.msg-status{
254
  cursor: pointer;
255
  float: left;
256
  font-size: 10px;
 
257
  text-transform: uppercase;
 
 
 
 
258
  }
259
 
260
  .mercadopago-coupon-action-remove{
@@ -262,7 +224,7 @@ p.msg-status{
262
  }
263
 
264
  .mercadopago-message-coupon p{
265
- margin: 0 0 0 0;
266
  }
267
 
268
  .mercadopago-focus{
@@ -286,4 +248,20 @@ p.msg-status{
286
  float: left;
287
  width: 100%;
288
  margin: 0 !important;
289
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  */
6
 
7
+ #mercadopago_checkout_custom ul li{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  float: left;
9
  width: 100%;
 
10
  }
11
 
12
+ #mercadopago_checkout_custom ul li label{
13
+ width: 100%;
14
  float: left;
 
15
  }
16
 
17
+ #mercadopago_checkout_custom ul li input, #mercadopago_checkout_custom ul li select{
18
+ height: 20px;
 
 
 
 
19
  }
20
 
21
+ #cardId{
22
+ background-position: 93% 50% !important;
23
+ height: 25px !important;
24
+ background-color: #fff !important;
25
  }
26
 
27
+ #cardNumber{
28
+ background-position: 98% 50% !important;
29
+ width: 225px;
30
+ background-color: #fff !important;
31
  }
32
 
33
+ #cardholderName{
34
+ width: 160px;
35
  }
36
 
37
+ #securityCode, #securityCodeOCP{
38
+ width: 53px;
 
 
39
  }
40
 
41
+ #securityCodeOCP__mp{
42
+ margin: 0 0 -10px;
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
+ #docNumber{
46
+ width: 106px;
 
 
47
  }
48
 
49
+ #box_month, #box_year{
50
+ width: 130px;
51
+ float: left;
 
52
  }
53
 
54
+ #box_month select, #box_year select{
55
+ width: 130px;
 
 
56
  }
57
 
58
+ #box_month{
59
+ margin: 0 5px 0 0;
 
 
60
  }
61
 
 
 
 
 
62
 
63
+ .message-error{
64
+ display: none;
65
  }
66
 
67
+
68
+ #mercadopago_checkout_custom_ticket .form-mercadopago{
69
+ padding-left: 0px;
70
  }
71
 
72
+ .action_ocp{
73
+ cursor: pointer;
74
+ width: 160px;
75
  }
76
 
77
+ #return_list_card_mp{
78
+ display: none;
79
  }
80
 
81
  /*
147
  width: 100%;
148
  margin: 0 0 5px 0;
149
  }
150
+
151
  .box-mes {
152
  width: 100%;
153
  }
154
+
155
  .box-ano{
156
  width: 100%;
157
  margin: 10px 0 0 0;
158
  }
159
+
160
  .box-mes select{
161
  width: 50%;
162
  }
167
  #mercadopago_transparent_doc {
168
  width: 50%;
169
  }
170
+
171
  #status{
172
  margin: 0 0 10px 0;
173
  }
174
+
175
  iframe#checkout_mercadopago{
176
  float: left;
177
  width: 100% !important;
178
  }
179
+
180
  .form-list.mercadopago{
181
  float: left;
182
  min-width: 100%;
198
  }
199
 
200
  .mercadopago-message-coupon{
201
+ margin: 5px 0 -5px 0px;
202
  float: left;
203
+ width: 92%;
204
  }
205
 
206
  .mercadopago-message-coupon li{
211
  cursor: pointer;
212
  float: left;
213
  font-size: 10px;
214
+ border: 1px solid #cecece;
215
  text-transform: uppercase;
216
+ padding: 2px 7px;
217
+ border-radius: 5px;
218
+ background-color: #F0F0F0;
219
+ margin: 5px 0 0 0;
220
  }
221
 
222
  .mercadopago-coupon-action-remove{
224
  }
225
 
226
  .mercadopago-message-coupon p{
227
+ margin: 0 0 0 0;
228
  }
229
 
230
  .mercadopago-focus{
248
  float: left;
249
  width: 100%;
250
  margin: 0 !important;
251
+ }
252
+
253
+ .mercadopago-discount-options {
254
+ display: inline-block;
255
+ }
256
+ .mercadopago-ticket-label {
257
+ vertical-align: top;
258
+ }
259
+ .optionsTicketMp {
260
+ float: left;
261
+ margin-right: 10px;
262
+ }
263
+
264
+ .banner_checkout_mp {
265
+ max-width:100%;
266
+ max-height:100%;
267
+ }
skin/frontend/base/default/mercadopago/images/loading.gif CHANGED
File without changes