KOKINIO - MANAGER
Edit File: credit-card.min.js
!function(e){"use strict";e((function(){var o=!1,t={site_id:wc_mercadopago_params.site_id,public_key:wc_mercadopago_params.public_key};e.getScript("https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js").done((function(){Mercadopago.setPublishableKey(t.public_key)}));var n={discount_action_url:wc_mercadopago_params.discount_action_url,payer_email:wc_mercadopago_params.payer_email,activated:wc_mercadopago_params.coupon_mode,status:!1},r={},c={};function d(){0!==document.getElementById("mp-card-number").value&&(document.getElementById("mp-card-number").value="",i(),_(),g(),f(),v())}function a(){var o=document.querySelector("#mp-frame-payments");e("#button-show-payments").on("click",(function(){o.style.display="inline-block"===o.style.display?"none":"inline-block"}))}function u(){return document.getElementById("mp-card-number").value.replace(/[ .-]/g,"").slice(0,6)}function l(){return(document.getElementById("mp-amount").value-document.getElementById("mp-discount").value)*document.getElementById("currency_ratio").value}function m(e,o){var t,n;200===e?(r=o[0],n=r.id,document.getElementById("paymentMethodId").value=n,t=r.secure_thumbnail,document.getElementById("mp-card-number").style.background="url("+t+") 98% 50% no-repeat #fff",function(e){c={issuer:!1,cardholder_name:!1,cardholder_identification_type:!1,cardholder_identification_number:!1};for(var o=0;o<e.length;o++)"issuer_id"===e[o]&&(c.issuer=!0),"cardholder_name"===e[o]&&(c.cardholder_name=!0),"cardholder_identification_type"===e[o]&&(c.cardholder_identification_type=!0),"cardholder_identification_number"===e[o]&&(c.cardholder_identification_number=!0)}(r.additional_info_needed),function(){c.cardholder_name?document.getElementById("mp-card-holder-div").style.display="block":document.getElementById("mp-card-holder-div").style.display="none";c.issuer?(document.getElementById("mp-issuer-div").style.display="block",document.getElementById("installments-div").classList.remove("mp-col-md-12"),document.getElementById("installments-div").classList.add("mp-col-md-8"),Mercadopago.getIssuers(r.id,u(),h)):(f(),b());c.cardholder_identification_type?(document.getElementById("mp-doc-div").style.display="inline-block",document.getElementById("mp-doc-type-div").style.display="block",Mercadopago.getIdentificationTypes()):document.getElementById("mp-doc-type-div").style.display="none";c.cardholder_identification_number?(document.getElementById("mp-doc-div").style.display="inline-block",document.getElementById("mp-doc-number-div").style.display="block"):document.getElementById("mp-doc-number-div").style.display="none";c.cardholder_identification_type||c.cardholder_identification_number||(document.getElementById("mp-doc-div").style.display="none")}(),document.getElementById("mp-card-number").classList.remove("mp-form-control-error"),document.getElementById("mp-error-E301").style.display="none"):(i(),document.getElementById("mp-card-number").classList.add("mp-form-control-error"),document.getElementById("mp-error-E301").style.display="inline-block")}function i(){document.getElementById("mp-card-number").style.background="no-repeat #fff"}function p(e){var o="";if("MLA"===t.site_id){for(var n=0;n<e.length;n++)-1!==e[n].indexOf("CFT_")&&(o='data-tax="'+e[n]+'"');return o}return o}function s(o,n){if(200===o){for(var r=document.getElementById("mp-installments"),c='<option value="-1">'+wc_mercadopago_params.choose+"...</option>",d=[],a=0;a<n.length;a++)"aggregator"===n[a].processing_mode&&(d=n[a].payer_costs);for(var u=0;u<d.length;u++)c+='<option value="'+d[u].installments+'" '+p(d[u].labels)+">"+(d[u].recommended_message||d[u].installments)+"</option>";r.innerHTML=c,"MLA"===t.site_id&&(g(),e("body").on("change","#mp-installments",y))}else _(),g()}function y(){var e=document.querySelector("#mp-installments"),o=e.options[e.selectedIndex].getAttribute("data-tax"),t="",n="";if(null!=o){var r=o.split("|");t=r[0].replace("_"," "),n=r[1].replace("_"," "),"CFT 0,00%"===t&&"TEA 0,00%"===n&&(t="",n="")}document.querySelector("#mp-tax-cft-text").innerHTML=t,document.querySelector("#mp-tax-tea-text").innerHTML=n}function _(){document.getElementById("mp-installments").innerHTML=""}function g(){document.querySelector("#mp-tax-cft-text").innerHTML="",document.querySelector("#mp-tax-tea-text").innerHTML=""}function f(){document.getElementById("mp-issuer-div").style.display="none",document.getElementById("installments-div").classList.remove("mp-col-md-8"),document.getElementById("installments-div").classList.add("mp-dis-md-12"),document.getElementById("mp-issuer").innerHTML=""}function v(){document.getElementById("mp-doc-div").style.display="none",document.getElementById("mp-doc-type-div").style.display="none",document.getElementById("docType").innerHTML="",document.getElementById("docNumber").value=""}function b(){for(var e={},o=l(),t=!1,n=0;n<r.additional_info_needed.length;n++)"issuer_id"===r.additional_info_needed[n]&&(t=!0);if(t){var c=document.getElementById("mp-issuer").value;if(e={bin:u(),amount:o,issuer_id:c},"-1"===c)return}else e={bin:u(),amount:o};Mercadopago.getInstallments(e,s)}function h(o,t){if(200===o){var n=document.getElementById("mp-issuer"),r=document.createDocumentFragment();n.options.length=0;var c=new Option(wc_mercadopago_params.choose+"...","-1");r.appendChild(c);for(var d=0;d<t.length;d++){var a="default"===t[d].name?"Otro":t[d].name;r.appendChild(new Option(a,t[d].id))}n.appendChild(r),n.removeAttribute("disabled"),e("body").on("change","#mp-issuer",b)}else f()}function S(){return document.querySelector("#mercadopago-form")}function q(){k();var e=function(){for(var e=!1,o=S(),t=o.querySelectorAll("[data-checkout]"),n=["installments","securityCode","cardExpirationDate","cardNumber"],r=0;r<t.length;r++){var c=t[r];if(n.indexOf(c.getAttribute("data-checkout"))>-1&&("-1"===c.value||""===c.value)){var d=o.querySelectorAll('span[data-main="#'+c.id+'"]');d.length>0&&(d[0].style.display="inline-block"),c.classList.add("mp-form-control-error"),e=!0}}return e||e}(),o=function(){var e=!1;if(c.issuer){var o=document.getElementById("mp-issuer");"-1"!==o.value&&""!==o.value||(o.classList.add("mp-form-control-error"),e=!0)}if(c.cardholder_name){var t=document.getElementById("mp-card-holder-name");"-1"!==t.value&&""!==t.value||(t.classList.add("mp-form-control-error"),e=!0)}if(c.cardholder_identification_type){var n=document.getElementById("docType");"-1"!==n.value&&""!==n.value||(n.classList.add("mp-form-control-error"),e=!0)}if(c.cardholder_identification_number){var r=document.getElementById("docNumber");"-1"!==r.value&&""!==r.value||(r.classList.add("mp-form-control-error"),document.getElementById("mp-error-324").style.display="inline-block",e=!0)}return e||e}();return!e&&!o||(I(),E(),!1)}function E(){void 0!==document.querySelectorAll(".mp-form-control-error")&&document.querySelectorAll(".mp-form-control-error")[0].focus()}function k(){for(var e=0;e<document.querySelectorAll("[data-checkout]").length;e++){var o=document.querySelectorAll("[data-checkout]")[e];o.classList.remove("mp-error-input"),o.classList.remove("mp-form-control-error")}for(var t=0;t<document.querySelectorAll(".mp-error").length;t++){document.querySelectorAll(".mp-error")[t].style.display="none"}}function I(){e("form#order_review").length>0&&e(".blockOverlay").css("display","none")}function B(t,n){(document.querySelector("#mp-box-loading").style.background="",200!==t&&201!==t)?(!function(e){for(var o=S(),t=0;t<e.cause.length;t++){var n=e.cause[t],r=void 0;if(void 0!==(r="208"===n.code||"209"===n.code||"325"===n.code||"326"===n.code?o.querySelector("#mp-error-208"):o.querySelector("#mp-error-"+n.code))){var c=o.querySelector(r.getAttribute("data-main"));r.style.display="inline-block",c.classList.add("mp-form-control-error")}}}(n),I(),E()):(document.querySelector("#token").value=n.id,o=!0,e("form.checkout, form#order_review").submit())}function C(){d(),document.querySelector("#mpCouponApplyed").style.display="none",""===document.querySelector("#couponCode").value?(n.status=!1,document.querySelector("#mpCouponError").style.display="block",document.querySelector("#mpCouponError").innerHTML=wc_mercadopago_params.coupon_empty,document.querySelector("#couponCode").style.background=null,document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#mp-discount").value=0):n.status?(n.status=!1,document.querySelector("#mpCouponError").style.display="none",document.querySelector("#applyCoupon").style.background=null,document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#couponCode").value="",document.querySelector("#couponCode").style.background=null,document.querySelector("#mp-discount").value=0):(document.querySelector("#mpCouponError").style.display="none",document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.loading+") 98% 50% no-repeat #fff",document.querySelector("#couponCode").style.border="1px solid #cecece",document.querySelector("#applyCoupon").disabled=!0,function(){var o=n.discount_action_url,t="?";o.indexOf("?")>=0&&(t="&");o+=t+"site_id="+wc_mercadopago_params.site_id,o+="&coupon_id="+document.querySelector("#couponCode").value,o+="&amount="+document.querySelector("#mp-amount").value,o+="&payer="+n.payer_email,e.ajax({url:o,method:"GET",timeout:5e3,error:function(){n.status=!1,document.querySelector("#mpCouponApplyed").style.display="none",document.querySelector("#mpCouponError").style.display="none",document.querySelector("#applyCoupon").style.background=null,document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#couponCode").value="",document.querySelector("#couponCode").style.background=null,document.querySelector("#mp-discount").value=0},success:function(e){200===e.status?(n.status=!0,document.querySelector("#mpCouponApplyed").style.display="block",document.querySelector("#mp-discount").value=e.response.coupon_amount,document.querySelector("#mpCouponApplyed").innerHTML=wc_mercadopago_params.discount_info1+" <strong>"+w(e.response.currency_id)+" "+Math.round(100*e.response.coupon_amount)/100+"</strong> "+wc_mercadopago_params.discount_info2+" "+e.response.name+".<br>"+wc_mercadopago_params.discount_info3+" <strong>"+w(e.response.currency_id)+" "+Math.round(100*document.querySelector("#mp-amount").value)/100+"</strong><br>"+wc_mercadopago_params.discount_info4+" <strong>"+w(e.response.currency_id)+" "+Math.round(100*l())/100+"*</strong><br><i>"+wc_mercadopago_params.discount_info5+'</i><br><a href="https://api.mercadolibre.com/campaigns/'+e.response.id+'/terms_and_conditions?format_type=html" target="_blank">'+wc_mercadopago_params.discount_info6+"</a>",document.querySelector("#mpCouponError").style.display="none",document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.check+") 94% 50% no-repeat #fff",document.querySelector("#couponCode").style.border="1px solid #cecece",document.querySelector("#applyCoupon").value=wc_mercadopago_params.remove,document.querySelector("#campaign_id").value=e.response.id,document.querySelector("#campaign").value=e.response.name):(n.status=!1,document.querySelector("#mpCouponApplyed").style.display="none",document.querySelector("#mpCouponError").style.display="block",document.querySelector("#mpCouponError").innerHTML=e.response.message,document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.error+") 94% 50% no-repeat #fff",document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#mp-discount").value=0),document.querySelector("#applyCoupon").disabled=!1}})}())}function w(e){return"ARS"===e?"$":"BRL"===e?"R$":"COP"===e||"CLP"===e||"MXN"===e?"$":"VEF"===e?"Bs":"PEN"===e?"S/":"UYU"===e?"$U":"$"}function L(){return o?(o=!1,!0):"wallet_button"===e("#mp_checkout_type").val()||(!document.getElementById("payment_method_woo-mercado-pago-custom").checked||(e("#mp_checkout_type").val("custom"),!!q()&&function(){k(),document.querySelector("#mp-box-loading").style.background="url("+wc_mercadopago_params.loading+") 0 50% no-repeat #fff";var e=S();return Mercadopago.createToken(e,B),!1}()))}e("form#order_review").length>0&&("yes"===n.activated&&e("#applyCoupon").on("click",C),a()),e("body").on("updated_checkout",(function(){"yes"===n.activated&&e("#applyCoupon").on("click",C),d(),a()})),e("body").on("change","#mp-card-number",(function(){k(),document.getElementById("mp-card-holder-name").value="",document.getElementById("mp-card-expiration-date").value="",document.getElementById("mp-security-code").value="",f(),_(),g(),v();var e=u();if(e.length<6)return void i();e.length>=6&&Mercadopago.getPaymentMethod({bin:e},m)})),e("form.checkout").on("checkout_place_order_woo-mercado-pago-custom",(function(){return L()})),e("form#order_review").submit((function(){return L()}))}))}(jQuery);