WooCommerce MercadoPago - Version 3.0.5

Version Description

Download this release

Release Info

Developer mercadopago
Plugin Icon 128x128 WooCommerce MercadoPago
Version 3.0.5
Comparing to
See all releases

Code changes from version old.2.0.4 to 3.0.5

Files changed (129) hide show
  1. README.txt +0 -187
  2. assets/css/custom_checkout_mercadopago.css +161 -13
  3. {images → assets/images}/MCO/CUPOM_MCO.jpg +0 -0
  4. {images → assets/images}/MCO/MCO.png +0 -0
  5. {images → assets/images}/MCO/banner_all_methods.png +0 -0
  6. {images → assets/images}/MCO/credit_card.png +0 -0
  7. {images → assets/images}/MCO/standard_mco.jpg +0 -0
  8. {images → assets/images}/MLA/CUPOM_MLA.jpg +0 -0
  9. {images → assets/images}/MLA/MLA.png +0 -0
  10. {images → assets/images}/MLA/banner_all_methods.png +0 -0
  11. {images → assets/images}/MLA/credit_card.png +0 -0
  12. {images → assets/images}/MLA/standard_mla.jpg +0 -0
  13. {images → assets/images}/MLB/CUPOM_MLB.jpg +0 -0
  14. {images → assets/images}/MLB/MLB.png +0 -0
  15. {images → assets/images}/MLB/banner_all_methods.png +0 -0
  16. {images → assets/images}/MLB/credit_card.png +0 -0
  17. {images → assets/images}/MLB/cupom1.jpg +0 -0
  18. {images → assets/images}/MLB/cupom2.jpg +0 -0
  19. {images → assets/images}/MLB/cupom3.jpg +0 -0
  20. {images → assets/images}/MLB/desconto_MLB.jpg +0 -0
  21. {images → assets/images}/MLB/standard_mlb.jpg +0 -0
  22. {images → assets/images}/MLC/CUPOM_MLC.jpg +0 -0
  23. {images → assets/images}/MLC/MLC.png +0 -0
  24. {images → assets/images}/MLC/banner_all_methods.png +0 -0
  25. {images → assets/images}/MLC/credit_card.png +0 -0
  26. {images → assets/images}/MLC/standard_mlc.gif +0 -0
  27. {images → assets/images}/MLM/CUPOM_MLM.jpg +0 -0
  28. {images → assets/images}/MLM/MLM.png +0 -0
  29. {images → assets/images}/MLM/banner_all_methods.png +0 -0
  30. {images → assets/images}/MLM/credit_card.png +0 -0
  31. {images → assets/images}/MLM/standard_mlm.jpg +0 -0
  32. images/MPE/CUPOM_MPE.png → assets/images/MLU/CUPOM_MLU.png +0 -0
  33. assets/images/MLU/MLU.png +0 -0
  34. {images/MPE → assets/images/MLU}/banner_all_methods.png +0 -0
  35. {images/MPE → assets/images/MLU}/credit_card.png +0 -0
  36. images/MPE/standard_mpe.png → assets/images/MLU/standard_mlu.png +0 -0
  37. {images → assets/images}/MLV/CUPOM_MLV.jpg +0 -0
  38. {images → assets/images}/MLV/MLV.png +0 -0
  39. {images → assets/images}/MLV/banner_all_methods.png +0 -0
  40. {images → assets/images}/MLV/credit_card.png +0 -0
  41. {images → assets/images}/MLV/standard_mlv.jpg +0 -0
  42. assets/images/MPE/CUPOM_MPE.png +0 -0
  43. {images → assets/images}/MPE/MPE.png +0 -0
  44. assets/images/MPE/banner_all_methods.png +0 -0
  45. assets/images/MPE/credit_card.png +0 -0
  46. assets/images/MPE/standard_mpe.png +0 -0
  47. {images → assets/images}/bandeiras/amex.png +0 -0
  48. {images → assets/images}/bandeiras/boleto.png +0 -0
  49. {images → assets/images}/bandeiras/cash.png +0 -0
  50. {images → assets/images}/bandeiras/diners.png +0 -0
  51. {images → assets/images}/bandeiras/elo.png +0 -0
  52. {images → assets/images}/bandeiras/hipercard.png +0 -0
  53. {images → assets/images}/bandeiras/master.png +0 -0
  54. {images → assets/images}/bandeiras/melicard.png +0 -0
  55. {images → assets/images}/bandeiras/visa.png +0 -0
  56. {images → assets/images}/banner.png +0 -0
  57. {images → assets/images}/bar_code.png +0 -0
  58. {images → assets/images}/boleto.png +0 -0
  59. assets/images/cart.png +0 -0
  60. {images → assets/images}/check.png +0 -0
  61. {images → assets/images}/credit_card.png +0 -0
  62. {images → assets/images}/cvv.png +0 -0
  63. {images → assets/images}/error.png +0 -0
  64. {images → assets/images}/loading.gif +0 -0
  65. {images → assets/images}/mercadopago.png +0 -0
  66. {images → assets/images}/mplogo.png +0 -0
  67. {images → assets/images}/warning.png +0 -0
  68. assets/js/credit-card.js +1085 -0
  69. assets/js/ticket.js +591 -0
  70. i18n/languages/woocommerce-mercadopago-es_AR.mo +0 -0
  71. i18n/languages/woocommerce-mercadopago-es_AR.po +1010 -0
  72. i18n/languages/woocommerce-mercadopago-es_CL.mo +0 -0
  73. i18n/languages/woocommerce-mercadopago-es_CL.po +1010 -0
  74. i18n/languages/woocommerce-mercadopago-es_CO.mo +0 -0
  75. i18n/languages/woocommerce-mercadopago-es_CO.po +1010 -0
  76. i18n/languages/woocommerce-mercadopago-es_ES.mo +0 -0
  77. i18n/languages/woocommerce-mercadopago-es_ES.po +1010 -0
  78. i18n/languages/woocommerce-mercadopago-es_MX.mo +0 -0
  79. i18n/languages/woocommerce-mercadopago-es_MX.po +1010 -0
  80. i18n/languages/woocommerce-mercadopago-es_PE.mo +0 -0
  81. i18n/languages/woocommerce-mercadopago-es_PE.po +1010 -0
  82. i18n/languages/woocommerce-mercadopago-es_UY.mo +0 -0
  83. i18n/languages/woocommerce-mercadopago-es_UY.po +1010 -0
  84. i18n/languages/woocommerce-mercadopago-es_VE.mo +0 -0
  85. i18n/languages/woocommerce-mercadopago-es_VE.po +1010 -0
  86. i18n/languages/woocommerce-mercadopago-pt_BR.mo +0 -0
  87. i18n/languages/woocommerce-mercadopago-pt_BR.po +1010 -0
  88. i18n/languages/woocommerce-mercadopago.pot +1010 -0
  89. includes/WC_WooMercadoPago_BasicGateway.php +1477 -0
  90. includes/WC_WooMercadoPago_CustomGateway.php +1337 -0
  91. includes/WC_WooMercadoPago_SubscriptionGateway.php +1133 -0
  92. includes/WC_WooMercadoPago_TicketGateway.php +1297 -0
  93. includes/admin/class-wc-mercadoenvios-admin-orders.php +94 -0
  94. includes/class-wc-product-mp_recurrent.php +210 -0
  95. {mercadopago → includes}/sdk/lib/cacert.pem +0 -0
  96. includes/sdk/lib/mercadopago.php +1245 -0
  97. includes/shipment/abstract-wc-mercadoenvios-shipping.php +355 -0
  98. includes/shipment/class-wc-mercadoenvios-package.php +257 -0
  99. includes/shipment/class-wc-mercadoenvios-shipping-express.php +35 -0
  100. includes/shipment/class-wc-mercadoenvios-shipping-normal.php +35 -0
  101. languages/woocommerce-mercadopago-module-es_AR.mo +0 -0
  102. languages/woocommerce-mercadopago-module-es_AR.po +0 -703
  103. languages/woocommerce-mercadopago-module-es_CL.mo +0 -0
  104. languages/woocommerce-mercadopago-module-es_CL.po +0 -703
  105. languages/woocommerce-mercadopago-module-es_CO.mo +0 -0
  106. languages/woocommerce-mercadopago-module-es_CO.po +0 -703
  107. languages/woocommerce-mercadopago-module-es_ES.mo +0 -0
  108. languages/woocommerce-mercadopago-module-es_ES.po +0 -703
  109. languages/woocommerce-mercadopago-module-es_MX.mo +0 -0
  110. languages/woocommerce-mercadopago-module-es_MX.po +0 -703
  111. languages/woocommerce-mercadopago-module-es_PE.mo +0 -0
  112. languages/woocommerce-mercadopago-module-es_PE.po +0 -703
  113. languages/woocommerce-mercadopago-module-es_VE.mo +0 -0
  114. languages/woocommerce-mercadopago-module-es_VE.po +0 -703
  115. languages/woocommerce-mercadopago-module-pt_BR.mo +0 -0
  116. languages/woocommerce-mercadopago-module-pt_BR.po +0 -695
  117. languages/woocommerce-mercadopago-module.pot +0 -701
  118. mercadopago-module.php +0 -128
  119. mercadopago/css/woo-mercadopago-module.css +0 -14
  120. mercadopago/mercadopago-custom-gateway.php +0 -1089
  121. mercadopago/mercadopago-gateway.php +0 -981
  122. mercadopago/mercadopago-ticket-gateway.php +0 -833
  123. mercadopago/sdk/lib/mercadopago.php +0 -677
  124. readme.txt +306 -0
  125. templates/credit-card/payment-form.php +1264 -817
  126. templates/mp_main_settings.php +386 -0
  127. templates/ticket/ticket-form.php +815 -66
  128. templates/woocommerce-altas.html +498 -0
  129. woocommerce-mercadopago.php +1202 -0
