MercadoPagoTransparent - Version 0.0.3

Version Notes

- Code improvements
- Improvements in javascript
- Successful page specific to MercadoPago
- API Cupom
- LOGS (Backend and Javascript)

Download this release

Release Info

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


Code changes from version 0.0.2 to 0.0.3

Files changed (88) hide show
  1. app/code/community/MercadoPago/.DS_Store +0 -0
  2. app/code/community/MercadoPago/{Transparent/Block → Block/Custom}/Form.php +7 -17
  3. app/code/community/MercadoPago/{TransparentTicket/Block → Block/Custom}/Info.php +10 -9
  4. app/code/community/MercadoPago/Block/Customticket/Form.php +69 -0
  5. app/code/community/MercadoPago/Block/Customticket/Info.php +38 -0
  6. app/code/community/MercadoPago/{Transparent/Helper/Data.php → Block/Discount.php} +7 -3
  7. app/code/community/MercadoPago/{Standard/Block → Block/Standard}/Form.php +3 -10
  8. app/code/community/MercadoPago/{Standard/Block → Block/Standard}/Info.php +19 -15
  9. app/code/community/MercadoPago/{TransparentTicket/Helper/Data.php → Block/Standard/Pay.php} +8 -3
  10. app/code/community/MercadoPago/Block/Success.php +74 -0
  11. app/code/community/MercadoPago/{Transparent/Block/Info.php → Helper/Data.php} +13 -17
  12. app/code/community/MercadoPago/Model/Core.php +314 -0
  13. app/code/community/MercadoPago/Model/Custom/Payment.php +436 -0
  14. app/code/community/MercadoPago/Model/CustomTicket/Payment.php +82 -0
  15. app/code/community/MercadoPago/Model/Observer.php +146 -0
  16. app/code/community/MercadoPago/Model/Source/CategoryId.php +48 -0
  17. app/code/community/MercadoPago/Model/Source/Country.php +32 -0
  18. app/code/community/MercadoPago/{Standard/Model → Model}/Source/Installments.php +5 -1
  19. app/code/community/MercadoPago/Model/Source/PaymentMethods.php +45 -0
  20. app/code/community/MercadoPago/{Standard/Model → Model}/Source/TypeCheckout.php +8 -8
  21. app/code/community/MercadoPago/Model/Standard/Payment.php +298 -0
  22. app/code/community/MercadoPago/Standard/Helper/Data.php +0 -22
  23. app/code/community/MercadoPago/Standard/Model/Checkout.php +0 -250
  24. app/code/community/MercadoPago/Standard/Model/Observer.php +0 -107
  25. app/code/community/MercadoPago/Standard/Model/Source/CategoryId.php +0 -44
  26. app/code/community/MercadoPago/Standard/Model/Source/Country.php +0 -32
  27. app/code/community/MercadoPago/Standard/Model/Source/PaymentMethods.php +0 -41
  28. app/code/community/MercadoPago/Standard/controllers/NotificationController.php +0 -190
  29. app/code/community/MercadoPago/Standard/controllers/PayController.php +0 -64
  30. app/code/community/MercadoPago/Standard/etc/system.xml +0 -256
  31. app/code/community/MercadoPago/Transparent/.DS_Store +0 -0
  32. app/code/community/MercadoPago/Transparent/Block/.DS_Store +0 -0
  33. app/code/community/MercadoPago/Transparent/Block/Success.php +0 -36
  34. app/code/community/MercadoPago/Transparent/Model/.DS_Store +0 -0
  35. app/code/community/MercadoPago/Transparent/Model/Resource/Setup.php +0 -14
  36. app/code/community/MercadoPago/Transparent/Model/Source/CategoryId.php +0 -44
  37. app/code/community/MercadoPago/Transparent/Model/Transparent.php +0 -393
  38. app/code/community/MercadoPago/Transparent/controllers/NotificacaoController.php +0 -190
  39. app/code/community/MercadoPago/Transparent/controllers/PayController.php +0 -194
  40. app/code/community/MercadoPago/Transparent/etc/config.xml +0 -103
  41. app/code/community/MercadoPago/Transparent/etc/system.xml +0 -81
  42. app/code/community/MercadoPago/TransparentTicket/Block/Form.php +0 -50
  43. app/code/community/MercadoPago/TransparentTicket/Model/Transparent.php +0 -86
  44. app/code/community/MercadoPago/TransparentTicket/etc/config.xml +0 -103
  45. app/code/community/MercadoPago/TransparentTicket/etc/system.xml +0 -74
  46. app/code/community/MercadoPago/controllers/ApiController.php +81 -0
  47. app/code/community/MercadoPago/controllers/NotificationsController.php +347 -0
  48. app/code/community/MercadoPago/controllers/PayController.php +43 -0
  49. app/code/community/MercadoPago/controllers/SuccessController.php +37 -0
  50. app/code/community/MercadoPago/{Standard/etc → etc}/config.xml +72 -21
  51. app/code/community/MercadoPago/etc/system.xml +403 -0
  52. app/design/adminhtml/default/default/template/mercadopago/custom/info.phtml +9 -0
  53. app/design/adminhtml/default/default/template/mercadopago/custom_ticket/info.phtml +23 -0
  54. app/design/adminhtml/default/default/template/mercadopago/standard/info.phtml +7 -27
  55. app/design/adminhtml/default/default/template/mercadopago/transparent/info.phtml +0 -33
  56. app/design/adminhtml/default/default/template/mercadopago/transparent_boleto/info.phtml +0 -13
  57. app/design/adminhtml/default/default/template/mercadopago/transparent_ticket/info.phtml +0 -15
  58. app/design/frontend/base/default/layout/mercadopago.xml +0 -9
  59. app/design/frontend/base/default/template/mercadopago/{clean_page.phtml → clean.phtml} +1 -1
  60. app/design/frontend/base/default/template/mercadopago/{transparent → custom}/form.phtml +48 -35
  61. app/design/frontend/base/default/template/mercadopago/custom/info.phtml +14 -0
  62. app/design/frontend/base/default/template/mercadopago/custom_ticket/form.phtml +61 -0
  63. app/design/frontend/base/default/template/mercadopago/custom_ticket/info.phtml +34 -0
  64. app/design/frontend/base/default/template/mercadopago/discount.phtml +47 -0
  65. app/design/frontend/base/default/template/mercadopago/standard/form.phtml +1 -1
  66. app/design/frontend/base/default/template/mercadopago/standard/info.phtml +7 -29
  67. app/design/frontend/base/default/template/mercadopago/standard/pay.phtml +60 -50
  68. app/design/frontend/base/default/template/mercadopago/success.phtml +135 -0
  69. app/design/frontend/base/default/template/mercadopago/transparent/info.phtml +0 -33
  70. app/design/frontend/base/default/template/mercadopago/transparent/success.phtml +0 -229
  71. app/design/frontend/base/default/template/mercadopago/transparent/sucesso.phtml +0 -103
  72. app/design/frontend/base/default/template/mercadopago/transparent_boleto/form.phtml +0 -20
  73. app/design/frontend/base/default/template/mercadopago/transparent_boleto/info.phtml +0 -23
  74. app/design/frontend/base/default/template/mercadopago/transparent_ticket/form.phtml +0 -31
  75. app/design/frontend/base/default/template/mercadopago/transparent_ticket/info.phtml +0 -27
  76. app/etc/modules/{MercadoPago_Standard.xml → MercadoPago.xml} +2 -2
  77. app/etc/modules/MercadoPago_Transparent.xml +0 -9
  78. app/etc/modules/MercadoPago_TransparentTicket.xml +0 -9
  79. app/locale/es_AR/mercadopago.csv +13 -4
  80. app/locale/es_CO/mercadopago.csv +13 -5
  81. app/locale/es_ES/mercadopago.csv +122 -41
  82. app/locale/es_MX/mercadopago.csv +13 -5
  83. app/locale/pt_BR/mercadopago.csv +150 -0
  84. js/mercadopago/mercadopago.js +361 -92
  85. lib/mercadopago/mercadopago.php +146 -35
  86. package.xml +11 -7
  87. skin/frontend/base/default/mercadopago/.DS_Store +0 -0
  88. skin/frontend/base/default/mercadopago/css/style.css +67 -0
app/code/community/MercadoPago/.DS_Store DELETED
Binary file
app/code/community/MercadoPago/{Transparent/Block → Block/Custom}/Form.php RENAMED
@@ -15,22 +15,17 @@
15
  */
16
 
17
 
18
- class MercadoPago_Transparent_Block_Form extends Mage_Payment_Block_Form_Cc{
19
 
20
  protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
  parent::_construct();
25
-
26
- $this->setTemplate('mercadopago/transparent/form.phtml');
27
-
28
  }
29
 
30
  protected function _prepareLayout(){
31
 
32
  //pega public key para settar no aquivo mercadopago.js
33
- $model = Mage::getModel('mercadopago_transparent/transparent');
34
  $public_key = $model->getConfigData('public_key');
35
 
36
  //init js no header
@@ -38,7 +33,7 @@ class MercadoPago_Transparent_Block_Form extends Mage_Payment_Block_Form_Cc{
38
  $block->setText(
39
  sprintf(
40
  '
41
- <script type="text/javascript">var PublicKeyMercadoPagoTransparent = "' . $public_key .'"; </script>
42
  <script type="text/javascript" src="%s"></script>',
43
  Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . 'mercadopago/mercadopago.js'
44
  )
@@ -55,18 +50,18 @@ class MercadoPago_Transparent_Block_Form extends Mage_Payment_Block_Form_Cc{
55
 
56
  /*
57
  *
58
- * Fun��o especifica para mexico
59
  *
60
  */
61
  function getCardsPaymentMethods(){
62
- $payment_methods = Mage::getModel('mercadopago_transparent/transparent')->getPaymentMethods();
63
  $payment_methods_types = array("credit_card", "debit_card", "prepaid_card");
64
  $types = array();
65
 
66
  //percorre todos os payments methods
67
  foreach($payment_methods['response'] as $pm){
68
 
69
- //filtra por tickets
70
  if(in_array($pm['payment_type_id'], $payment_methods_types)){
71
  $types[] = $pm;
72
  }
@@ -75,8 +70,3 @@ class MercadoPago_Transparent_Block_Form extends Mage_Payment_Block_Form_Cc{
75
  return $types;
76
  }
77
  }
78
-
79
-
80
-
81
-
82
- ?>
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
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
  )
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
  }
70
  return $types;
71
  }
72
  }
 
 
 
 
 
app/code/community/MercadoPago/{TransparentTicket/Block → Block/Custom}/Info.php RENAMED
@@ -15,22 +15,23 @@
15
  */
16
 
17
 
18
- class MercadoPago_TransparentTicket_Block_Info extends Mage_Payment_Block_Info_Cc{
19
 
20
  protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
-
25
  parent::_construct();
26
- $this->setTemplate('mercadopago/transparent_ticket/info.phtml');
27
  $this->setModuleName('Mage_Payment');
28
  }
29
 
30
-
31
  public function getOrder() {
 
 
32
 
33
- return $this->getInfo();
34
-
 
 
 
 
35
  }
36
  }
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 ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/{Transparent/Helper/Data.php → Block/Discount.php} RENAMED
@@ -13,10 +13,14 @@
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
- <?php
18
 
19
 
20
- class MercadoPago_Transparent_Helper_Data extends Mage_Payment_Helper_Data{
21
 
 
 
 
 
 
 
22
  }
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_Discount extends Mage_Core_Block_Template{
19
 
20
+ protected function _construct(){
21
+
22
+ parent::_construct();
23
+ $this->setTemplate('mercadopago/discount.phtml');
24
+
25
+ }
26
  }
app/code/community/MercadoPago/{Standard/Block → Block/Standard}/Form.php RENAMED
@@ -15,20 +15,13 @@
15
  */
16
 
17
 
18
- class MercadoPago_Standard_Block_Form extends Mage_Payment_Block_Form_Cc{
19
 
20
  protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
  parent::_construct();
25
 
26
  $this->setTemplate('mercadopago/standard/form.phtml');
27
 
28
  }
29
- }
30
-
31
-
32
-
33
-
34
- ?>
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/{Standard/Block → Block/Standard}/Info.php RENAMED
@@ -15,22 +15,26 @@
15
  */
16
 
17
 
18
- class MercadoPago_Standard_Block_Info extends Mage_Payment_Block_Info_Cc{
19
 
20
- protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
-
25
- parent::_construct();
26
- $this->setTemplate('mercadopago/standard/info.phtml');
27
- $this->setModuleName('Mage_Payment');
28
- }
29
-
30
-
31
- public function getOrder() {
32
 
33
- return $this->getInfo();
34
-
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  }
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/{TransparentTicket/Helper/Data.php → Block/Standard/Pay.php} RENAMED
@@ -13,10 +13,15 @@
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
- <?php
18
 
19
 
20
- class MercadoPago_TransparentTicket_Helper_Data extends Mage_Payment_Helper_Data{
21
 
 
 
 
 
 
 
 
22
  }
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/Block/Success.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/community/MercadoPago/{Transparent/Block/Info.php → Helper/Data.php} RENAMED
@@ -14,23 +14,19 @@
14
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
  */
16
 
17
-
18
- class MercadoPago_Transparent_Block_Info extends Mage_Payment_Block_Info_Cc{
19
 
20
- protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
-
25
- parent::_construct();
26
- $this->setTemplate('mercadopago/transparent/info.phtml');
27
- $this->setModuleName('Mage_Payment');
28
- }
29
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- public function getOrder() {
32
-
33
- return $this->getInfo();
34
-
35
- }
36
- }
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/Model/Core.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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
+ 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 ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/{Standard/Model → Model}/Source/Installments.php RENAMED
@@ -16,12 +16,16 @@
16
 
17
  require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
 
