PageSourceSearch

https://onegps.com.ar/wp-content/plugins/woocommerce-mercadopago/a…/entities/event-handler.min.js?ver=8.9.1

js onegps.com.ar collected 2026-10-02 01:16:55 UTC 13,489 bytes, 1 lines download raw bytes

1const VALIDATION_ACTION={PROCEED:"PROCEED",BLOCK:"BLOCK",FAIL_OPEN:"FAIL_OPEN"},FAIL_OPEN_REASON={TIMEOUT:"TIMEOUT",NETWORK:"NETWORK",ENDPOINT_MISSING:"ENDPOINT_MISSING",CDN_UNAVAILABLE:"CDN_UNAVAILABLE",CDN_ERROR:"CDN_ERROR"},FAIL_OPEN_METRIC="MP_CHECKOUT_AJAX_VALIDATION_FAIL_OPEN";class MPEventHandler{REMOVE_LOAD_SPINNER_DELAY=500;MAX_ORDER_PAY_RETRIES=5;constructor(e,r,t=MobileCheckoutClassicObserver){this.cardForm=e,this.threeDSHandler=r,this.triggeredPaymentMethodSelectedEvent=!1,this.mercado_pago_submit=!1,this.hasToken=!1,this.mpFormId="checkout",this.mpSuperTokenTriggerHandler=null,this.mpSuperTokenAuthenticator=null,this.mpSuperTokenPaymentMethods=null,this.mpSuperTokenMetrics=null,this.mpSuperTokenErrorHandler=null,this.loadSpinnerTimeout=null,this._mobileObserver=null,this._MobileCheckoutClassicObserver=t,this.isValidating=!1,this._validationAbortController=null,this._validationCancelled=!1}setSuperTokenDependencies({triggerHandler:e,authenticator:r,paymentMethods:t,metrics:o,errorHandler:i}){e&&r&&t&&o&&i?(this.mpSuperTokenTriggerHandler=e,this.mpSuperTokenAuthenticator=r,this.mpSuperTokenPaymentMethods=t,this.mpSuperTokenMetrics=o,this.mpSuperTokenErrorHandler=i):"function"==typeof sendMetric&&sendMetric("MP_SUPER_TOKEN_DEPENDENCIES_NOT_SET","setSuperTokenDependencies","mp_super_token_init_error")}getSuperTokenDeps(){return this.mpSuperTokenTriggerHandler&&this.mpSuperTokenAuthenticator||!window.mpSuperTokenTriggerHandler||this.setSuperTokenDependencies({triggerHandler:window.mpSuperTokenTriggerHandler,authenticator:window.mpSuperTokenAuthenticator,paymentMethods:window.mpSuperTokenPaymentMethods,metrics:window.mpSuperTokenMetrics,errorHandler:window.mpSuperTokenErrorHandler}),{superTokenTriggerHandler:this.mpSuperTokenTriggerHandler,superTokenAuthenticator:this.mpSuperTokenAuthenticator,superTokenPaymentMethods:this.mpSuperTokenPaymentMethods,superTokenMetrics:this.mpSuperTokenMetrics,superTokenErrorHandler:this.mpSuperTokenErrorHandler}}bindEvents(){jQuery("form.checkout").on("checkout_place_order_woo-mercado-pago-custom",((e,r)=>this.mercadoPagoFormHandler(e,r))),jQuery("body").on("payment_method_selected",this.handlePaymentMethodSelected.bind(this)),jQuery("form#order_review").submit(this.handleOrderReviewSubmit.bind(this)),jQuery(document.body).on("checkout_error",this.handleCheckoutError.bind(this)),jQuery(document).ready((()=>{this.threeDSHandler.set3dsStatusValidationListener(),wc_mercadopago_custom_event_handler_params.is_mobile?this._mobileObserver=new this._MobileCheckoutClassicObserver(this.cardForm,this.isCheckoutCustomPaymentMethodSelected.bind(this),this.handleUpdatedCheckout.bind(this),this.initCardFormWhenReady.bind(this)):(jQuery(document).on("updated_checkout",this.handleUpdatedCheckout.bind(this)),this.initCardFormWhenReady())}))}initCardFormWhenReady(){const e=document.querySelector(".mp-checkout-custom-container"),r=document.querySelector("#payment_method_woo-mercado-pago-custom"),t=this.isOrderPayPage();if(r?.checked)if(e){if(!this.cardForm.formMounted)return t?(this.cardForm.createLoadSpinner(),void Promise.resolve(this.cardForm.initCardForm()).finally((()=>this.cardForm.removeLoadSpinner()))):void(null!==e.offsetParent&&this.cardForm.initCardForm())}else t&&this.scheduleOrderPayInitRetry()}scheduleOrderPayInitRetry(){this.orderPayInitRetries=(this.orderPayInitRetries||0)+1,this.orderPayInitRetries>this.MAX_ORDER_PAY_RETRIES||setTimeout((()=>this.initCardFormWhenReady()),300)}isOrderPayPage(){const e=document.body?.classList?.contains("woocommerce-order-pay"),r=!!document.querySelector("form#order_review");return e||r}getCheckoutForm(){return this.isOrderPayPage()?jQuery("form#order_review"):jQuery("form.checkout")}showCheckoutClassicLoader(){this.getCheckoutForm()?.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}hideCheckoutClassicLoader(){this.getCheckoutForm()?.unblock()}mercadoPagoFormHandler(e,r){this.setMercadoPagoSessionId();const{superTokenPaymentMethods:t,superTokenMetrics:o}=this.getSuperTokenDeps();return t?.hideSuperTokenError(),!!this.mercado_pago_submit||("wallet_button"===jQuery("#mp_checkout_type").val()||("super_token"===jQuery("#mp_checkout_type").val()?(o?.registerClickOnPlaceOrderButton(),this.validateCheckoutThenContinue(e,(()=>this.handleWithSuperTokenSubmit(e,r))),!1):(jQuery("#mp_checkout_type").val("custom"),this.hasToken||(this.setPayerIdentificationInfo(),this.createToken()),!1)))}validateCheckoutThenContinue(e,r){if(this.isValidating)return;
1if(this._validationCancelled=!1,this.isOrderPayPage())return void r();const t=window.wc_mercadopago_checkout_update_params,o=t?.validationEndpoint,i=(e,t)=>{"function"==typeof sendMetric&&sendMetric(e,t||"validate_checkout_then_continue",FAIL_OPEN_METRIC),this.hideValidationLoader(),r()};if(!o)return void i(FAIL_OPEN_REASON.ENDPOINT_MISSING);this.isValidating=!0,e.preventDefault(),this.showValidationLoader();const n=this.getCheckoutForm()?.serialize()??"";this._validationAbortController=new AbortController;const a=this._validationAbortController,s=setTimeout((()=>a.abort()),8e3);window.fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n,signal:a.signal}).then((e=>e.json())).then((e=>{if(this._validationCancelled)return;const t=this.resolveCheckoutValidation(e);if(t.action===VALIDATION_ACTION.BLOCK)return this.displayCheckoutValidationErrors(t.errors),void this.hideValidationLoader();t.action!==VALIDATION_ACTION.FAIL_OPEN?(this.hideValidationLoader(),r()):i(t.reason,t.detail)})).catch((e=>{if("AbortError"===e?.name&&this._validationCancelled)return;const r="AbortError"===e?.name?FAIL_OPEN_REASON.TIMEOUT:FAIL_OPEN_REASON.NETWORK;i(r,e?.message||e?.name||r)})).finally((()=>{clearTimeout(s),this.isValidating=!1,this._validationAbortController=null,this._validationCancelled=!1}))}resolveCheckoutValidation(e){try{if("function"==typeof window.mpResolveCheckoutValidation){const r=window.mpResolveCheckoutValidation(e);if(r?.action)return r}}catch(e){return{action:VALIDATION_ACTION.FAIL_OPEN,reason:FAIL_OPEN_REASON.CDN_ERROR,detail:e?.message||e?.name}}return{action:VALIDATION_ACTION.FAIL_OPEN,reason:FAIL_OPEN_REASON.CDN_UNAVAILABLE}}showValidationLoader(){this.isOrderPayPage()?this.cardForm?.createLoadSpinner():this.showCheckoutClassicLoader()}hideValidationLoader(){this.isOrderPayPage()?this.cardForm?.removeLoadSpinner():this.hideCheckoutClassicLoader()}displayCheckoutValidationErrors(e){const r=(Array.isArray(e)?e:[]).map((e=>e?.message)).filter(Boolean);if(0===r.length)return;const t=document.createElement("ul");t.className="woocommerce-error",t.setAttribute("role","alert"),r.forEach((e=>{const r=document.createElement("li");r.textContent=e,t.appendChild(r)}));const o=this.getCheckoutForm(),i=document.querySelector(".woocommerce-NoticeGroup-checkout");i?i.replaceChildren(t):o?.length&&o.prepend(t),t.scrollIntoView({behavior:"smooth"})}async handleWithSuperTokenSubmit(e,r){const{superTokenTriggerHandler:t,superTokenAuthenticator:o,superTokenPaymentMethods:i,superTokenErrorHandler:n}=this.getSuperTokenDeps();try{if(e.preventDefault(),this.showCheckoutClassicLoader(),!i)throw new Error(MPSuperTokenErrorCodes.SUPER_TOKEN_PAYMENT_METHODS_NOT_FOUND);if(!o)throw new Error(MPSuperTokenErrorCodes.SUPER_TOKEN_AUTHENTICATOR_NOT_FOUND);const t=i.getActivePaymentMethod(),n=t&&i.isSelectedPaymentMethodValid();if(!t)throw new Error(MPSuperTokenErrorCodes.SELECT_PAYMENT_METHOD_ERROR);if(!n)throw new Error(MPSuperTokenErrorCodes.SELECT_PAYMENT_METHOD_NOT_VALID);if(!i.validateInstallmentSelection())return this.cardForm.removeLoadSpinner(),void this.hideCheckoutClassicLoader();this.isOrderPayPage()&&i.unmountCardForm(),await i.updateSecurityCode(),await o.authorizePayment(t.token),this.mercado_pago_submit=!0,o?.setSuperTokenValidation(!0),this.isOrderPayPage()?this.handle3dsPayOrderFormSubmission():r.$checkout_form.trigger("submit")}catch(e){if(e?.message===MPSuperTokenErrorCodes.SELECT_PAYMENT_METHOD_NOT_VALID)return n?.handleError(e),this.cardForm.removeLoadSpinner(),void this.hideCheckoutClassicLoader();const r=[MPSuperTokenErrorCodes.UPDATE_SECURITY_CODE_ERROR,MPSuperTokenErrorCodes.AUTHORIZE_PAYMENT_METHOD_ERROR,MPSuperTokenErrorCodes.AUTHORIZE_PAYMENT_METHOD_USER_CANCELLED];t?.resetSuperTokenOnError(r.includes(e?.message)),t?.setLastException(e),o?.setSuperTokenValidation(!1)}}createToken(){if("undefined"!=typeof CheckoutPage&&"function"==typeof CheckoutPage.runPreSubmitGates){if(!CheckoutPage.runPreSubmitGates(this.cardForm).passed)return!1}return(window.callSdkWithMetrics||(e=>e()))((()=>this.cardForm.form.createCardToken()),"createCardToken").then((e=>{if(!e.token)throw"undefined"!=typeof CheckoutPage&&"function"==typeof CheckoutPage.emitGateBlockedMetric&&CheckoutPage.emitGateBlockedMetric("CARD","mp_custom_card_validation","empty_token"),new Error("cardToken is empty");if(!this.hasToken)return document.querySelector("#cardTokenId").value=e.token,this.mercado_pago_submit=!0,this.hasToken=!0,"order_review"===this.mpFormId?(this.handle3dsPayOrderFormSubmission(),!1):void jQuery("form.checkout").submit()})).catch((e=>{console.warn("Token creation error: ",e),this.cardForm.scrollToCardForm(),this.cardForm.removeLoadSpinner(),this.cardForm.removeBlockOverlay()})),!1}setMercadoPagoSessionId(){if("undefined"!=typeof MP_DEVICE_SESSION_ID&&MP_DEVICE_SESSION_ID)try{document.querySelector("#mpCardSessionId").value=MP_DEVICE_SESSION_ID}catch(e){console.warn(e)}}isCheckoutCustomPaymentMethodSelected(){const e=document.getElementById("payment_method_woo-mercado-pago-custom")||document.querySelector("input[value=woo-mercado-pago-custom]");return e&&e.checked}handlePaymentMethodSelected(){if(this.isCheckoutCustomPaymentMethodSelected()){if
1(this.isOrderPayPage())return this.onSelectCheckoutCustomInOrderPayPage()}else{this.cardForm.formMounted&&this.cardForm.form.unmount(),clearTimeout(this.loadSpinnerTimeout);const{superTokenTriggerHandler:e,superTokenPaymentMethods:r}=this.getSuperTokenDeps();e?.isSuperTokenPaymentMethodsLoaded()?r?.getPaymentMethodsListElement()?.style.setProperty("display","none","important"):e?.isFetchingPaymentMethods&&e.cancelLoad()}}handleOrderReviewSubmit(e){if(this.isCheckoutCustomPaymentMethodSelected())return e?.originalEvent&&null===e.originalEvent.submitter?(e.stopImmediatePropagation(),e.preventDefault(),!1):this.mercadoPagoFormHandler(e);this.cardForm.formMounted&&this.cardForm.form.unmount()}handleCheckoutError(){this._validationCancelled=!0,this._validationAbortController?.abort(),this._validationAbortController=null,this.isValidating=!1,this.hideValidationLoader(),this.hasToken=!1,this.mercado_pago_submit=!1,this.cardForm.removeLoadSpinner();const{superTokenTriggerHandler:e}=this.getSuperTokenDeps();e?.resetSuperTokenOnError(!0)}handleUpdatedCheckout(){if(this.isOrderPayPage())return Promise.resolve();if(this.isCheckoutCustomPaymentMethodSelected()){clearTimeout(this.loadSpinnerTimeout),this.cardForm.createLoadSpinner();const e=this.cardForm.getAmount(),r=this.cardForm.amount,t=[],{superTokenTriggerHandler:o}=this.getSuperTokenDeps();o&&t.push(o.loadSuperToken(e));return this.cardForm.formMounted&&["form-checkout__cardNumber-container","form-checkout__expirationDate-container","form-checkout__securityCode-container"].every((e=>{const r=document.getElementById(e);return!!r&&!r.querySelector("iframe")}))?(this.cardForm.form.unmount(),this.cardForm.formMounted=!1):this.cardForm.formMounted&&e!==r&&this.cardForm.form.unmount(),this.cardForm.formMounted||t.push(this.cardForm.initCardForm()),Promise.all(t).finally((()=>{this.loadSpinnerTimeout=setTimeout((()=>this.cardForm.removeLoadSpinner()),this.REMOVE_LOAD_SPINNER_DELAY)}))}return Promise.resolve()}handle3dsPayOrderFormSubmission(){var e=jQuery("#order_review").serialize();jQuery.post("#",e).done((e=>{if(e.three_ds_flow)this.threeDSHandler.load3DSFlow(e.last_four_digits);else if("success"===e.result&&e.redirect)window.location.href=e.redirect;else{if("fail"===e.result){jQuery("#order_review .woocommerce-error, #order_review .woocommerce-message").remove(),jQuery("#order_review").prepend('<div class="woocommerce-error">'+e.messages+"</div>");const r=document.querySelector("#order_review .woocommerce-error");return r&&r.scrollIntoView({behavior:"smooth"}),this.cardForm.removeBlockOverlay(),this.cardForm.removeLoadSpinner(),this.cardForm.form.unmount(),this.cardForm.initCardForm(),this.hasToken=!1,void(this.mercado_pago_submit=!1)}window.location.reload()}})).error((()=>{window.location.reload()}))}normalizeDocumentNumber(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"")}setPayerIdentificationInfo(){[{selector:"#form-checkout__identificationType",hiddenInputId:"#payerDocType"},{selector:"#form-checkout__identificationNumber",hiddenInputId:"#payerDocNumber"}].forEach((({selector:e,hiddenInputId:r})=>{const t=document.querySelector(e),o=document.querySelector(r);if(t&&o&&t.value){const e="#payerDocNumber"===r;o.value=e?this.normalizeDocumentNumber(t.value):t.value}}))}onSelectCheckoutCustomInOrderPayPage(){let e=0;this.cardForm.createLoadSpinner();const r=setInterval((()=>{const{superTokenTriggerHandler:t}=this.getSuperTokenDeps();if(++e<100&&!t)return;clearInterval(r);const o=this.cardForm.getAmount(),i=[];return t&&i.push(t.loadSuperToken(o)),this.cardForm.formMounted||i.push(this.cardForm.initCardForm()),Promise.all(i).finally((()=>{setTimeout((()=>this.cardForm.removeLoadSpinner()),this.REMOVE_LOAD_SPINNER_DELAY)}))}),100)}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.