Version Description
Please refer to our github repo.
Download this release
Release Info
Developer | mercadopago |
Plugin | ![]() |
Version | old.1.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.4 to old.1.0.3
- README.txt +92 -0
- assets/css/custom_checkout_mercadopago.css +0 -307
- assets/images/MCO/CUPOM_MCO.jpg +0 -0
- assets/images/MCO/banner_all_methods.png +0 -0
- assets/images/MCO/standard_mco.jpg +0 -0
- assets/images/MLA/CUPOM_MLA.jpg +0 -0
- assets/images/MLA/banner_all_methods.png +0 -0
- assets/images/MLA/credit_card.png +0 -0
- assets/images/MLB/CUPOM_MLB.jpg +0 -0
- assets/images/MLB/banner_all_methods.png +0 -0
- assets/images/MLB/cupom1.jpg +0 -0
- assets/images/MLB/cupom2.jpg +0 -0
- assets/images/MLB/cupom3.jpg +0 -0
- assets/images/MLB/desconto_MLB.jpg +0 -0
- assets/images/MLB/standard_mlb.jpg +0 -0
- assets/images/MLC/CUPOM_MLC.jpg +0 -0
- assets/images/MLC/banner_all_methods.png +0 -0
- assets/images/MLC/standard_mlc.gif +0 -0
- assets/images/MLM/CUPOM_MLM.jpg +0 -0
- assets/images/MLM/banner_all_methods.png +0 -0
- assets/images/MLM/credit_card.png +0 -0
- assets/images/MLU/CUPOM_MLU.png +0 -0
- assets/images/MLU/MLU.png +0 -0
- assets/images/MLU/banner_all_methods.png +0 -0
- assets/images/MLU/credit_card.png +0 -0
- assets/images/MLU/standard_mlu.png +0 -0
- assets/images/MLV/CUPOM_MLV.jpg +0 -0
- assets/images/MLV/banner_all_methods.png +0 -0
- assets/images/MLV/standard_mlv.jpg +0 -0
- assets/images/MPE/CUPOM_MPE.png +0 -0
- assets/images/MPE/MPE.png +0 -0
- assets/images/MPE/banner_all_methods.png +0 -0
- assets/images/MPE/credit_card.png +0 -0
- assets/images/MPE/standard_mpe.png +0 -0
- assets/images/bandeiras/amex.png +0 -0
- assets/images/bandeiras/boleto.png +0 -0
- assets/images/bandeiras/cash.png +0 -0
- assets/images/bandeiras/diners.png +0 -0
- assets/images/bandeiras/elo.png +0 -0
- assets/images/bandeiras/hipercard.png +0 -0
- assets/images/bandeiras/master.png +0 -0
- assets/images/bandeiras/melicard.png +0 -0
- assets/images/bandeiras/visa.png +0 -0
- assets/images/banner.png +0 -0
- assets/images/bar_code.png +0 -0
- assets/images/boleto.png +0 -0
- assets/images/cart.png +0 -0
- assets/images/credit_card.png +0 -0
- assets/images/cvv.png +0 -0
- assets/images/loading.gif +0 -0
- assets/js/credit-card.js +0 -1085
- assets/js/ticket.js +0 -591
- i18n/languages/woocommerce-mercadopago-es_AR.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_AR.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_CL.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_CL.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_CO.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_CO.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_ES.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_ES.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_MX.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_MX.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_PE.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_PE.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_UY.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_UY.po +0 -1010
- i18n/languages/woocommerce-mercadopago-es_VE.mo +0 -0
- i18n/languages/woocommerce-mercadopago-es_VE.po +0 -1010
- i18n/languages/woocommerce-mercadopago-pt_BR.mo +0 -0
- i18n/languages/woocommerce-mercadopago-pt_BR.po +0 -1010
- i18n/languages/woocommerce-mercadopago.pot +0 -1010
- assets/images/MCO/credit_card.png → images/MCO.jpg +0 -0
- {assets/images/MCO → images}/MCO.png +0 -0
- assets/images/MLA/standard_mla.jpg → images/MLA.jpg +0 -0
- {assets/images/MLA → images}/MLA.png +0 -0
- assets/images/MLB/credit_card.png → images/MLB.jpg +0 -0
- {assets/images/MLB → images}/MLB.png +0 -0
- assets/images/MLC/credit_card.png → images/MLC.gif +0 -0
- {assets/images/MLC → images}/MLC.png +0 -0
- assets/images/MLM/standard_mlm.jpg → images/MLM.jpg +0 -0
- {assets/images/MLM → images}/MLM.png +0 -0
- assets/images/MLV/credit_card.png → images/MLV.jpg +0 -0
- {assets/images/MLV → images}/MLV.png +0 -0
- {assets/images → images}/check.png +0 -0
- {assets/images → images}/error.png +0 -0
- {assets/images → images}/mercadopago.png +0 -0
- {assets/images → images}/mplogo.png +0 -0
- {assets/images → images}/warning.png +0 -0
- includes/WC_WooMercadoPago_BasicGateway.php +0 -1477
- includes/WC_WooMercadoPago_CustomGateway.php +0 -1337
- includes/WC_WooMercadoPago_SubscriptionGateway.php +0 -1133
- includes/WC_WooMercadoPago_TicketGateway.php +0 -1297
- includes/admin/class-wc-mercadoenvios-admin-orders.php +0 -94
- includes/class-wc-product-mp_recurrent.php +0 -210
- includes/sdk/lib/mercadopago.php +0 -1245
- includes/shipment/abstract-wc-mercadoenvios-shipping.php +0 -355
- includes/shipment/class-wc-mercadoenvios-package.php +0 -257
- includes/shipment/class-wc-mercadoenvios-shipping-express.php +0 -35
- includes/shipment/class-wc-mercadoenvios-shipping-normal.php +0 -35
- languages/woocommerce-mercadopago-module-es_AR.mo +0 -0
- languages/woocommerce-mercadopago-module-es_AR.po +348 -0
- languages/woocommerce-mercadopago-module-es_CL.mo +0 -0
- languages/woocommerce-mercadopago-module-es_CL.po +348 -0
- languages/woocommerce-mercadopago-module-es_CO.mo +0 -0
- languages/woocommerce-mercadopago-module-es_CO.po +355 -0
- languages/woocommerce-mercadopago-module-es_MX.mo +0 -0
- languages/woocommerce-mercadopago-module-es_MX.po +348 -0
- languages/woocommerce-mercadopago-module-es_VE.mo +0 -0
- languages/woocommerce-mercadopago-module-es_VE.po +348 -0
- languages/woocommerce-mercadopago-module-pt_BR.mo +0 -0
- languages/woocommerce-mercadopago-module-pt_BR.po +412 -0
- languages/woocommerce-mercadopago-module.pot +527 -0
- mercadopago-module.php +110 -0
- mercadopago/css/woo-mercadopago-module.css +14 -0
- mercadopago/mercadopago-gateway.php +902 -0
- {includes → mercadopago}/sdk/lib/cacert.pem +0 -0
- mercadopago/sdk/lib/mercadopago.php +578 -0
- readme.txt +0 -193
- templates/credit-card/payment-form.php +0 -1379
- templates/mp_main_settings.php +0 -386
- templates/ticket/ticket-form.php +0 -835
- templates/woocommerce-altas.html +0 -498
- woocommerce-mercadopago.php +0 -1202
README.txt
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Woo Mercado Pago Module ===
|
2 |
+
Contributors: mercadopago, mercadolivre
|
3 |
+
Donate link: https://www.mercadopago.com.br/developers/
|
4 |
+
Tags: mercadopago, ecommerce, payment, checkout
|
5 |
+
Requires at least: WooCommerce 2.1.x
|
6 |
+
Tested up to: WooCommerce 2.5.x
|
7 |
+
Stable tag: 1.0.3
|
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 |
+
== Installation ==
|
18 |
+
|
19 |
+
1. Copy **woo-mercado-pago-module** folder to **[WordPressRootDirectory]/wp-content/plugins/** folder.
|
20 |
+
|
21 |
+
2. On your store administration, go to **Plugins** option in sidebar.
|
22 |
+
|
23 |
+
3. Search by **WooCommerce Mercado Pago** and click enable. <br />
|
24 |
+
You will receive the following message: "Plugin enabled." as a notice in your WordPress.
|
25 |
+
|
26 |
+
== Upgrade Notice ==
|
27 |
+
|
28 |
+
Please refer to our github repo.
|
29 |
+
|
30 |
+
== Installation ==
|
31 |
+
|
32 |
+
1. Go to **WooCommerce > Configuration > Checkout Tab > Mercado Pago**. <br />
|
33 |
+
Fist of all, you need to configure your client credentials. To make it, fill your **Client_id**, **Client_secret** in Mercado Pago Credentials section.
|
34 |
+
|
35 |
+
You can obtain your **Client_id** and **Client_secret**, accordingly to your country, in the following links:
|
36 |
+
|
37 |
+
* Argentina: https://www.mercadopago.com/mla/herramientas/aplicaciones
|
38 |
+
* Brazil: https://www.mercadopago.com/mlb/ferramentas/aplicacoes
|
39 |
+
* Chile: https://www.mercadopago.com/mlc/herramientas/aplicaciones
|
40 |
+
* Colombia: https://www.mercadopago.com/mco/herramientas/aplicaciones
|
41 |
+
* Mexico: https://www.mercadopago.com/mlm/herramientas/aplicaciones
|
42 |
+
* Venezuela: https://www.mercadopago.com/mlv/herramientas/aplicaciones
|
43 |
+
|
44 |
+
2. Other general configurations. <br />
|
45 |
+
* **Instant Payment Notification (IPN) URL**
|
46 |
+
The highlighted URL is where you will get notified about payment updates.<br /><br />
|
47 |
+
* **Checkout Options**
|
48 |
+
**Title**: This is the title of the payment option that will be shown to your customers;<br />
|
49 |
+
**Description**: This is the description of the payment option that will be shown to your customers;<br />
|
50 |
+
**Store Category**: Sets up the category of the store;<br />
|
51 |
+
**Store Identificator**: A prefix to identify your store, when you have multiple stores for only one Mercado Pago account;<br />
|
52 |
+
**Integration Method**: How your customers will interact with Mercado Pago to pay their orders;<br />
|
53 |
+
**iFrame Width**: The width, in pixels, of the iFrame (used only with iFrame Integration Method);<br />
|
54 |
+
**iFrame Height**: The height, in pixels, of the iFrame (used only with iFrame Integration Method);<br />
|
55 |
+
**Auto Return**: If set, the platform will return to your store when the payment is approved.<br /><br />
|
56 |
+
* **Payment Options**
|
57 |
+
**Max Installments**: The maximum installments allowed for your customers;<br />
|
58 |
+
**Exclude Payment Methods**: Select the payment methods that you want to not work with Mercado Pago.<br /><br />
|
59 |
+
* **Test and Debug Options**
|
60 |
+
**Mercado Pago Sandboxs**: Test your payments in Mercado Pago sandbox environment;<br />
|
61 |
+
**Debug and Log**: Enables/disables system logs.<br />
|
62 |
+
|
63 |
+
== Frequently Asked Questions ==
|
64 |
+
|
65 |
+
= Any questions? =
|
66 |
+
|
67 |
+
Please, check our FAQ at: https://www.mercadopago.com.br/ajuda/
|
68 |
+
|
69 |
+
== Screenshots ==
|
70 |
+
|
71 |
+
1. Settings page.
|
72 |
+
|
73 |
+
== Changelog ==
|
74 |
+
|
75 |
+
= v1.0.0 (16/03/2016) =
|
76 |
+
* LatAm support;
|
77 |
+
* Title, description, category, and external reference customizations;
|
78 |
+
* Integrations via iframe, modal, and redirection, with configurable auto-returning;
|
79 |
+
* Max installments and payment method exclusion setup;
|
80 |
+
* Sandbox and debug options.
|
81 |
+
|
82 |
+
= v1.0.1 (23/03/2016) =
|
83 |
+
* Added payment ID in order custom fields information;
|
84 |
+
* Removed some unused files/code;
|
85 |
+
* Redesign of the logic of preferences when creating cart, separating items;
|
86 |
+
* Proper information of shipment cost
|
87 |
+
|
88 |
+
= v1.0.2 (23/03/2016) =
|
89 |
+
* IPN URL wasn’t triggered when topic=payment
|
90 |
+
|
91 |
+
= v1.0.3 (23/03/2016) =
|
92 |
+
* Improving algorithm when processing IPN
|
assets/css/custom_checkout_mercadopago.css
DELETED
@@ -1,307 +0,0 @@
|
|
1 |
-
body{
|
2 |
-
background-color: #F5F5F5;
|
3 |
-
padding: 0;
|
4 |
-
margin: 0;
|
5 |
-
}
|
6 |
-
|
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;
|
14 |
-
}
|
15 |
-
|
16 |
-
.mp-box-inputs{
|
17 |
-
float: left;
|
18 |
-
}
|
19 |
-
|
20 |
-
.mp-col-10{
|
21 |
-
width: 10%;
|
22 |
-
}
|
23 |
-
|
24 |
-
.mp-col-20{
|
25 |
-
width: 20%;
|
26 |
-
}
|
27 |
-
|
28 |
-
.mp-col-25{
|
29 |
-
width: 25%;
|
30 |
-
}
|
31 |
-
|
32 |
-
.mp-col-30{
|
33 |
-
width: 30%;
|
34 |
-
}
|
35 |
-
|
36 |
-
.mp-col-35{
|
37 |
-
width: 35%;
|
38 |
-
}
|
39 |
-
|
40 |
-
.mp-col-45{
|
41 |
-
width: 45%;
|
42 |
-
}
|
43 |
-
|
44 |
-
.mp-col-50{
|
45 |
-
width: 50%;
|
46 |
-
}
|
47 |
-
|
48 |
-
.mp-col-55{
|
49 |
-
width: 55%;
|
50 |
-
}
|
51 |
-
|
52 |
-
.mp-col-65{
|
53 |
-
width: 65%;
|
54 |
-
}
|
55 |
-
|
56 |
-
.mp-col-75{
|
57 |
-
width: 75%;
|
58 |
-
}
|
59 |
-
|
60 |
-
.mp-col-100{
|
61 |
-
width: 100%;
|
62 |
-
margin: 5px 0;
|
63 |
-
}
|
64 |
-
|
65 |
-
.mp-line{
|
66 |
-
width: 100%;
|
67 |
-
margin: 5px 0;
|
68 |
-
}
|
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;
|
76 |
-
}
|
77 |
-
|
78 |
-
.mp-box-inputs label em{
|
79 |
-
color: red;
|
80 |
-
}
|
81 |
-
|
82 |
-
.mp-box-inputs input, .mp-box-inputs select{
|
83 |
-
width: 100%;
|
84 |
-
background-color: #fff;
|
85 |
-
border: 1px solid #cecece;
|
86 |
-
padding: 5px;
|
87 |
-
border-radius: 3px;
|
88 |
-
color: #666;
|
89 |
-
height: 40px;
|
90 |
-
}
|
91 |
-
|
92 |
-
.mp-box-inputs input:focus, .mp-box-inputs select:focus{
|
93 |
-
border: 1px solid #999;
|
94 |
-
outline: 0;
|
95 |
-
}
|
96 |
-
|
97 |
-
|
98 |
-
.mp-box-inputs input.mp-error-input, .mp-box-inputs select.mp-error-input{
|
99 |
-
border: 1px solid red;
|
100 |
-
}
|
101 |
-
|
102 |
-
#mp-box-loading{
|
103 |
-
width: 30px;
|
104 |
-
height: 30px;
|
105 |
-
display: inline-block;
|
106 |
-
margin: -10px 0px;
|
107 |
-
}
|
108 |
-
|
109 |
-
#mp-separete-date{
|
110 |
-
vertical-align: middle;
|
111 |
-
line-height: 65px;
|
112 |
-
text-align: center;
|
113 |
-
height: 48px;
|
114 |
-
font-size: 24px;
|
115 |
-
font-weight: 100;
|
116 |
-
}
|
117 |
-
|
118 |
-
#mercadopago-utilities{
|
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;
|
140 |
-
border-color: #2e6da4;
|
141 |
-
padding: 6px 12px;
|
142 |
-
border: 1px solid transparent;
|
143 |
-
border-radius: 4px;
|
144 |
-
text-align: center;
|
145 |
-
font-size: 14px;
|
146 |
-
font-weight: 400;
|
147 |
-
}
|
148 |
-
|
149 |
-
#submit:hover {
|
150 |
-
color: #fff;
|
151 |
-
background-color: #286090;
|
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 |
-
*
|
261 |
-
*
|
262 |
-
* Error
|
263 |
-
*
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/images/MCO/CUPOM_MCO.jpg
DELETED
Binary file
|
assets/images/MCO/banner_all_methods.png
DELETED
Binary file
|
assets/images/MCO/standard_mco.jpg
DELETED
Binary file
|
assets/images/MLA/CUPOM_MLA.jpg
DELETED
Binary file
|
assets/images/MLA/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLA/credit_card.png
DELETED
Binary file
|
assets/images/MLB/CUPOM_MLB.jpg
DELETED
Binary file
|
assets/images/MLB/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLB/cupom1.jpg
DELETED
Binary file
|
assets/images/MLB/cupom2.jpg
DELETED
Binary file
|
assets/images/MLB/cupom3.jpg
DELETED
Binary file
|
assets/images/MLB/desconto_MLB.jpg
DELETED
Binary file
|
assets/images/MLB/standard_mlb.jpg
DELETED
Binary file
|
assets/images/MLC/CUPOM_MLC.jpg
DELETED
Binary file
|
assets/images/MLC/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLC/standard_mlc.gif
DELETED
Binary file
|
assets/images/MLM/CUPOM_MLM.jpg
DELETED
Binary file
|
assets/images/MLM/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLM/credit_card.png
DELETED
Binary file
|
assets/images/MLU/CUPOM_MLU.png
DELETED
Binary file
|
assets/images/MLU/MLU.png
DELETED
Binary file
|
assets/images/MLU/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLU/credit_card.png
DELETED
Binary file
|
assets/images/MLU/standard_mlu.png
DELETED
Binary file
|
assets/images/MLV/CUPOM_MLV.jpg
DELETED
Binary file
|
assets/images/MLV/banner_all_methods.png
DELETED
Binary file
|
assets/images/MLV/standard_mlv.jpg
DELETED
Binary file
|
assets/images/MPE/CUPOM_MPE.png
DELETED
Binary file
|
assets/images/MPE/MPE.png
DELETED
Binary file
|
assets/images/MPE/banner_all_methods.png
DELETED
Binary file
|
assets/images/MPE/credit_card.png
DELETED
Binary file
|
assets/images/MPE/standard_mpe.png
DELETED
Binary file
|
assets/images/bandeiras/amex.png
DELETED
Binary file
|
assets/images/bandeiras/boleto.png
DELETED
Binary file
|
assets/images/bandeiras/cash.png
DELETED
Binary file
|
assets/images/bandeiras/diners.png
DELETED
Binary file
|
assets/images/bandeiras/elo.png
DELETED
Binary file
|
assets/images/bandeiras/hipercard.png
DELETED
Binary file
|
assets/images/bandeiras/master.png
DELETED
Binary file
|
assets/images/bandeiras/melicard.png
DELETED
Binary file
|
assets/images/bandeiras/visa.png
DELETED
Binary file
|
assets/images/banner.png
DELETED
Binary file
|
assets/images/bar_code.png
DELETED
Binary file
|
assets/images/boleto.png
DELETED
Binary file
|
assets/images/cart.png
DELETED
Binary file
|
assets/images/credit_card.png
DELETED
Binary file
|
assets/images/cvv.png
DELETED
Binary file
|
assets/images/loading.gif
DELETED
Binary file
|
assets/js/credit-card.js
DELETED
@@ -1,1085 +0,0 @@
|
|
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
DELETED
@@ -1,591 +0,0 @@
|
|
1 |
-
( function() {
|
2 |
-
|
3 |
-
var MPv1Ticket = {
|
4 |
-
site_id: "",
|
5 |
-
coupon_of_discounts: {
|
6 |
-
discount_action_url: "",
|
7 |
-
payer_email: "",
|
8 |
-
default: true,
|
9 |
-
status: false
|
10 |
-
},
|
11 |
-
inputs_to_create_discount: [
|
12 |
-
"couponCodeTicket",
|
13 |
-
"applyCouponTicket"
|
14 |
-
],
|
15 |
-
inputs_to_validate_ticket: [
|
16 |
-
"firstname",
|
17 |
-
"lastname",
|
18 |
-
"docNumber",
|
19 |
-
"address",
|
20 |
-
"number",
|
21 |
-
"city",
|
22 |
-
"state",
|
23 |
-
"zipcode"
|
24 |
-
],
|
25 |
-
selectors: {
|
26 |
-
// currency
|
27 |
-
currency_ratio: "#currency_ratioTicket",
|
28 |
-
// coupom
|
29 |
-
couponCode: "#couponCodeTicket",
|
30 |
-
applyCoupon: "#applyCouponTicket",
|
31 |
-
mpCouponApplyed: "#mpCouponApplyedTicket",
|
32 |
-
mpCouponError: "#mpCouponErrorTicket",
|
33 |
-
campaign_id: "#campaign_idTicket",
|
34 |
-
campaign: "#campaignTicket",
|
35 |
-
discount: "#discountTicket",
|
36 |
-
// payment method and checkout
|
37 |
-
paymentMethodId: "#paymentMethodIdTicket",
|
38 |
-
amount: "#amountTicket",
|
39 |
-
// other rules
|
40 |
-
boxFirstName: "#box-firstname",
|
41 |
-
boxLastName: "#box-lastname",
|
42 |
-
boxDocNumber: "#box-docnumber",
|
43 |
-
titleFirstName: ".title-name",
|
44 |
-
titleFirstNameRazaoSocial: ".title-razao-social",
|
45 |
-
titleDocNumber: ".title-cpf",
|
46 |
-
titleDocNumberCNPJ: ".title-cnpj",
|
47 |
-
radioTypeFisica: '#MPv1Ticket-docType-fisica',
|
48 |
-
radioTypeJuridica: '#MPv1Ticket-docType-juridica',
|
49 |
-
// febraban
|
50 |
-
firstname: "#febrabanFirstname",
|
51 |
-
lastname: "#febrabanLastname",
|
52 |
-
cpfcnpj: "#cpfcnpj",
|
53 |
-
address: "#febrabanAddress",
|
54 |
-
number: "#febrabanNumber",
|
55 |
-
city: "#febrabanCity",
|
56 |
-
state: "#febrabanState",
|
57 |
-
zipcode: "#febrabanZipcode",
|
58 |
-
// form
|
59 |
-
formCoupon: "#mercadopago-form-coupon-ticket",
|
60 |
-
formTicket: "#form-ticket",
|
61 |
-
box_loading: "#mp-box-loading",
|
62 |
-
submit: "#btnSubmit",
|
63 |
-
form: "#mercadopago-form-ticket"
|
64 |
-
},
|
65 |
-
text: {
|
66 |
-
discount_info1: "You will save",
|
67 |
-
discount_info2: "with discount from",
|
68 |
-
discount_info3: "Total of your purchase:",
|
69 |
-
discount_info4: "Total of your purchase with discount:",
|
70 |
-
discount_info5: "*Uppon payment approval",
|
71 |
-
discount_info6: "Terms and Conditions of Use",
|
72 |
-
coupon_empty: "Please, inform your coupon code",
|
73 |
-
apply: "Apply",
|
74 |
-
remove: "Remove"
|
75 |
-
},
|
76 |
-
paths: {
|
77 |
-
loading: "images/loading.gif",
|
78 |
-
check: "images/check.png",
|
79 |
-
error: "images/error.png"
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
// === Coupon of Discounts
|
84 |
-
|
85 |
-
MPv1Ticket.currencyIdToCurrency = function ( currency_id ) {
|
86 |
-
if ( currency_id == "ARS" ) {
|
87 |
-
return "quot;;
|
88 |
-
} else if ( currency_id == "BRL" ) {
|
89 |
-
return "Rquot;;
|
90 |
-
} else if ( currency_id == "COP" ) {
|
91 |
-
return "quot;;
|
92 |
-
} else if ( currency_id == "CLP" ) {
|
93 |
-
return "quot;;
|
94 |
-
} else if ( currency_id == "MXN" ) {
|
95 |
-
return "quot;;
|
96 |
-
} else if ( currency_id == "VEF" ) {
|
97 |
-
return "Bs";
|
98 |
-
} else if ( currency_id == "PEN" ) {
|
99 |
-
return "S/";
|
100 |
-
} else if ( currency_id == "UYU" ) {
|
101 |
-
return "$U";
|
102 |
-
} else {
|
103 |
-
return "quot;;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
MPv1Ticket.checkCouponEligibility = function () {
|
108 |
-
if ( document.querySelector( MPv1Ticket.selectors.couponCode ).value == "" ) {
|
109 |
-
// Coupon code is empty.
|
110 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display = "none";
|
111 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display = "block";
|
112 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).innerHTML = MPv1Ticket.text.coupon_empty;
|
113 |
-
MPv1Ticket.coupon_of_discounts.status = false;
|
114 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background = null;
|
115 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).value = MPv1Ticket.text.apply;
|
116 |
-
document.querySelector( MPv1Ticket.selectors.discount ).value = 0;
|
117 |
-
// --- No cards handler ---
|
118 |
-
} else if ( MPv1Ticket.coupon_of_discounts.status ) {
|
119 |
-
// We already have a coupon set, so we remove it.
|
120 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display = "none";
|
121 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display = "none";
|
122 |
-
MPv1Ticket.coupon_of_discounts.status = false;
|
123 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).style.background = null;
|
124 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).value = MPv1Ticket.text.apply;
|
125 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).value = "";
|
126 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background = null;
|
127 |
-
document.querySelector( MPv1Ticket.selectors.discount ).value = 0;
|
128 |
-
// --- No cards handler ---
|
129 |
-
} else {
|
130 |
-
// Set loading.
|
131 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display = "none";
|
132 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display = "none";
|
133 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background = "url(" + MPv1Ticket.paths.loading + ") 98% 50% no-repeat #fff";
|
134 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).disabled = true;
|
135 |
-
|
136 |
-
// Check if there are params in the url.
|
137 |
-
var url = MPv1Ticket.coupon_of_discounts.discount_action_url;
|
138 |
-
var sp = "?";
|
139 |
-
if ( url.indexOf( "?" ) >= 0 ) {
|
140 |
-
sp = "&";
|
141 |
-
}
|
142 |
-
url += sp + "site_id=" + MPv1Ticket.site_id;
|
143 |
-
url += "&coupon_id=" + document.querySelector( MPv1Ticket.selectors.couponCode ).value;
|
144 |
-
url += "&amount=" + document.querySelector( MPv1Ticket.selectors.amount ).value;
|
145 |
-
url += "&payer=" + MPv1Ticket.coupon_of_discounts.payer_email;
|
146 |
-
//url += "&payer=" + document.getElementById( "billing_email" ).value;
|
147 |
-
|
148 |
-
MPv1Ticket.AJAX({
|
149 |
-
url: url,
|
150 |
-
method : "GET",
|
151 |
-
timeout : 5000,
|
152 |
-
error: function() {
|
153 |
-
// Request failed.
|
154 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display = "none";
|
155 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display = "none";
|
156 |
-
MPv1Ticket.coupon_of_discounts.status = false;
|
157 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).style.background = null;
|
158 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).value = MPv1Ticket.text.apply;
|
159 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).value = "";
|
160 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background = null;
|
161 |
-
document.querySelector( MPv1Ticket.selectors.discount ).value = 0;
|
162 |
-
// --- No cards handler ---
|
163 |
-
},
|
164 |
-
success : function ( status, response ) {
|
165 |
-
if ( response.status == 200 ) {
|
166 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display =
|
167 |
-
"block";
|
168 |
-
document.querySelector( MPv1Ticket.selectors.discount ).value =
|
169 |
-
response.response.coupon_amount;
|
170 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).innerHTML =
|
171 |
-
//"<div style='border-style: solid; border-width:thin; " +
|
172 |
-
//"border-color: #009EE3; padding: 8px 8px 8px 8px; margin-top: 4px;'>" +
|
173 |
-
MPv1Ticket.text.discount_info1 + " <strong>" +
|
174 |
-
MPv1Ticket.currencyIdToCurrency( response.response.currency_id ) + " " +
|
175 |
-
Math.round( response.response.coupon_amount * 100 ) / 100 +
|
176 |
-
"</strong> " + MPv1Ticket.text.discount_info2 + " " +
|
177 |
-
response.response.name + ".<br>" + MPv1Ticket.text.discount_info3 + " <strong>" +
|
178 |
-
MPv1Ticket.currencyIdToCurrency( response.response.currency_id ) + " " +
|
179 |
-
Math.round( MPv1Ticket.getAmountWithoutDiscount() * 100 ) / 100 +
|
180 |
-
"</strong><br>" + MPv1Ticket.text.discount_info4 + " <strong>" +
|
181 |
-
MPv1Ticket.currencyIdToCurrency( response.response.currency_id ) + " " +
|
182 |
-
Math.round( MPv1Ticket.getAmount() * 100 ) / 100 + "*</strong><br>" +
|
183 |
-
"<i>" + MPv1Ticket.text.discount_info5 + "</i><br>" +
|
184 |
-
"<a href='https://api.mercadolibre.com/campaigns/" +
|
185 |
-
response.response.id +
|
186 |
-
"/terms_and_conditions?format_type=html' target='_blank'>" +
|
187 |
-
MPv1Ticket.text.discount_info6 + "</a>";
|
188 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display =
|
189 |
-
"none";
|
190 |
-
MPv1Ticket.coupon_of_discounts.status = true;
|
191 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background =
|
192 |
-
null;
|
193 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background =
|
194 |
-
"url(" + MPv1Ticket.paths.check + ") 98% 50% no-repeat #fff";
|
195 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).value =
|
196 |
-
MPv1Ticket.text.remove;
|
197 |
-
// --- No cards handler ---
|
198 |
-
document.querySelector( MPv1Ticket.selectors.campaign_id ).value =
|
199 |
-
response.response.id;
|
200 |
-
document.querySelector( MPv1Ticket.selectors.campaign ).value =
|
201 |
-
response.response.name;
|
202 |
-
} else {
|
203 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponApplyed ).style.display = "none";
|
204 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).style.display = "block";
|
205 |
-
document.querySelector( MPv1Ticket.selectors.mpCouponError ).innerHTML = response.response.message;
|
206 |
-
MPv1Ticket.coupon_of_discounts.status = false;
|
207 |
-
document.querySelector(MPv1Ticket.selectors.couponCode).style.background = null;
|
208 |
-
document.querySelector( MPv1Ticket.selectors.couponCode ).style.background = "url(" + MPv1Ticket.paths.error + ") 98% 50% no-repeat #fff";
|
209 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).value = MPv1Ticket.text.apply;
|
210 |
-
document.querySelector( MPv1Ticket.selectors.discount ).value = 0;
|
211 |
-
// --- No cards handler ---
|
212 |
-
}
|
213 |
-
document.querySelector( MPv1Ticket.selectors.applyCoupon ).disabled = false;
|
214 |
-
}
|
215 |
-
});
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
// === Initialization function
|
220 |
-
|
221 |
-
MPv1Ticket.addListenerEvent = function( el, eventName, handler ) {
|
222 |
-
if ( el.addEventListener ) {
|
223 |
-
el.addEventListener( eventName, handler );
|
224 |
-
} else {
|
225 |
-
el.attachEvent( "on" + eventName, function() {
|
226 |
-
handler.call( el );
|
227 |
-
} );
|
228 |
-
}
|
229 |
-
};
|
230 |
-
|
231 |
-
/*
|
232 |
-
*
|
233 |
-
* Utilities
|
234 |
-
*
|
235 |
-
*/
|
236 |
-
|
237 |
-
MPv1Ticket.referer = (function () {
|
238 |
-
var referer = window.location.protocol + "//" +
|
239 |
-
window.location.hostname + ( window.location.port ? ":" + window.location.port: "" );
|
240 |
-
return referer;
|
241 |
-
})();
|
242 |
-
|
243 |
-
MPv1Ticket.AJAX = function( options ) {
|
244 |
-
var useXDomain = !!window.XDomainRequest;
|
245 |
-
var req = useXDomain ? new XDomainRequest() : new XMLHttpRequest()
|
246 |
-
var data;
|
247 |
-
options.url += ( options.url.indexOf( "?" ) >= 0 ? "&" : "?" ) + "referer=" + escape( MPv1Ticket.referer );
|
248 |
-
options.requestedMethod = options.method;
|
249 |
-
if ( useXDomain && options.method == "PUT" ) {
|
250 |
-
options.method = "POST";
|
251 |
-
options.url += "&_method=PUT";
|
252 |
-
}
|
253 |
-
req.open( options.method, options.url, true );
|
254 |
-
req.timeout = options.timeout || 1000;
|
255 |
-
if ( window.XDomainRequest ) {
|
256 |
-
req.onload = function() {
|
257 |
-
data = JSON.parse( req.responseText );
|
258 |
-
if ( typeof options.success === "function" ) {
|
259 |
-
options.success( options.requestedMethod === "POST" ? 201 : 200, data );
|
260 |
-
}
|
261 |
-
};
|
262 |
-
req.onerror = req.ontimeout = function() {
|
263 |
-
if ( typeof options.error === "function" ) {
|
264 |
-
options.error( 400, {
|
265 |
-
user_agent:window.navigator.userAgent, error : "bad_request", cause:[]
|
266 |
-
});
|
267 |
-
}
|
268 |
-
};
|
269 |
-
req.onprogress = function() {};
|
270 |
-
} else {
|
271 |
-
req.setRequestHeader( "Accept", "application/json" );
|
272 |
-
if ( options.contentType ) {
|
273 |
-
req.setRequestHeader( "Content-Type", options.contentType );
|
274 |
-
} else {
|
275 |
-
req.setRequestHeader( "Content-Type", "application/json" );
|
276 |
-
}
|
277 |
-
req.onreadystatechange = function() {
|
278 |
-
if ( this.readyState === 4 ) {
|
279 |
-
try {
|
280 |
-
if ( this.status >= 200 && this.status < 400 ) {
|
281 |
-
// Success!
|
282 |
-
data = JSON.parse( this.responseText );
|
283 |
-
if ( typeof options.success === "function" ) {
|
284 |
-
options.success( this.status, data );
|
285 |
-
}
|
286 |
-
} else if ( this.status >= 400 ) {
|
287 |
-
data = JSON.parse( this.responseText );
|
288 |
-
if ( typeof options.error === "function" ) {
|
289 |
-
options.error( this.status, data );
|
290 |
-
}
|
291 |
-
} else if ( typeof options.error === "function" ) {
|
292 |
-
options.error( 503, {} );
|
293 |
-
}
|
294 |
-
} catch (e) {
|
295 |
-
options.error( 503, {} );
|
296 |
-
}
|
297 |
-
}
|
298 |
-
};
|
299 |
-
}
|
300 |
-
if ( options.method === "GET" || options.data == null || options.data == undefined ) {
|
301 |
-
req.send();
|
302 |
-
} else {
|
303 |
-
req.send( JSON.stringify( options.data ) );
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
// Form validation
|
308 |
-
|
309 |
-
var doSubmitTicket = false;
|
310 |
-
|
311 |
-
MPv1Ticket.doPay = function(febraban) {
|
312 |
-
if(!doSubmitTicket){
|
313 |
-
doSubmitTicket=true;
|
314 |
-
document.querySelector(MPv1Ticket.selectors.box_loading).style.background = "url("+MPv1Ticket.paths.loading+") 0 50% no-repeat #fff";
|
315 |
-
btn = document.querySelector(MPv1Ticket.selectors.form);
|
316 |
-
btn.submit();
|
317 |
-
}
|
318 |
-
}
|
319 |
-
|
320 |
-
MPv1Ticket.validateInputsTicket = function(event) {
|
321 |
-
event.preventDefault();
|
322 |
-
MPv1Ticket.hideErrors();
|
323 |
-
var valid_to_ticket = true;
|
324 |
-
var $inputs = MPv1Ticket.getForm().querySelectorAll("[data-checkout]");
|
325 |
-
var $inputs_to_validate_ticket = MPv1Ticket.inputs_to_validate_ticket;
|
326 |
-
var febraban = [];
|
327 |
-
var arr = [];
|
328 |
-
for (var x = 0; x < $inputs.length; x++) {
|
329 |
-
|