19
- class MercadoPago_Standard_Model_Source_Installments extends Mage_Payment_Model_Method_Abstract{
20
 
21
  public function toOptionArray (){
22
 
23
  $inst = array();
 
 
24
  $response = MPRestClient::get("/sites/MLB/payment_methods/melicard?marketplace=NONE");
 
 
25
  $response = $response['response'];
26
 
27
  foreach($response['payer_costs'] as $i){
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){
app/code/community/MercadoPago/Model/Source/PaymentMethods.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/{Standard/Model → Model}/Source/TypeCheckout.php RENAMED
@@ -16,16 +16,16 @@
16
 
17
  require_once(Mage::getBaseDir('lib') . '/mercadopago/mercadopago.php');
18
 
19
- class MercadoPago_Standard_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
  }
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 ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Standard/Helper/Data.php DELETED
@@ -1,22 +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
- <?php
18
-
19
-
20
- class MercadoPago_Standard_Helper_Data extends Mage_Payment_Helper_Data{
21
-
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/Model/Checkout.php DELETED
@@ -1,250 +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_Standard_Model_Checkout 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
- protected function _construct(){
43
- $this->_init('mercadopago_standard/checkout');
44
- }
45
-
46
- public function postPago(){
47
- //seta sdk php mercadopago
48
- $client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
49
- $client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
50
- $mp = new MP($client_id, $client_secret);
51
-
52
- //monta a prefernecia
53
- $pref = $this->makePreference();
54
-
55
- //faz o posto do pagamento
56
- return $mp->create_preference($pref);
57
- }
58
-
59
- public function getOrderPlaceRedirectUrl() {
60
-
61
- // requisicao vem da pagina de finalizacao de pedido
62
- return Mage::getUrl('mercadopago_standard/pay', array('_secure' => true));
63
-
64
- }
65
-
66
- public function getDiscount($order){
67
- $discount = 0;
68
-
69
- $order = $order->getData();
70
-
71
- if(isset($order['base_discount_amount']) && $order['base_discount_amount'] < 0) {
72
- $discount = $order['base_discount_amount'];
73
- }
74
-
75
- return $discount;
76
- }
77
-
78
- function makePreference(){
79
-
80
- //pega a order atual
81
- $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
82
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
83
- $customer = Mage::getSingleton('customer/session')->getCustomer();
84
- $model = Mage::getModel('catalog/product');
85
-
86
-
87
-
88
- //pega payment dentro da order para pegar as informacoes adicionadas pela funcao assignData()
89
- $payment = $order->getPayment();
90
-
91
- //init array preferneces
92
- $arr = array();
93
-
94
- //seta o external_reference para concilia��o futura
95
- $arr['external_reference'] = $orderIncrementId;
96
-
97
- //monta array de produtos
98
- $arr['items'] = array();
99
- foreach ($order->getAllVisibleItems() as $item) {
100
-
101
- $prod = $model->loadByAttribute('sku', $item->getSku());
102
-
103
- //get image
104
- try{
105
- $imagem = $prod->getImageUrl();
106
- }catch(Exception $e){
107
- $imagem = "";
108
- }
109
-
110
- $arr['items'][] = array(
111
- "id" => $item->getSku(),
112
- "title" => $item->getName(),
113
- "description" => $item->getName(),
114
- "picture_url" => $imagem,
115
- "category_id" => Mage::getStoreConfig('payment/mercadopago_configuration/category_id'),
116
- "quantity" => (int) number_format($item->getQtyOrdered(), 0, '.', ''),
117
- "unit_price" => (float) number_format($prod->getFinalPrice(), 2, '.', '')
118
- );
119
-
120
- }
121
-
122
- //verifica se existe desconto, caso exista adiciona como um item
123
- $discount = $this->getDiscount($order);
124
-
125
- if($discount != 0){
126
- $arr['items'][] = array(
127
- "title" => "Discount by the Store",
128
- "description" => "Discount by the Store",
129
- "quantity" => (int) 1,
130
- "unit_price" => (float) number_format($discount, 2, '.', '')
131
- );
132
- }
133
-
134
-
135
- //pega dados de envio
136
- if(method_exists($order->getShippingAddress(), "getData")){
137
- $shipping = $order->getShippingAddress()->getData();
138
- $arr['shipments']['receiver_address'] = array(
139
- "floor" => "-",
140
- "zip_code" => $shipping['postcode'],
141
- "street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
142
- "apartment" => "-",
143
- "street_number" => "0"
144
- );
145
- $arr['payer']['phone'] = array(
146
- "area_code" => "-",
147
- "number" => $shipping['telephone']
148
- );
149
- }
150
-
151
- //adiciona o valor do frete nas preferencias
152
- if($order->getBaseShippingAmount() != "" && $order->getBaseShippingAmount() > 0){
153
- $arr['shipments']['cost'] = (float) $order->getBaseShippingAmount();
154
- }
155
-
156
-
157
- //pega informa�oes de cadastro do usuario
158
- $billing_address = $order->getBillingAddress();
159
- $billing_address = $billing_address->getData();
160
-
161
- //formata a data do usuario para o padrao do mercado pago YYYY-MM-DDTHH:MM:SS
162
- $arr['payer']['date_created'] = date('Y-m-d',$customer->getCreatedAtTimestamp()) . "T" . date('H:i:s',$customer->getCreatedAtTimestamp());
163
-
164
- //set informa�oes do usuario
165
- $arr['payer']['email'] = htmlentities($customer->getEmail());
166
- $arr['payer']['first_name'] = htmlentities($customer->getFirstname());
167
- $arr['payer']['last_name'] = htmlentities($customer->getLastname());
168
-
169
- //set o documento do usuario
170
- if(isset($payment['additional_information']['doc_number']) && $payment['additional_information']['doc_number'] != ""){
171
- $arr['payer']['identification'] = array(
172
- "type" => "CPF",
173
- "number" => $payment['additional_information']['doc_number']
174
- );
175
- }
176
-
177
- //set endereco do usuario
178
- $arr['payer']['address'] = array(
179
- "zip_code" => $billing_address['postcode'],
180
- "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
181
- "street_number" => "0"
182
- );
183
-
184
- //setta as urls de retorno
185
- $arr['back_urls'] = array(
186
- "success" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "checkout/onepage/success",
187
- "pending" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "checkout/onepage/success",
188
- "failure" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "checkout/onepage/success"
189
- );
190
-
191
- //define a url de notificacao
192
- $arr['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago_standard/notification";
193
-
194
- //pega o email e o nome do usuario guest
195
- if($arr['payer']['email'] == ""){
196
- $arr['payer']['email'] = $order['customer_email'];
197
- $arr['payer']['first_name'] = $order->getBillingAddress()->getFirstname();
198
- $arr['payer']['last_name'] = $order->getBillingAddress()->getLastname();
199
- }
200
-
201
- // pega os meios de pagamento que ele dejexa excluir
202
- $checkout = Mage::getModel('mercadopago_standard/checkout');
203
- $excluded_payment_methods = $checkout->getConfigData('excluded_payment_methods');
204
- $arr_epm = explode(",", $excluded_payment_methods);
205
- if(count($arr_epm) > 0){
206
- $arr['payment_methods']['excluded_payment_methods'] = array();
207
-
208
- foreach($arr_epm as $m):
209
- $arr['payment_methods']['excluded_payment_methods'][] = array("id" => $m);
210
- endforeach;
211
-
212
- }
213
-
214
- //seta o numero de parcelas maxima aceita pelo lojista
215
- $installments = $checkout->getConfigData('installments');
216
- $arr['payment_methods']['installments'] = (int) $installments;
217
-
218
-
219
- //define o retorno automatico ao finalizar o checkout
220
- $auto_return = $checkout->getConfigData('auto_return');
221
- if($auto_return == 1){
222
- $arr['auto_return'] = "approved";
223
- }
224
-
225
- //adiciona o sponsor_id para as vendas serem identificadas
226
- //$arr['sponsor_id'] = "";
227
-
228
- return $arr;
229
-
230
- }
231
-
232
-
233
- public function getPayment($payment_id){
234
- $model = $this;
235
- $this->client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
236
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
237
- $mp = new MP($this->client_id, $this->client_secret);
238
- return $mp->get_payment($payment_id);
239
- }
240
-
241
- public function getMerchantOrder($merchant_order_id){
242
- $model = $this;
243
- $this->client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
244
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
245
- $mp = new MP($this->client_id, $this->client_secret);
246
- return $mp->get_merchant_order($merchant_order_id);
247
- }
248
- }
249
-
250
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/Model/Observer.php DELETED
@@ -1,107 +0,0 @@
1
- <?php
2
- ini_set('display_errors',1);
3
- ini_set('display_startup_erros',1);
4
- error_reporting(E_ALL);
5
-
6
- /**
7
- *
8
- * NOTICE OF LICENSE
9
- *
10
- * This source file is subject to the Open Software License (OSL).
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- *
14
- * @category Payment Gateway
15
- * @package MercadoPago
16
- * @author Gabriel Matsuoka (gabriel.matsuoka@gmail.com)
17
- * @copyright Copyright (c) MercadoPago [http://www.mercadopago.com]
18
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
- */
20
-
21
- class MercadoPago_Standard_Model_Observer{
22
-
23
- private $banners_credit_card = array(
24
- "mla" => "http://imgmp.mlstatic.com/org-img/banners/ar/medios/online/468X60.jpg",
25
- "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg",
26
- "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
27
- "mlm" => "http://imgmp.mlstatic.com/org-img/banners/mx/medios/MLM_468X60.JPG"
28
- );
29
-
30
- private $banner_ticket = array(
31
- "mla" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
32
- "mlb" => "http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png",
33
- "mco" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png",
34
- "mlm" => "https://a248.e.akamai.net/secure.mlstatic.com/components/resources/mp/css/assets/desktop-logo-mercadopago.png"
35
- );
36
-
37
- private $available_transparent_credit_cart = array('mla', 'mlb', 'mlm');
38
- private $available_transparent_ticket = array('mla', 'mlb', 'mlm');
39
-
40
- public function checkAndValidData($observer){
41
- $this->availableCheckout();
42
-
43
- $this->checkBanner('mercadopago_transparentticket', 'transparent');
44
- $this->checkBanner('mercadopago_transparent', 'transparent');
45
- $this->checkBanner('mercadopago_standard', 'checkout');
46
- }
47
-
48
-
49
- public function availableCheckout(){
50
- //verifica se o pais selecionado possui integra��o para utilizar os checkouts transparents
51
- $core = new Mage_Core_Model_Resource_Setup('core_setup');
52
- $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
53
-
54
- if(!in_array($country, $this->available_transparent_credit_cart)){
55
- $core->setConfigData('payment/mercadopago_transparent/active', 0);
56
- }
57
-
58
- if(!in_array($country, $this->available_transparent_ticket)){
59
- $core->setConfigData('payment/mercadopago_transparentticket/active', 0);
60
- }
61
-
62
-
63
- }
64
-
65
- function checkBanner($model_path, $file){
66
- //pega o model/file
67
- $model = Mage::getModel($model_path . '/' . $file);
68
-
69
- //pega o banner do tipo de checkout
70
- $banner = $model->getConfigData('banner_checkout');
71
-
72
- //pega o pais configurado
73
- $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
74
-
75
- if($model_path == "mercadopago_transparentticket"){
76
- if($this->banner_ticket[$country] != $banner){
77
- $this->setNewBanner($model_path, $country);
78
- }
79
- }else{
80
- if($this->banners_credit_card[$country] != $banner){
81
- $this->setNewBanner($model_path, $country);
82
- }
83
- }
84
-
85
-
86
- }
87
- public function setNewBanner($model, $country){
88
- //instacia model do core para atualiza os dados no banco de dados
89
- //no model n�o existe fun��o para fazer isso, por esse motivo foi feito assim
90
- $core = new Mage_Core_Model_Resource_Setup('core_setup');
91
- $core->setConfigData('payment/' . $model . '/banner_checkout', $this->getBannerByCountry($model, $country));
92
- }
93
-
94
- public function getBannerByCountry($model, $country){
95
- $banner = "";
96
-
97
- //caso seja boleto o banner � diferente
98
- if($model == "mercadopago_transparentticket"){
99
- $banner = $this->banner_ticket[$country];
100
- }else{
101
- $banner = $this->banners_credit_card[$country];
102
- }
103
-
104
- return $banner;
105
- }
106
-
107
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/Model/Source/CategoryId.php DELETED
@@ -1,44 +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_Standard_Model_Source_CategoryId extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- $response = MPRestClient::get("/item_categories");
24
- $response = $response['response'];
25
-
26
- $cat = array();
27
- $count = 0;
28
- foreach($response as $v):
29
- //force category others first
30
- if($v['id'] == "others"):
31
- $cat[0] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
32
- else:
33
- $count++;
34
- $cat[$count] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
35
- endif;
36
-
37
- endforeach;
38
-
39
- //force order by key
40
- ksort($cat);
41
- return $cat;
42
-
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/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_Standard_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/Standard/Model/Source/PaymentMethods.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_Standard_Model_Source_PaymentMethods extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- $country = strtoupper(Mage::getStoreConfig('payment/mercadopago_configuration/country'));
24
- $methods = array();
25
- //adiciona um valor vazio caso n�o queria excluir nada
26
- $methods[] = array("value" => "", "label" => "");
27
- $response = MPRestClient::get("/sites/" . $country . "/payment_methods");
28
- $response = $response['response'];
29
-
30
- foreach($response as $m){
31
- if ( $m['id'] != 'account_money' ) {
32
- $methods[] = array(
33
- 'value' => $m['id'],
34
- 'label'=>Mage::helper('adminhtml')->__($m['name'])
35
- );
36
- }
37
- }
38
-
39
- return $methods;
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/controllers/NotificationController.php DELETED
@@ -1,190 +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_Standard_NotificationController 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
- $params = $this->getRequest()->getParams();
28
- if (isset($params['id']) && isset($params['topic']) && $params['topic'] == 'payment'){
29
- $model = Mage::getModel('mercadopago_standard/checkout');
30
- $response = $model->getPayment($params['id']);
31
-
32
- if($response['status'] == 200 || $response['status'] == 201):
33
- $message = "";
34
- $status = "";
35
- $payment = $response['response']['collection'];
36
-
37
- $order = Mage::getModel('sales/order')->loadByIncrementId($payment["external_reference"]);
38
-
39
- //update info de status no pagamento
40
- $payment_order = $order->getPayment();
41
- $payment_order->setAdditionalInformation('status',$payment['status']);
42
- $payment_order->setAdditionalInformation('status_detail',$payment['status_detail']);
43
- $payment_order->setAdditionalInformation('payment_id',$payment['id']);
44
-
45
- if($payment_order->getAdditionalInformation('cardholderName') == ""):
46
- $payment_order->setAdditionalInformation('cardholderName', $payment['payer']['first_name'] . " " . $payment['payer']['last_name']);
47
- endif;
48
-
49
- if($payment_order->getAdditionalInformation('payment_method') == ""):
50
- $payment_order->setAdditionalInformation('payment_method', $payment['payment_method_id']);
51
- endif;
52
-
53
- if($payment_order->getAdditionalInformation('statement_descriptor') == ""):
54
- if(isset($payment['statement_descriptor'])):
55
- $payment_order->setAdditionalInformation('statement_descriptor', $payment['statement_descriptor']);
56
- endif;
57
- endif;
58
-
59
- if($payment_order->getAdditionalInformation('trunc_card') == ""):
60
- if(isset($payment['last_four_digits'])):
61
- $payment_order->setAdditionalInformation('trunc_card', "XXXXXXXXXXXX" . $payment['last_four_digits']);
62
- endif;
63
-
64
- endif;
65
-
66
- $payment_order->save();
67
-
68
- //adiciona informações sobre o comprador na order
69
- if ($payment['payer']['first_name'])
70
- $order->setCustomerFirstname($payment['payer']['first_name']);
71
- if ($payment['payer']['last_name'])
72
- $order->setCustomerLastname($payment['payer']['last_name']);
73
- if ($payment['payer']['email'])
74
- $order->setCustomerEmail($payment['payer']['email']);
75
-
76
- $order->save();
77
-
78
- switch ( $payment['status']) {
79
-
80
- case 'approved':
81
- //add status na order
82
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment was approved.');
83
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_approved');
84
-
85
- //cria a invoice
86
- $invoice = $order->prepareInvoice();
87
- $invoice->register()->pay();
88
- Mage::getModel('core/resource_transaction')
89
- ->addObject($invoice)
90
- ->addObject($invoice->getOrder())
91
- ->save();
92
-
93
- $invoice->sendEmail(true, $message);
94
- break;
95
- case 'refunded':
96
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_refunded');
97
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment was refunded.');
98
- $order->cancel();
99
- break;
100
- case 'pending':
101
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_process');
102
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment is being processed.');
103
- break;
104
- case 'in_process':
105
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_process');
106
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment is being processed. Will be approved within 2 business days.');
107
- break;
108
- case 'in_mediation':
109
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_mediation');
110
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment is in the process of Dispute, check the graphic account of the MercadoPago for more information.');
111
- break;
112
- case 'cancelled':
113
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_cancelled');
114
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment was cancelled.');
115
- $order->cancel();
116
- break;
117
- case 'rejected':
118
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_rejected');
119
- $message = Mage::helper('mercadopago_transparent')->__('Automatic notification of the MercadoPago: The payment was rejected.');
120
- break;
121
- default:
122
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_process');
123
- $message = '';
124
- }
125
-
126
- //adiciona informações do pagamento
127
- $message .= Mage::helper('mercadopago_transparent')->__('<br/> Payment id: %s', $payment['id']);
128
- $message .= Mage::helper('mercadopago_transparent')->__('<br/> Status: %s', $payment['status']);
129
- $message .= Mage::helper('mercadopago_transparent')->__('<br/> Status Detail: %s', $payment['status_detail']);
130
-
131
- $order->addStatusToHistory($status,$message, true);
132
- $order->sendOrderUpdateEmail(true, $message);
133
-
134
- $order->save();
135
- echo $message;
136
- else:
137
- //caso de algum erro na consulta da ipn
138
- header(' ', true, 404);
139
- exit;
140
- endif;
141
-
142
- }elseif(isset($params['topic']) && $params['topic'] == 'merchant_order'){
143
-
144
- $model = Mage::getModel('mercadopago_transparent/transparent');
145
- $response = $model->getMerchantOrder($params['id']);
146
-
147
- if($response['status'] == 200 || $response['status'] == 201):
148
- $message = "";
149
- $status = "";
150
- $merchant_order = $response['response'];
151
- $order = Mage::getModel('sales/order')->loadByIncrementId($merchant_order["external_reference"]);
152
-
153
- switch ( $merchant_order['status']) {
154
-
155
- case 'opened':
156
- $message = 'Payment flow started. The order still dont have payments recorded.';
157
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_process');
158
-
159
- $message .= "<br /> Merchant Order: " . $merchant_order['id'];
160
- $message .= "<br /> Status: " . $merchant_order['status'];
161
-
162
- $order->addStatusToHistory($status,$message);
163
- $order->save();
164
- echo $message;
165
- break;
166
-
167
- /*
168
- case 'closed':
169
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_refunded');
170
- $message = 'A payment was created and it was associated to the order.';
171
- break;
172
- case 'expired':
173
- $status = Mage::getStoreConfig('payment/mercadopago_configuration/order_status_in_process');
174
- $message = 'Order cancelled by the seller.';
175
- break;
176
- default:
177
-
178
- $message = "";
179
- */
180
- }
181
-
182
- else:
183
- //caso de algum erro na consulta da ipn
184
- header(' ', true, 404);
185
- exit;
186
- endif;
187
- }
188
-
189
- }
190
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/controllers/PayController.php DELETED
@@ -1,64 +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_Standard_PayController extends Mage_Core_Controller_Front_Action{
18
-
19
- // /mercadopago_strandard/pay
20
- public function indexAction(){
21
- $init_point = "";
22
-
23
-
24
- //chama model para fazer o post do pagamento
25
- $response = Mage::getModel('mercadopago_standard/checkout')->postPago();
26
-
27
- if($response['status'] == 200 || $response['status'] == 201):
28
- $payment = $response['response'];
29
- $init_point = $payment['init_point'];
30
-
31
- endif;
32
-
33
- $this->loadLayout();
34
-
35
- //cria um block e adiciona uma view
36
- $block = $this->getLayout()->createBlock(
37
- 'Mage_Core_Block_Template',
38
- 'mercadopago_standard/pay',
39
- array('template' => 'mercadopago/standard/pay.phtml')
40
- );
41
-
42
- //envia as informações para view
43
- $block->assign(
44
- array(
45
- "init_point" => $init_point,
46
- "type_checkout" => Mage::getModel('mercadopago_standard/checkout')->getConfigData('type_checkout'),
47
- "iframe_width" => Mage::getModel('mercadopago_standard/checkout')->getConfigData('iframe_width'),
48
- "iframe_height" => Mage::getModel('mercadopago_standard/checkout')->getConfigData('iframe_height'),
49
- "banner_checkout" => Mage::getModel('mercadopago_standard/checkout')->getConfigData('banner_checkout')
50
- )
51
- );
52
-
53
- //insere o block
54
- $this->getLayout()->getBlock('content')->append($block);
55
- $this->_initLayoutMessages('core/session');
56
-
57
- //adiciona uma clean page
58
- $root = $this->getLayout()->getBlock('root');
59
- $root->setTemplate("mercadopago/clean_page.phtml");
60
-
61
- $this->renderLayout();
62
- }
63
-
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Standard/etc/system.xml DELETED
@@ -1,256 +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
-
24
- <mercadopago_configuration>
25
- <label>MercadoPago - Configuration</label>
26
- <sort_order>99</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
-
32
- <client_id translate="label">
33
- <label>Client Id</label>
34
- <frontend_type>text</frontend_type>
35
- <sort_order>3</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>0</show_in_store>
39
- </client_id>
40
-
41
- <client_secret translate="label">
42
- <label>Client Secret</label>
43
- <frontend_type>text</frontend_type>
44
- <sort_order>4</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
- </client_secret>
49
-
50
- <country translate="label">
51
- <label>Country</label>
52
- <frontend_type>select</frontend_type>
53
- <source_model>MercadoPago_Standard_Model_Source_Country</source_model>
54
- <sort_order>6</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
- </country>
59
-
60
- <category_id translate="label">
61
- <label>Category of your store</label>
62
- <frontend_type>select</frontend_type>
63
- <source_model>MercadoPago_Standard_Model_Source_CategoryId</source_model>
64
- <sort_order>7</sort_order>
65
- <show_in_default>1</show_in_default>
66
- <show_in_website>1</show_in_website>
67
- <show_in_store>0</show_in_store>
68
- </category_id>
69
-
70
- <order_status_approved translate="label">
71
- <label>Choose the status of approved orders</label>
72
- <comment>To manage the status available go to System > Order Statuses</comment>
73
- <frontend_type>select</frontend_type>
74
- <source_model>adminhtml/system_config_source_order_status</source_model>
75
- <sort_order>8</sort_order>
76
- <show_in_default>1</show_in_default>
77
- <show_in_website>1</show_in_website>
78
- <show_in_store>1</show_in_store>
79
- </order_status_approved>
80
-
81
- <order_status_refunded translate="label">
82
- <label>Choose the status of refunded orders</label>
83
- <comment>To manage the status available go to System > Order Statuses</comment>
84
- <frontend_type>select</frontend_type>
85
- <source_model>adminhtml/system_config_source_order_status</source_model>
86
- <sort_order>9</sort_order>
87
- <show_in_default>1</show_in_default>
88
- <show_in_website>1</show_in_website>
89
- <show_in_store>1</show_in_store>
90
- </order_status_refunded>
91
-
92
- <order_status_in_process translate="label">
93
- <label>Choose the status when payment is pending</label>
94
- <comment>To manage the status available go to System > Order Statuses</comment>
95
- <frontend_type>select</frontend_type>
96
- <source_model>adminhtml/system_config_source_order_status</source_model>
97
- <sort_order>9</sort_order>
98
- <show_in_default>1</show_in_default>
99
- <show_in_website>1</show_in_website>
100
- <show_in_store>1</show_in_store>
101
- </order_status_in_process>
102
-
103
- <order_status_in_mediation translate="label">
104
- <label>Choose the status when client open a mediation</label>
105
- <comment>To manage the status available go to System > Order Statuses</comment>
106
- <frontend_type>select</frontend_type>
107
- <source_model>adminhtml/system_config_source_order_status</source_model>
108
- <sort_order>10</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>1</show_in_website>
111
- <show_in_store>1</show_in_store>
112
- </order_status_in_mediation>
113
-
114
- <order_status_rejected translate="label">
115
- <label>Choose the status when payment was reject</label>
116
- <comment>To manage the status available go to System > Order Statuses</comment>
117
- <frontend_type>select</frontend_type>
118
- <source_model>adminhtml/system_config_source_order_status</source_model>
119
- <sort_order>11</sort_order>
120
- <show_in_default>1</show_in_default>
121
- <show_in_website>1</show_in_website>
122
- <show_in_store>1</show_in_store>
123
- </order_status_rejected>
124
-
125
- <order_status_cancelled translate="label">
126
- <label>Choose the status when payment was canceled</label>
127
- <comment>To manage the status available go to System > Order Statuses</comment>
128
- <frontend_type>select</frontend_type>
129
- <source_model>adminhtml/system_config_source_order_status</source_model>
130
- <sort_order>12</sort_order>
131
- <show_in_default>1</show_in_default>
132
- <show_in_website>1</show_in_website>
133
- <show_in_store>1</show_in_store>
134
- </order_status_cancelled>
135
-
136
- </fields>
137
- </mercadopago_configuration>
138
-
139
-
140
- <mercadopago_standard module="mercadopago_standard">
141
- <label>MercadoPago Standard - Credit Card, Ticket and Account Money</label>
142
- <sort_order>102</sort_order>
143
- <show_in_default>1</show_in_default>
144
- <show_in_website>1</show_in_website>
145
- <show_in_store>0</show_in_store>
146
- <fields>
147
- <active translate="label">
148
- <label>Enabled</label>
149
- <frontend_type>select</frontend_type>
150
- <source_model>adminhtml/system_config_source_yesno</source_model>
151
- <sort_order>1</sort_order>
152
- <show_in_default>1</show_in_default>
153
- <show_in_website>1</show_in_website>
154
- <show_in_store>0</show_in_store>
155
- <comment>For the operation of the Checkout Standard is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'</comment>
156
- </active>
157
-
158
- <title translate="label">
159
- <label>Payment Title</label>
160
- <frontend_type>text</frontend_type>
161
- <sort_order>2</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
- </title>
166
-
167
-
168
- <banner_checkout translate="label">
169
- <label>Banner Checkout</label>
170
- <frontend_type>text</frontend_type>
171
- <sort_order>3</sort_order>
172
- <show_in_default>1</show_in_default>
173
- <show_in_website>1</show_in_website>
174
- <show_in_store>0</show_in_store>
175
- </banner_checkout>
176
-
177
- <sort_order translate="label">
178
- <label>Checkout Position</label>
179
- <frontend_type>text</frontend_type>
180
- <sort_order>4</sort_order>
181
- <show_in_default>1</show_in_default>
182
- <show_in_website>1</show_in_website>
183
- <show_in_store>0</show_in_store>
184
- <frontend_class>validate-number</frontend_class>
185
- </sort_order>
186
-
187
- <type_checkout>
188
- <label>Type Checkout</label>
189
- <frontend_type>select</frontend_type>
190
- <source_model>MercadoPago_Standard_Model_Source_TypeCheckout</source_model>
191
- <sort_order>5</sort_order>
192
- <show_in_default>1</show_in_default>
193
- <show_in_website>1</show_in_website>
194
- <show_in_store>1</show_in_store>
195
- </type_checkout>
196
-
197
- <auto_return translate="label">
198
- <label>Auto Redirect</label>
199
- <frontend_type>select</frontend_type>
200
- <source_model>adminhtml/system_config_source_yesno</source_model>
201
- <sort_order>6</sort_order>
202
- <show_in_default>1</show_in_default>
203
- <show_in_website>1</show_in_website>
204
- <show_in_store>0</show_in_store>
205
- <comment>Auto-redirect the buyer when finishing the payment.</comment>
206
- </auto_return>
207
-
208
- <excluded_payment_methods translate="label">
209
- <label>Exclude Payment Methods</label>
210
- <comment>Select payment methods not accepted</comment>
211
- <frontend_type>multiselect</frontend_type>
212
- <source_model>MercadoPago_Standard_Model_Source_PaymentMethods</source_model>
213
- <sort_order>8</sort_order>
214
- <show_in_default>1</show_in_default>
215
- <show_in_website>1</show_in_website>
216
- <show_in_store>1</show_in_store>
217
- <can_be_empty>1</can_be_empty>
218
- </excluded_payment_methods>
219
-
220
- <installments>
221
- <label>Maximum number of accepted installments</label>
222
- <frontend_type>select</frontend_type>
223
- <source_model>MercadoPago_Standard_Model_Source_Installments</source_model>
224
- <sort_order>9</sort_order>
225
- <show_in_default>1</show_in_default>
226
- <show_in_website>1</show_in_website>
227
- <show_in_store>1</show_in_store>
228
- </installments>
229
-
230
-
231
- <iframe_width translate="label">
232
- <label>Width Checkout Iframe</label>
233
- <frontend_type>text</frontend_type>
234
- <sort_order>10</sort_order>
235
- <show_in_default>1</show_in_default>
236
- <show_in_website>1</show_in_website>
237
- <show_in_store>0</show_in_store>
238
- <frontend_class>validate-number</frontend_class>
239
- </iframe_width>
240
-
241
- <iframe_height translate="label">
242
- <label>Height Checkout Iframe</label>
243
- <frontend_type>text</frontend_type>
244
- <sort_order>11</sort_order>
245
- <show_in_default>1</show_in_default>
246
- <show_in_website>1</show_in_website>
247
- <show_in_store>0</show_in_store>
248
- <frontend_class>validate-number</frontend_class>
249
- </iframe_height>
250
-
251
- </fields>
252
- </mercadopago_standard>
253
- </groups>
254
- </payment>
255
- </sections>
256
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/.DS_Store DELETED
Binary file
app/code/community/MercadoPago/Transparent/Block/.DS_Store DELETED
Binary file
app/code/community/MercadoPago/Transparent/Block/Success.php DELETED
@@ -1,36 +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_Transparent_Block_Success extends Mage_Core_Block_Template{
19
-
20
- protected function _construct(){
21
-
22
- parent::_construct();
23
- $this->setTemplate('mercadopago/transparent/success.phtml');
24
-
25
- return $this->toHtml();
26
- }
27
-
28
-
29
- public function getOrder() {
30
-
31
- $orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
32
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
33
-
34
- return $order;
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/Model/.DS_Store DELETED
Binary file
app/code/community/MercadoPago/Transparent/Model/Resource/Setup.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * To change this template, choose Tools | Templates
5
- * and open the template in the editor.
6
- */
7
-
8
- class MercadoPago_Transparent_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
9
-
10
- }
11
-
12
-
13
-
14
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/Model/Source/CategoryId.php DELETED
@@ -1,44 +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_Transparent_Model_Source_CategoryId extends Mage_Payment_Model_Method_Abstract{
20
-
21
- public function toOptionArray (){
22
-
23
- $response = MPRestClient::get("/item_categories");
24
- $response = $response['response'];
25
-
26
- $cat = array();
27
- $count = 0;
28
- foreach($response as $v):
29
- //force category others first
30
- if($v['id'] == "others"):
31
- $cat[0] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
32
- else:
33
- $count++;
34
- $cat[$count] = array('value' => $v['id'], 'label'=>Mage::helper('adminhtml')->__($v['description']));
35
- endif;
36
-
37
- endforeach;
38
-
39
- //force order by key
40
- ksort($cat);
41
- return $cat;
42
-
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/Model/Transparent.php DELETED
@@ -1,393 +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_Transparent_Model_Transparent extends Mage_Payment_Model_Method_Abstract{
20
-
21
- //configura o block do formulario e de informações sobre o pagamento
22
- protected $_formBlockType = 'mercadopago_transparent/form';
23
- protected $_infoBlockType = 'mercadopago_transparent/info';
24
-
25
- protected $_code = 'mercadopago_transparent';
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_transparent')->__('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($info_form['card_token_id'] != ""):
90
- $info->setAdditionalInformation('expiration_date', $info_form['cardExpirationMonth'] . "/" . $info_form['cardExpirationYear']);
91
- $info->setAdditionalInformation('cardholderName', $info_form['cardholderName']);
92
- $info->setAdditionalInformation('trunc_card', $info_form['trunc_card']);
93
- endif;
94
-
95
-
96
- //caso seja não tenha card_token_id
97
- if($info_form['card_token_id'] == ""):
98
- Mage::throwException(Mage::helper('mercadopago_transparent')->__('Verify the form data or wait until the validation of the payment data'));
99
- return false;
100
- endif;
101
-
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * @return Mage_Checkout_Model_Session
108
- */
109
- protected function _getCheckout() {
110
- return Mage::getSingleton('checkout/session');
111
- }
112
-
113
- /**
114
- * Get admin checkout session namespace
115
- *
116
- * @return Mage_Adminhtml_Model_Session_Quote
117
- */
118
- protected function _getAdminCheckout() {
119
- return Mage::getSingleton('adminhtml/session_quote');
120
- }
121
-
122
- /**
123
- * Retrieves Quote
124
- *
125
- * @param integer $quoteId
126
- * @return Mage_Sales_Model_Quote
127
- */
128
- protected function _getQuote($quoteId = null) {
129
- if (!empty($quoteId)) {
130
- return Mage::getModel('sales/quote')->load($quoteId);
131
- }
132
- else {
133
- if(Mage::app()->getStore()->isAdmin()) {
134
- return $this->_getAdminCheckout()->getQuote();
135
- } else {
136
- return $this->_getCheckout()->getQuote();
137
- }
138
- }
139
- }
140
-
141
- /**
142
- * Retrieves Order
143
- *
144
- * @param integer $incrementId
145
- * @return Mage_Sales_Model_Order
146
- */
147
- protected function _getOrder($incrementId) {
148
- return Mage::getModel('sales/order')->loadByIncrementId($incrementId);
149
- }
150
-
151
-
152
-
153
- public function getDiscount(){
154
- $discount = 0;
155
- $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
156
-
157
- if(isset($totals['discount']) && $totals['discount']->getValue()) {
158
- $discount = $totals['discount']->getValue();
159
- }
160
-
161
- return $discount;
162
- }
163
-
164
- public function postPago(){
165
-
166
- //seta sdk php mercadopago
167
- $client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
168
- $client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
169
-
170
- $mp = new MP($client_id, $client_secret);
171
-
172
- //monta a preferencia
173
- $pref = $this->makePreference();
174
-
175
- //faz o post do pagamento
176
- $response = $mp->create_custon_payment($pref);
177
-
178
- if($response['status'] == 200 || $response['status'] == 201):
179
- return $response;
180
- else:
181
- $e = "";
182
- foreach($response['response']['cause'] as $error):
183
- switch ($error['code']) {
184
- case "106":
185
- $e .= Mage::helper('mercadopago_transparent')->__('You can not make payments to users in other countries.');
186
- break;
187
-
188
- case "109":
189
- $e .= Mage::helper('mercadopago_transparent')->__('Payment Method selected does not process payments in installments selected. Choose another card or another payment method.');
190
- break;
191
-
192
- case "126":
193
- $e .= Mage::helper('mercadopago_transparent')->__('We could not process your payment. Error code: 126.');
194
- break;
195
-
196
- case "129":
197
- $e .= Mage::helper('mercadopago_transparent')->__('Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.');
198
- break;
199
-
200
- case "145":
201
- $e .= Mage::helper('mercadopago_transparent')->__('We could not process your payment. Error code: 145.');
202
- break;
203
-
204
- case "150":
205
- $e .= Mage::helper('mercadopago_transparent')->__('You can not make payments. Error code: 150.');
206
- break;
207
-
208
- case "151":
209
- $e .= Mage::helper('mercadopago_transparent')->__('You can not make payments.');
210
- break;
211
-
212
- case "160":
213
- $e .= Mage::helper('mercadopago_transparent')->__('We could not process your payment. Error code: 160.');
214
- break;
215
-
216
- case "204":
217
- $e .= Mage::helper('mercadopago_transparent')->__('Payment Method selected is not available at this time. Choose another card or another payment method.');
218
- break;
219
-
220
- case "801":
221
- $e .= Mage::helper('mercadopago_transparent')->__('You made a similar payment moments ago. Try again in a few minutes.');
222
- break;
223
-
224
- default:
225
- $e .= Mage::helper('mercadopago_transparent')->__("We could not process your payment. %s", $this->htmlEscape(json_encode($error)));
226
- break;
227
- }
228
-
229
- endforeach;
230
-
231
- Mage::throwException($e);
232
- return false;
233
- endif;
234
-
235
- }
236
-
237
- function makePreference(){
238
-
239
- $quote = $this->_getQuote();
240
- $orderId = $quote->getReservedOrderId();
241
- $order = $this->_getOrder($orderId);
242
-
243
-
244
- $customer = Mage::getSingleton('customer/session')->getCustomer();
245
- $model = Mage::getModel('catalog/product');
246
-
247
-
248
- //pega payment dentro da order para pegar as informacoes adicionadas pela funcao assignData()
249
- $payment = $order->getPayment();
250
-
251
- //pega valor total da compra
252
- $item_price = $order->getBaseGrandTotal();
253
- if (!$item_price) {
254
- $item_price = $order->getBasePrice() + $order->getBaseShippingAmount();
255
- }
256
-
257
- //pega o valor total da compra somando o frete
258
- $item_price = number_format($item_price, 2, '.', '');
259
-
260
- //setta informaçnoes
261
- $arr = array();
262
- $arr['external_reference'] = $orderId;
263
- $arr['amount'] = (float) $item_price;
264
- $arr['reason'] = Mage::helper('mercadopago_transparent')->__("Order # %s in store %s", $orderId, Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true));
265
- //não é necessario settar currency_id, pois ja identifica no backend
266
- //$arr['currency_id'] = "BRL";
267
- $arr['installments'] = (int) $payment->getAdditionalInformation("installments");
268
- $arr['payment_method_id'] = $payment->getAdditionalInformation("payment_method");
269
- $arr['payer_email'] = htmlentities($customer->getEmail());
270
-
271
- if($payment->getAdditionalInformation("card_token_id") != ""){
272
- $arr['card_token_id'] = $payment->getAdditionalInformation("card_token_id");
273
- }
274
-
275
- if($payment->getAdditionalInformation("issuers") != ""){
276
- $arr['card_issuer_id'] = (int) $payment->getAdditionalInformation("issuers");
277
- }
278
-
279
-
280
- //monta array de produtos
281
- $arr['items'] = array();
282
- foreach ($order->getAllVisibleItems() as $item) {
283
-
284
- $prod = $model->loadByAttribute('sku', $item->getSku());
285
-
286
- //get image
287
- try{
288
- $imagem = $prod->getImageUrl();
289
- }catch(Exception $e){
290
- $imagem = "";
291
- }
292
-
293
- $arr['items'][] = array(
294
- "id" => $item->getSku(),
295
- "title" => $item->getName(),
296
- "description" => $item->getName(),
297
- "picture_url" => $imagem,
298
- "category_id" => Mage::getStoreConfig('payment/mercadopago_configuration/category_id'),
299
- "quantity" => (int) number_format($item->getQtyOrdered(), 0, '.', ''),
300
- "unit_price" => (float) number_format($prod->getPrice(), 2, '.', '')
301
- );
302
-
303
- }
304
-
305
-
306
- //verifica se existe desconto, caso exista adiciona como um item
307
- $discount = $this->getDiscount();
308
- if($discount != 0){
309
- $arr['items'][] = array(
310
- "title" => "Discount by the Store",
311
- "description" => "Discount by the Store",
312
- "quantity" => (int) 1,
313
- "unit_price" => (float) number_format($discount, 2, '.', '')
314
- );
315
- }
316
-
317
- //pega dados de envio
318
- if(method_exists($order->getShippingAddress(), "getData")){
319
- $shipping = $order->getShippingAddress()->getData();
320
- $arr['shipments']['receiver_address'] = array(
321
- "floor" => "-",
322
- "zip_code" => $shipping['postcode'],
323
- "street_name" => $shipping['street'] . " - " . $shipping['city'] . " - " . $shipping['country_id'],
324
- "apartment" => "-",
325
- "street_number" => "0"
326
- );
327
- $arr['customer']['phone'] = array(
328
- "area_code" => "-",
329
- "number" => $shipping['telephone']
330
- );
331
- }
332
-
333
- //formata a data do usuario para o padrao do mercado pago YYYY-MM-DDTHH:MM:SS
334
- $date_creation_user = date('Y-m-d',$customer->getCreatedAtTimestamp()) . "T" . date('H:i:s',$customer->getCreatedAtTimestamp());
335
-
336
- //$quote = Mage::getSingleton('checkout/session')->getQuote();
337
- $billing_address = $quote->getBillingAddress();
338
- $billing_address = $billing_address->getData();
339
-
340
- //set informaçoes do usuario
341
- $arr['customer']['registration_date'] = $date_creation_user;
342
- $arr['customer']['email'] = htmlentities($customer->getEmail());
343
- $arr['customer']['first_name'] = htmlentities($customer->getFirstname());
344
- $arr['customer']['last_name'] = htmlentities($customer->getLastname());
345
-
346
- //set o documento do usuario
347
- if($payment['additional_information']['doc_number'] != ""){
348
- $arr['customer']['identification'] = array(
349
- "type" => "CPF",
350
- "number" => $payment->getAdditionalInformation("doc_number")
351
- );
352
- }
353
-
354
- //set endereco do usuario
355
- $arr['customer']['address'] = array(
356
- "zip_code" => $billing_address['postcode'],
357
- "street_name" => $billing_address['street'] . " - " . $billing_address['city'] . " - " . $billing_address['country_id'],
358
- "street_number" => "0"
359
- );
360
-
361
- //define a url de notificacao
362
- $arr['notification_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "mercadopago_standard/notification";
363
-
364
- //pega o email e o nome do usuario guest
365
- if($arr['payer_email'] == "" && $arr['customer']['email'] == ""){
366
- $arr['payer_email'] = $order['customer_email'];
367
- $arr['customer']['email'] = $order['customer_email'];
368
- $arr['customer']['first_name'] = $order->getBillingAddress()->getFirstname();
369
- $arr['customer']['last_name'] = $order->getBillingAddress()->getLastname();
370
- }
371
-
372
- //adiciona a sponsor_id para as vendas serem identificadas
373
- //$arr['sponsor_id'] = "";
374
-
375
- return $arr;
376
-
377
- }
378
-
379
- public function getPaymentMethods(){
380
-
381
- $this->client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
382
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
383
-
384
- $mp = new MP ($this->client_id, $this->client_secret);
385
- $access_token = $mp->get_access_token();
386
-
387
- $payment_methods = MPRestClient::get("/checkout/custom/payment_methods?access_token=" . $access_token);
388
-
389
- return $payment_methods;
390
- }
391
- }
392
-
393
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/controllers/NotificacaoController.php DELETED
@@ -1,190 +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_Transparent_NotificacaoController 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
- $params = $this->getRequest()->getParams();
28
- if (isset($params['id']) && isset($params['topic']) && $params['topic'] == 'payment'){
29
- $model = Mage::getModel('mercadopago_transparent/transparent');
30
- $response = $model->getPayment($params['id']);
31
-
32
- if($response['status'] == 200 || $response['status'] == 201):
33
- $message = "";
34
- $status = "";
35
- $payment = $response['response']['collection'];
36
-
37
- $order = Mage::getModel('sales/order')->loadByIncrementId($payment["external_reference"]);
38
-
39
- //update info de status no pagamento
40
- $payment_order = $order->getPayment();
41
- $payment_order->setAdditionalInformation('status',$payment['status']);
42
- $payment_order->setAdditionalInformation('status_detail',$payment['status_detail']);
43
- $payment_order->setAdditionalInformation('payment_id',$payment['id']);
44
-
45
- if($payment_order->getAdditionalInformation('cardholderName') == ""):
46
- $payment_order->setAdditionalInformation('cardholderName', $payment['payer']['first_name'] . " " . $payment['payer']['last_name']);
47
- endif;
48
-
49
- if($payment_order->getAdditionalInformation('payment_method') == ""):
50
- $payment_order->setAdditionalInformation('payment_method', $payment['payment_method_id']);
51
- endif;
52
-
53
- if($payment_order->getAdditionalInformation('statement_descriptor') == ""):
54
- if(isset($payment['statement_descriptor'])):
55
- $payment_order->setAdditionalInformation('statement_descriptor', $payment['statement_descriptor']);
56
- endif;
57
- endif;
58
-
59
- if($payment_order->getAdditionalInformation('trunc_card') == ""):
60
- if(isset($payment['last_four_digits'])):
61
- $payment_order->setAdditionalInformation('trunc_card', "XXXXXXXXXXXX" . $payment['last_four_digits']);
62
- endif;
63
-
64
- endif;
65
-
66
- $payment_order->save();
67
-
68
- //adiciona informações sobre o comprador na order
69
- if ($payment['payer']['first_name'])
70
- $order->setCustomerFirstname($payment['payer']['first_name']);
71
- if ($payment['payer']['last_name'])
72
- $order->setCustomerLastname($payment['payer']['last_name']);
73
- if ($payment['payer']['email'])
74
- $order->setCustomerEmail($payment['payer']['email']);
75
-
76
- $order->save();
77
-
78
- switch ( $payment['status']) {
79
-
80
- case 'approved':
81
- //add status na order
82
- $message = 'Notificação automática do MercadoPago: O pagamento foi aprovado.';
83
- $status = $model->getConfigData('order_status_approved');
84
-
85
- //cria a invoice
86
- $invoice = $order->prepareInvoice();
87
- $invoice->register()->pay();
88
- Mage::getModel('core/resource_transaction')
89
- ->addObject($invoice)
90
- ->addObject($invoice->getOrder())
91
- ->save();
92
-
93
- $invoice->sendEmail(true, $message);
94
- break;
95
- case 'refunded':
96
- $status = $model->getConfigData('order_status_refunded');
97
- $message = 'Notificação automática do MercadoPago: O pagamento foi devolvido.';
98
- $order->cancel();
99
- break;
100
- case 'pending':
101
- $status = $model->getConfigData('order_status_in_process');
102
- $message = 'Notificação automática do MercadoPago: O pagamento está sendo processado.';
103
- break;
104
- case 'in_process':
105
- $status = $model->getConfigData('order_status_in_process');
106
- $message = 'Notificação automática do MercadoPago: O pagamento está sendo processado. Em até 2 dias úteis o pagamento será analisado.';
107
- break;
108
- case 'in_mediation':
109
- $status = $model->getConfigData('order_status_in_mediation');
110
- $message = 'Notificação automática do MercadoPago: O pagamento está em processo de Disputa, verifique a conta gráfica do MercadoPago para maiores informações.';
111
- break;
112
- case 'cancelled':
113
- $status = $model->getConfigData('order_status_cancelled');
114
- $message = 'Notificação automática do MercadoPago: O pagamento foi cancelado.';
115
- $order->cancel();
116
- break;
117
- case 'rejected':
118
- $status = $model->getConfigData('order_status_rejected');
119
- $message = 'Notificação automática do MercadoPago: O pagamento foi rejeitado.';
120
- break;
121
- default:
122
- $status = $model->getConfigData('order_status_in_process');
123
- $message = "";
124
- }
125
-
126
- //adiciona informações do pagamento
127
- $message .= "<br /> Operation id: " . $payment['id'];
128
- $message .= "<br /> Status: " . $payment['status'];
129
- $message .= "<br /> Status Detail: " . $payment['status_detail'];
130
-
131
- $order->addStatusToHistory($status,$message, true);
132
- $order->sendOrderUpdateEmail(true, $message);
133
-
134
- $order->save();
135
- echo $message;
136
- else:
137
- //caso de algum erro na consulta da ipn
138
- header(' ', true, 404);
139
- exit;
140
- endif;
141
-
142
- }elseif(isset($params['topic']) && $params['topic'] == 'merchant_order'){
143
-
144
- $model = Mage::getModel('mercadopago_transparent/transparent');
145
- $response = $model->getMerchantOrder($params['id']);
146
-
147
- if($response['status'] == 200 || $response['status'] == 201):
148
- $message = "";
149
- $status = "";
150
- $merchant_order = $response['response'];
151
- $order = Mage::getModel('sales/order')->loadByIncrementId($merchant_order["external_reference"]);
152
-
153
- switch ( $merchant_order['status']) {
154
-
155
- case 'opened':
156
- $message = 'Payment flow started. The order still dont have payments recorded.';
157
- $status = $model->getConfigData('order_status_in_process');
158
-
159
- $message .= "<br /> Merchant Order: " . $merchant_order['id'];
160
- $message .= "<br /> Status: " . $merchant_order['status'];
161
-
162
- $order->addStatusToHistory($status,$message);
163
- $order->save();
164
- echo $message;
165
- break;
166
-
167
- /*
168
- case 'closed':
169
- $status = $model->getConfigData('order_status_refunded');
170
- $message = 'A payment was created and it was associated to the order.';
171
- break;
172
- case 'expired':
173
- $status = $model->getConfigData('order_status_in_process');
174
- $message = 'Order cancelled by the seller.';
175
- break;
176
- default:
177
-
178
- $message = "";
179
- */
180
- }
181
-
182
- else:
183
- //caso de algum erro na consulta da ipn
184
- header(' ', true, 404);
185
- exit;
186
- endif;
187
- }
188
-
189
- }
190
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/controllers/PayController.php DELETED
@@ -1,194 +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_Transparent_PayController extends Mage_Core_Controller_Front_Action{
18
-
19
- // /mercadopago_transparent/pay
20
- public function indexAction(){
21
- $msg = "";
22
- $status = false;
23
- $payment = false;
24
- $order = false;
25
- $payment_method_id = false;
26
-
27
-
28
- //chama model para fazer o post do pagamento
29
- $response = Mage::getModel('mercadopago_transparent/transparent')->postPago();
30
-
31
- if($response['status'] == 200 || $response['status'] == 201):
32
-
33
- $payment = $response['response'];
34
-
35
- //set order_id
36
- $order = Mage::getModel('sales/order')->loadByIncrementId($payment['external_reference']);
37
-
38
- //set status
39
- $status = $payment['status'];
40
- $payment_method_id = $payment['payment_method_id'];
41
-
42
- switch ($payment['status']){
43
- case "approved":
44
- $msg = "";
45
- break;
46
- case "in_process":
47
- $msg = "Em menos de 2 dias úteis você será avisado por e-mail se foi creditado ou se precisarmos de mais informações.";
48
- break;
49
- case "pending":
50
- $msg = "Em menos de 1 hora, nós enviaremos o resultado por e-mail.";
51
- break;
52
- case "rejected":
53
-
54
- switch ($payment['status_detail']){
55
- case "cc_rejected_bad_filled_card_number":
56
- $msg = "Verifique o número do cartão.";
57
- break;
58
- case "cc_rejected_bad_filled_date":
59
- $msg = "Verifique a data de validade.";
60
- break;
61
- case "cc_rejected_bad_filled_other":
62
- $msg = "Verifique os dados.";
63
- break;
64
- case "cc_rejected_bad_filled_security_code":
65
- $msg = "Verifique o código de segurança.";
66
- break;
67
- case "cc_rejected_blacklist":
68
- $msg = "Não foi possível processar o pagamento.";
69
- break;
70
- case "cc_rejected_call_for_authorize":
71
- $msg = "Você precisa autorizar com a " . strtoupper($payment['payment_method_id']) . " o pagamento de R$" . strtoupper($payment['amount']) . " ao MercadoPago";
72
- break;
73
- case "cc_rejected_card_disabled":
74
- $msg = "Ligue para " . strtoupper($payment['payment_method_id']) . " e ative o seu cartão. <br/>
75
- O telefone está no verso do seu cartão de crédito.";
76
- break;
77
- case "cc_rejected_card_error":
78
- $msg = "Não foi possível processar o pagamento.";
79
- break;
80
- case "cc_rejected_duplicated_payment":
81
- $msg = "Você já fez o pagamento deste valor. <br/>
82
- Se você precisa pagar novamente use outro cartão ou outro meio de pagamento.";
83
- break;
84
- case "cc_rejected_high_risk":
85
- $msg = "O seu pagamento foi recusado. <br/>
86
- Recomendamos que você pague com outro dos meios de pagamento oferecidos, preferencialmente à vista.";
87
- break;
88
- case "cc_rejected_insufficient_amount":
89
- $msg = "O seu " . strtoupper($payment['payment_method_id']) . " não tem limite suficiente.";
90
- break;
91
- case "cc_rejected_invalid_installments":
92
- echo strtoupper($payment['payment_method_id']) . " não processa pagamentos em " . $payment['installments']. " parcelas.";
93
- break;
94
- case "cc_rejected_max_attempts":
95
- $msg = "Você atingiu o limite de tentativas permitidas. <br/>
96
- Use outro cartão ou outro meio de pagamento.";
97
- break;
98
- case "cc_rejected_other_reason":
99
- echo strtoupper($payment['payment_method_id']) . " não processou o pagamento.";
100
- break;
101
- }
102
-
103
- break;
104
- }
105
- else:
106
- $e = "";
107
- foreach($response['response']['cause'] as $error):
108
-
109
- switch ($error) {
110
- case "106":
111
- $e .= "Você não pode fazer pagamentos para usuários em outros países. <br/>";
112
- break;
113
-
114
- case "109":
115
- $e .= "O meio de pagamento selecionado não processa pagamentos as parcelas selecionadas.
116
- Use outro cartão ou outro meio de pagamento. <br/>";
117
- break;
118
-
119
- case "126":
120
- $e .= "Não foi possível processar o pagamento. Erro de numero: 126.<br/>";
121
- break;
122
-
123
- case "129":
124
- $e .= "O meio de pagamento selecionado não processa pagamentos do valor selecionado.
125
- Use outro cartão ou outro meio de pagamento.. <br/>";
126
- break;
127
-
128
- case "145":
129
- $e .= "Não foi possível processar o pagamento. Erro de numero: 145. <br/>";
130
- break;
131
-
132
- case "150":
133
- $e .= "Você não pode fazer pagamentos. <br/>";
134
- break;
135
-
136
- case "151":
137
- $e .= "Você não pode fazer pagamentos com esse meio de pagamento. <br/>";
138
- break;
139
-
140
- case "160":
141
- $e .= "Não foi possível processar o pagamento. Erro de numero: 160. <br/>";
142
- break;
143
-
144
- case "204":
145
- $e .= "O meio de pagamento selecionado não está disponível neste momento.
146
- Use outro cartão ou outro meio de pagamento. <br/>";
147
- break;
148
-
149
- case "801":
150
- $e .= "Você realizou um pagamento similar há pouco tempo.
151
- Tente novamente em alguns minutos. <br/>";
152
- break;
153
-
154
- default:
155
- $e .= "Não foi possível processar o pagamento. <br/>" . json_encode($response['response']). "<br/>";
156
- break;
157
- }
158
- endforeach;
159
-
160
- Mage::getSingleton('core/session')->addError('Ocorreu um erro: <br/>' . $e);
161
- endif;
162
-
163
- $this->loadLayout();
164
-
165
- //cria um block e adiciona uma view
166
- $block = $this->getLayout()->createBlock(
167
- 'Mage_Core_Block_Template',
168
- 'mercadopago_transparent/sucesso',
169
- array('template' => 'mercadopago/transparent/sucesso.phtml')
170
- );
171
-
172
- //envia as informações para view
173
- $block->assign(
174
- array(
175
- "mensagem"=> $msg,
176
- "status" => $status,
177
- "order" => $order,
178
- "payment_method_id" => $payment_method_id,
179
- "payment" => $payment
180
- )
181
- );
182
-
183
- //insere o block
184
- $this->getLayout()->getBlock('content')->append($block);
185
- $this->_initLayoutMessages('core/session');
186
-
187
- //adiciona uma clean page
188
- $root = $this->getLayout()->getBlock('root');
189
- $root->setTemplate("mercadopago/clean_page.phtml");
190
-
191
- $this->renderLayout();
192
- }
193
-
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/etc/config.xml DELETED
@@ -1,103 +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
- <config>
19
- <modules>
20
- <MercadoPago_Transparent>
21
- <version>2.0.0</version>
22
- </MercadoPago_Transparent>
23
- </modules>
24
-
25
- <global>
26
- <models>
27
- <mercadopago_transparent>
28
- <class>MercadoPago_Transparent_Model</class>
29
- </mercadopago_transparent>
30
- </models>
31
- <blocks>
32
- <mercadopago_transparent>
33
- <class>MercadoPago_Transparent_Block</class>
34
- </mercadopago_transparent>
35
- </blocks>
36
- <helpers>
37
- <mercadopago_transparent>
38
- <class>MercadoPago_Transparent_Helper</class>
39
- </mercadopago_transparent>
40
- </helpers>
41
-
42
- </global>
43
-
44
-
45
- <frontend>
46
- <routers>
47
- <mercadopago_transparent>
48
- <use>standard</use>
49
- <args>
50
- <module>MercadoPago_Transparent</module>
51
- <frontName>mercadopago_transparent</frontName>
52
- </args>
53
- </mercadopago_transparent>
54
- </routers>
55
-
56
- <layout>
57
- <updates>
58
- <mpexpress>
59
- <file>mercadopago.xml</file>
60
- </mpexpress>
61
- </updates>
62
- </layout>
63
-
64
- <translate>
65
- <modules>
66
- <mercadopago>
67
- <files>
68
- <default>mercadopago.csv</default>
69
- </files>
70
- </mercadopago>
71
- </modules>
72
- </translate>
73
- </frontend>
74
-
75
-
76
- <adminhtml>
77
- <translate>
78
- <modules>
79
- <translations>
80
- <files>
81
- <default>mercadopago.csv</default>
82
- </files>
83
- </translations>
84
- </modules>
85
- </translate>
86
- </adminhtml>
87
-
88
- <default>
89
- <payment translate="label">
90
- <mercadopago_transparent>
91
- <active>1</active>
92
- <model>MercadoPago_Transparent_Model_Transparent</model>
93
- <!-- nome do modulo na exibição para o comprador -->
94
- <title translate="label">Credit Card - MercadoPago</title>
95
- <allowspecific>0</allowspecific>
96
- <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/tipo2_468X60.jpg</banner_checkout>
97
- <sort_order>-2</sort_order>
98
- <payment_action>authorize</payment_action>
99
- </mercadopago_transparent>
100
- </payment>
101
- </default>
102
-
103
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/Transparent/etc/system.xml DELETED
@@ -1,81 +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_transparent translate="label" module="mercadopago_transparent">
24
- <label>MercadoPago Transparent - Credit Card</label>
25
- <sort_order>100</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
- <active translate="label">
31
- <label>Enabled</label>
32
- <frontend_type>select</frontend_type>
33
- <source_model>adminhtml/system_config_source_yesno</source_model>
34
- <sort_order>1</sort_order>
35
- <show_in_default>1</show_in_default>
36
- <show_in_website>1</show_in_website>
37
- <show_in_store>0</show_in_store>
38
- </active>
39
- <title translate="label">
40
- <label>Payment Title</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>2</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
- </title>
47
-
48
- <public_key translate="label">
49
- <label>Public Key</label>
50
- <frontend_type>text</frontend_type>
51
- <sort_order>5</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>0</show_in_store>
55
- </public_key>
56
-
57
-
58
- <banner_checkout translate="label">
59
- <label>Banner Checkout</label>
60
- <frontend_type>text</frontend_type>
61
- <sort_order>13</sort_order>
62
- <show_in_default>1</show_in_default>
63
- <show_in_website>1</show_in_website>
64
- <show_in_store>0</show_in_store>
65
- </banner_checkout>
66
-
67
- <sort_order translate="label">
68
- <label>Checkout Position</label>
69
- <frontend_type>text</frontend_type>
70
- <sort_order>14</sort_order>
71
- <show_in_default>1</show_in_default>
72
- <show_in_website>1</show_in_website>
73
- <show_in_store>0</show_in_store>
74
- <frontend_class>validate-number</frontend_class>
75
- </sort_order>
76
- </fields>
77
- </mercadopago_transparent>
78
- </groups>
79
- </payment>
80
- </sections>
81
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/TransparentTicket/Block/Form.php DELETED
@@ -1,50 +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_TransparentTicket_Block_Form extends Mage_Payment_Block_Form_Cc{
19
-
20
- protected function _construct(){
21
-
22
- // Route: /checkout/onepage
23
- // inicia formulario para a escolha de pagamento
24
- parent::_construct();
25
-
26
- $this->setTemplate('mercadopago/transparent_ticket/form.phtml');
27
-
28
- }
29
-
30
- function getTicketsOptions(){
31
- $payment_methods = Mage::getModel('mercadopago_transparentticket/transparent')->getPaymentMethods();
32
- $tickets = array();
33
-
34
- //percorre todos os payments methods
35
- foreach($payment_methods['response'] as $pm){
36
-
37
- //filtra por tickets
38
- if($pm['payment_type_id'] == "ticket"){
39
- $tickets[] = $pm;
40
- }
41
- }
42
-
43
- return $tickets;
44
- }
45
- }
46
-
47
-
48
-
49
-
50
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/TransparentTicket/Model/Transparent.php DELETED
@@ -1,86 +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_TransparentTicket_Model_Transparent extends Mage_Payment_Model_Method_Abstract{
20
-
21
- //configura o lugar do arquivo para listar meios de pagamento
22
- protected $_formBlockType = 'mercadopago_transparentticket/form';
23
- protected $_infoBlockType = 'mercadopago_transparentticket/info';
24
-
25
- protected $_code = 'mercadopago_transparentticket';
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
-
39
- public function initialize($paymentAction, $stateObject) {
40
- //chama model para fazer o post do pagamento
41
- $response = Mage::getModel('mercadopago_transparent/transparent')->postPago();
42
-
43
- if($response !== false):
44
- $this->getInfoInstance()->setAdditionalInformation('activation_uri', $response['response']['activation_uri']);
45
- return true;
46
- endif;
47
-
48
- return false;
49
-
50
- }
51
-
52
- public function assignData($data){
53
-
54
- // route /checkout/onepage/savePayment
55
- if(!($data instanceof Varien_Object)){
56
- $data = new Varien_Object($data);
57
- }
58
-
59
- //get array info
60
- $info_form = $data->getData();
61
-
62
- $info = $this->getInfoInstance();
63
- $info->setAdditionalInformation('payment_type_id', "ticket");
64
- $info->setAdditionalInformation('payment_method', $info_form['payment_method_boleto']);
65
- $info->setAdditionalInformation('card_token_id', "");
66
- $info->setAdditionalInformation('installments', 1);
67
- $info->setAdditionalInformation('doc_number', "");
68
-
69
- return $this;
70
- }
71
-
72
- public function getPaymentMethods(){
73
-
74
- $this->client_id = Mage::getStoreConfig('payment/mercadopago_configuration/client_id');
75
- $this->client_secret = Mage::getStoreConfig('payment/mercadopago_configuration/client_secret');
76
-
77
- $mp = new MP ($this->client_id, $this->client_secret);
78
- $access_token = $mp->get_access_token();
79
-
80
- $payment_methods = MPRestClient::get("/checkout/custom/payment_methods?access_token=" . $access_token);
81
-
82
- return $payment_methods;
83
- }
84
- }
85
-
86
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/TransparentTicket/etc/config.xml DELETED
@@ -1,103 +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
- <config>
19
- <modules>
20
- <MercadoPago_TransparentTicket>
21
- <version>2.0.0</version>
22
- </MercadoPago_TransparentTicket>
23
- </modules>
24
-
25
- <global>
26
- <models>
27
- <mercadopago_transparentticket>
28
- <class>MercadoPago_TransparentTicket_Model</class>
29
- </mercadopago_transparentticket>
30
- </models>
31
- <blocks>
32
- <mercadopago_transparentticket>
33
- <class>MercadoPago_TransparentTicket_Block</class>
34
- </mercadopago_transparentticket>
35
- </blocks>
36
- <helpers>
37
- <mercadopago_transparentticket>
38
- <class>MercadoPago_TransparentTicket_Helper</class>
39
- </mercadopago_transparentticket>
40
- </helpers>
41
- </global>
42
-
43
-
44
- <frontend>
45
- <routers>
46
- <mercadopago_transparentticket>
47
- <use>standard</use>
48
- <args>
49
- <module>MercadoPago_TransparentTicket</module>
50
- <frontName>mercadopago_transparentticket</frontName>
51
- </args>
52
- </mercadopago_transparentticket>
53
- </routers>
54
-
55
- <layout>
56
- <updates>
57
- <mpexpress>
58
- <file>mercadopago.xml</file>
59
- </mpexpress>
60
- </updates>
61
- </layout>
62
-
63
- <translate>
64
- <modules>
65
- <mercadopago>
66
- <files>
67
- <default>mercadopago.csv</default>
68
- </files>
69
- </mercadopago>
70
- </modules>
71
- </translate>
72
- </frontend>
73
-
74
-
75
- <adminhtml>
76
- <translate>
77
- <modules>
78
- <translations>
79
- <files>
80
- <default>mercadopago.csv</default>
81
- </files>
82
- </translations>
83
- </modules>
84
- </translate>
85
- </adminhtml>
86
-
87
-
88
- <default>
89
- <payment translate="label">
90
- <mercadopago_transparentticket>
91
- <active>1</active>
92
- <model>MercadoPago_TransparentTicket_Model_Transparent</model>
93
- <!-- nome do modulo na exibição para o comprador -->
94
- <title translate="label">Ticket - MercadoPago</title>
95
- <allowspecific>0</allowspecific>
96
- <banner_checkout>http://imgmp.mlstatic.com/org-img/MLB/MP/BANNERS/2014/230x60.png</banner_checkout>
97
- <sort_order>-1</sort_order>
98
- <payment_action>authorize</payment_action>
99
- </mercadopago_transparentticket>
100
- </payment>
101
- </default>
102
-
103
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/TransparentTicket/etc/system.xml DELETED
@@ -1,74 +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_transparentticket translate="label" module="mercadopago_transparentticket">
24
- <label>MercadoPago Transparent - Ticket</label>
25
- <sort_order>101</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
- <active translate="label">
31
- <label>Enabled</label>
32
- <frontend_type>select</frontend_type>
33
- <source_model>adminhtml/system_config_source_yesno</source_model>
34
- <sort_order>1</sort_order>
35
- <show_in_default>1</show_in_default>
36
- <show_in_website>1</show_in_website>
37
- <show_in_store>0</show_in_store>
38
- <comment>For the operation of the Checkout Transparent Ticket is necessary to configure the Credentials 'CLIENT_ID' and 'CLIENT_SECRET' in 'MercadoPago - Configuration'</comment>
39
- </active>
40
- <title translate="label">
41
- <label>Payment Title</label>
42
- <frontend_type>text</frontend_type>
43
- <sort_order>2</sort_order>
44
- <show_in_default>1</show_in_default>
45
- <show_in_website>1</show_in_website>
46
- <show_in_store>0</show_in_store>
47
- </title>
48
-
49
-
50
- <banner_checkout translate="label">
51
- <label>Banner Checkout</label>
52
- <frontend_type>text</frontend_type>
53
- <sort_order>3</sort_order>
54
- <show_in_default>1</show_in_default>
55
- <show_in_website>1</show_in_website>
56
- <show_in_store>0</show_in_store>
57
- </banner_checkout>
58
-
59
- <sort_order translate="label">
60
- <label>Checkout Position</label>
61
- <frontend_type>text</frontend_type>
62
- <sort_order>4</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
- <frontend_class>validate-number</frontend_class>
67
- </sort_order>
68
-
69
- </fields>
70
- </mercadopago_transparentticket>
71
- </groups>
72
- </payment>
73
- </sections>
74
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/MercadoPago/controllers/ApiController.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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
+ 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 ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/{Standard/etc → etc}/config.xml RENAMED
@@ -17,25 +17,50 @@
17
  -->
18
  <config>
19
  <modules>
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  <MercadoPago_Standard>
21
  <version>2.0.0</version>
22
  </MercadoPago_Standard>
 
23
  </modules>
24
 
25
  <global>
26
  <models>
27
- <mercadopago_standard>
28
- <class>MercadoPago_Standard_Model</class>
29
- </mercadopago_standard>
30
  </models>
 
31
  <blocks>
32
- <mercadopago_standard>
33
- <class>MercadoPago_Standard_Block</class>
34
- </mercadopago_standard>
35
  </blocks>
 
36
  <helpers>
 
 
 
 
 
 
 
 
 
37
  <mercadopago_standard>
38
- <class>MercadoPago_Standard_Helper</class>
39
  </mercadopago_standard>
40
  </helpers>
41
 
@@ -43,7 +68,7 @@
43
  <admin_system_config_changed_section_payment>
44
  <observers>
45
  <observer>
46
- <class>MercadoPago_Standard_Model_Observer</class>
47
  <method>checkAndValidData</method>
48
  </observer>
49
  </observers>
@@ -54,13 +79,13 @@
54
 
55
  <frontend>
56
  <routers>
57
- <mercadopago_standard>
58
  <use>standard</use>
59
  <args>
60
- <module>MercadoPago_Standard</module>
61
- <frontName>mercadopago_standard</frontName>
62
  </args>
63
- </mercadopago_standard>
64
  </routers>
65
  <translate>
66
  <modules>
@@ -85,12 +110,12 @@
85
  </modules>
86
  </translate>
87
  </adminhtml>
88
-
89
-
 
90
  <default>
91
- <payment>
92
-
93
- <mercadopago_configuration>
94
  <country>mlb</country>
95
  <order_status_approved>processing</order_status_approved>
96
  <order_status_refunded>pending</order_status_refunded>
@@ -98,11 +123,37 @@
98
  <order_status_in_mediation>pending</order_status_in_mediation>
99
  <order_status_rejected>pending</order_status_rejected>
100
  <order_status_cancelled>pending</order_status_cancelled>
101
- </mercadopago_configuration>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  <mercadopago_standard>
104
  <active>1</active>
105
- <model>MercadoPago_Standard_Model_Checkout</model>
106
  <!-- nome do modulo na exibição para o comprador -->
107
  <title>MercadoPago</title>
108
  <allowspecific>0</allowspecific>
@@ -112,9 +163,9 @@
112
  <type_checkout>iframe</type_checkout>
113
  <auto_return>1</auto_return>
114
  <iframe_width>900</iframe_width>
115
- <iframe_height>600</iframe_height>
116
  </mercadopago_standard>
 
117
  </payment>
118
  </default>
119
-
120
  </config>
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
 
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>
79
 
80
  <frontend>
81
  <routers>
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>
110
  </modules>
111
  </translate>
112
  </adminhtml>
113
+
114
+
115
+
116
  <default>
117
+ <payment>
118
+ <mercadopago>
 
119
  <country>mlb</country>
120
  <order_status_approved>processing</order_status_approved>
121
  <order_status_refunded>pending</order_status_refunded>
123
  <order_status_in_mediation>pending</order_status_in_mediation>
124
  <order_status_rejected>pending</order_status_rejected>
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>
163
  <type_checkout>iframe</type_checkout>
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>
app/code/community/MercadoPago/etc/system.xml ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/template/mercadopago/custom/info.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $info_payment = $this->getInfoPayment();
3
+ ?>
4
+
5
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
6
+
7
+ <?php foreach($info_payment as $info): ?>
8
+ <p><?php echo $info['text']; ?></p>
9
+ <?php endforeach; ?>
app/design/adminhtml/default/default/template/mercadopago/custom_ticket/info.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $info_payment = $this->getInfoPayment();
3
+ ?>
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
+
19
+ <p><?php echo $this->__('Click on the link to generate the ticket'); ?>.</p>
20
+ <a href="<?php echo urldecode($info_payment['activation_uri']['value']); ?>" target="_blank">
21
+ <?php echo $this->__('Generate Ticket'); ?>
22
+ </a>
23
+
app/design/adminhtml/default/default/template/mercadopago/standard/info.phtml CHANGED
@@ -1,29 +1,9 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if($this->getOrder()->getAdditionalInformation('cardholderName') != ""): ?>
4
- <p><?php echo $this->__('Card Holder Name: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('cardholderName'))); ?></p>
5
- <?php endif; ?>
6
-
7
- <?php if($this->getOrder()->getAdditionalInformation('trunc_card') != ""): ?>
8
- <p><?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('trunc_card'))); ?></p>
9
- <?php endif; ?>
10
-
11
- <?php if($this->getOrder()->getAdditionalInformation('payment_method') != ""): ?>
12
- <p><?php echo $this->__('Payment Method: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_method'))); ?></p>
13
- <?php endif; ?>
14
 
15
- <?php if($this->getOrder()->getAdditionalInformation('installments') != ""): ?>
16
- <p><?php echo $this->__('Installments: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('installments'))); ?></p>
17
- <?php endif; ?>
18
-
19
- <?php if($this->getOrder()->getAdditionalInformation('statement_descriptor') != ""): ?>
20
- <p><?php echo $this->__('Statement Descriptor: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('statement_descriptor'))); ?></p>
21
- <?php endif; ?>
22
-
23
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
24
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
25
- <?php endif; ?>
26
 
27
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
28
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
29
- <?php endif; ?>
1
+ <?php
2
+ $info_payment = $this->getInfoPayment();
3
+ ?>
 
 
 
 
 
 
 
 
 
 
4
 
5
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
 
 
 
 
 
 
 
 
 
 
6
 
7
+ <?php foreach($info_payment as $info): ?>
8
+ <p><?php echo $info['text']; ?></p>
9
+ <?php endforeach; ?>
app/design/adminhtml/default/default/template/mercadopago/transparent/info.phtml DELETED
@@ -1,33 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if($this->getOrder()->getAdditionalInformation('cardholderName') != ""): ?>
4
- <p><?php echo $this->__('Card Holder Name: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('cardholderName'))); ?></p>
5
- <?php endif; ?>
6
-
7
- <?php if($this->getOrder()->getAdditionalInformation('trunc_card') != ""): ?>
8
- <p><?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('trunc_card'))); ?></p>
9
- <?php endif; ?>
10
-
11
- <?php if($this->getOrder()->getAdditionalInformation('payment_method') != ""): ?>
12
- <p><?php echo $this->__('Payment Method: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_method'))); ?></p>
13
- <?php endif; ?>
14
-
15
- <?php if($this->getOrder()->getAdditionalInformation('expiration_date') != ""): ?>
16
- <p><?php echo $this->__('Expiration Date: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('expiration_date'))); ?></p>
17
- <?php endif; ?>
18
-
19
- <?php if($this->getOrder()->getAdditionalInformation('installments') != ""): ?>
20
- <p><?php echo $this->__('Installments: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('installments'))); ?></p>
21
- <?php endif; ?>
22
-
23
- <?php if($this->getOrder()->getAdditionalInformation('statement_descriptor') != ""): ?>
24
- <p><?php echo $this->__('Statement Descriptor: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('statement_descriptor'))); ?></p>
25
- <?php endif; ?>
26
-
27
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
28
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
29
- <?php endif; ?>
30
-
31
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
32
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
33
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/mercadopago/transparent_boleto/info.phtml DELETED
@@ -1,13 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
4
- <p><?php echo $this->__('Numero de Pagamento (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
5
- <?php endif; ?>
6
-
7
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
8
- <p><?php echo $this->__('Status de Pagamento: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
9
- <?php endif; ?>
10
-
11
- <p>Clique no link para gerar o boleto.</p>
12
- <a href="<?php echo urldecode($this->htmlEscape($this->getOrder()->getAdditionalInformation('activation_uri'))); ?>" target="_blank">Gerar Boleto</a>
13
-
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/mercadopago/transparent_ticket/info.phtml DELETED
@@ -1,15 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
4
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
5
- <?php endif; ?>
6
-
7
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
8
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
9
- <?php endif; ?>
10
-
11
- <p><?php echo $this->__('Click on the link to generate the ticket'); ?>.</p>
12
- <a href="<?php echo urldecode($this->htmlEscape($this->getOrder()->getAdditionalInformation('activation_uri'))); ?>" target="_blank">
13
- <?php echo $this->__('Generate Ticket'); ?>
14
- </a>
15
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/mercadopago.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <layout version="0.1.0">
4
- <checkout_onepage_success translate="label">
5
- <reference name="content">
6
- <block name="mercadopago.transparent.success" template="mercadopago/transparent/success.phtml" type="mercadopago_transparent/success" />
7
- </reference>
8
- </checkout_onepage_success>
9
- </layout>
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/{clean_page.phtml → clean.phtml} RENAMED
@@ -9,7 +9,7 @@
9
  *
10
  * @category Payment Gateway
11
  * @package MercadoPago
12
- * @author Andr Fuhrman (andrefuhrman@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
  */
9
  *
10
  * @category Payment Gateway
11
  * @package MercadoPago
12
+ * @author AndrŽ Fuhrman (andrefuhrman@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
  */
app/design/frontend/base/default/template/mercadopago/{transparent → custom}/form.phtml RENAMED
@@ -1,15 +1,19 @@
1
  <?php
2
 
3
- $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
 
 
 
 
 
 
 
4
 
5
  ?>
6
 
7
 
8
  <fieldset class="form-list mercadopago">
9
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" />
10
-
11
- <?php $_code = $this->getMethodCode(); ?>
12
- <?php $_country = $this->getMethodCountry(); ?>
13
 
14
  <script>
15
  //load nas actions para funcionar o js do mercadopago
@@ -39,11 +43,19 @@ $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
39
  <input type="hidden" name="payment[payment_method]" type="text" value="" id="payment_method" />
40
  <?php endif; ?>
41
 
 
 
 
 
 
 
 
42
  <li>
43
  <label for="<?php echo $_code ?>_cn" class="required"><em>*</em><?php echo $this->__('Card Number'); ?></label>
44
  <div class="input-box">
45
  <input data-checkout="cardNumber" id="<?php echo $_code ?>_cn" type="text" class="input-text required-entry"/>
46
- <div id="img_payment_method"></div>
 
47
  </div>
48
  </li>
49
 
@@ -59,22 +71,24 @@ $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
59
  <div class="box-mes">
60
  <label for="<?php echo $_code ?>_month" class="required"><em>*</em><?php echo $this->__('Month'); ?></label>
61
  <div class="input-box mes">
62
- <select data-checkout="cardExpirationMonth" name="payment[cardExpirationMonth]" id="<?php echo $_code ?>_month" class="input-text required-entry validate-digits">
63
  <?php foreach ($this->getCcMonths() as $m=>$v): ?>
64
  <option value="<?php echo $m?$m:'' ?>"><?php echo $v ?></option>
65
  <?php endforeach ?>
66
  </select>
 
67
  </div>
68
  </div>
69
 
70
  <div class="box-ano">
71
  <label for="<?php echo $_code ?>_year" class="required"><em>*</em><?php echo $this->__('Year'); ?></label>
72
  <div class="input-box">
73
- <select data-checkout="cardExpirationYear" name="payment[cardExpirationYear]" id="<?php echo $_code ?>_year" class="input-text required-entry validate-digits">
74
  <?php foreach ($this->getCcYears() as $y=>$v): ?>
75
  <option value="<?php echo $y?$y:'' ?>"><?php echo $v ?></option>
76
  <?php endforeach ?>
77
  </select>
 
78
  </div>
79
  </div>
80
  </li>
@@ -85,6 +99,7 @@ $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
85
  <label for="<?php echo $_code ?>_name" class="required"><em>*</em><?php echo $this->__('Card Holder Name'); ?></label>
86
  <div class="input-box">
87
  <input data-checkout="cardholderName" name="payment[cardholderName]" id="<?php echo $_code ?>_name" type="text" class="input-text required-entry" type="text"/>
 
88
  </div>
89
  </div>
90
  </li>
@@ -110,6 +125,8 @@ $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
110
  <?php endif; ?>
111
 
112
  <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" />
 
 
113
  </div>
114
  </div>
115
  </li>
@@ -119,57 +136,53 @@ $country = Mage::getStoreConfig('payment/mercadopago_configuration/country');
119
  <div class="box-input">
120
  <label for="<?php echo $_code ?>_code" class="required"><em>*</em><?php echo $this->__('CVV'); ?></label>
121
  <div class="input-box">
122
- <input data-checkout="securityCode" id="<?php echo $_code ?>_code" type="text" class="input-text required-entry validate-digits" type="text"/>
 
123
  </div>
124
  </div>
125
- </li>
126
 
127
  <li>
128
  <div class="box-input">
129
  <label for="<?php echo $_code ?>_installments" class="required"><em>*</em><?php echo $this->__('Installments'); ?></label>
130
  <div class="input-box box-installments">
131
- <select name="payment[installments]" id="installments" data-checkout="installments" id="<?php echo $_code ?>_installments" class="input-text required-entry validate-digits">
132
  <option><?php echo $this->__('Enter the card number'); ?></option>
133
  </select>
 
 
 
134
  </div>
135
  </div>
136
 
137
- <div id="status">
138
- <div class="box">
139
- <div class="loading-mp">
140
- <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif') ;?>" alt="loading" />
141
- </div>
142
-
143
- <div class="text-mp">
144
- <p class="msg-status msg-loading"><?php echo $this->__('Validating Data'); ?>...</p>
145
- <p class="msg-status error-011"><?php echo $this->__('An error has occurred. Please refresh the page.'); ?></p>
146
- <p class="msg-status error-E301"><?php echo $this->__('Card Number is invalid.'); ?></p>
147
- <p class="msg-status error-E302"><?php echo $this->__('CVV is invalid.'); ?></p>
148
- <p class="msg-status error-316"><?php echo $this->__('Card Holder Name is invalid.'); ?></p>
149
- <p class="msg-status error-324"><?php echo $this->__('Document Number is invalid.'); ?></p>
150
- <p class="msg-status error-325"><?php echo $this->__('Month is invalid.'); ?></p>
151
- <p class="msg-status error-326"><?php echo $this->__('Year is invalid.'); ?></p>
152
- <p class="msg-status error-other"><?php echo $this->__('Please validate your data.'); ?></p>
153
- </div>
154
- </div>
155
  </div>
156
- <input type="hidden" id="amount" value="<?php echo $this->helper('checkout/cart')->getQuote()->getGrandTotal(); ?>">
157
  <input type="hidden" name="payment[card_token_id]" type="text" value="" id="card_token_id" />
158
  <input type="hidden" name="payment[trunc_card]" type="text" value="" id="trunc_card" />
159
 
 
 
 
 
 
 
 
160
  <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
161
  <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
162
  <?php endif;?>
163
 
164
  <div style="display: none;">
165
- <span id="mercadopago-text-currency"><?php echo $this->__('$'); ?></span>
166
- <span id="mercadopago-text-choice"><?php echo $this->__('Choice'); ?></span>
167
- <span id="mercadopago-text-default-issuer"><?php echo $this->__('Default issuer'); ?></span>
168
- <span id="mercadopago-country"><?php echo $country; ?></span>
169
  </div>
170
  </li>
171
  </ul>
172
 
173
 
174
  </div>
175
- </fieldset>
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
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
 
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>
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>
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>
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>
app/design/frontend/base/default/template/mercadopago/custom/info.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
3
+
4
+ <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
5
+
6
+ <?php
7
+ $info_payment = $this->getInfoPayment();
8
+ ?>
9
+
10
+ <?php foreach($info_payment as $info): ?>
11
+ <p><?php echo $info['text']; ?></p>
12
+ <?php endforeach; ?>
13
+
14
+ <?php endif;?>
app/design/frontend/base/default/template/mercadopago/custom_ticket/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
app/design/frontend/base/default/template/mercadopago/custom_ticket/info.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
+
3
+ <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
4
+
5
+ <?php
6
+ $info_payment = $this->getInfoPayment();
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
+
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
+ <p><?php echo $this->__('Click on the link to generate the ticket'); ?>.</p>
29
+
30
+ <a href="<?php echo urldecode($info_payment['activation_uri']['value']); ?>" target="_blank">
31
+ <?php echo $this->__('Generate Ticket'); ?>
32
+ </a>
33
+
34
+ <?php endif;?>
app/design/frontend/base/default/template/mercadopago/discount.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
9
+
10
+ <ul class="mercadopago-message-coupon">
11
+ <li class="loading">
12
+ <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif') ;?>" alt="loading" />
13
+ </li>
14
+
15
+ <li class="error error-get validation-advice">
16
+ <?php echo $this->__('An error occurred while validating the coupon. Try again.'); ?>
17
+ </li>
18
+
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
+
27
+ <li class="error run-out-of-uses validation-advice">
28
+ <?php echo $this->__("Run Out of uses per user."); ?>
29
+ </li>
30
+
31
+
32
+ <li class="error invalid_id validation-advice">
33
+ <?php echo $this->__('Please enter a valid coupon code.'); ?>
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>
41
+ <p><a href="" class="mercadopago-coupon-terms" target="_blank"><?php echo $this->__('Terms and conditions'); ?></a></p>
42
+ </li>
43
+ </ul>
44
+
45
+ <span class="mercadopago-coupon-action-apply"><?php echo $this->__('Apply discount'); ?></span>
46
+ <span class="mercadopago-coupon-action-remove"><?php echo $this->__('Remove discount'); ?></span>
47
+ </li>
app/design/frontend/base/default/template/mercadopago/standard/form.phtml CHANGED
@@ -1,6 +1,6 @@
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(); ?>
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(); ?>
app/design/frontend/base/default/template/mercadopago/standard/info.phtml CHANGED
@@ -1,36 +1,14 @@
 
1
  <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
 
3
  <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
4
 
5
-
6
- <?php if($this->getOrder()->getAdditionalInformation('cardholderName') != ""): ?>
7
- <p><?php echo $this->__('Card Holder Name: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('cardholderName'))); ?></p>
8
- <?php endif; ?>
9
-
10
- <?php if($this->getOrder()->getAdditionalInformation('trunc_card') != ""): ?>
11
- <p><?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('trunc_card'))); ?></p>
12
- <?php endif; ?>
13
-
14
- <?php if($this->getOrder()->getAdditionalInformation('payment_method') != ""): ?>
15
- <p><?php echo $this->__('Payment Method: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_method'))); ?></p>
16
- <?php endif; ?>
17
-
18
- <?php if($this->getOrder()->getAdditionalInformation('installments') != ""): ?>
19
- <p><?php echo $this->__('Installments: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('installments'))); ?></p>
20
- <?php endif; ?>
21
-
22
- <?php if($this->getOrder()->getAdditionalInformation('statement_descriptor') != ""): ?>
23
- <p><?php echo $this->__('Statement Descriptor: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('statement_descriptor'))); ?></p>
24
- <?php endif; ?>
25
-
26
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
27
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
28
- <?php endif; ?>
29
-
30
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
31
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
32
- <?php endif; ?>
33
 
34
-
 
 
35
 
36
  <?php endif;?>
1
+
2
  <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
3
 
4
  <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
5
 
6
+ <?php
7
+ $info_payment = $this->getInfoPayment();
8
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ <?php foreach($info_payment as $info): ?>
11
+ <p><?php echo $info['text']; ?></p>
12
+ <?php endforeach; ?>
13
 
14
  <?php endif;?>
app/design/frontend/base/default/template/mercadopago/standard/pay.phtml CHANGED
@@ -1,51 +1,61 @@
1
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" />
2
-
3
- <div id="standard_banner_checkout">
4
- <img src="<?php echo $banner_checkout; ?>" class="banner_checkout_mp"/>
5
- </div>
6
-
7
- <?php if($type_checkout == "lightbox"):?>
8
-
9
- <script type="text/javascript" src="https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js"></script>
10
-
11
- <!-- Abra o Checkout -->
12
- <script type="text/javascript">
13
- $MPC.openCheckout ({
14
- url: "<?php echo $init_point; ?>",
15
- mode: "modal",
16
- onreturn: function(data) {
17
- // execute_my_onreturn (Apenas modelo)
18
- }
19
- });
20
- </script>
21
-
22
- <a href="<?php echo $init_point; ?>" name="MP-Checkout" class="blue-M-Rn" mp-mode="modal">Pagar</a>
23
- <!-- Cole esse código antes de fechar a etiqueta </body> -->
24
-
25
- <?php elseif($type_checkout == "redirect"):?>
26
- <script type="text/javascript" src="https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js"></script>
27
-
28
- <!-- Abra o Checkout -->
29
- <script type="text/javascript">
30
- $MPC.openCheckout ({
31
- url: "<?php echo $init_point; ?>",
32
- mode: "redirect",
33
- onreturn: function(data) {
34
- // execute_my_onreturn (Apenas modelo)
35
- }
36
- });
37
- </script>
38
- <?php else: ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- <!-- Aqui você deve inserir a URL que corresponde a "init_point" -->
41
- <iframe src="<?php echo $init_point; ?>" name="MP-Checkout" width="<?php echo $iframe_width; ?>" height="<?php echo $iframe_height; ?>" frameborder="0" scrolling="no" id="checkout_mercadopago"></iframe>
42
-
43
- <!-- Cole esse código antes de fechar a etiqueta </body> -->
44
- <script type="text/javascript">
45
- (function(){function $MPBR_load(){window.$MPBR_loaded !== true && (function(){var s = document.createElement("script");s.type = "text/javascript";s.async = true;
46
- s.src = ("https:"==document.location.protocol?"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/":"http://mp-tools.mlstatic.com/buttons/")+"render.js";
47
- var x = document.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);window.$MPBR_loaded = true;})();}
48
- window.$MPBR_loaded !== true ? (window.attachEvent ? window.attachEvent('onload', $MPBR_load) : window.addEventListener('load', $MPBR_load, false)) : null;})();
49
- </script>
50
-
51
- <?php endif;?>
1
+ <?php if($status == 201): ?>
2
+
3
+
4
+ <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" />
5
+
6
+ <div id="standard_banner_checkout">
7
+ <img src="<?php echo $banner_checkout; ?>" class="banner_checkout_mp"/>
8
+ </div>
9
+
10
+ <?php if($type_checkout == "lightbox"):?>
11
+
12
+ <script type="text/javascript" src="https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js"></script>
13
+
14
+ <!-- Abra o Checkout -->
15
+ <script type="text/javascript">
16
+ $MPC.openCheckout ({
17
+ url: "<?php echo $init_point; ?>",
18
+ mode: "modal",
19
+ onreturn: function(data) {
20
+ // execute_my_onreturn (Apenas modelo)
21
+ }
22
+ });
23
+ </script>
24
+
25
+ <a href="<?php echo $init_point; ?>" name="MP-Checkout" class="blue-M-Rn" mp-mode="modal">Pagar</a>
26
+ <!-- Cole esse código antes de fechar a etiqueta </body> -->
27
+
28
+ <?php elseif($type_checkout == "redirect"):?>
29
+ <script type="text/javascript" src="https://www.mercadopago.com/org-img/jsapi/mptools/buttons/render.js"></script>
30
+
31
+ <!-- Abra o Checkout -->
32
+ <script type="text/javascript">
33
+ $MPC.openCheckout ({
34
+ url: "<?php echo $init_point; ?>",
35
+ mode: "redirect",
36
+ onreturn: function(data) {
37
+ // execute_my_onreturn (Apenas modelo)
38
+ }
39
+ });
40
+ </script>
41
+ <?php else: ?>
42
+
43
+ <!-- Aqui você deve inserir a URL que corresponde a "init_point" -->
44
+ <iframe src="<?php echo $init_point; ?>" name="MP-Checkout" width="<?php echo $iframe_width; ?>" height="<?php echo $iframe_height; ?>" frameborder="0" scrolling="no" id="checkout_mercadopago"></iframe>
45
+
46
+ <!-- Cole esse código antes de fechar a etiqueta </body> -->
47
+ <script type="text/javascript">
48
+ (function(){function $MPBR_load(){window.$MPBR_loaded !== true && (function(){var s = document.createElement("script");s.type = "text/javascript";s.async = true;
49
+ s.src = ("https:"==document.location.protocol?"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/":"http://mp-tools.mlstatic.com/buttons/")+"render.js";
50
+ var x = document.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);window.$MPBR_loaded = true;})();}
51
+ window.$MPBR_loaded !== true ? (window.attachEvent ? window.attachEvent('onload', $MPBR_load) : window.addEventListener('load', $MPBR_load, false)) : null;})();
52
+ </script>
53
+
54
+ <?php endif;?>
55
 
56
+ <?php else: ?>
57
+
58
+ <h1><?php echo $message; ?></h1>
59
+ <pre><?php echo $json; ?></pre>
60
+
61
+ <?php endif;?>
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/success.phtml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/design/frontend/base/default/template/mercadopago/transparent/info.phtml DELETED
@@ -1,33 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if($this->getOrder()->getAdditionalInformation('cardholderName') != ""): ?>
4
- <p><?php echo $this->__('Card Holder Name: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('cardholderName'))); ?></p>
5
- <?php endif; ?>
6
-
7
- <?php if($this->getOrder()->getAdditionalInformation('trunc_card') != ""): ?>
8
- <p><?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('trunc_card'))); ?></p>
9
- <?php endif; ?>
10
-
11
- <?php if($this->getOrder()->getAdditionalInformation('payment_method') != ""): ?>
12
- <p><?php echo $this->__('Payment Method: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_method'))); ?></p>
13
- <?php endif; ?>
14
-
15
- <?php if($this->getOrder()->getAdditionalInformation('expiration_date') != ""): ?>
16
- <p><?php echo $this->__('Expiration Date: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('expiration_date'))); ?></p>
17
- <?php endif; ?>
18
-
19
- <?php if($this->getOrder()->getAdditionalInformation('installments') != ""): ?>
20
- <p><?php echo $this->__('Installments: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('installments'))); ?></p>
21
- <?php endif; ?>
22
-
23
- <?php if($this->getOrder()->getAdditionalInformation('statement_descriptor') != ""): ?>
24
- <p><?php echo $this->__('Statement Descriptor: %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('statement_descriptor'))); ?></p>
25
- <?php endif; ?>
26
-
27
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
28
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
29
- <?php endif; ?>
30
-
31
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
32
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?></p>
33
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent/success.phtml DELETED
@@ -1,229 +0,0 @@
1
- <style>
2
- #btn-boleto-mercadopago{
3
- font-size: 1.25em;
4
- text-align: center;
5
- line-height: 1.25em;
6
- padding: 6px 12px;
7
- font-family: 'Lato',sans-serif;
8
- font-weight: 400;
9
- background-color: #36A1F1;
10
- background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#36A1F1),color-stop(100%,#0F79C9));
11
- background-image: -webkit-linear-gradient(#36A1F1,#0F79C9);
12
- background-image: -moz-linear-gradient(#36A1F1,#0F79C9);
13
- background-image: -o-linear-gradient(#36A1F1,#0F79C9);
14
- background-image: linear-gradient(#36A1F1,#0F79C9);
15
- -webkit-box-shadow: inset 0 1px #97DCFF;
16
- box-shadow: 0 1px #97DCFF inset;
17
- color: #FFF!important;
18
- border: 1px solid #0D6FB9;
19
- border-radius: 4px 4px 4px 4px;
20
- cursor: pointer;
21
- display: inline-block;
22
- text-decoration:none;
23
- }
24
- #btn-boleto-mercadopago:hover{
25
- background-color:#4CBFF8;
26
- background-image:linear-gradient(#4CBFF8,#1699DF);
27
- box-shadow:0 1px #B6EBFF inset;
28
- background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#4CBFF8),color-stop(100%,#1699DF));
29
- background-image:-webkit-linear-gradient(#4CBFF8,#1699DF);
30
- background-image:-moz-linear-gradient(#4CBFF8,#1699DF);
31
- background-image:-o-linear-gradient(#4CBFF8,#1699DF);
32
- background-image:linear-gradient(#4CBFF8,#1699DF);-webkit-box-shadow:inset 0 1px #B6EBFF;
33
- border:1px solid #1890D3;
34
- color:#FFF;
35
- text-decoration:none;
36
- }
37
- #box-mercadopago{
38
- float:left;
39
- text-align: left;
40
- margin: 10px 0;
41
- }
42
-
43
- #title-mercadopago{
44
- text-transform:uppercase;
45
- }
46
-
47
- #logo-mercadopago{
48
- margin: 10px 0;
49
- }
50
- </style>
51
-
52
- <div id="box-mercadopago">
53
-
54
- <?php
55
- //mensagem apenas para checkout transparent
56
- if(!isset($_REQUEST['preference_id'])):
57
- ?>
58
- <h5>
59
- <b>
60
- <?php echo $this->__('Payment Method'); ?>
61
- </b>
62
- </h5>
63
-
64
- <?php
65
- $order = $this->getOrder();
66
-
67
- $total = $order->getBaseGrandTotal();
68
-
69
- if (!$total) {
70
- $total = $order->getBasePrice() + $order->getBaseShippingAmount();
71
- }
72
-
73
- $total = number_format($total, 2, '.', '');
74
-
75
- $payment = $order->getPayment();
76
-
77
- if($payment->getAdditionalInformation('payment_type_id') == 'ticket'):
78
- ?>
79
-
80
- <p>
81
- <?php echo $this->__('Generate the ticket and pay it wherever you want.'); ?>
82
- </p>
83
- <p>
84
- <?php echo $this->__('Will be approved within 2 business days.'); ?>
85
- </p>
86
- <a href="<?php echo urldecode($this->htmlEscape($payment->getAdditionalInformation('activation_uri'))); ?>" target="_blank" id="btn-boleto-mercadopago">
87
- <?php echo $this->__('Generate Ticket'); ?>
88
- </a>
89
-
90
- <?php else: ?>
91
-
92
- <?php
93
- $title = "";
94
- $msg = "";
95
-
96
- switch ($payment->getAdditionalInformation('status')){
97
- case "approved":
98
- $title = $this->__('Done, your payment was accredited!');
99
- $msg = "";
100
- break;
101
-
102
- case "in_process":
103
- $title = $this->__('We are processing the payment.');
104
- $msg = $this->__('In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.');
105
- break;
106
-
107
- case "pending":
108
- $title = $this->__('We are processing the payment.');
109
- $msg = $this->__('In less than an hour we will send you by e-mail the result.');
110
- break;
111
-
112
- case "rejected":
113
- $title = $this->__('We could not process your payment.');
114
-
115
- switch ($payment->getAdditionalInformation('status_detail')){
116
- case "cc_rejected_bad_filled_card_number":
117
- $msg = $this->__('Check the card number.');
118
- break;
119
-
120
- case "cc_rejected_bad_filled_date":
121
- $msg = $this->__('Check the expiration date.');
122
- break;
123
-
124
- case "cc_rejected_bad_filled_other":
125
- $msg = $this->__('Check the data.');
126
- break;
127
-
128
- case "cc_rejected_bad_filled_security_code":
129
- $msg = $this->__('Check the security code.');
130
- break;
131
-
132
- case "cc_rejected_blacklist":
133
- $msg = $this->__('We could not process your payment.');
134
- break;
135
-
136
- case "cc_rejected_call_for_authorize":
137
- $msg = $this->__('You must authorize to %s the payment of $ %s to MercadoPago.', strtoupper($payment->getAdditionalInformation('payment_method')), strtoupper($total));
138
- break;
139
-
140
- case "cc_rejected_card_disabled":
141
- $msg = $this->__('Call %s to activate your card.<br/>The phone is on the back of your card.', strtoupper($payment->getAdditionalInformation('payment_method')));
142
- break;
143
-
144
- case "cc_rejected_card_error":
145
- $msg = $this->__('We could not process your payment.');
146
- break;
147
-
148
- case "cc_rejected_duplicated_payment":
149
- $msg = $this->__('You already made a payment by that value.<br/>If you need to repay, use another card or other payment method.');
150
- break;
151
-
152
- case "cc_rejected_high_risk":
153
- $msg = $this->__('Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.');
154
- break;
155
-
156
- case "cc_rejected_insufficient_amount":
157
- $msg = $this->__('Your %s do not have sufficient funds.', strtoupper($payment->getAdditionalInformation('payment_method')));
158
- break;
159
-
160
- case "cc_rejected_invalid_installments":
161
- $msg = $this->__('%s does not process payments in %s installments.', strtoupper($payment->getAdditionalInformation('payment_method')), $payment->getAdditionalInformation('installments'));
162
- break;
163
-
164
- case "cc_rejected_max_attempts":
165
- $msg = $this->__('You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.');
166
- break;
167
-
168
- case "cc_rejected_other_reason":
169
- $msg = $this->__('%s did not process the payment.', strtoupper($payment->getAdditionalInformation('payment_method')));
170
- break;
171
- }
172
- break;
173
- }
174
- ?>
175
-
176
- <p>
177
- <b id="title-mercadopago">
178
- <?php echo $title; ?>
179
- </b>
180
- </p>
181
- <p>
182
- <i>
183
- <?php echo $msg; ?>
184
- </i>
185
- </p>
186
-
187
- <br />
188
-
189
- <?php if($payment->getAdditionalInformation('cardholderName') != ""): ?>
190
- <p><?php echo $this->__('Card Holder Name: %s', $this->htmlEscape($payment->getAdditionalInformation('cardholderName'))); ?></p>
191
- <?php endif; ?>
192
-
193
- <?php if($payment->getAdditionalInformation('trunc_card') != ""): ?>
194
- <p><?php echo $this->__('Card Number: %s', $this->htmlEscape($payment->getAdditionalInformation('trunc_card'))); ?></p>
195
- <?php endif; ?>
196
-
197
- <?php if($payment->getAdditionalInformation('payment_method') != ""): ?>
198
- <p><?php echo $this->__('Payment Method: %s', $this->htmlEscape($payment->getAdditionalInformation('payment_method'))); ?></p>
199
- <?php endif; ?>
200
-
201
- <?php if($payment->getAdditionalInformation('expiration_date') != ""): ?>
202
- <p><?php echo $this->__('Expiration Date: %s', $this->htmlEscape($payment->getAdditionalInformation('expiration_date'))); ?></p>
203
- <?php endif; ?>
204
-
205
- <?php if($payment->getAdditionalInformation('installments') != ""): ?>
206
- <p><?php echo $this->__('Installments: %s', $this->htmlEscape($payment->getAdditionalInformation('installments'))); ?></p>
207
- <?php endif; ?>
208
-
209
- <?php if($payment->getAdditionalInformation('statement_descriptor') != ""): ?>
210
- <p><?php echo $this->__('Statement Descriptor: %s', $this->htmlEscape($payment->getAdditionalInformation('statement_descriptor'))); ?></p>
211
- <?php endif; ?>
212
-
213
- <?php if($payment->getAdditionalInformation('payment_id') != ""): ?>
214
- <p><?php echo $this->__('Payment id (MercadoPago): %s', $this->htmlEscape($payment->getAdditionalInformation('payment_id'))); ?></p>
215
- <?php endif; ?>
216
-
217
- <?php if($payment->getAdditionalInformation('status') != ""): ?>
218
- <p><?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($payment->getAdditionalInformation('status')), $this->htmlEscape($payment->getAdditionalInformation('status_detail'))); ?></p>
219
- <?php endif; ?>
220
-
221
-
222
- <?php endif; ?>
223
-
224
- <div id="logo-mercadopago">
225
- <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
226
- </div>
227
- <?php endif; ?>
228
- </div>
229
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent/sucesso.phtml DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- $page_redirec = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true) . "checkout/onepage/success";
3
- ?>
4
-
5
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" />
6
-
7
- <script>
8
- window.onload = function() {
9
- contagem_tempo();
10
- };
11
-
12
- function contagem_tempo(){
13
- if(document.getElementById("segundos_redirect") != null){
14
- var segundos = document.getElementById("segundos_redirect").innerHTML;
15
-
16
- segundos = segundos - 1;
17
-
18
- if (segundos == -1) {
19
- segundos = 0;
20
- location.href = "<?php echo $page_redirec; ?>";
21
- return;
22
- }
23
- document.getElementById("segundos_redirect").innerHTML = segundos ;
24
- timerID = setTimeout("contagem_tempo()", 1000);
25
- }
26
- }
27
-
28
- </script>
29
-
30
- <div id="mensagem_mp">
31
-
32
- <?php if($payment_method_id == "bolbradesco"): ?>
33
-
34
- <?php
35
- /*
36
- *
37
- * Processo para boleto
38
- *
39
- */
40
- ?>
41
-
42
- <h4>Pronto, seu pedido foi gerado com sucesso!</h4>
43
-
44
- <p>
45
- Gere o boleto e pague-o onde quiser.
46
- </p>
47
- <p>
48
- <a href="<?php echo $payment['activation_uri']; ?>" target="_blank" class="btn-boleto"> Gerar boleto </a>
49
- </p>
50
-
51
- <p>Será aprovado até 2 dias úteis.</p>
52
-
53
- <?php else: ?>
54
-
55
- <?php
56
- /*
57
- *
58
- * Processo para cartão
59
- *
60
- */
61
- ?>
62
-
63
- <?php if($status == "approved"): ?>
64
-
65
- <h4>Pronto, seu pagamento foi aprovado!</h4>
66
-
67
- <p>
68
- <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif') ;?>" alt="loading" />
69
- Em <span id="segundos_redirect">6</span> segundos <a href="<?php echo $page_redirec; ?>">você será redirecionado para tela de finalização.</a>
70
- </p>
71
-
72
- <?php elseif($status == "pending" || $status == "in_process"): ?>
73
-
74
- <h4>Estamos processando o pagamento</h4>
75
- <p class="status"><?php echo $mensagem; ?></p>
76
-
77
- <p>
78
- <img src="<?php echo $this->getSkinUrl('mercadopago/images/loading.gif') ;?>" alt="loading" />
79
- Em <span id="segundos_redirect">10</span> segundos <a href="<?php echo $page_redirec; ?>">você será redirecionado para tela de finalização.</a>
80
- </p>
81
-
82
- <?php elseif($status == "rejected"): ?>
83
-
84
- <h4>O seu pagamento não foi processado.</h4>
85
- <p class="status"><?php echo $mensagem; ?></p>
86
- <p><a class="voltar" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true); ?>sales/order/reorder/order_id/<?php echo $order->getId(); ?> ">Voltar para o carrinho</a></p>
87
-
88
- <?php elseif(!$status): ?>
89
-
90
- <h4>O seu pagamento não foi processado.</h4>
91
- <p><a class="voltar" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK,true); ?>">Voltar</a></p>
92
-
93
- <?php endif; ?>
94
-
95
- <?php endif; ?>
96
-
97
- </div>
98
-
99
-
100
-
101
- <div id="logo_mp">
102
- <img src="https://secure.mlstatic.com/components/resources/mp/desktop/css/assets/desktop-logo-mercadopago.png" />
103
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent_boleto/form.phtml DELETED
@@ -1,20 +0,0 @@
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
- <div id="mp-form-boleto">
13
- <ul class="form-list form-mercadopago" id="payment_form_<?php echo $_code ?>" style="display:none;" >
14
- <li style="display:none;">
15
- <input type="hidden" name="payment[payment_method_boleto]" type="text" value="bolbradesco"/>
16
- </li>
17
- </ul>
18
- </div>
19
-
20
- </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent_boleto/info.phtml DELETED
@@ -1,23 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
4
-
5
-
6
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
7
- <p><?php echo $this->__('Numero de Pagamento (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
8
- <?php endif; ?>
9
-
10
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
11
- <p>
12
- <?php echo $this->__('Status de Pagamento: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?>
13
- </p>
14
- <?php endif; ?>
15
-
16
- <p>Gere o boleto e pague-o onde quiser.</p>
17
- <p>Será aprovado até 2 dias úteis.</p>
18
- <a href="<?php echo urldecode($this->htmlEscape($this->getOrder()->getAdditionalInformation('activation_uri'))); ?>" target="_blank">Gerar Boleto</a>
19
-
20
- <?php endif;?>
21
-
22
-
23
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent_ticket/form.phtml DELETED
@@ -1,31 +0,0 @@
1
-
2
- <fieldset class="form-list">
3
- <link rel="stylesheet" href="<?php echo $this->getSkinUrl('mercadopago/css/style.css'); ?>" />
4
- <?php $_code = $this->getMethodCode(); ?>
5
- <?php $_country = $this->getMethodCountry(); ?>
6
-
7
- <?php if($this->getMethod()->getConfigData('banner_checkout') != ""): ?>
8
- <img src="<?php echo $this->getMethod()->getConfigData('banner_checkout'); ?>" class="banner_checkout_mp"/>
9
- <?php endif;?>
10
-
11
- <div id="mp-form-boleto">
12
- <ul class="form-list form-mercadopago" id="payment_form_<?php echo $_code ?>" style="display:none;" >
13
- <li>
14
-
15
- <?php
16
- $optionsTicket = $this->getTicketsOptions();
17
- if(count($optionsTicket) == 1){ ?>
18
- <input type="hidden" name="payment[payment_method_boleto]" type="text" value="<?php echo $optionsTicket[0]['id']; ?>" id="payment_method_boleto" />
19
- <?php } else { ?>
20
-
21
- <?php
22
- foreach($optionsTicket as $ticket){ ?>
23
- <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/>
24
- <?php } ?>
25
- <?php } ?>
26
- </li>
27
-
28
- </ul>
29
- </div>
30
-
31
- </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/mercadopago/transparent_ticket/info.phtml DELETED
@@ -1,27 +0,0 @@
1
- <p><strong><?php echo $this->getMethod()->getTitle() ?></strong></p>
2
-
3
- <?php if(Mage::app()->getRequest()->getRouteName()=="sales"): ?>
4
-
5
-
6
- <?php if($this->getOrder()->getAdditionalInformation('payment_id') != ""): ?>
7
- <p><?php echo $this->__('Payment Id (MercadoPago): %s', $this->htmlEscape($this->getOrder()->getAdditionalInformation('payment_id'))); ?></p>
8
- <?php endif; ?>
9
-
10
- <?php if($this->getOrder()->getAdditionalInformation('status') != ""): ?>
11
- <p>
12
- <?php echo $this->__('Payment Status: %s (%s)', $this->htmlEscape($this->getOrder()->getAdditionalInformation('status')), $this->htmlEscape($this->getOrder()->getAdditionalInformation('status_detail'))); ?>
13
- </p>
14
- <?php endif; ?>
15
-
16
- <p>
17
- <?php echo $this->__('Generate the ticket and pay it wherever you want.'); ?>
18
- </p>
19
- <p>
20
- <?php echo $this->__('Will be approved within 2 business days.'); ?>
21
- </p>
22
- <a href="<?php echo urldecode($this->htmlEscape($this->getOrder()->getAdditionalInformation('activation_uri'))); ?>" target="_blank">
23
- <?php echo $this->__('Generate Ticket'); ?>
24
- </a>
25
-
26
- <?php endif;?>
27
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/{MercadoPago_Standard.xml → MercadoPago.xml} RENAMED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <MercadoPago_Standard>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- </MercadoPago_Standard>
8
  </modules>
9
  </config>
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>
app/etc/modules/MercadoPago_Transparent.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <MercadoPago_Transparent>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </MercadoPago_Transparent>
8
- </modules>
9
- </config>
 
 
 
 
 
 
 
 
 
app/etc/modules/MercadoPago_TransparentTicket.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <MercadoPago_TransparentTicket>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </MercadoPago_TransparentTicket>
8
- </modules>
9
- </config>
 
 
 
 
 
 
 
 
 
app/locale/es_AR/mercadopago.csv CHANGED
@@ -3,7 +3,7 @@
3
  "MercadoPago - Configuration", "MercadoPago - Configuración"
4
  "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Transparent - Credit Card","MercadoPago 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"
@@ -15,7 +15,7 @@
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 Transparent - Ticket","MercadoPago Transparente - 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"
@@ -27,7 +27,7 @@
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 'MercadoPago - Configuration'",""Para el funcionamento del Checkout Transparente - 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"
@@ -46,9 +46,11 @@
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
 
53
  "Card Number: %s","Número de Tarjeta: %s"
54
  "Card Holder Name: %s","Titular de la Tarjeta: %s"
@@ -67,6 +69,10 @@
67
  "Generate the ticket and pay it wherever you want.","Genere el ticket de pago y pague"
68
  "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
69
 
 
 
 
 
70
  "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
71
  "We are processing the payment.","Estamos procesando el pago."
72
  "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."
@@ -111,4 +117,7 @@
111
  "Automatic notification of the MercadoPago: The payment was rejected.","Notificación automática de MercadoPago: El pago fué rechazado."
112
  "<br/> Payment id: %s","<br/> Número de Pago: %s"
113
  "<br/> Status: %s","<br/> Estado: %s"
114
- "<br/> Status Detail: %s","<br/> Detalle del Estado: %s"
 
 
 
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
  "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"
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"
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"
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."
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"
app/locale/es_CO/mercadopago.csv CHANGED
@@ -3,7 +3,7 @@
3
  "MercadoPago - Configuration", "MercadoPago - Configuración"
4
  "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Transparent - Credit Card","MercadoPago 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"
@@ -15,7 +15,7 @@
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 Transparent - Ticket","MercadoPago Transparente - 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"
@@ -27,7 +27,7 @@
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 'MercadoPago - Configuration'",""Para el funcionamento del Checkout Transparente - 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"
@@ -42,13 +42,15 @@
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
 
53
  "Card Number: %s","Número de Tarjeta: %s"
54
  "Card Holder Name: %s","Titular de la Tarjeta: %s"
@@ -67,6 +69,9 @@
67
  "Generate the ticket and pay it wherever you want.","Genere el ticket de pago y pague"
68
  "Will be approved within 2 business days.","Será aprobado en hasta 2 días hábiles"
69
 
 
 
 
70
  "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
71
  "We are processing the payment.","Estamos procesando el pago."
72
  "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."
@@ -116,4 +121,7 @@
116
 
117
  "$", "$"
118
  "Choice", "Elige"
119
- "Default issuer", "Cualquier otro banco"
 
 
 
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
  "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"
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"
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"
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
+ "Thank you for your purchase!","Gracias por su compra!"
74
+ "Your order %s has been successfully generated.","Su pedido con el numero %s fué generado con éxito."
75
  "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
76
  "We are processing the payment.","Estamos procesando el pago."
77
  "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."
121
 
122
  "$", "$"
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"
app/locale/es_ES/mercadopago.csv CHANGED
@@ -1,41 +1,122 @@
1
- "Escolha a forma de entrega","Elige un método de envío"
2
- "Desculpe, não há formas de entrega disponível nesse momento","Disculpe, no hay método de envío disponible"
3
- "É necessário escolher uma opção de envio","Es necesario elegir el método de envío"
4
- "Insira seu cep","Ingrese su código postal"
5
- "Continuar","Continuar"
6
- "Seu pedido está sendo gerado. Por favor aguarde","Por favor, espere"
7
- "Por favor aguarde","Por favor, espere"
8
- "Calculando valor do frete. Por favor aguarde","Por favor, espere"
9
- "Fechar","Cerrar"
10
- "Não método de entrega disponível","Disculpe, no hay método de envío disponible"
11
- "Alterar o Cep","Cambiar código postal"
12
- "Iniciando o Checkout Expresso do MercadoPago","Empezando con MercadoPago Express Checkout"
13
- "Enter your shipping information for the order #","Ingrese la información del envío para el pedido #"
14
- "Your order is now been processing","Su pedido está procesando"
15
- "Country where your account was created","Pais que su conta no MercadoPago fue creada"
16
- "Enabled","Activo"
17
- "Title","Nombre"
18
- "Chose how the checkout should be displayed","Elije la forma (en el modo convencional) de Checkout"
19
- "Show ShopCart Express Checkout button","Mostrar el botón de Express Checkout en la cesta de compra"
20
- "Show ShopCart Express Checkout Sidebar button","Mostrar el botón ExpressCheckout em la cesta lateral"
21
- "Show Express Checkout Product button","Mostrar el botón ExpressCheckout en cada produto"
22
- "Postal Code Request on Express Payment on Express Checkout","Solicite el código postal para calcular de envío"
23
- "Allow to change postal code after the order is paid on Express Payment on Express Checkout","Permitir al cliente cambiar el código postal después de que el pago ya efectuado por el Checkout Express"
24
- "Auto Create Invoice","Generar facturas automáticamente"
25
- "Currency to be paid","Elija la moneda"
26
- "URL to successful payment","URL de redireccionamiento si el pago ya ha sido aprobado"
27
- "URL for pendind payment","URL de redireccionamiento si el pago es pendiente"
28
- "Payment Methods what should be excluded","Seleccione los métodos de pago que MercadoPago ofrece que usted NO desea aceptar"
29
- "Choose the maximum number of installments accepted","Elija el número máximo de cuatas que deseja parcelar"
30
- "Choose the status of new orders","Elija el estado para nuevos pedidos"
31
- "Choose the status of approved orders","Elija el estado si el pago es aprobado"
32
- "Choose the status of refunded orders","Elija el estado si el pago es regresó"
33
- "Choose the status when payment is pending","Elija el estado si el pago es pendiente"
34
- "Choose the status when client open a mediation","Elija el estado si el pago es en disputa"
35
- "Choose the status when payment was reject","Elija el estado si el pago es rechazado"
36
- "Choose the status when payment was canceled","Elija el estado si el pago es cancelado"
37
- "Debug Mode","Modo de depuración"
38
- "Thank you for your purchase. Fill the address information for your order. ","Gracias por su compra. Ingrese la informacion de direccíon de su pedido. "
39
- "Complete your order shipping information","Necesitamos de mas informaciones del su pedido"
40
- "Thank you for your purchase. ","Gracias por su compra"
41
- "To complete your order, if is not done yet, fill the address information at the address below.""Para completar su pedido, llenar la información de su dirección en la siguiente dirección."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"
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
+ "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"
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 '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"
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 (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"
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
+ "Thank you for your purchase!","Gracias por su compra!"
74
+ "Your order %s has been successfully generated.","Su pedido con el numero %s fué generado con éxito."
75
+ "Done, your payment was accredited!","¡Listo, se acreditó tu pago!"
76
+ "We are processing the payment.","Estamos procesando el pago."
77
+ "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."
78
+ "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."
79
+
80
+ "Check the card number.","Revisa el número de la tarjeta."
81
+ "Check the expiration date.","Revisa la fecha de vencimiento."
82
+ "Check the data.","Revisa los datos."
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."
90
+ "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."
91
+ "Your %s do not have sufficient funds.","Tu %s no tiene fondos suficientes."
92
+ "%s does not process payments in %s installments.","%s no procesa pagos en %s cuotas."
93
+ "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."
94
+ "%s did not process the payment.","%s no procesó el pago."
95
+
96
+ "You can not make payments to users in other countries.","No puedes realizar pagos a usuarios de otros países."
97
+ "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."
98
+ "We could not process your payment. Error code: 126.","No pudimos procesar tu pago. Código de error: 126."
99
+ "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."
100
+ "We could not process your payment. Error code: 145.","No pudimos procesar tu pago. Código de error: 145"
101
+ "You can not make payments. Error code: 150.","No puedes realizar pagos. Código de error: 150."
102
+ "You can not make payments.","No puedes realizar pagos."
103
+ "We could not process your payment. Error code: 160.","No pudimos procesar tu pago. Código de error: 160."
104
+ "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."
105
+ "You made a similar payment moments ago. Try again in a few minutes.","Realizaste un pago similar hace instantes. Intenta nuevamente en unos minutos."
106
+ "We could not process your payment. %s","No pudimos procesar tu pago. %s"
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"
app/locale/es_MX/mercadopago.csv CHANGED
@@ -3,7 +3,7 @@
3
  "MercadoPago - Configuration", "MercadoPago - Configuración"
4
  "Credit Card - MercadoPago","Tarjetas de crédito - MercadoPago"
5
 
6
- "MercadoPago Transparent - Credit Card","MercadoPago 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"
@@ -15,7 +15,7 @@
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 Transparent - Ticket","MercadoPago Transparente - 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"
@@ -27,7 +27,7 @@
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 'MercadoPago - Configuration'",""Para el funcionamento del Checkout Transparente - 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"
@@ -43,13 +43,15 @@
43
  "Enter the card number","Digite el número de tarjeta"
44
  "Validating Data","Validando datos"
45
  "An error has occurred. Please refresh the page.","Ocurrio un error. Por favor, actualice la página."
46
- "Card Number is invalid.","Número de Tarjeta inválido."
47
  "CVV is invalid.","Código de Seguridad inválido."
48
  "Card Holder Name is invalid.","Nombre de titular de tarjeta inválido."
49
  "Document Number is invalid.","Número 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
 
54
  "Card Number: %s","Número de Tarjeta: %s"
55
  "Card Holder Name: %s","Titular de la Tarjeta: %s"
@@ -68,6 +70,9 @@
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."
@@ -117,4 +122,7 @@
117
 
118
  "$", "$"
119
  "Choice", "Elige"
120
- "Default issuer", "Cualquier otro banco"
 
 
 
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
  "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"
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
  "Payment Method", "Medio de pago"
43
  "Enter the card number","Digite el número de tarjeta"
44
  "Validating Data","Validando datos"
45
  "An error has occurred. Please refresh the page.","Ocurrio un error. Por favor, actualice la página."
46
+ "Card number is invalid.","Número de Tarjeta inválido."
47
  "CVV is invalid.","Código de Seguridad inválido."
48
  "Card Holder Name is invalid.","Nombre de titular de tarjeta inválido."
49
  "Document Number is invalid.","Número de Documento inválido."
50
+ "Document Type is invalid.","Tipo de Documento inválido."
51
  "Year is invalid.","Año inválido."
52
  "Month is invalid.","Mes inválido."
53
  "Please validate your data.","Por favor, valide los datos"
54
+ "Cannot pay this amount with this payment_method_id.","No se puede pagar esta monto con este medio de pago."
55
 
56
  "Card Number: %s","Número de Tarjeta: %s"
57
  "Card Holder Name: %s","Titular de la Tarjeta: %s"
70
  "Generate the ticket and pay it wherever you want.","Genere el ticket de pago y pague"
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!"
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."
122
 
123
  "$", "$"
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"
app/locale/pt_BR/mercadopago.csv ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"
10
+ "Choose the status of refunded orders", "Escolha o status dos pedidos para pagamentos Devolvidos"
11
+ "Choose the status when payment is pending", "Escolha o status dos pedidos para pagamentos Pendentes"
12
+ "Choose the status when client open a mediation", "Escolha o status dos pedidos para pagamentos que estão em Disputa"
13
+ "Choose the status when payment was reject", "Escolha o status dos pedidos para pagamentos Rejeitados"
14
+ "Choose the status when payment was canceled", "Escolha o status dos pedidos para pagamentos Cancelados"
15
+
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"
25
+ "Exclude Payment Methods","Excluir Meios de Pagamento"
26
+ "Maximum number of accepted installments","Numero maximo de parcelas"
27
+ "Width Checkout Iframe","Largura do Checkout Iframe (Width)"
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"
36
+ "Year", "Ano de vencimento"
37
+ "Card Holder Name", "Titular do cartão"
38
+ "Document Number", "CPF"
39
+ "CVV", "Código de segurança"
40
+ "Installments", "Parcelas"
41
+ "Banks", "Bancos"
42
+
43
+ "Enter the card number", "Digite o numero do cartão"
44
+ "Validating Data", "Validando dados"
45
+ "An error has occurred. Please refresh the page.", "Ocorreu um erro. Por favor, atualize a pagina."
46
+ "Card number is invalid.", "Numero do Cartão inválido."
47
+ "CVV is invalid.", "Código de Segurança inválido."
48
+ "Card Holder Name is invalid.", "Nome do titular do cartão inválido."
49
+ "Document Number is invalid.", "CPF inválido."
50
+ "Document Type is invalid.","Tipo de Documento inválido."
51
+ "Year is invalid.", "Ano inválido."
52
+ "Month is invalid.", "Mês inválido."
53
+ "Please validate your data.", "Dados incorretos, valide os dados. Por favor."
54
+ "Cannot pay this amount with this payment_method_id.","Não é possível pagar esse valor com essa forma de pagamento."
55
+ "It was not possible to calculate the installments, click here and try again.","Não foi possível calcular as parcelas, clique aqui e tente novamente."
56
+
57
+ "Discount coupon","Cupom de Desconto"
58
+ "Run Out of uses per user.","Cupom já utilizado."
59
+ "An error occurred while validating the coupon. Try again.", "Ocorreu um erro ao validar o cupom. Tente novamente."
60
+ "The coupon can not be applied to this amount.", "O cupom não pode ser aplicado para esse valor."
61
+ "Please enter a valid coupon code.","Digite um código de cupom válido."
62
+ "Exclusive discount","Desconto exclusivo do"
63
+ "You save %s with the exclusive discount","Você economizará %s com o desconto exclusivo do"
64
+ "Total of your purchase","Total da sua compra"
65
+ "Total of your purchase discount","Total da sua compra com desconto"
66
+ "Upon approval of payment","Mediante aprovação do pagamento"
67
+ "Terms and conditions","Termos e condições"
68
+ "Apply discount","Aplicar desconto"
69
+ "Remove discount","Remover desconto"
70
+
71
+
72
+
73
+ "Thank you for your purchase!","Obrigado pela sua Compra!"
74
+ "Your order %s has been successfully generated.","O seu pedido de numero %s foi gerado com sucesso."
75
+ "Payment information","Informações sobre o pagamento"
76
+ "Card Number: %s", "Número do cartão: %s"
77
+ "Card Holder Name: %s", "Titular do cartão: %s"
78
+ "Payment Method: %s", "Método de Pagamento: %s"
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"
86
+ "Generate Ticket", "Gerar Boleto"
87
+
88
+ "Payment Method", "Método de Pagamento"
89
+
90
+ "Generate the ticket and pay it wherever you want.", "Gere o boleto e pague-o onde quiser."
91
+ "Will be approved within 2 business days.","Será aprovado até 2 dias úteis."
92
+
93
+ "Done, your payment was accredited!", "O seu pagamento foi aprovado!"
94
+ "We are processing the payment.", "Estamos processando o pagamento."
95
+ "In less than 2 business days we will tell you by e-mail if it is accredited or if we need more information.", "Em menos de 2 dias úteis você será avisado por e-mail se foi creditado ou se precisarmos de mais informações."
96
+ "In less than an hour we will send you by e-mail the result.", "Em menos de 1 hora, nós enviaremos o resultado por e-mail."
97
+
98
+ "Check the card number.", "Verifique o número do cartão."
99
+ "Check the expiration date.", "Verifique a data de validade."
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."
107
+ "Your payment was rejected.<br/>Choose another payment method, we recommend cash methods.", "O seu pagamento foi recusado.<br/>Recomendamos que você pague com outro dos meios de pagamento oferecidos, preferencialmente à vista."
108
+ "Your %s do not have sufficient funds.", "O seu %s não tem limite suficiente."
109
+ "%s does not process payments in %s installments.", "%s não processa pagamentos em %s parcelas."
110
+ "You have got to the limit of allowed attempts.<br/>Choose another card or another payment method.", "Você atingiu o limite de tentativas permitidas.<br/>Use outro cartão ou outro meio de pagamento."
111
+ "%s did not process the payment.", "%s não processou o pagamento."
112
+
113
+ "You can not make payments to users in other countries.", "Você não pode fazer pagamentos para usuários em outros países."
114
+ "Payment Method selected does not process payments in installments selected. Choose another card or another payment method.", "O meio de pagamento selecionado não processa pagamentos as parcelas selecionadas. Use outro cartão ou outro meio de pagamento."
115
+ "We could not process your payment. Error code: 126.", "Não foi possível processar o pagamento. Erro de numero: 126."
116
+ "Payment Method selected does not process payments for the selected amount. Choose another card or another payment method.", "O meio de pagamento selecionado não processa pagamentos do valor selecionado. Use outro cartão ou outro meio de pagamento."
117
+ "We could not process your payment. Error code: 145.", "Não foi possível processar o pagamento. Erro de numero: 145."
118
+ "You can not make payments. Error code: 150.", "Você não pode fazer pagamentos. Erro de numero: 150."
119
+ "You can not make payments.", "Você não pode fazer pagamentos com esse meio de pagamento."
120
+ "We could not process your payment. Error code: 160.", "Não foi possível processar o pagamento. Erro de numero: 160."
121
+ "Payment Method selected is not available at this time. Choose another card or another payment method.", "O meio de pagamento selecionado não está disponível neste momento. Use outro cartão ou outro meio de pagamento."
122
+ "You made a similar payment moments ago. Try again in a few minutes.", "Você realizou um pagamento similar há pouco tempo. Tente novamente em alguns minutos."
123
+ "We could not process your payment. %s", "Não foi possível processar o pagamento. %s"
124
+
125
+ "Verify the form data or wait until the validation of the payment data", "Verifique os dados do formulario ou aguarde a validação dos dados de pagamento."
126
+ "Doesn't find a campaign with the given code.","Cupom inválido."
127
+
128
+ "Payments were canceled.","O pagamento foi cancelado."
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"
142
+
143
+ "Order # %s in store %s","Pedido # %s realizado na loja %s"
144
+
145
+ "$", "R$"
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"
js/mercadopago/mercadopago.js CHANGED
@@ -9,32 +9,43 @@ function loadJsAsync(url, callback) {
9
  head.appendChild(script);
10
  }
11
 
 
 
 
 
 
 
 
12
  loadJsAsync("//code.jquery.com/jquery-1.11.0.min.js", function () {
13
- console.log("jQuery Running ...");
14
  $.noConflict();
 
15
  loadJsAsync("https://secure.mlstatic.com/org-img/checkout/custom/1.0/checkout.js?nocache=" + Math.random() * 10, function () {
16
- console.log("MercadoPago Running ...");
17
- Checkout.setPublishableKey(PublicKeyMercadoPagoTransparent);
18
- //end load mp
19
- });
20
 
21
- //end load js
22
- });
23
 
24
 
25
  function loadFilesMP() {
26
- loadJsAsync("//code.jquery.com/jquery-1.11.0.min.js", function () {
27
  $.noConflict();
28
  jQuery(document).ready(function ($) {
 
 
 
 
29
 
30
  //variables translates
31
- var currency_text_mercadopago = $("#mercadopago-text-currency").html();
32
- var choice_text_mercadopago = $("#mercadopago-text-choice").html();
33
- var default_issuer_text_mercadopago = $("#mercadopago-text-default-issuer").html();
34
 
35
 
36
- //hide loading
37
- $("#status").hide();
38
 
39
  //caso tenha alteração no campo de banco
40
  $("#issuers").change(function(){
@@ -47,7 +58,7 @@ function loadFilesMP() {
47
  Checkout.getInstallmentsByIssuerId(
48
  bin,
49
  this.value,
50
- parseFloat($("#amount").val()),
51
  setInstallmentInfo
52
  );
53
 
@@ -55,50 +66,77 @@ function loadFilesMP() {
55
 
56
  //caso o cartão copie e cole
57
  $("input[data-checkout='cardNumber']").focusout(function () {
58
- var card = $(this).val().replace(/ /g, '').replace(/-/g, '').replace(/\./g, '');
59
- var bin = card.substr(0,6);
60
- getBin(bin);
61
  });
62
 
63
  //pega o bin enquanto digita
64
  $("input[data-checkout='cardNumber']").bind("keyup", function () {
65
- var bin = $(this).val().replace(/ /g, '').replace(/-/g, '').replace(/\./g, '');
66
- getBin(bin);
67
- });
68
-
69
- $("#mp-form input").focusout(function () {
70
- validCreateToken();
71
  });
72
 
73
- $("#mp-form select").change(function () {
74
- validCreateToken();
75
- });
76
-
77
-
78
- function getBin(bin){
79
- if (bin.length == 6) {
80
- if ($("#mercadopago-country").html() == 'mlm') {
81
- Checkout.getPaymentMethod(bin, parseFloat($("#amount").val()), setPaymentMethodInfo, $('#payment_method option:checked').val());
82
- }else{
83
- Checkout.getPaymentMethod(bin, setPaymentMethodInfo);
 
 
84
  }
 
 
85
  }
 
86
  }
87
 
88
  function setPaymentMethodInfo(status, result){
89
- var method_payment = result[0];
90
-
91
- //adiciona a imagem do meio de pagamento
92
- $("#img_payment_method").html('<img src="' + method_payment.secure_thumbnail + '">')
93
-
94
- //setta o meio de pagamento
95
- $("#payment_method").val(method_payment.id);
96
 
97
- //lista parcelas
98
- Checkout.getInstallments(method_payment.id, parseFloat($("#amount").val()), setInstallmentInfo);
99
- Checkout.getCardIssuers(method_payment.id, showIssuers);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
 
 
 
 
 
 
 
 
102
  function validCreateToken(){
103
 
104
  var valid = true;
@@ -112,14 +150,19 @@ function loadFilesMP() {
112
 
113
  //caso o documento seja CPF, faz a validação em um função especifica
114
  if($("#docType").val() == "CPF"){
 
 
 
 
115
  if(validCpf($(this).val())){
116
- $("#status").hide();
 
117
  }else{
 
 
118
  valid = false;
119
- //hide all msg status
120
- $(".msg-status").hide();
121
  $(".error-324").show();
122
- showError();
123
  }
124
  }
125
  }
@@ -134,73 +177,61 @@ function loadFilesMP() {
134
  });
135
 
136
  if (valid) {
 
137
 
138
  //hide all msg status
139
- $(".msg-status").hide();
140
-
141
- //remove erro class
142
- $("#status").removeClass("msg-error");
143
-
144
- //add msg e mostra o loading
145
- $("#status").show();
146
- $("#status .loading-mp").show();
147
-
148
- //show span loading
149
- $("#status .text-mp .msg-loading").show();
150
 
 
 
151
 
 
152
  var $form = $("#mp-form");
153
 
154
  Checkout.createToken($form, function (status, response) {
155
- removeClass();
 
 
156
  var html = ""
157
  if (status == 200 || status == 201) {
158
- $("#status .status-mp").hide();
 
159
  $("#card_token_id").val(response.id);
160
  $("#trunc_card").val(response.trunc_card_number);
161
- $("#status").hide();
162
  }else{
163
 
164
  $.each(response.cause, function(p, e){
165
-
 
166
  //mapea os erros
167
  switch (e.code) {
168
  case "011":
169
  case "E301":
170
  case "E302":
171
  case "316":
 
172
  case "324":
173
  case "325":
174
  case "326":
175
- $(".error-" + e.code).show();
176
  break;
177
  default:
178
- $(".error-other").show();
179
  }
180
 
181
- showError();
 
182
  });
183
 
184
  }
185
 
186
  //hide loading
187
- $("#status .text-mp .msg-loading").hide();
188
- $("#status .loading-mp").hide();
189
 
190
  });
191
-
192
-
193
-
194
  }
195
  }
196
-
197
-
198
- function showError() {
199
- $("#status .loading-mp").hide();
200
- $("#status").show();
201
- $("#status").addClass("msg-error");
202
- $("#card_token_id").val("");
203
- }
204
 
205
  function validCpf(cpf){
206
  var soma;
@@ -237,24 +268,152 @@ function loadFilesMP() {
237
  }
238
  }
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  //setta parcelas
241
  function setInstallmentInfo(status, installments){
 
 
 
 
 
242
 
243
  var html_options = '<option value="">' + choice_text_mercadopago + '... </option>';
244
  for(i=0; installments && i<installments.length; i++){
245
- 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>";
 
 
246
  };
247
  $("#installments").html(html_options);
248
  }
249
 
250
- function showIssuers(status, issuers){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
  //caso tenha apenas um registro, pega o valor dele e setta em um input escondido
253
  if (issuers.length == 1) {
 
254
  var input_issuers = '<input type="text" name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off" value="' + issuers[0].id + '">';
255
  $("#issuers").html(input_issuers);
256
  $("#issuersOptions").hide();
257
- }else{
258
 
259
  var options = '<select name="payment[issuers]" id="issuers" data-checkout="issuers" class="input-text" autocomplete="off">'
260
  options += '<option value="-1">' + choice_text_mercadopago + '...</option>';
@@ -278,17 +437,127 @@ function loadFilesMP() {
278
  $("#issuersOptions").hide();
279
  }
280
  }
281
- }
282
 
283
- function removeClass(){
284
- //remove as class
285
- $("#status").removeClass("msg-error");
286
- $("#status").removeClass("msg-success");
287
- $("#status").removeClass("msg-alert");
288
- }
289
- //end load ready
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  });
291
  //end load js
292
- });
293
 
294
- }
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(){
58
  Checkout.getInstallmentsByIssuerId(
59
  bin,
60
  this.value,
61
+ parseFloat($form_custom_payment.find(".amount").val()),
62
  setInstallmentInfo
63
  );
64
 
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;
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
  }
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;
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>';
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
+ }
lib/mercadopago/mercadopago.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * MercadoPago Integration Library
5
  * Access MercadoPago for payments integration
@@ -7,20 +6,32 @@
7
  * @author hcasatti
8
  *
9
  */
10
- $GLOBALS["LIB_LOCATION"] = dirname(__FILE__);
11
 
12
  class MP {
13
 
14
- const version = "0.2.1";
15
 
16
  private $client_id;
17
  private $client_secret;
 
18
  private $access_data;
19
  private $sandbox = FALSE;
20
 
21
- function __construct($client_id, $client_secret) {
22
- $this->client_id = $client_id;
23
- $this->client_secret = $client_secret;
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  public function sandbox_mode($enable = NULL) {
@@ -35,34 +46,27 @@ class MP {
35
  * Get Access Token for API use
36
  */
37
  public function get_access_token() {
 
 
 
 
38
  $app_client_values = $this->build_query(array(
39
  'client_id' => $this->client_id,
40
  'client_secret' => $this->client_secret,
41
  'grant_type' => 'client_credentials'
42
- ));
43
 
44
  $access_data = MPRestClient::post("/oauth/token", $app_client_values, "application/x-www-form-urlencoded");
45
 
 
 
 
 
46
  $this->access_data = $access_data['response'];
47
 
48
  return $this->access_data['access_token'];
49
  }
50
 
51
- /**
52
- * Get information for specific merchant_order
53
- * @param int $id
54
- * @return array(json)
55
- */
56
-
57
- public function get_merchant_order($id){
58
-
59
- $access_token = $this->get_access_token();
60
-
61
- $merchant_order = MPRestClient::get("/merchant_orders/" . $id . "?access_token=" . $access_token);
62
-
63
- return $merchant_order;
64
- }
65
-
66
  /**
67
  * Get information for specific payment
68
  * @param int $id
@@ -222,21 +226,20 @@ class MP {
222
  return $preapproval_payment_result;
223
  }
224
 
225
- /**
226
  * Update a preapproval payment
227
  * @param string $preapproval_payment, $id
228
  * @return array(json)
229
- */
230
-
231
- public function update_preapproval_payment($id, $preapproval_payment) {
232
  $access_token = $this->get_access_token();
233
 
234
  $preapproval_payment_result = MPRestClient::put("/preapproval/" . $id . "?access_token=" . $access_token, $preapproval_payment);
235
  return $preapproval_payment_result;
236
  }
237
-
238
 
239
- /**
240
  * Create a custon payment
241
  * @param array $preference
242
  * @return array(json)
@@ -247,8 +250,96 @@ class MP {
247
  $preference_result = MPRestClient::post("/checkout/custom/create_payment?access_token=" . $access_token, $info);
248
  return $preference_result;
249
  }
250
-
251
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  /* **************************************************************************************** */
253
 
254
  private function build_query($params) {
@@ -270,12 +361,16 @@ class MP {
270
  */
271
  class MPRestClient {
272
 
273
- const API_BASE_URL = "https://api.mercadolibre.com";
274
 
275
  private static function get_connect($uri, $method, $content_type) {
 
 
 
 
276
  $connect = curl_init(self::API_BASE_URL . $uri);
277
 
278
- curl_setopt($connect, CURLOPT_USERAGENT, "MercadoPago Magento-1.9.x-transparent Cart v1.0.1");
279
  curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
280
  curl_setopt($connect, CURLOPT_CUSTOMREQUEST, $method);
281
  curl_setopt($connect, CURLOPT_HTTPHEADER, array("Accept: application/json", "Content-Type: " . $content_type));
@@ -311,13 +406,28 @@ class MPRestClient {
311
  $api_result = curl_exec($connect);
312
  $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
313
 
 
 
 
 
314
  $response = array(
315
  "status" => $api_http_code,
316
  "response" => json_decode($api_result, true)
317
  );
318
 
319
  /*if ($response['status'] >= 400) {
320
- throw new Exception ($response['response']['message'], $response['status']);
 
 
 
 
 
 
 
 
 
 
 
321
  }*/
322
 
323
  curl_close($connect);
@@ -337,6 +447,7 @@ class MPRestClient {
337
  return self::exec("PUT", $uri, $data, $content_type);
338
  }
339
 
 
 
 
340
  }
341
-
342
- ?>
1
  <?php
 
2
  /**
3
  * MercadoPago Integration Library
4
  * Access MercadoPago for payments integration
6
  * @author hcasatti
7
  *
8
  */
 
9
 
10
  class MP {
11
 
12
+ const version = "0.3.3";
13
 
14
  private $client_id;
15
  private $client_secret;
16
+ private $ll_access_token;
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");
25
+ }
26
+
27
+ if ($i == 1) {
28
+ $this->ll_access_token = func_get_arg(0);
29
+ }
30
+
31
+ if ($i == 2) {
32
+ $this->client_id = func_get_arg(0);
33
+ $this->client_secret = func_get_arg(1);
34
+ }
35
  }
36
 
37
  public function sandbox_mode($enable = NULL) {
46
  * Get Access Token for API use
47
  */
48
  public function get_access_token() {
49
+ if (isset ($this->ll_access_token) && !is_null($this->ll_access_token)) {
50
+ return $this->ll_access_token;
51
+ }
52
+
53
  $app_client_values = $this->build_query(array(
54
  'client_id' => $this->client_id,
55
  'client_secret' => $this->client_secret,
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']);
63
+ }
64
+
65
  $this->access_data = $access_data['response'];
66
 
67
  return $this->access_data['access_token'];
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  /**
71
  * Get information for specific payment
72
  * @param int $id
226
  return $preapproval_payment_result;
227
  }
228
 
229
+ /**
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)
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
+
265
+ if ($authenticate !== false) {
266
+ $access_token = $this->get_access_token();
267
+
268
+ $params["access_token"] = $access_token;
269
+ }
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
+
289
+ $access_token = $this->get_access_token();
290
+ $params["access_token"] = $access_token;
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
+
310
+ $access_token = $this->get_access_token();
311
+ $params["access_token"] = $access_token;
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
+
331
+ $access_token = $this->get_access_token();
332
+ $params["access_token"] = $access_token;
333
+
334
+ if (count($params) > 0) {
335
+ $uri .= (strpos($uri, "?") === false) ? "?" : "&";
336
+ $uri .= $this->build_query($params);
337
+ }
338
+
339
+ $result = MPRestClient::delete($uri);
340
+ return $result;
341
+ }
342
+
343
  /* **************************************************************************************** */
344
 
345
  private function build_query($params) {
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));
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);
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
  }
 
 
package.xml CHANGED
@@ -1,25 +1,29 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MercadoPagoTransparent</name>
4
- <version>0.0.2</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>MercadoPago payment extension for Magento: receive payments with our customizable checkout</summary>
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>fix function that takes the value of the product (final value)</notes>
 
 
 
 
19
  <authors><author><name>Developers MercadoPago Brasil</name><user>developers_mercadopago</user><email>developers@mercadopago.com.br</email></author></authors>
20
- <date>2015-04-27</date>
21
- <time>18:42:38</time>
22
- <contents><target name="magecommunity"><dir name="MercadoPago"><dir name="Standard"><dir name="Block"><file name="Form.php" hash="9bdf1f52cf6a679b44f3722caec66f6a"/><file name="Info.php" hash="21aac16dbe66bc09af3a9de47f76a1b5"/></dir><dir name="Helper"><file name="Data.php" hash="710ec99ea6abea4cf734aa914c85b85b"/></dir><dir name="Model"><file name="Checkout.php" hash="2b097c85c5098d9ff1f4b9cd326c0fb8"/><file name="Observer.php" hash="cb21534771553ef3aed3ea3e2de26f27"/><dir name="Source"><file name="CategoryId.php" hash="5f3ff392848a53c2fa6603c963ae82b5"/><file name="Country.php" hash="c16df06c2007393db005ea79213ee05e"/><file name="Installments.php" hash="2fae68dbabad4c1eef8b834c90dd0b96"/><file name="PaymentMethods.php" hash="ab8008e14838f77491db3b8d15f50ef3"/><file name="TypeCheckout.php" hash="d8b1d8eed83a019a6c21a417fb05ce6a"/></dir></dir><dir name="controllers"><file name="NotificationController.php" hash="99de23a5c9aa3badf03c239686696061"/><file name="PayController.php" hash="e8493b2ef86bd99ef86989861e82ba86"/></dir><dir name="etc"><file name="config.xml" hash="44f0473a9ecb35d9ba6e4f7a0232cbc9"/><file name="system.xml" hash="4227fb788f898b1785d0fb15da65b2fe"/></dir></dir><dir name="Transparent"><dir name="Block"><file name="Form.php" hash="2d74865fe22dba4437209181af6858a1"/><file name="Info.php" hash="32adfbd59dc2f7b8a97a5a778e2c66d5"/><file name="Success.php" hash="a85361ea7af2adf623ea967d297d1545"/><file name=".DS_Store" hash="2074c5a443aba7e611980b76135fd198"/></dir><dir name="Helper"><file name="Data.php" hash="93f79cb3b534e05e8d4576916aaba2e0"/></dir><dir name="Model"><dir name="Resource"><file name="Setup.php" hash="0878b25e586a30e84d308b45e3b82af4"/></dir><dir name="Source"><file name="CategoryId.php" hash="d62071499f4815e3e4244c851aad8fbe"/></dir><file name="Transparent.php" hash="52973d870c2c8df0c3206438bedda707"/><file name=".DS_Store" hash="beeba7d5cb9298ed5ca24b7cb3b6f70a"/></dir><dir name="controllers"><file name="NotificacaoController.php" hash="fcc18d169285346a7548e3a79de84ee0"/><file name="PayController.php" hash="a0b0b0b9695581e2011f29b6767b26b3"/></dir><dir name="etc"><file name="config.xml" hash="4dc111452c4403c22e2d5e2be6b276e6"/><file name="system.xml" hash="52b4e773795bc29f7588aaf2b1343155"/></dir><file name=".DS_Store" hash="16eff6348e7c6882d4e9c990c14eb34a"/></dir><dir name="TransparentTicket"><dir name="Block"><file name="Form.php" hash="c7332ee1427371d7ec6495b8e7d2ea55"/><file name="Info.php" hash="3fad7f5cf0e9f3e2c45cb3084e9abf0c"/></dir><dir name="Helper"><file name="Data.php" hash="0cb47ec830a90247ab08a55c2826698d"/></dir><dir name="Model"><file name="Transparent.php" hash="524b905aba91c740b833b4f6055a42b6"/></dir><dir name="etc"><file name="config.xml" hash="ed7b309497f8bd92220776e6c093ae9f"/><file name="system.xml" hash="1829c574575e26926738e7447cef735e"/></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mercadopago"><dir name="standard"><file name="info.phtml" hash="bbf59a7a5da905777001128af6c62fb5"/></dir><dir name="transparent"><file name="info.phtml" hash="5df93a3c76af32912fd0806035e758f4"/></dir><dir name="transparent_boleto"><file name="info.phtml" hash="e02cd75cf7831044c1ba4f123418d692"/></dir><dir name="transparent_ticket"><file name="info.phtml" hash="42b77943bbc3e159d9208fbdf47e8243"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="mercadopago"><file name="clean_page.phtml" hash="1f45b4c91be19a384591cb04b2d11805"/><dir name="standard"><file name="form.phtml" hash="804a6cf27cb502749ba71e2ae48507e6"/><file name="info.phtml" hash="a5d8b4ecf65495c12579027a38148368"/><file name="pay.phtml" hash="13091e8ed10cafa4e9de391e1285a234"/></dir><dir name="transparent"><file name="form.phtml" hash="9f9aad246f1767c024c4bbd6579c35e4"/><file name="info.phtml" hash="5df93a3c76af32912fd0806035e758f4"/><file name="success.phtml" hash="62b670733cfedc11dd280c63be1a7161"/><file name="sucesso.phtml" hash="fbfa9d4f2c32a43d301cac7d1418dd40"/></dir><dir name="transparent_boleto"><file name="form.phtml" hash="4dca920aea45d0b211bbf5ee65d95f4e"/><file name="info.phtml" hash="64a3f25e28237be5eaf77c277547da42"/></dir><dir name="transparent_ticket"><file name="form.phtml" hash="17e3ea654229c5f96940f7e7748ca1a8"/><file name="info.phtml" hash="972315ee71242cd527d468e537c2f3f7"/></dir></dir></dir><dir name="layout"><file name="mercadopago.xml" hash="69e3f318b680d1332ea226887ae3ad40"/></dir></dir></dir></dir></target><target name="magelib"><dir name="mercadopago"><file name="mercadopago.php" hash="7d4620c0f68bda77bde9790a7f566ff4"/></dir></target><target name="magelocale"><dir name="es_AR"><file name="mercadopago.csv" hash="db2db0c4f635fda9efde0eceea20597d"/></dir><dir name="es_CO"><file name="mercadopago.csv" hash="096ca1c8dd9ed626f9b9eb7b9dcbc00c"/></dir><dir name="es_ES"><file name="mercadopago.csv" hash="04187abbece8cea73b6d113e952d5592"/></dir><dir name="es_MX"><file name="mercadopago.csv" hash="838605dee2f14e4a79a0f7ca0f622263"/></dir><dir name="es_BR"><file name="mercadopago.csv" hash=""/></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="5b44c857924de425d6a5942d98880b89"/></dir><dir name="images"><file name="loading.gif" hash="5c43434f066c2fbc4714c768b8f83853"/></dir><file name=".DS_Store" hash="fc730dea33a1da421ae6af1247e8468d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MercadoPago_Standard.xml" hash="4f582192168ac08a0dedf19b049503f9"/><file name="MercadoPago_Transparent.xml" hash="fb32c46f0b74fa2b5722b59bd627c621"/><file name="MercadoPago_TransparentTicket.xml" hash="cccc9919309346b38b754582bc1526e7"/></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="c9fd0b5b94ad9c9234c8fa6827ff223b"/></dir></dir></target></contents>
23
  <compatible/>
24
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
25
  </package>
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>
8
  <extends/>
9
  <summary>MercadoPago payment extension for Magento: receive payments with our customizable checkout</summary>
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>
skin/frontend/base/default/mercadopago/.DS_Store DELETED
Binary file
skin/frontend/base/default/mercadopago/css/style.css CHANGED
@@ -4,6 +4,14 @@
4
  *
5
  */
6
 
 
 
 
 
 
 
 
 
7
  .sp-methods .form-list.mercadopago{
8
  padding:0 !important;
9
  }
@@ -49,10 +57,13 @@
49
  margin: 0 0 10px 0;
50
  }
51
 
 
 
52
  #docType{
53
  width: 60px;
54
  }
55
 
 
56
  #installments{
57
  margin: 0 0 5px 0;
58
  }
@@ -219,4 +230,60 @@ p.msg-status{
219
 
220
 
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  }
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
  }
230
 
231
 
232
 
233
+ #mercadopago-loading{
234
+ display: none;
235
+ margin: -5px 0 10px 0;
236
+ float: left;
237
+ width: 100%;
238
+ }
239
+ .msg-status{
240
+ display: none;
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{
250
+ display: none;
251
+ }
252
+
253
+ .mercadopago-coupon-action-apply, .mercadopago-coupon-action-remove{
254
+ cursor: pointer;
255
+ float: left;
256
+ font-size: 10px;
257
+ text-transform: uppercase;
258
+ }
259
+
260
+ .mercadopago-coupon-action-remove{
261
+ display: none;
262
+ }
263
+
264
+ .mercadopago-message-coupon p{
265
+ margin: 0 0 0 0;
266
+ }
267
 
268
+ .mercadopago-focus{
269
+ color: #004098;
270
+ font-family: arial;
271
+ font-weight: bold;
272
+ }
273
+
274
+ .discount-ok{
275
+ padding: 10px;
276
+ border: 1px solid #cecece;
277
+ background-color: #F0F0F0;
278
+ float: left;
279
+ }
280
+ .error-installment-not-work{
281
+ cursor: pointer;
282
+ }
283
+
284
+ .mercadopago-info-discount li{
285
+ display: block !important;
286
+ float: left;
287
+ width: 100%;
288
+ margin: 0 !important;
289
+ }