KOKINIO - MANAGER
Edit File: credit-card.min.js
!function(w){"use strict";w(function(){var t=!1,d={site_id:wc_mercadopago_params.site_id,public_key:wc_mercadopago_params.public_key};w.getScript("https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js").done(function(){Mercadopago.setPublishableKey(d.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},c={},r={};function e(){0!==document.getElementById("mp-card-number").value&&(document.getElementById("mp-card-number").value="",m(),s(),y(),g(),_())}function o(){var e=document.querySelector("#mp-frame-payments");w("#button-show-payments").on("click",function(){e.style.display="inline-block"===e.style.display?"none":"inline-block"})}function a(){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 u(e,o){200===e?(c=o[0],o=c.id,document.getElementById("paymentMethodId").value=o,o=c.secure_thumbnail,document.getElementById("mp-card-number").style.background="url("+o+") 98% 50% no-repeat #fff",function(e){r={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]&&(r.issuer=!0),"cardholder_name"===e[o]&&(r.cardholder_name=!0),"cardholder_identification_type"===e[o]&&(r.cardholder_identification_type=!0),"cardholder_identification_number"===e[o]&&(r.cardholder_identification_number=!0)}(c.additional_info_needed),function(){r.cardholder_name?document.getElementById("mp-card-holder-div").style.display="block":document.getElementById("mp-card-holder-div").style.display="none";r.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(c.id,a(),v)):(g(),f());r.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";r.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";r.cardholder_identification_type||r.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"):(m(),document.getElementById("mp-card-number").classList.add("mp-form-control-error"),document.getElementById("mp-error-E301").style.display="inline-block")}function m(){document.getElementById("mp-card-number").style.background="no-repeat #fff"}function i(e,o){if(200===e){for(var e=document.getElementById("mp-installments"),t='<option value="-1">'+wc_mercadopago_params.choose+"...</option>",n=[],r=0;r<o.length;r++)"aggregator"===o[r].processing_mode&&(n=o[r].payer_costs);for(var c=0;c<n.length;c++)t+='<option value="'+n[c].installments+'" '+function(e){var o="";if("MLA"!==d.site_id)return o;for(var t=0;t<e.length;t++)-1!==e[t].indexOf("CFT_")&&(o='data-tax="'+e[t]+'"');return o}(n[c].labels)+">"+(n[c].recommended_message||n[c].installments)+"</option>";e.innerHTML=t,"MLA"===d.site_id&&(y(),w("body").on("change","#mp-installments",p))}else s(),y()}function p(){var e=document.querySelector("#mp-installments"),o=e.options[e.selectedIndex].getAttribute("data-tax"),t="",e="";null!=o&&(t=(o=o.split("|"))[0].replace("_"," "),e=o[1].replace("_"," "),"CFT 0,00%"===t&&"TEA 0,00%"===e&&(e=t="")),document.querySelector("#mp-tax-cft-text").innerHTML=t,document.querySelector("#mp-tax-tea-text").innerHTML=e}function s(){document.getElementById("mp-installments").innerHTML=""}function y(){document.querySelector("#mp-tax-cft-text").innerHTML="",document.querySelector("#mp-tax-tea-text").innerHTML=""}function g(){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 _(){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 f(){for(var e={},o=l(),t=!1,n=0;n<c.additional_info_needed.length;n++)"issuer_id"===c.additional_info_needed[n]&&(t=!0);if(t){var r=document.getElementById("mp-issuer").value,e={bin:a(),amount:o,issuer_id:r};if("-1"===r)return}else e={bin:a(),amount:o};Mercadopago.getInstallments(e,i)}function v(e,o){if(200===e){var t=document.getElementById("mp-issuer"),n=document.createDocumentFragment();t.options.length=0;e=new Option(wc_mercadopago_params.choose+"...","-1");n.appendChild(e);for(var r=0;r<o.length;r++){var c="default"===o[r].name?"Otro":o[r].name;n.appendChild(new Option(c,o[r].id))}t.appendChild(n),t.removeAttribute("disabled"),w("body").on("change","#mp-issuer",f)}else g()}function b(){return document.querySelector("#mercadopago-form")}function h(){q();var e,o,t,n=function(){for(var e=!1,o=b(),t=o.querySelectorAll("[data-checkout]"),n=["installments","securityCode","cardExpirationDate","cardNumber"],r=0;r<t.length;r++){var c,d=t[r];-1<n.indexOf(d.getAttribute("data-checkout"))&&("-1"!==d.value&&""!==d.value||(0<(c=o.querySelectorAll('span[data-main="#'+d.id+'"]')).length&&(c[0].style.display="inline-block"),d.classList.add("mp-form-control-error"),e=!0))}return e||e}(),t=(t=!1,r.issuer&&("-1"!==(e=document.getElementById("mp-issuer")).value&&""!==e.value||(e.classList.add("mp-form-control-error"),t=!0)),r.cardholder_name&&("-1"!==(e=document.getElementById("mp-card-holder-name")).value&&""!==e.value||(e.classList.add("mp-form-control-error"),t=!0)),r.cardholder_identification_type&&("-1"!==(o=document.getElementById("docType")).value&&""!==o.value||(o.classList.add("mp-form-control-error"),t=!0)),r.cardholder_identification_number&&("-1"!==(o=document.getElementById("docNumber")).value&&""!==o.value||(o.classList.add("mp-form-control-error"),document.getElementById("mp-error-324").style.display="inline-block",t=!0)),t||t);return!n&&!t||(E(),void S())}function S(){void 0!==document.querySelectorAll(".mp-form-control-error")&&document.querySelectorAll(".mp-form-control-error")[0].focus()}function q(){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 E(){0<w("form#order_review").length&&w(".blockOverlay").css("display","none")}function I(e,o){document.querySelector("#mp-box-loading").style.background="",200!==e&&201!==e?(function(e){for(var o=b(),t=0;t<e.cause.length;t++){var n=e.cause[t],r=void 0;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))&&(n=o.querySelector(r.getAttribute("data-main")),r.style.display="inline-block",n.classList.add("mp-form-control-error"))}}(o),E(),S()):(document.querySelector("#token").value=o.id,t=!0,w("form.checkout, form#order_review").submit())}function k(){e(),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 e=n.discount_action_url,o="?";0<=e.indexOf("?")&&(o="&");e+=o+"site_id="+wc_mercadopago_params.site_id,e+="&coupon_id="+document.querySelector("#couponCode").value,e+="&amount="+document.querySelector("#mp-amount").value,e+="&payer="+n.payer_email,w.ajax({url:e,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>"+B(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>"+B(e.response.currency_id)+" "+Math.round(100*document.querySelector("#mp-amount").value)/100+"</strong><br>"+wc_mercadopago_params.discount_info4+" <strong>"+B(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 B(e){return"ARS"===e?"$":"BRL"===e?"R$":"COP"===e||"CLP"===e||"MXN"===e?"$":"VEF"===e?"Bs":"PEN"===e?"S/":"UYU"===e?"$U":"$"}function C(){return t?!(t=!1):!document.getElementById("payment_method_woo-mercado-pago-custom").checked||!!h()&&function(){q(),document.querySelector("#mp-box-loading").style.background="url("+wc_mercadopago_params.loading+") 0 50% no-repeat #fff";var e=b();return Mercadopago.createToken(e,I),!1}()}0<w("form#order_review").length&&("yes"===n.activated&&w("#applyCoupon").on("click",k),o()),w("body").on("updated_checkout",function(){"yes"===n.activated&&w("#applyCoupon").on("click",k),e(),o()}),w("body").on("change","#mp-card-number",function(){q(),document.getElementById("mp-card-holder-name").value="",document.getElementById("mp-card-expiration-date").value="",document.getElementById("mp-security-code").value="",g(),s(),y(),_();var e=a();if(e.length<6)return void m();6<=e.length&&Mercadopago.getPaymentMethod({bin:e},u)}),w("form.checkout").on("checkout_place_order_woo-mercado-pago-custom",C),w("form#order_review").submit(C)})}(jQuery);