README.txt DELETED
@@ -1,187 +0,0 @@
1
- === Woo Mercado Pago Module Oficial ===
2
- Contributors: mercadopago, mercadolivre
3
- Donate link: https://www.mercadopago.com.br/developers/
4
- Tags: ecommerce, mercadopago, woocommerce
5
- Requires at least: WooCommerce 2.1.x
6
- Tested up to: WooCommerce 2.5.x
7
- Stable tag: 2.0.4
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- This is the oficial module of Mercado Pago for WooCommerce plugin.
12
-
13
- == Description ==
14
-
15
- This module enables WooCommerce to use Mercado Pago as a payment Gateway for purchases made in your e-commerce store.
16
-
17
- = Why chose Mercado Pago =
18
- Mercado Pago owns the highest security standards with PCI certification level 1 and a specialized internal team working on fraud analysis. With Mercado Pago, you will be able to accept payments from the most common brands of credit card, offer purchase installments options and receive your payment with antecipation. You can also enable your customers to pay in the web or in their mobile devices.
19
-
20
- = Mercado Pago Main Features =
21
- * Online and real-time processment through IPN mechanism;
22
- * High approval rate with a robust fraud analysis;
23
- * Potential new customers with a base of more than 120 millions of users in Latin America;
24
- * PCI Level 1 Certification;
25
- * Support to major credit card brands;
26
- * Payment installments;
27
- * Anticipation of receivables in D+2 or D+14 (According to Mercado Pago terms and conditions);
28
- * Payment in one click with Mercado Pago standard and custom checkouts;
29
- * Payment via tickets;
30
- * Seller's Protection Program.
31
-
32
- == Installation ==
33
-
34
- You have two way to install this module: from your WordPress Store, or by downloading and manually copying the module directory.
35
-
36
- = Install from WordPress =
37
- 1. On your store administration, go to **Plugins** option in sidebar;
38
- 2. Click in **Add New** button and type "Woo Mercado Pago Module" in the **Search Plugins** text field. Press Enter;
39
- 3. You should find the module read to be installed. Click install.
40
-
41
- = Manual Download =
42
- 1. Get the module sources from a repository (<a href="https://github.com/mercadopago/cart-woocommerce/archive/master.zip">Github</a> or <a href="https://downloads.wordpress.org/plugin/woo-mercado-pago-module.2.0.4.zip">WordPress Plugin Directory</a>);
43
- 2. Unzip the folder and find "woo-mercado-pago-module" directory;
44
- 3. Copy "woo-mercado-pago-module" directory to **[WordPressRootDirectory]/wp-content/plugins/** directory.
45
-
46
- To confirm that your module is really installed, you can click in **Plugins** item in the store administration menu, and check your just installed module. Just click **enable** to activate it and you should receive the message "Plugin enabled." as a notice in your WordPress.
47
-
48
- = Configuration =
49
- 1. On your store administration, go to **WooCommerce > Settings > Checkout** tab. In **Checkout Options**, you can find configurations for **Mercado Pago - Standard Checkout**, **Mercado Pago - Custom Checkout**, and **Mercado Pago - Ticket**.
50
- * To get your **Client_id** and **Client_secret** for your country, you can go to:
51
- * Argentina: https://www.mercadopago.com/mla/account/credentials?type=basic
52
- * Brazil: https://www.mercadopago.com/mlb/account/credentials?type=basic
53
- * Chile: https://www.mercadopago.com/mlc/account/credentials?type=basic
54
- * Colombia: https://www.mercadopago.com/mco/account/credentials?type=basic
55
- * Mexico: https://www.mercadopago.com/mlm/account/credentials?type=basic
56
- * Peru: https://www.mercadopago.com/mpe/account/credentials?type=basic
57
- * Venezuela: https://www.mercadopago.com/mlv/account/credentials?type=basic
58
- * And to get your **Public Key**/**Access Token** you can go to:
59
- * Argentina: https://www.mercadopago.com/mla/account/credentials?type=custom
60
- * Brazil: https://www.mercadopago.com/mlb/account/credentials?type=custom
61
- * Chile: https://www.mercadopago.com/mlc/account/credentials?type=custom
62
- * Colombia: https://www.mercadopago.com/mco/account/credentials?type=custom
63
- * Mexico: https://www.mercadopago.com/mlm/account/credentials?type=custom
64
- * Peru: https://www.mercadopago.com/mpe/account/credentials?type=custom
65
- * Venezuela: https://www.mercadopago.com/mlv/account/credentials?type=custom
66
- 2. For the solutions **Mercado Pago - Standard Checkout**, **Mercado Pago - Custom Checkout**, and **Mercado Pago - Ticket**, you can:
67
- * Enable/Disable you plugin (for all solutions);
68
- * Set up your credentials (Client_id/Client_secret for Standard, Public Key/Access Token for Custom and Ticket);
69
- * Check your IPN URL, where you will get notified about payment updates (for all solutions);
70
- * Set the title of the payment option that will be shown to your customers (for all solutions);
71
- * Set the description of the payment option that will be shown to your customers (for all solutions);
72
- * Set the description that will be shown in your customer's invoice (for Custom and Ticket);
73
- * Set binary mode that when charging a credit card, only [approved] or [reject] status will be taken (only for Custom);
74
- * Set the category of your store (for all solutions);
75
- * Set a prefix to identify your store, when you have multiple stores for only one Mercado Pago account (for all solutions);
76
- * Define how your customers will interact with Mercado Pago to pay their orders (only for Standard);
77
- * Configure the after-pay return behavior (only for Standard);
78
- * Configure the maximum installments allowed for your customers (only for Standard);
79
- * Configure the payment methods that you want to not work with Mercado Pago (only for Standard);
80
- * Enable/disable sandbox mode, where you can test your payments in Mercado Pago sandbox environment (for all solutions);
81
- * Enables/disable system logs (for all solutions).
82
-
83
- = In this video, we show how you can install and configure from your WordPress store =
84
-
85
- [youtube https://www.youtube.com/watch?v=CgV9aVlx5SE]
86
-
87
- == Frequently Asked Questions ==
88
-
89
- = What is Mercado Pago? =
90
- Please, take a look: https://vimeo.com/125253122
91
-
92
- = Any questions? =
93
- Please, check our FAQ at: https://www.mercadopago.com.br/ajuda/
94
-
95
- == Screenshots ==
96
-
97
- 1. `Custom Checkout`
98
-
99
- 2. `One Click Payment`
100
-
101
- 3. `Tickets`
102
-
103
- 4. `Configuration of Standard Checkout`
104
-
105
- == Changelog ==
106
-
107
- = v2.0.4 (29/06/2016) =
108
- * Bug fixes
109
- - We have wrote a snippet to handle the absent shipment cost problem;
110
- - Fixed some URLs of the credentials link for Standard Checkout.
111
- * Improvements
112
- - Added a message in admin view when currency is different from used locally (used in credential's country).
113
-
114
- = v2.0.3 (21/06/2016) =
115
- * Bug fix in Standard Checkout for WooCommerce v2.6.x
116
- - In WooCommerce v2.6.x, there was a bug related with the ampersand char that was wrongly converted to #38; on URLs and breaking the checkout flow. This update should place a fix to this problem.
117
-
118
- = v2.0.2 (13/06/2016) =
119
- * Rollout to Peru
120
- - This plugin is now supporting Peru, which includes Standard Checkout, Custom Checkout, Tickets, and local language translations.
121
- * Fix a PHP version issue
122
- - It was reported to us an issue in a function that uses an assign made directly from an array field. This feature is available in PHP 5.4.x or above and we've made an update to support older versions;
123
- * Fix a tax issue
124
- - It wasn't been correctly added to the total value in Mercado Pago gateway.
125
-
126
- = v2.0.1 (09/06/2016) =
127
- * Customer Cards (One Click Payment)
128
- - This feature allows customers to proceed to checkout with only one click. As Mercado Pago owns PCI standards, it can securely store credit card sensitive data and so register the customer card in the first time he uses it. Next time the customer comes back, he can use his card again, only by inserting its CVV code.
129
- - Want to see how it works on-the-fly? Please check this video: <a href="https://www.youtube.com/watch?v=_KB8CtDei_4">Custom Checkout + Customer Cards</a>.
130
- * SSL verifications for custom checkout and ticket
131
- - Custom Checkout and Ticket solutions can only be used with SSL certification. As the module behaves inconsistently if there is no SSL, we've put a watchdog to lock the solution if it is active without SSL.
132
- * Enabling any type of currency without disabling module (now, error message from API)
133
- - Now, merchants have the option to use currencies of their choices in WooCommerce. Pay attention that Woo Mercado Pago will always set the currency related to the country of the Mercado Pago credentials.
134
-
135
- = v2.0.0 (01/06/2016) =
136
- * Custom Checkout for LatAm
137
- - Offer a checkout fully customized to your brand experience with our simple-to-use payments API.
138
- - Want to see how it works on-the-fly? Please check this video: <a href="https://www.youtube.com/watch?v=_KB8CtDei_4">Custom Checkout + Customer Cards</a>.
139
- * Ticket for LatAm
140
- - Now, customer can pay orders with bank tickets.
141
- - Want to see how it works on-the-fly? Please check this video: <a href="https://www.youtube.com/watch?v=97VSVx5Uaj0">Tickets</a>.
142
- * Removed possibility to setting supportable but invalid currency
143
- - We've made a fix to prevent users to select a valid currency (such as ARS), but for a different country set by credentials origin (such as MLB - Mercado Pago Brazil).
144
-
145
- = v1.0.5 (29/04/2016) =
146
- * Removal of extra shipment setup in checkout view
147
- - We have made a workaround to prevent an extra shipment screen to appear.
148
- * Translation to es_ES
149
- - Users can select Spain as module country, and translation should be ok.
150
- * Some bug fixes and code improvements
151
-
152
- = v1.0.4 (15/04/2016) =
153
- * Added a link to module settings page in plugin page
154
- - We've increased the module description informations. Also we've put a link to make a vote on us. Please, VOTE US 5 STARS. Any feedback will be welcome!
155
- * Fixed status change when processing with two cards
156
- - When using payments with two cards in Standard Checkout, the flow of order status wasn't correct in some cases when async IPN events occurs. We've made some adjustments to fix it.
157
-
158
- = v1.0.3 (23/03/2016) =
159
- * Improving algorithm when processing IPN
160
- - Async calls and processment were refined.
161
-
162
- = v1.0.2 (23/03/2016) =
163
- * IPN URL wasn’t triggered when topic=payment
164
- - Fixed a bug for some specific IPN messages of Mercado Pago.
165
-
166
- = v1.0.1 (23/03/2016) =
167
- * Added payment ID in order custom fields information
168
- - Added some good informations about the payment in the order view.
169
- * Removed some unused files/code
170
- - We've made some code cleaning.
171
- * Redesign of the logic of preferences when creating cart, separating items
172
- - Itens are now separated in cart description. This increases the readability and consistency of informations in API level.
173
- * Proper information of shipment cost
174
- - Previously, the shipment cost was passed together with the cart total order amount.
175
-
176
- = v1.0.0 (16/03/2016) =
177
- * LatAm Standard Checkout support
178
- - Great for merchants who want to get going quickly and easily. This is the standard payment integration with Mercado Pago.
179
- - Want to see how it works on-the-fly? Please check this video: <a href="https://www.youtube.com/watch?v=DgOsX1eXjBU">Standard Checkout</a>.
180
- * Set of configurable fields and customizations
181
- - Title, description, category, and external reference customizations, integrations via iframe, modal, and redirection, with configurable auto-returning, max installments and payment method exclusion setup.
182
- * Sandbox and debug options
183
- - Customer can test orders by enabling debug mode or using sandbox environment.
184
-
185
- == Upgrade Notice ==
186
-
187
- If you're migrating from version 1.x.x to 2.x.x, please be sure to make a backup of your site and database, as there are many additional features and modifications between these versions.
assets/css/custom_checkout_mercadopago.css CHANGED
@@ -7,7 +7,7 @@ body{
7
#mp-box-form{
8
padding: 15px 10px;
9
margin: 30px auto;
10
- width: 320px;
11
background-color: #fff;
12
overflow: auto;
13
border-radius: 5px;
@@ -69,7 +69,7 @@ body{
69
70
.mp-box-inputs label{
71
text-transform: uppercase;
72
- font-size: 14px;
73
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
74
margin: 0 0 5px 0;
75
display: block;
@@ -87,7 +87,6 @@ body{
87
border-radius: 3px;
88
color: #666;
89
height: 40px;
90
- font-size: 20px;
91
}
92
93
.mp-box-inputs input:focus, .mp-box-inputs select:focus{
@@ -120,6 +119,21 @@ body{
120
display: none;
121
}
122
123
#submit{
124
color: #fff;
125
background-color: #337ab7;
@@ -138,6 +152,109 @@ body{
138
border-color: #204d74;
139
}
140
141
142
/*
143
*
@@ -147,13 +264,44 @@ body{
147
*
148
*/
149
150
- .mp-error{
151
- text-transform: uppercase;
152
- font-size: 10px;
153
- color: red;
154
- font-weight: bold;
155
- display: none;
156
- font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
157
- clear: both;
158
- float: left;
159
- }
7
#mp-box-form{
8
padding: 15px 10px;
9
margin: 30px auto;
10
+ width: 400px;
11
background-color: #fff;
12
overflow: auto;
13
border-radius: 5px;
69
70
.mp-box-inputs label{
71
text-transform: uppercase;
72
+ font-size: 12px;
73
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
74
margin: 0 0 5px 0;
75
display: block;
87
border-radius: 3px;
88
color: #666;
89
height: 40px;
90
}
91
92
.mp-box-inputs input:focus, .mp-box-inputs select:focus{
119
display: none;
120
}
121
122
+ .mp-btn, .ch-btn {
123
+ background-color: #009ee3;
124
+ border: 1px solid #009ee3;
125
+ border-radius: 4px;
126
+ color: #fff;
127
+ display: inline-block;
128
+ font-family: Arial,sans-serif;
129
+ font-size: 18px;
130
+ font-weight: normal;
131
+ margin: 0;
132
+ padding: 10px;
133
+ text-align: center;
134
+ width: 100%;
135
+ }
136
+
137
#submit{
138
color: #fff;
139
background-color: #337ab7;
152
border-color: #204d74;
153
}
154
155
+ .mp-discount{
156
+ text-transform: uppercase;
157
+ font-size: 12px;
158
+ /*color: #009EE3;*/
159
+ color: #333333;
160
+ display: none;
161
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
162
+ clear: both;
163
+ float: left;
164
+ }
165
+
166
+ #mpCouponApplyed{
167
+ display: none;
168
+ border-style: solid;
169
+ border-width: thin;
170
+ border-color: #009EE3;
171
+ padding: 8px 8px 8px 8px;
172
+ }
173
+
174
+ #mpCouponApplyedTicket{
175
+ display: none;
176
+ border-style: solid;
177
+ border-width: thin;
178
+ border-color: #009EE3;
179
+ padding: 8px 8px 8px 8px;
180
+ }
181
+
182
+ #mercadopago-form-coupon .mp-box-message{
183
+ margin: -5px 0 5px;
184
+ }
185
+
186
+ [class^=form-col-]{
187
+ position: relative;
188
+ min-height: 1px;
189
+ padding-right: 5px;
190
+ padding-left: 5px;
191
+ float: left;
192
+ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
193
+ -moz-box-sizing: border-box; /* Firefox, other Gecko */
194
+ box-sizing: border-box;
195
+ }
196
+
197
+ .form-col-1{
198
+ width: 8.33333333%;
199
+ }
200
+ .form-col-2{
201
+ width: 16.66666667%;
202
+ }
203
+ .form-col-3{
204
+ width: 25%;
205
+ }
206
+ .form-col-4{
207
+ width: 33.33333333%;
208
+ }
209
+ .form-col-5{
210
+ width: 41.66666667%;
211
+ }
212
+ .form-col-6{
213
+ width: 50%;
214
+ }
215
+ .form-col-7{
216
+ width: 58.33333333%;
217
+ }
218
+ .form-col-8{
219
+ width: 66.66666667%;
220
+ }
221
+ .form-col-9{
222
+ width: 75%;
223
+ }
224
+ .form-col-10{
225
+ width: 83.33333333%;
226
+ }
227
+ .form-col-11{
228
+ width: 91.66666667%;
229
+ }
230
+ .form-col-12{
231
+ width: 100%;
232
+ }
233
+
234
+ .form-control-mine {
235
+ width: 100%;
236
+ padding: 5px;
237
+ font-size: 16px;
238
+ color: #555;
239
+ background-color: #fff;
240
+ background-image: none;
241
+ border: 1px solid #ccc;
242
+ border-radius: 4px;
243
+ margin-bottom: 12px;
244
+ }
245
+
246
+ select#fixed {
247
+ -webkit-appearance: none;
248
+ }
249
+
250
+ .mensagem-febraban{
251
+ text-transform: uppercase;
252
+ font-size: 12px;
253
+ display: block;
254
+ margin-top: 8px;
255
+ margin-bottom: 16px;
256
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
257
+ }
258
259
/*
260
*
264
*
265
*/
266
267
+ .mp-error{
268
+ text-transform: uppercase;
269
+ font-size: 10px;
270
+ margin-bottom: 12px;
271
+ color: red;
272
+ font-weight: bold;
273
+ display: none;
274
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
275
+ clear: both;
276
+ float: left;
277
+ }
278
+
279
+ .erro_febraban{
280
+ text-transform: uppercase;
281
+ font-size: 10px;
282
+ margin-left: -10px;
283
+ margin-right: -10px;
284
+ margin-bottom: 12px;
285
+ color: red;
286
+ font-weight: bold;
287
+ display: none;
288
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
289
+ clear: both;
290
+ }
291
+
292
+ #mp-box-input-tax-tea{
293
+ font-weight: 300;
294
+ text-align: center;
295
+ color: #333;
296
+ font-size: 12px;
297
+ display: none;
298
+ }
299
+
300
+ #mp-box-input-tax-cft{
301
+ font-weight: 300;
302
+ text-align: center;
303
+ color: #333;
304
+ font-size: 20px;
305
+ margin-top: 16px;
306
+ display: none;
307
+ }
{images → assets/images}/MCO/CUPOM_MCO.jpg RENAMED
File without changes
{images → assets/images}/MCO/MCO.png RENAMED
File without changes
{images → assets/images}/MCO/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MCO/credit_card.png RENAMED
File without changes
{images → assets/images}/MCO/standard_mco.jpg RENAMED
File without changes
{images → assets/images}/MLA/CUPOM_MLA.jpg RENAMED
File without changes
{images → assets/images}/MLA/MLA.png RENAMED
File without changes
{images → assets/images}/MLA/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MLA/credit_card.png RENAMED
File without changes
{images → assets/images}/MLA/standard_mla.jpg RENAMED
File without changes
{images → assets/images}/MLB/CUPOM_MLB.jpg RENAMED
File without changes
{images → assets/images}/MLB/MLB.png RENAMED
File without changes
{images → assets/images}/MLB/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MLB/credit_card.png RENAMED
File without changes
{images → assets/images}/MLB/cupom1.jpg RENAMED
File without changes
{images → assets/images}/MLB/cupom2.jpg RENAMED
File without changes
{images → assets/images}/MLB/cupom3.jpg RENAMED
File without changes
{images → assets/images}/MLB/desconto_MLB.jpg RENAMED
File without changes
{images → assets/images}/MLB/standard_mlb.jpg RENAMED
File without changes
{images → assets/images}/MLC/CUPOM_MLC.jpg RENAMED
File without changes
{images → assets/images}/MLC/MLC.png RENAMED
File without changes
{images → assets/images}/MLC/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MLC/credit_card.png RENAMED
File without changes
{images → assets/images}/MLC/standard_mlc.gif RENAMED
File without changes
{images → assets/images}/MLM/CUPOM_MLM.jpg RENAMED
File without changes
{images → assets/images}/MLM/MLM.png RENAMED
File without changes
{images → assets/images}/MLM/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MLM/credit_card.png RENAMED
File without changes
{images → assets/images}/MLM/standard_mlm.jpg RENAMED
File without changes
images/MPE/CUPOM_MPE.png → assets/images/MLU/CUPOM_MLU.png RENAMED
File without changes
assets/images/MLU/MLU.png ADDED
Binary file
{images/MPE → assets/images/MLU}/banner_all_methods.png RENAMED
File without changes
{images/MPE → assets/images/MLU}/credit_card.png RENAMED
File without changes
images/MPE/standard_mpe.png → assets/images/MLU/standard_mlu.png RENAMED
File without changes
{images → assets/images}/MLV/CUPOM_MLV.jpg RENAMED
File without changes
{images → assets/images}/MLV/MLV.png RENAMED
File without changes
{images → assets/images}/MLV/banner_all_methods.png RENAMED
File without changes
{images → assets/images}/MLV/credit_card.png RENAMED
File without changes
{images → assets/images}/MLV/standard_mlv.jpg RENAMED
File without changes
assets/images/MPE/CUPOM_MPE.png ADDED
Binary file
{images → assets/images}/MPE/MPE.png RENAMED
File without changes
assets/images/MPE/banner_all_methods.png ADDED
Binary file
assets/images/MPE/credit_card.png ADDED
Binary file
assets/images/MPE/standard_mpe.png ADDED
Binary file
{images → assets/images}/bandeiras/amex.png RENAMED
File without changes
{images → assets/images}/bandeiras/boleto.png RENAMED
File without changes
{images → assets/images}/bandeiras/cash.png RENAMED
File without changes
{images → assets/images}/bandeiras/diners.png RENAMED
File without changes
{images → assets/images}/bandeiras/elo.png RENAMED
File without changes
{images → assets/images}/bandeiras/hipercard.png RENAMED
File without changes
{images → assets/images}/bandeiras/master.png RENAMED
File without changes
{images → assets/images}/bandeiras/melicard.png RENAMED
File without changes
{images → assets/images}/bandeiras/visa.png RENAMED
File without changes
{images → assets/images}/banner.png RENAMED
File without changes
{images → assets/images}/bar_code.png RENAMED
File without changes
{images → assets/images}/boleto.png RENAMED
File without changes
assets/images/cart.png ADDED
Binary file
{images → assets/images}/check.png RENAMED
File without changes
{images → assets/images}/credit_card.png RENAMED
File without changes
{images → assets/images}/cvv.png RENAMED
File without changes
{images → assets/images}/error.png RENAMED
File without changes
{images → assets/images}/loading.gif RENAMED
File without changes
{images → assets/images}/mercadopago.png RENAMED
File without changes
{images → assets/images}/mplogo.png RENAMED
File without changes
{images → assets/images}/warning.png RENAMED
File without changes
assets/js/credit-card.js ADDED
@@ -0,0 +1,1085 @@
1
+ ( function() {
2
+
3
+ var MPv1 = {
4
+ debug: true,
5
+ add_truncated_card: true,
6
+ site_id: "",
7
+ public_key: "",
8
+ coupon_of_discounts: {
9
+ discount_action_url: "",
10
+ payer_email: "",
11
+ default: true,
12
+ status: false
13
+ },
14
+ customer_and_card: {
15
+ default: true,
16
+ status: true
17
+ },
18
+ create_token_on: {
19
+ event: true, //if true create token on event, if false create on click and ignore others
20
+ keyup: false,
21
+ paste: true
22
+ },
23
+ inputs_to_create_discount: [
24
+ "couponCode",
25
+ "applyCoupon"
26
+ ],
27
+ inputs_to_create_token: [
28
+ "cardNumber",
29
+ "cardExpirationMonth",
30
+ "cardExpirationYear",
31
+ "cardholderName",
32
+ "securityCode",
33
+ "docType",
34
+ "docNumber"
35
+ ],
36
+ inputs_to_create_token_customer_and_card: [
37
+ "paymentMethodSelector",
38
+ "securityCode"
39
+ ],
40
+ selectors: {
41
+ // currency
42
+ currency_ratio: "#currency_ratio",
43
+ // coupom
44
+ couponCode: "#couponCode",
45
+ applyCoupon: "#applyCoupon",
46
+ mpCouponApplyed: "#mpCouponApplyed",
47
+ mpCouponError: "#mpCouponError",
48
+ campaign_id: "#campaign_id",
49
+ campaign: "#campaign",
50
+ discount: "#discount",
51
+ // customer cards
52
+ paymentMethodSelector: "#paymentMethodSelector",
53
+ pmCustomerAndCards: "#payment-methods-for-customer-and-cards",
54
+ pmListOtherCards: "#payment-methods-list-other-cards",
55
+ // card data
56
+ mpSecurityCodeCustomerAndCard: "#mp-securityCode-customer-and-card",
57
+ cardNumber: "#cardNumber",
58
+ cardExpirationMonth: "#cardExpirationMonth",
59
+ cardExpirationYear: "#cardExpirationYear",
60
+ cardholderName: "#cardholderName",
61
+ securityCode: "#securityCode",
62
+ docType: "#docType",
63
+ docNumber: "#docNumber",
64
+ issuer: "#issuer",
65
+ installments: "#installments",
66
+ // document
67
+ mpDoc: ".mp-doc",
68
+ mpIssuer: ".mp-issuer",
69
+ mpDocType: ".mp-docType",
70
+ mpDocNumber: ".mp-docNumber",
71
+ // payment method and checkout
72
+ paymentMethodId: "#paymentMethodId",
73
+ amount: "#amount",
74
+ token: "#token",
75
+ cardTruncated: "#cardTruncated",
76
+ site_id: "#site_id",
77
+ CustomerAndCard: "#CustomerAndCard",
78
+ box_loading: "#mp-box-loading",
79
+ submit: "#submit",
80
+ // tax resolution AG 51/2017
81
+ boxInstallments: "#mp-box-installments",
82
+ boxInstallmentsSelector: "#mp-box-installments-selector",
83
+ taxCFT: "#mp-box-input-tax-cft",
84
+ taxTEA: "#mp-box-input-tax-tea",
85
+ taxTextCFT: "#mp-tax-cft-text",
86
+ taxTextTEA: "#mp-tax-tea-text",
87
+ // form
88
+ form: "#mercadopago-form",
89
+ formCoupon: "#mercadopago-form-coupon",
90
+ formCustomerAndCard: "#mercadopago-form-customer-and-card",
91
+ utilities_fields: "#mercadopago-utilities"
92
+ },
93
+ text: {
94
+ choose: "Choose",
95
+ other_bank: "Other Bank",
96
+ discount_info1: "You will save",
97
+ discount_info2: "with discount from",
98
+ discount_info3: "Total of your purchase:",
99
+ discount_info4: "Total of your purchase with discount:",
100
+ discount_info5: "*Uppon payment approval",
101
+ discount_info6: "Terms and Conditions of Use",
102
+ coupon_empty: "Please, inform your coupon code",
103
+ apply: "Apply",
104
+ remove: "Remove"
105
+ },
106
+ paths: {
107
+ loading: "images/loading.gif",
108
+ check: "images/check.png",
109
+ error: "images/error.png"
110
+ }
111
+ }
112
+
113
+ // === Coupon of Discounts
114
+
115
+ MPv1.currencyIdToCurrency = function ( currency_id ) {
116
+ if ( currency_id == "ARS" ) {
117
+ return "quot;;
118
+ } else if ( currency_id == "BRL" ) {
119
+ return "Rquot;;
120
+ } else if ( currency_id == "COP" ) {
121
+ return "quot;;
122
+ } else if ( currency_id == "CLP" ) {
123
+ return "quot;;
124
+ } else if ( currency_id == "MXN" ) {
125
+ return "quot;;
126
+ } else if ( currency_id == "VEF" ) {
127
+ return "Bs";
128
+ } else if ( currency_id == "PEN" ) {
129
+ return "S/";
130
+ } else if ( currency_id == "UYU" ) {
131
+ return "$U";
132
+ } else {
133
+ return "quot;;
134
+ }
135
+ }
136
+
137
+ MPv1.checkCouponEligibility = function () {
138
+ if ( document.querySelector( MPv1.selectors.couponCode).value == "" ) {
139
+ // Coupon code is empty.
140
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display = "none";
141
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display = "block";
142
+ document.querySelector( MPv1.selectors.mpCouponError ).innerHTML = MPv1.text.coupon_empty;
143
+ MPv1.coupon_of_discounts.status = false;
144
+ document.querySelector( MPv1.selectors.couponCode ).style.background = null;
145
+ document.querySelector( MPv1.selectors.applyCoupon ).value = MPv1.text.apply;
146
+ document.querySelector( MPv1.selectors.discount ).value = 0;
147
+ MPv1.cardsHandler();
148
+ } else if ( MPv1.coupon_of_discounts.status ) {
149
+ // We already have a coupon set, so we remove it.
150
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display = "none";
151
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display = "none";
152
+ MPv1.coupon_of_discounts.status = false;
153
+ document.querySelector( MPv1.selectors.applyCoupon ).style.background = null;
154
+ document.querySelector( MPv1.selectors.applyCoupon ).value = MPv1.text.apply;
155
+ document.querySelector( MPv1.selectors.couponCode ).value = "";
156
+ document.querySelector( MPv1.selectors.couponCode ).style.background = null;
157
+ document.querySelector( MPv1.selectors.discount ).value = 0;
158
+ MPv1.cardsHandler();
159
+ } else {
160
+ // Set loading.
161
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display = "none";
162
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display = "none";
163
+ document.querySelector( MPv1.selectors.couponCode ).style.background = "url(" + MPv1.paths.loading + ") 98% 50% no-repeat #fff";
164
+ document.querySelector( MPv1.selectors.applyCoupon ).disabled = true;
165
+
166
+ // Check if there are params in the url.
167
+ var url = MPv1.coupon_of_discounts.discount_action_url;
168
+ var sp = "?";
169
+ if ( url.indexOf( "?" ) >= 0 ) {
170
+ sp = "&";
171
+ }
172
+ url += sp + "site_id=" + MPv1.site_id;
173
+ url += "&coupon_id=" + document.querySelector( MPv1.selectors.couponCode ).value;
174
+ url += "&amount=" + document.querySelector( MPv1.selectors.amount ).value;
175
+ url += "&payer=" + MPv1.coupon_of_discounts.payer_email;
176
+ //url += "&payer=" + document.getElementById( "billing_email" ).value;
177
+
178
+ MPv1.AJAX({
179
+ url: url,
180
+ method : "GET",
181
+ timeout : 5000,
182
+ error: function() {
183
+ // Request failed.
184
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display = "none";
185
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display = "none";
186
+ MPv1.coupon_of_discounts.status = false;
187
+ document.querySelector( MPv1.selectors.applyCoupon ).style.background = null;
188
+ document.querySelector( MPv1.selectors.applyCoupon ).value = MPv1.text.apply;
189
+ document.querySelector( MPv1.selectors.couponCode ).value = "";
190
+ document.querySelector( MPv1.selectors.couponCode ).style.background = null;
191
+ document.querySelector( MPv1.selectors.discount ).value = 0;
192
+ MPv1.cardsHandler();
193
+ },
194
+ success : function ( status, response ) {
195
+ if ( response.status == 200 ) {
196
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display =
197
+ "block";
198
+ document.querySelector( MPv1.selectors.discount ).value =
199
+ response.response.coupon_amount;
200
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).innerHTML =
201
+ //"<div style='border-style: solid; border-width:thin; " +
202
+ //"border-color: #009EE3; padding: 8px 8px 8px 8px; margin-top: 4px;'>" +
203
+ MPv1.text.discount_info1 + " <strong>" +
204
+ MPv1.currencyIdToCurrency( response.response.currency_id ) + " " +
205
+ Math.round( response.response.coupon_amount * 100 ) / 100 +
206
+ "</strong> " + MPv1.text.discount_info2 + " " +
207
+ response.response.name + ".<br>" + MPv1.text.discount_info3 + " <strong>" +
208
+ MPv1.currencyIdToCurrency( response.response.currency_id ) + " " +
209
+ Math.round( MPv1.getAmountWithoutDiscount() * 100 ) / 100 +
210
+ "</strong><br>" + MPv1.text.discount_info4 + " <strong>" +
211
+ MPv1.currencyIdToCurrency( response.response.currency_id ) + " " +
212
+ Math.round( MPv1.getAmount() * 100 ) / 100 + "*</strong><br>" +
213
+ "<i>" + MPv1.text.discount_info5 + "</i><br>" +
214
+ "<a href='https://api.mercadolibre.com/campaigns/" +
215
+ response.response.id +
216
+ "/terms_and_conditions?format_type=html' target='_blank'>" +
217
+ MPv1.text.discount_info6 + "</a>";
218
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display =
219
+ "none";
220
+ MPv1.coupon_of_discounts.status = true;
221
+ document.querySelector( MPv1.selectors.couponCode ).style.background =
222
+ null;
223
+ document.querySelector( MPv1.selectors.couponCode ).style.background =
224
+ "url(" + MPv1.paths.check + ") 98% 50% no-repeat #fff";
225
+ document.querySelector( MPv1.selectors.applyCoupon ).value =
226
+ MPv1.text.remove;
227
+ MPv1.cardsHandler();
228
+ document.querySelector( MPv1.selectors.campaign_id ).value =
229
+ response.response.id;
230
+ document.querySelector( MPv1.selectors.campaign ).value =
231
+ response.response.name;
232
+ } else {
233
+ document.querySelector( MPv1.selectors.mpCouponApplyed ).style.display = "none";
234
+ document.querySelector( MPv1.selectors.mpCouponError ).style.display = "block";
235
+ document.querySelector( MPv1.selectors.mpCouponError ).innerHTML = response.response.message;
236
+ MPv1.coupon_of_discounts.status = false;
237
+ document.querySelector( MPv1.selectors.couponCode ).style.background = null;
238
+ document.querySelector( MPv1.selectors.couponCode ).style.background = "url(" + MPv1.paths.error + ") 98% 50% no-repeat #fff";
239
+ document.querySelector( MPv1.selectors.applyCoupon ).value = MPv1.text.apply;
240
+ document.querySelector( MPv1.selectors.discount ).value = 0;
241
+ MPv1.cardsHandler();
242
+ }
243
+ document.querySelector( MPv1.selectors.applyCoupon ).disabled = false;
244
+ }
245
+ });
246
+ }
247
+ }
248
+
249
+ MPv1.getBin = function() {
250
+
251
+ var cardSelector = document.querySelector( MPv1.selectors.paymentMethodSelector );
252
+
253
+ if (cardSelector && cardSelector[cardSelector.options.selectedIndex].value != "-1") {
254
+ return cardSelector[cardSelector.options.selectedIndex]
255
+ .getAttribute( "first_six_digits" );
256
+ }
257
+
258
+ var ccNumber = document.querySelector( MPv1.selectors.cardNumber );
259
+ return ccNumber.value.replace( /[ .-]/g, "" ).slice( 0, 6 );
260
+
261
+ }
262
+
263
+ MPv1.clearOptions = function() {
264
+
265
+ var bin = MPv1.getBin();
266
+
267
+ if ( bin.length == 0 ) {
268
+
269
+ MPv1.hideIssuer();
270
+
271
+ var selectorInstallments = document.querySelector( MPv1.selectors.installments ),
272
+ fragment = document.createDocumentFragment(),
273
+ option = new Option( MPv1.text.choose + "...", "-1" );
274
+
275
+ selectorInstallments.options.length = 0;
276
+ fragment.appendChild( option );
277
+ selectorInstallments.appendChild( fragment );
278
+ selectorInstallments.setAttribute( "disabled", "disabled" );
279
+
280
+ }
281
+
282
+ }
283
+
284
+ MPv1.guessingPaymentMethod = function( event ) {
285
+
286
+ var bin = MPv1.getBin();
287
+ var amount = MPv1.getAmount();
288
+
289
+ if ( event.type == "keyup" ) {
290
+ if ( bin != null && bin.length == 6 ) {
291
+ Mercadopago.getPaymentMethod( {
292
+ "bin": bin
293
+ }, MPv1.setPaymentMethodInfo );
294
+ }
295
+ } else {
296
+ setTimeout( function() {
297
+ if ( bin.length >= 6 ) {
298
+ Mercadopago.getPaymentMethod( {
299
+ "bin": bin
300
+ }, MPv1.setPaymentMethodInfo );
301
+ }
302
+ }, 100 );
303
+ }
304
+
305
+ };
306
+
307
+ MPv1.setPaymentMethodInfo = function( status, response ) {
308
+
309
+ if ( status == 200 ) {
310
+
311
+ if ( MPv1.site_id != "MLM" ) {
312
+ // Guessing...
313
+ document.querySelector( MPv1.selectors.paymentMethodId ).value = response[0].id;
314
+ if ( MPv1.customer_and_card.status ) {
315
+ document.querySelector( MPv1.selectors.paymentMethodSelector )
316
+ .style.background = "url(" + response[0].secure_thumbnail + ") 90% 50% no-repeat #fff";
317
+ } else {
318
+ document.querySelector( MPv1.selectors.cardNumber ).style.background = "url(" +
319
+ response[0].secure_thumbnail + ") 98% 50% no-repeat #fff";
320
+ }
321
+ }
322
+
323
+ // Check if the security code (ex: Tarshop) is required.
324
+ var cardConfiguration = response[0].settings;
325
+ var bin = MPv1.getBin();
326
+ var amount = MPv1.getAmount();
327
+
328
+ Mercadopago.getInstallments(
329
+ { "bin": bin, "amount": amount },
330
+ MPv1.setInstallmentInfo
331
+ );
332
+
333
+ // Check if the issuer is necessary to pay.
334
+ var issuerMandatory = false, additionalInfo = response[0].additional_info_needed;
335
+
336
+ for ( var i=0; i<additionalInfo.length; i++ ) {
337
+ if ( additionalInfo[i] == "issuer_id" ) {
338
+ issuerMandatory = true;
339
+ }
340
+ };
341
+
342
+ if ( issuerMandatory && MPv1.site_id != "MLM" ) {
343
+ var payment_method_id = response[0].id;
344
+ MPv1.getIssuersPaymentMethod( payment_method_id );
345
+ } else {
346
+ MPv1.hideIssuer();
347
+ }
348
+
349
+ }
350
+
351
+ }
352
+
353
+ MPv1.changePaymetMethodSelector = function() {
354
+ var payment_method_id =
355
+ document.querySelector( MPv1.selectors.paymentMethodSelector ).value;
356
+ MPv1.getIssuersPaymentMethod( payment_method_id );
357
+ }
358
+
359
+ // === Issuers
360
+
361
+ MPv1.getIssuersPaymentMethod = function( payment_method_id ) {
362
+
363
+ var amount = MPv1.getAmount();
364
+
365
+ // flow: MLM mercadopagocard
366
+ if ( payment_method_id == "mercadopagocard" ) {
367
+ Mercadopago.getInstallments(
368
+ { "payment_method_id": payment_method_id, "amount": amount },
369
+ MPv1.setInstallmentInfo
370
+ );
371
+ }
372
+
373
+ Mercadopago.getIssuers( payment_method_id, MPv1.showCardIssuers );
374
+ MPv1.addListenerEvent(
375
+ document.querySelector( MPv1.selectors.issuer ),
376
+ "change",
377
+ MPv1.setInstallmentsByIssuerId
378
+ );
379
+
380
+ }
381
+
382
+ MPv1.showCardIssuers = function( status, issuers ) {
383
+
384
+ // If the API does not return any bank.
385
+ if ( issuers.length > 0 ) {
386
+ var issuersSelector = document.querySelector( MPv1.selectors.issuer );
387
+ var fragment = document.createDocumentFragment();
388
+
389
+ issuersSelector.options.length = 0;
390
+ var option = new Option( MPv1.text.choose + "...", "-1" );
391
+ fragment.appendChild( option );
392
+
393
+ for ( var i=0; i<issuers.length; i++ ) {
394
+ if ( issuers[i].name != "default" ) {
395
+ option = new Option( issuers[i].name, issuers[i].id );
396
+ } else {
397
+ option = new Option( "Otro", issuers[i].id );
398
+ }
399
+ fragment.appendChild( option );
400
+ }
401
+
402
+ issuersSelector.appendChild( fragment );
403
+ issuersSelector.removeAttribute( "disabled" );
404
+ } else {
405
+ MPv1.hideIssuer();
406
+ }
407
+
408
+ }
409
+
410
+ MPv1.setInstallmentsByIssuerId = function( status, response ) {
411
+
412
+ var issuerId = document.querySelector( MPv1.selectors.issuer ).value;
413
+ var amount = MPv1.getAmount();
414
+
415
+ if ( issuerId === "-1" ) {
416
+ return;
417
+ }
418
+
419
+ var params_installments = {
420
+ "bin": MPv1.getBin(),
421
+ "amount": amount,
422
+ "issuer_id": issuerId
423
+ }
424
+
425
+ if ( MPv1.site_id == "MLM" ) {
426
+ params_installments = {
427
+ "payment_method_id": document.querySelector(
428
+ MPv1.selectors.paymentMethodSelector
429
+ ).value,
430
+ "amount": amount,
431
+ "issuer_id": issuerId
432
+ }
433
+ }
434
+ Mercadopago.getInstallments( params_installments, MPv1.setInstallmentInfo );
435
+
436
+ }
437
+
438
+ MPv1.hideIssuer = function() {
439
+ var $issuer = document.querySelector( MPv1.selectors.issuer );
440
+ var opt = document.createElement( "option" );
441
+ opt.value = "-1";
442
+ opt.innerHTML = MPv1.text.other_bank;
443
+ opt.style = "font-size: 12px;";
444
+
445
+ $issuer.innerHTML = "";
446
+ $issuer.appendChild( opt );
447
+ $issuer.setAttribute( "disabled", "disabled" );
448
+ }
449
+
450
+ // === Installments
451
+
452
+ MPv1.setInstallmentInfo = function( status, response ) {
453
+
454
+ var selectorInstallments = document.querySelector( MPv1.selectors.installments );
455
+
456
+ if ( response.length > 0 ) {
457
+
458
+ var html_option = "<option value='-1'>" + MPv1.text.choose + "...</option>";
459
+ payerCosts = response[0].payer_costs;
460
+
461
+ // fragment.appendChild(option);
462
+ for ( var i=0; i<payerCosts.length; i++) {
463
+ /*html_option += "<option value='" + payerCosts[i].installments + "'>" +
464
+ ( payerCosts[i].recommended_message || payerCosts[i].installments ) +
465
+ "</option>";*/
466
+ // Resolution 51/2017
467
+ var dataInput = "";
468
+ if ( MPv1.site_id == "MLA" ) {
469
+ var tax = payerCosts[i].labels;
470
+ if ( tax.length > 0 ) {
471
+ for ( var l=0; l<tax.length; l++ ) {
472
+ if ( tax[l].indexOf( "CFT_" ) !== -1 ) {
473
+ dataInput = "data-tax='" + tax[l] + "'";
474
+ }
475
+ }
476
+ }
477
+ }
478
+ html_option += "<option value='" + payerCosts[i].installments + "' " + dataInput + ">" +
479
+ (payerCosts[i].recommended_message || payerCosts[i].installments) +
480
+ "</option>";
481
+ }
482
+
483
+ // Not take the user's selection if equal.
484
+ if ( selectorInstallments.innerHTML != html_option ) {
485
+ selectorInstallments.innerHTML = html_option;
486
+ }
487
+
488
+ selectorInstallments.removeAttribute( "disabled" );
489
+ MPv1.showTaxes();
490
+
491
+ }
492
+
493
+ }
494
+
495
+ MPv1.showTaxes = function() {
496
+ var selectorIsntallments = document.querySelector( MPv1.selectors.installments );
497
+ var tax = selectorIsntallments.options[selectorIsntallments.selectedIndex].getAttribute( "data-tax" );
498
+ var cft = "";
499
+ var tea = "";
500
+ if ( tax != null ) {
501
+ var tax_split = tax.split( "|" );
502
+ cft = tax_split[0].replace( "_", " ");
503
+ tea = tax_split[1].replace( "_", " ");
504
+ if ( cft == "CFT 0,00%" && tea == "TEA 0,00%" ) {
505
+ cft = "";
506
+ tea = "";
507
+ }
508
+ }
509
+ document.querySelector( MPv1.selectors.taxTextCFT ).innerHTML = cft;
510
+ document.querySelector( MPv1.selectors.taxTextTEA ).innerHTML = tea;
511
+ }
512
+
513
+ // === Customer & Cards
514
+
515
+ MPv1.cardsHandler = function() {
516
+
517
+ var cardSelector = document.querySelector( MPv1.selectors.paymentMethodSelector );
518
+ var type_checkout =
519
+ cardSelector[cardSelector.options.selectedIndex].getAttribute( "type_checkout" );
520
+ var amount = MPv1.getAmount();
521
+
522
+ if ( MPv1.customer_and_card.default ) {
523
+
524
+ if ( cardSelector &&
525
+ cardSelector[cardSelector.options.selectedIndex].value != "-1" &&
526
+ type_checkout == "customer_and_card" ) {
527
+
528
+ document.querySelector( MPv1.selectors.paymentMethodId )
529
+ .value = cardSelector[cardSelector.options.selectedIndex]
530
+ .getAttribute( "payment_method_id" );
531
+
532
+ MPv1.clearOptions();
533
+
534
+ MPv1.customer_and_card.status = true;
535
+
536
+ var _bin = cardSelector[cardSelector.options.selectedIndex]
537
+ .getAttribute( "first_six_digits" );
538
+
539
+ Mercadopago.getPaymentMethod(
540
+ { "bin": _bin },
541
+ MPv1.setPaymentMethodInfo
542
+ );
543
+
544
+ } else {
545
+
546
+ document.querySelector( MPv1.selectors.paymentMethodId )
547
+ .value = cardSelector.value != -1 ? cardSelector.value : "";
548
+ MPv1.customer_and_card.status = false;
549
+ MPv1.resetBackgroundCard();
550
+ MPv1.guessingPaymentMethod(
551
+ { type: "keyup" }
552
+ );
553
+
554
+ }
555
+
556
+ MPv1.setForm();
557
+
558
+ }
559
+
560
+ }
561
+
562
+ // === Payment Methods
563
+
564
+ MPv1.getPaymentMethods = function() {
565
+
566
+ var fragment = document.createDocumentFragment();
567
+ var paymentMethodsSelector =
568
+ document.querySelector( MPv1.selectors.paymentMethodSelector )
569
+ var mainPaymentMethodSelector =
570
+ document.querySelector( MPv1.selectors.paymentMethodSelector )
571
+
572
+ // Set loading.
573
+ mainPaymentMethodSelector.style.background =
574
+ "url(" + MPv1.paths.loading + ") 95% 50% no-repeat #fff";
575
+
576
+ // If customer and card.
577
+ if ( MPv1.customer_and_card.status ) {
578
+ paymentMethodsSelector = document.querySelector( MPv1.selectors.pmListOtherCards )
579
+ // Clean payment methods.
580
+ paymentMethodsSelector.innerHTML = "";
581
+ } else {
582
+ paymentMethodsSelector.innerHTML = "";
583
+ option = new Option( MPv1.text.choose + "...", "-1" );
584
+ fragment.appendChild( option );
585
+ }
586
+
587
+ Mercadopago.getAllPaymentMethods( function( code, payment_methods ) {
588
+
589
+ for ( var x=0; x < payment_methods.length; x++ ) {
590
+
591
+ var pm = payment_methods[x];
592
+
593
+ if ( ( pm.payment_type_id == "credit_card" || pm.payment_type_id == "debit_card" ||
594
+ pm.payment_type_id == "prepaid_card" ) && pm.status == "active" ) {
595
+
596
+ option = new Option( pm.name, pm.id );
597
+ option.setAttribute( "type_checkout", "custom" );
598
+ fragment.appendChild( option );
599
+
600
+ } // end if
601
+
602
+ } // end for
603
+
604
+ paymentMethodsSelector.appendChild( fragment );
605
+ mainPaymentMethodSelector.style.background = "#fff";
606
+
607
+ } );
608
+
609
+ }
610
+
611
+ // === Functions related to Create Tokens
612
+
613
+ MPv1.createTokenByEvent = function() {
614
+
615
+ var $inputs = MPv1.getForm().querySelectorAll( "[data-checkout]" );
616
+ var $inputs_to_create_token = MPv1.getInputsToCreateToken();
617
+
618
+ for (var x=0; x<$inputs.length; x++) {
619
+
620
+ var element = $inputs[x];
621
+
622
+ // Add events only in the required fields.
623
+ if ( $inputs_to_create_token
624
+ .indexOf( element.getAttribute( "data-checkout" ) ) > -1 ) {
625
+
626
+ var event = "focusout";
627
+
628
+ if ( element.nodeName == "SELECT" ) {
629
+ event = "change";
630
+ }
631
+
632
+ MPv1.addListenerEvent( element, event, MPv1.validateInputsCreateToken );
633
+
634
+ // For firefox.
635
+ MPv1.addListenerEvent( element, "blur", MPv1.validateInputsCreateToken );
636
+
637
+ if ( MPv1.create_token_on.keyup ) {
638
+ MPv1.addListenerEvent(element, "keyup", MPv1.validateInputsCreateToken );
639
+ }
640
+
641
+ if ( MPv1.create_token_on.paste ) {
642
+ MPv1.addListenerEvent(element, "paste", MPv1.validateInputsCreateToken );
643
+ }
644
+
645
+ }
646
+
647
+ }
648
+
649
+ }
650
+
651
+ MPv1.createTokenBySubmit = function() {
652
+ MPv1.addListenerEvent( document.querySelector( MPv1.selectors.form ), "submit", MPv1.doPay );
653
+ }
654
+
655
+ var doSubmit = false;
656
+
657
+ MPv1.doPay = function( event ) {
658
+ event.preventDefault();
659
+ if ( ! doSubmit ) {
660
+ MPv1.createToken();
661
+ return false;
662
+ }
663
+ }
664
+
665
+ MPv1.validateInputsCreateToken = function() {
666
+
667
+ var valid_to_create_token = true;
668
+ var $inputs = MPv1.getForm().querySelectorAll( "[data-checkout]" );
669
+ var $inputs_to_create_token = MPv1.getInputsToCreateToken();
670
+
671
+ for (var x=0; x<$inputs.length; x++) {
672
+
673
+ var element = $inputs[x];
674
+
675
+ // Check is a input to create token.
676
+ if ( $inputs_to_create_token
677
+ .indexOf( element.getAttribute( "data-checkout" ) ) > -1 ) {
678
+
679
+ if ( element.value == -1 || element.value == "" ) {
680
+ valid_to_create_token = false;
681
+ } // end if check values
682
+ } // end if check data-checkout
683
+ } // end for
684
+
685
+ if ( valid_to_create_token ) {
686
+ MPv1.createToken();
687
+ }
688
+
689
+ }
690
+
691
+ MPv1.createToken = function() {
692
+ MPv1.hideErrors();
693
+
694
+ // Show loading.
695
+ document.querySelector( MPv1.selectors.box_loading ).style.background =
696
+ "url(" + MPv1.paths.loading + ") 0 50% no-repeat #fff";
697
+
698
+ // Form.
699
+ var $form = MPv1.getForm();
700
+
701
+ Mercadopago.createToken( $form, MPv1.sdkResponseHandler );
702
+
703
+ return false;
704
+ }
705
+
706
+ MPv1.sdkResponseHandler = function( status, response ) {
707
+
708
+ // Hide loading.
709
+ document.querySelector( MPv1.selectors.box_loading ).style.background = "";
710
+
711
+ if ( status != 200 && status != 201 ) {
712
+ MPv1.showErrors( response );
713
+ } else {
714
+ var token = document.querySelector( MPv1.selectors.token );
715
+ token.value = response.id;
716
+
717
+ if ( MPv1.add_truncated_card ) {
718
+ var card = MPv1.truncateCard( response );
719
+ document.querySelector( MPv1.selectors.cardTruncated ).value = card;
720
+ }
721
+
722
+ if ( ! MPv1.create_token_on.event ) {
723
+ doSubmit = true;
724
+ btn = document.querySelector( MPv1.selectors.form );
725
+ btn.submit();
726
+ }
727
+ }
728
+
729
+ }
730
+
731
+ // === Useful functions
732
+
733
+ MPv1.resetBackgroundCard = function() {
734
+ document.querySelector( MPv1.selectors.paymentMethodSelector ).style.background =
735
+ "no-repeat #fff";
736
+ document.querySelector( MPv1.selectors.cardNumber ).style.background =
737
+ "no-repeat #fff";
738
+ }
739
+
740
+ MPv1.setForm = function() {
741
+ if ( MPv1.customer_and_card.status ) {
742
+ document.querySelector( MPv1.selectors.formDiv ).style.display = "none";
743
+ document.querySelector( MPv1.selectors.mpSecurityCodeCustomerAndCard ).removeAttribute( "style" );
744
+ } else {
745
+ document.querySelector( MPv1.selectors.mpSecurityCodeCustomerAndCard ).style.display = "none";
746
+ document.querySelector( MPv1.selectors.formDiv ).removeAttribute( "style" );
747
+ }
748
+
749
+ Mercadopago.clearSession();
750
+
751
+ if ( MPv1.create_token_on.event ) {
752
+ MPv1.createTokenByEvent();
753
+ MPv1.validateInputsCreateToken();
754
+ }
755
+
756
+ document.querySelector( MPv1.selectors.CustomerAndCard ).value =
757
+ MPv1.customer_and_card.status;
758
+ }
759
+
760
+ MPv1.getForm = function() {
761
+ if ( MPv1.customer_and_card.status ) {
762
+ return document.querySelector( MPv1.selectors.formCustomerAndCard );
763
+ } else {
764
+ return document.querySelector( MPv1.selectors.form );
765
+ }
766
+ }
767
+
768
+ MPv1.getInputsToCreateToken = function() {
769
+ if ( MPv1.customer_and_card.status ) {
770
+ return MPv1.inputs_to_create_token_customer_and_card;
771
+ } else {
772
+ return MPv1.inputs_to_create_token;
773
+ }
774
+ }
775
+
776
+ MPv1.truncateCard = function( response_card_token ) {
777
+
778
+ var first_six_digits;
779
+ var last_four_digits;
780
+
781
+ if ( MPv1.customer_and_card.status ) {
782
+ var cardSelector = document.querySelector( MPv1.selectors.paymentMethodSelector );
783
+ first_six_digits = cardSelector[cardSelector.options.selectedIndex]
784
+ .getAttribute( "first_six_digits" ).match( /.{1,4}/g )
785
+ last_four_digits = cardSelector[cardSelector.options.selectedIndex]
786
+ .getAttribute( "last_four_digits" )
787
+ } else {
788
+ first_six_digits = response_card_token.first_six_digits.match( /.{1,4}/g )
789
+ last_four_digits = response_card_token.last_four_digits
790
+ }
791
+
792
+ var card = first_six_digits[0] + " " +
793
+ first_six_digits[1] + "** **** " + last_four_digits;
794
+
795
+ return card;
796
+
797
+ }
798
+
799
+ MPv1.getAmount = function() {
800
+ return document.querySelector( MPv1.selectors.amount ).value;
801
+ }
802
+
803
+ // === Show errors
804
+
805
+ MPv1.showErrors = function( response ) {
806
+ var $form = MPv1.getForm();
807
+
808
+ for ( var x=0; x<response.cause.length; x++ ) {
809
+ var error = response.cause[x];
810
+ var $span = $form.querySelector( "#mp-error-" + error.code );
811
+ var $input = $form.querySelector( $span.getAttribute( "data-main" ) );
812
+
813
+ $span.style.display = "inline-block";
814
+ $input.classList.add( "mp-error-input" );
815
+ }
816
+
817
+ return;
818
+ }
819
+
820
+ MPv1.hideErrors = function() {
821
+
822
+ for ( var x = 0; x < document.querySelectorAll( "[data-checkout]" ).length; x++ ) {
823
+ var $field = document.querySelectorAll( "[data-checkout]" )[x];
824
+ $field.classList.remove( "mp-error-input" );
825
+ } // end for
826
+
827
+ for ( var x = 0; x < document.querySelectorAll( ".mp-error" ).length; x++ ) {
828
+ var $span = document.querySelectorAll( ".mp-error" )[x];
829
+ $span.style.display = "none";
830
+ }
831
+
832
+ return;
833
+
834
+ }
835
+
836
+ // === Add events to guessing
837
+
838
+ MPv1.addListenerEvent = function( el, eventName, handler ) {
839
+ if ( el.addEventListener ) {
840
+ el.addEventListener( eventName, handler );
841
+ } else {
842
+ el.attachEvent( "on" + eventName, function() {
843
+ handler.call( el );
844
+ });
845
+ }
846
+ };
847
+
848
+ MPv1.addListenerEvent(
849
+ document.querySelector( MPv1.selectors.cardNumber ),
850
+ "keyup", MPv1.guessingPaymentMethod
851
+ );
852
+ MPv1.addListenerEvent(
853
+ document.querySelector( MPv1.selectors.cardNumber ),
854
+ "keyup", MPv1.clearOptions
855
+ );
856
+ MPv1.addListenerEvent(
857
+ document.querySelector( MPv1.selectors.cardNumber),
858
+ "change", MPv1.guessingPaymentMethod
859
+ );
860
+
861
+ /*
862
+ *
863
+ * Utilities
864
+ *
865
+ */
866
+
867
+ MPv1.referer = (function () {
868
+ var referer = window.location.protocol + "//" +
869
+ window.location.hostname + ( window.location.port ? ":" + window.location.port: "" );
870
+ return referer;
871
+ })();
872
+
873
+ MPv1.AJAX = function( options ) {
874
+ var useXDomain = !!window.XDomainRequest;
875
+ var req = useXDomain ? new XDomainRequest() : new XMLHttpRequest()
876
+ var data;
877
+ options.url += ( options.url.indexOf( "?" ) >= 0 ? "&" : "?" ) + "referer=" + escape( MPv1.referer );
878
+ options.requestedMethod = options.method;
879
+ if ( useXDomain && options.method == "PUT" ) {
880
+ options.method = "POST";
881
+ options.url += "&_method=PUT";
882
+ }
883
+ req.open( options.method, options.url, true );
884
+ req.timeout = options.timeout || 1000;
885
+ if ( window.XDomainRequest ) {
886
+ req.onload = function() {
887
+ data = JSON.parse( req.responseText );
888
+ if ( typeof options.success === "function" ) {
889
+ options.success( options.requestedMethod === "POST" ? 201 : 200, data );
890
+ }
891
+ };
892
+ req.onerror = req.ontimeout = function() {
893
+ if ( typeof options.error === "function" ) {
894
+ options.error( 400, {
895
+ user_agent:window.navigator.userAgent, error : "bad_request", cause:[]
896
+ });
897
+ }
898
+ };
899
+ req.onprogress = function() {};
900
+ } else {
901
+ req.setRequestHeader( "Accept", "application/json" );
902
+ if ( options.contentType ) {
903
+ req.setRequestHeader( "Content-Type", options.contentType );
904
+ } else {
905
+ req.setRequestHeader( "Content-Type", "application/json" );
906
+ }
907
+ req.onreadystatechange = function() {
908
+ if ( this.readyState === 4 ) {
909
+ try {
910
+ if ( this.status >= 200 && this.status < 400 ) {
911
+ // Success!
912
+ data = JSON.parse( this.responseText );
913
+ if ( typeof options.success === "function" ) {
914
+ options.success( this.status, data );
915
+ }
916
+ } else if ( this.status >= 400 ) {
917
+ data = JSON.parse( this.responseText );
918
+ if ( typeof options.error === "function" ) {
919
+ options.error( this.status, data );
920
+ }
921
+ } else if ( typeof options.error === "function" ) {
922
+ options.error( 503, {} );
923
+ }
924
+ } catch (e) {
925
+ options.error( 503, {} );
926
+ }
927
+ }
928
+ };
929
+ }
930
+ if ( options.method === "GET" || options.data == null || options.data == undefined ) {
931
+ req.send();
932
+ } else {
933
+ req.send( JSON.stringify( options.data ) );
934
+ }
935
+ }
936
+
937
+ // === Initialization function
938
+
939
+ MPv1.Initialize = function( site_id, public_key, coupon_mode, discount_action_url, payer_email ) {
940
+
941
+ // Sets
942
+ MPv1.site_id = site_id;
943
+ MPv1.public_key = public_key;
944
+ MPv1.coupon_of_discounts.default = coupon_mode;
945
+ MPv1.coupon_of_discounts.discount_action_url = discount_action_url;
946
+ MPv1.coupon_of_discounts.payer_email = payer_email;
947
+
948
+ Mercadopago.setPublishableKey( MPv1.public_key );
949
+
950
+ // flow coupon of discounts
951
+ if ( MPv1.coupon_of_discounts.default ) {
952
+ MPv1.addListenerEvent(
953
+ document.querySelector( MPv1.selectors.applyCoupon ),
954
+ "click",
955
+ MPv1.checkCouponEligibility
956
+ );
957
+ } else {
958
+ document.querySelector( MPv1.selectors.formCoupon ).style.display = "none";
959
+ }
960
+
961
+ // Flow: customer & cards.
962
+ var selectorPmCustomerAndCards = document.querySelector( MPv1.selectors.pmCustomerAndCards );
963
+ if ( MPv1.customer_and_card.default && selectorPmCustomerAndCards.childElementCount > 0 ) {
964
+ MPv1.addListenerEvent(
965
+ document.querySelector( MPv1.selectors.paymentMethodSelector ),
966
+ "change", MPv1.cardsHandler
967
+ );
968
+ MPv1.cardsHandler();
969
+ } else {
970
+ // If customer & cards is disabled or customer does not have cards.
971
+ MPv1.customer_and_card.status = false;
972
+ document.querySelector( MPv1.selectors.formCustomerAndCard ).style.display = "none";
973
+ }
974
+
975
+ if ( MPv1.create_token_on.event ) {
976
+ MPv1.createTokenByEvent();
977
+ } else {
978
+ MPv1.createTokenBySubmit()
979
+ }
980
+
981
+ // flow: MLM
982
+ if ( MPv1.site_id != "MLM" ) {
983
+ Mercadopago.getIdentificationTypes();
984
+ }
985
+
986
+ if ( MPv1.site_id == "MLM" ) {
987
+
988
+ // Hide documento for mex.
989
+ document.querySelector( MPv1.selectors.mpDoc ).style.display = "none";
990
+
991
+ document.querySelector( MPv1.selectors.formCustomerAndCard ).removeAttribute( "style" );
992
+ document.querySelector( MPv1.selectors.formCustomerAndCard ).style.padding = "36px 12px 16px 12px";
993
+ document.querySelector( MPv1.selectors.mpSecurityCodeCustomerAndCard ).style.display = "none";
994
+
995
+ // Removing not used fields for this country.
996
+ MPv1.inputs_to_create_token.splice(
997
+ MPv1.inputs_to_create_token.indexOf( "docType" ),
998
+ 1 );
999
+ MPv1.inputs_to_create_token.splice(
1000
+ MPv1.inputs_to_create_token.indexOf( "docNumber" ),
1001
+ 1 );
1002
+
1003
+ MPv1.addListenerEvent(
1004
+ document.querySelector( MPv1.selectors.paymentMethodSelector ),
1005
+ "change",
1006
+ MPv1.changePaymetMethodSelector
1007
+ );
1008
+
1009
+ // Get payment methods and populate selector.
1010
+ MPv1.getPaymentMethods();
1011
+
1012
+ }
1013
+
1014
+ // flow: MLB AND MCO
1015
+ if ( MPv1.site_id == "MLB" ) {
1016
+
1017
+ document.querySelector( MPv1.selectors.mpDocType ).style.display = "none";
1018
+ document.querySelector( MPv1.selectors.mpIssuer ).style.display = "none";
1019
+ // Adjust css.
1020
+ document.querySelector( MPv1.selectors.docNumber ).classList.remove( "mp-col-75" );
1021
+ document.querySelector( MPv1.selectors.docNumber ).classList.add( "mp-col-100" );
1022
+
1023
+ } else if ( MPv1.site_id == "MCO" ) {
1024
+ document.querySelector( MPv1.selectors.mpIssuer ).style.display = "none";
1025
+ } else if ( MPv1.site_id == "MLA" ) {
1026
+ document.querySelector( MPv1.selectors.boxInstallmentsSelector ).classList.remove( "mp-col-100" );
1027
+ document.querySelector( MPv1.selectors.boxInstallmentsSelector ).classList.add( "mp-col-70" );
1028
+ document.querySelector( MPv1.selectors.taxCFT ).style.display = "block";
1029
+ document.querySelector( MPv1.selectors.taxTEA ).style.display = "block";
1030
+ MPv1.addListenerEvent( document.querySelector( MPv1.selectors.installments ), "change", MPv1.showTaxes );
1031
+ } else if ( MPv1.site_id == "MLC" ) {
1032
+ document.querySelector(MPv1.selectors.mpIssuer).style.display = "none";
1033
+ }
1034
+
1035
+ if ( MPv1.debug ) {
1036
+ document.querySelector( MPv1.selectors.utilities_fields ).style.display = "inline-block";
1037
+ }
1038
+
1039
+ document.querySelector( MPv1.selectors.site_id ).value = MPv1.site_id;
1040
+
1041
+ return;
1042
+
1043
+ }
1044
+
1045
+ this.MPv1 = MPv1;
1046
+
1047
+ } ).call();
1048
+
1049
+ // Overriding this function to give form padding attribute.
1050
+ MPv1.setForm = function() {
1051
+ if ( MPv1.customer_and_card.status ) {
1052
+ document.querySelector( MPv1.selectors.form ).style.display = "none";
1053
+ document.querySelector( MPv1.selectors.mpSecurityCodeCustomerAndCard ).removeAttribute( "style" );
1054
+ } else {
1055
+ document.querySelector( MPv1.selectors.mpSecurityCodeCustomerAndCard ).style.display = "none";
1056
+ document.querySelector( MPv1.selectors.form ).removeAttribute( "style" );
1057
+ document.querySelector( MPv1.selectors.form ).style.padding = "0px 12px 0px 12px";
1058
+ }
1059
+ Mercadopago.clearSession();
1060
+ if ( MPv1.create_token_on.event ) {
1061
+ MPv1.createTokenByEvent();
1062
+ MPv1.validateInputsCreateToken();
1063
+ }
1064
+ document.querySelector( MPv1.selectors.CustomerAndCard ).value = MPv1.customer_and_card.status;
1065
+ }
1066
+
1067
+ MPv1.getAmount = function() {
1068
+ return document.querySelector( MPv1.selectors.amount ).value - document.querySelector( MPv1.selectors.discount ).value;
1069
+ }
1070
+
1071
+ MPv1.getAmountWithoutDiscount = function() {
1072
+ return document.querySelector( MPv1.selectors.amount ).value;
1073
+ }
1074
+
1075
+ MPv1.showErrors = function( response ) {
1076
+ var $form = MPv1.getForm();
1077
+ for ( var x=0; x<response.cause.length; x++ ) {
1078
+ var error = response.cause[x];
1079
+ var $span = $form.querySelector( "#mp-error-" + error.code );
1080
+ var $input = $form.querySelector( $span.getAttribute( "data-main" ) );
1081
+ $span.style.display = "inline-block";
1082
+ $input.classList.add( "mp-error-input" );
1083
+ }
1084
+ return;
1085
+ }
assets/js/ticket.js ADDED
@@ -0,0 +1,591 @@