Файловый менеджер - Редактировать - /home/harasnat/www/labour/wp-content/plugins/woocommerce-payments/dist/woopay-direct-checkout.js
Назад
/*! For license information please see woopay-direct-checkout.js.LICENSE.txt */ (()=>{var e={5338:(e,t,s)=>{"use strict";var o=s(5795);t.H=o.createRoot,o.hydrateRoot},1020:(e,t,s)=>{"use strict";var o=s(1609),n=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,s){var o,c={},d=null,l=null;for(o in void 0!==s&&(d=""+s),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(l=t.ref),t)a.call(t,o)&&!r.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===c[o]&&(c[o]=t[o]);return{$$typeof:n,type:e,key:d,ref:l,props:c,_owner:i.current}}},4848:(e,t,s)=>{"use strict";e.exports=s(1020)},1609:e=>{"use strict";e.exports=window.React},5795:e=>{"use strict";e.exports=window.ReactDOM}},t={};function s(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,s),a.exports}s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var n=o.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=o[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),s.p=window.wcpayAssets.url,(()=>{"use strict";const e=window.wp.data,t=window.wp.hooks,o=window.lodash,n="wc/store/cart",a=e=>new Promise((t=>{setTimeout(t,e)})),i=(e,t,s=2e3)=>{const o=Date.now(),n=()=>{if(Date.now()-o>s)return;const a=document.querySelector(e);a?t(a):requestAnimationFrame(n)};requestAnimationFrame(n)},r=e=>"undefined"!=typeof wcpayConfig?wcpayConfig[e]:c(e),c=e=>{let t=null;if("undefined"!=typeof wcpay_upe_config)t=wcpay_upe_config;else{if("object"!=typeof wc||void 0===wc.wcSettings)return null;t=wc.wcSettings.getSetting("woocommerce_payments_data")||{}}return t[e]||null};function d(e,t="",s){for(const o in e){const n=e[o],a=t?t+"["+o+"]":o;"string"==typeof n||"number"==typeof n?s.append(a,n):"object"==typeof n&&d(n,a,s)}return s}async function l(e,t,s){const o=d(t,"",new FormData),n=await fetch(e,{method:"POST",body:o,...s});return await n.json()}const u=e=>"object"==typeof wcpayExpressCheckoutParams&&wcpayExpressCheckoutParams.hasOwnProperty(e)?wcpayExpressCheckoutParams[e]:null,y=(e,t,s="wcpay_")=>e.toString().replace("%%endpoint%%",s+t);var h=s(1609);const p=window.wp.i18n;window.wp.domReady;const m=()=>{return e=void 0,t=void 0,o=function*(){var e,t,s;let o=(()=>{const e=document.cookie.split(";");for(let t=0;t<e.length;t++){let s=e[t];for(;" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf("tk_ai="))return s.substring(6,s.length)}})();if(o){const e={_ut:"anon",_ui:o};return JSON.stringify(e)}const n=null!==(e=r("platformTrackerNonce"))&&void 0!==e?e:null===(t=u("nonce"))||void 0===t?void 0:t.platform_tracker,a=null!==(s=r("ajaxUrl"))&&void 0!==s?s:u("ajax_url"),i=new FormData;i.append("tracksNonce",n),i.append("action","get_identity");try{const e=yield fetch(a,{method:"post",body:i});if(!e.ok)return;const t=yield e.json();return t.success&&t.data&&t.data._ui&&t.data._ut?JSON.stringify(t.data):void 0}catch(e){return}},new((s=void 0)||(s=Promise))((function(n,a){function i(e){try{c(o.next(e))}catch(e){a(e)}}function r(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,r)}c((o=o.apply(e,t||[])).next())}));var e,t,s,o};function w(e){window.WooPayConnect||(window.WooPayConnect={}),window.WooPayConnect.iframeInjectedState=e}function g(){return window?.WooPayConnect?.postMessageTimeout||5e3}var _=s(4848);const f=()=>{const e=(0,h.useRef)(),[t,s]=(0,h.useState)("");return(0,h.useEffect)((()=>{(async()=>{const e=r("testMode"),t=r("woopayHost"),o=r("woopayMerchantId"),n=new URLSearchParams({testMode:e,source_url:window.location.href,blogId:o}),a=await m();a&&n.append("tracksUserIdentity",a),s(`${t}/connect/?${n.toString()}`)})()}),[]),(0,h.useEffect)((()=>{if(!e.current)return;const t=e.current;t.addEventListener("load",(()=>{w(2),window.dispatchEvent(new MessageEvent("message",{source:window,origin:r("woopayHost"),data:{action:"get_iframe_post_message_success",value:e=>t.contentWindow.postMessage(e,r("woopayHost"))}}))}))}),[t]),(0,_.jsx)("iframe",{ref:e,id:"woopay-connect-iframe",src:t,style:{height:0,width:0,border:"none",margin:0,padding:0,overflow:"hidden",display:"block",visibility:"hidden",position:"fixed",pointerEvents:"none",userSelect:"none"},title:(0,p.__)("WooPay Connect Direct Checkout","woocommerce-payments")})};var C=s(5338);const P=class{iframePostMessage=null;listeners={};constructor(){this.listeners={getIframePostMessageCallback:()=>{},getPostMessageTimeoutCallback:()=>{}},this.removeMessageListener=this.attachMessageListener(),this.injectWooPayConnectIframe()}attachMessageListener(){const e=e=>{r("woopayHost").startsWith(e.origin)&&this.callbackFn(e.data)};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}detachMessageListener(){"function"==typeof this.removeMessageListener&&this.removeMessageListener()}injectWooPayConnectIframe(){const e=window?.WooPayConnect?.iframeInjectedState||0;if(2===e){const e=document.querySelector("#woopay-connect-iframe");return void(e&&(this.iframePostMessage=Promise.resolve((t=>{e.contentWindow.postMessage(t,r("woopayHost"))}))))}if(1===e)return void(this.iframePostMessage=new Promise((e=>{this.listeners.getIframePostMessageCallback=e})));w(1);const t=document.createElement("div");t.style.visibility="hidden",t.style.position="fixed",t.style.height="0",t.style.width="0",t.style.bottom="0",t.style.right="0",t.id="woopay-connect-iframe-container",document.body.appendChild(t);const s=this;this.iframePostMessage=new Promise((e=>{s.listeners.getIframePostMessageCallback=e})),(0,C.H)(t).render((0,_.jsx)(f,{}))}injectTemporaryWooPayConnectIframe(){let e;const t=new Promise((t=>{e=t})),s=document.createElement("iframe");return s.id="temp-woopay-connect-iframe",s.src=r("woopayHost")+"/connect/",s.height=0,s.width=0,s.border="none",s.margin=0,s.padding=0,s.overflow="hidden",s.display="block",s.visibility="hidden",s.position="fixed",s.pointerEvents="none",s.userSelect="none",s.addEventListener("load",(()=>{e((e=>s.contentWindow.postMessage(e,r("woopayHost"))))})),document.body.appendChild(s),{resolvePostMessagePromise:t,removeTemporaryIframe:()=>{document.body.removeChild(s)}}}async sendMessageAndListenWith(e,t){const s=new Promise(((e,s)=>{let o=!1;const n=setTimeout((()=>{o=!0,s(new Error("WooPayConnectIframe did not respond within the allotted time."))}),g());this.listeners[t]=t=>{o||(n&&clearTimeout(n),e(t))}}));if("function"!=typeof this.iframePostMessage?.then)throw new Error("iframePostMessage is not set");return(await this.iframePostMessage)(e),await s}async getPostMessageTimeout(){try{return await this.sendMessageAndListenWith({action:"getPostMessageTimeout"},"getPostMessageTimeoutCallback")}catch(e){return null}}callbackFn(e){switch(e.action){case"get_iframe_post_message_success":this.listeners.getIframePostMessageCallback(e.value);break;case"get_post_message_timeout_success":this.listeners.getPostMessageTimeoutCallback(e.value)}}},b=class extends P{constructor(){super(),this.listeners={...this.listeners,getIsUserLoggedInCallback:()=>{},getEncryptedDataCallback:()=>{}}}async isUserLoggedIn(){try{return await this.sendMessageAndListenWith({action:"getIsUserLoggedIn"},"getIsUserLoggedInCallback")}catch(e){return!1}}async getEncryptedData(){try{return await this.sendMessageAndListenWith({action:"getEncryptedData"},"getEncryptedDataCallback")}catch(e){return null}}callbackFn(e){switch(super.callbackFn(e),e.action){case"get_is_user_logged_in_success":this.listeners.getIsUserLoggedInCallback(e.value);break;case"get_encrypted_data_success":this.listeners.getEncryptedDataCallback(e.value)}}},k=class extends P{constructor(){super(),this.listeners={...this.listeners,setRedirectSessionDataCallback:()=>{},setTempThirdPartyCookieCallback:()=>{},getIsWooPayReachableCallback:()=>{},getIsThirdPartyCookiesEnabledCallback:()=>{},setPreemptiveSessionDataCallback:()=>{}}}async isWooPayThirdPartyCookiesEnabled(){const{resolvePostMessagePromise:e,removeTemporaryIframe:t}=this.injectTemporaryWooPayConnectIframe(),s=new Promise(((e,t)=>{let s=!1;const o=setTimeout((()=>{s=!0,t(new Error("WooPayConnectIframe did not respond within the allotted time."))}),g());this.listeners.setTempThirdPartyCookieCallback=t=>{s||(o&&clearTimeout(o),e(t))}}));if("function"!=typeof e?.then)return!1;const o=await e;o({action:"setTempThirdPartyCookie"});try{if(!await s)return t(),!1}catch(e){return t(),!1}const n=new Promise(((e,t)=>{let s=!1;const o=setTimeout((()=>{s=!0,t(new Error("WooPayConnectIframe did not respond within the allotted time."))}),g());this.listeners.getIsThirdPartyCookiesEnabledCallback=t=>{s||(o&&clearTimeout(o),e(t))}}));o({action:"getIsThirdPartyCookiesEnabled"});try{return await n}catch(e){return!1}finally{t()}}async sendRedirectSessionDataToWooPay(e){try{return await super.sendMessageAndListenWith({action:"setRedirectSessionData",value:e},"setRedirectSessionDataCallback")}catch(e){return null}}async setPreemptiveSessionData(e){try{return await super.sendMessageAndListenWith({action:"setPreemptiveSessionData",value:e},"setPreemptiveSessionDataCallback")}catch(e){return null}}async isWooPayReachable(){try{return await this.sendMessageAndListenWith({action:"isWooPayReachable"},"getIsWooPayReachableCallback")}catch(e){return!1}}callbackFn(e){switch(super.callbackFn(e),e.action){case"set_redirect_session_data_success":this.listeners.setRedirectSessionDataCallback(e.value);break;case"set_redirect_session_data_error":this.listeners.setRedirectSessionDataCallback({is_error:!0});break;case"set_temp_third_party_cookie_success":this.listeners.setTempThirdPartyCookieCallback(e.value);break;case"get_is_third_party_cookies_enabled_success":this.listeners.getIsThirdPartyCookiesEnabledCallback(e.value);break;case"get_is_woopay_reachable_success":this.listeners.getIsWooPayReachableCallback(e.value);break;case"set_preemptive_session_data_success":this.listeners.setPreemptiveSessionDataCallback(e.value);break;case"set_preemptive_session_data_error":this.listeners.setPreemptiveSessionDataCallback({is_error:!0})}}},E=class{static userConnect;static sessionConnect;static encryptedSessionDataPromise;static redirectElements={CLASSIC_CART_PROCEED_BUTTON:".wc-proceed-to-checkout .checkout-button",BLOCKS_CART_PROCEED_BUTTON:".wp-block-woocommerce-proceed-to-checkout-block",BLOCKS_MINI_CART_PROCEED_BUTTON:"a.wp-block-woocommerce-mini-cart-checkout-button-block",BLOCKS_FOOTER_MINI_CART_PROCEED_BUTTON:"a.wc-block-mini-cart__footer-checkout",CLASSIC_MINI_CART_PROCEED_BUTTON:".widget_shopping_cart a.button.checkout"};static init(){this.getSessionConnect()}static getUserConnect(){return this.userConnect||(this.userConnect=new b),this.userConnect}static getSessionConnect(){return this.sessionConnect||(this.sessionConnect=new k),this.sessionConnect}static teardown(){this.sessionConnect?.detachMessageListener(),this.userConnect?.detachMessageListener(),this.sessionConnect=null,this.userConnect=null}static isWooPayDirectCheckoutEnabled(){return r("isWooPayDirectCheckoutEnabled")}static async isWooPayReachable(){return this.getSessionConnect().isWooPayReachable()}static async isUserLoggedIn(){return this.getUserConnect().isUserLoggedIn()}static async getEncryptedData(){return this.getUserConnect().getEncryptedData()}static async isWooPayThirdPartyCookiesEnabled(){return this.getSessionConnect().isWooPayThirdPartyCookiesEnabled()}static async initPostMessageTimeout(){const e=await this.getSessionConnect().getPostMessageTimeout();var t;e&&(t=e,window.WooPayConnect||(window.WooPayConnect={}),window.WooPayConnect.postMessageTimeout=t)}static async getWooPayCheckoutUrl(){try{let e;if(e=this.isEncryptedSessionDataPrefetched()?await this.encryptedSessionDataPromise:await this.getEncryptedSessionData(),!this.isValidEncryptedSessionData(e))throw new Error("Could not retrieve encrypted session data from store.");const t=await this.getSessionConnect().sendRedirectSessionDataToWooPay(e);if(!t?.redirect_url)throw new Error("Could not retrieve WooPay checkout URL.");const{redirect_url:s}=t;if(!this.validateRedirectUrl(s,"platform_checkout_key"))throw new Error("Invalid WooPay session URL: "+s);return t.redirect_url}catch(e){throw new Error(e.message)}}static isValidEncryptedSessionData(e){return e&&e?.blog_id&&e?.data?.session&&e?.data?.iv&&e?.data?.hash}static async getWooPayMinimumSessionUrl(){const e=await this.getWooPayMinimumSesssionDataFromMerchant();if(!1===e?.success)throw new Error("Could not retrieve redirect data from merchant.");if(!this.isValidEncryptedSessionData(e))throw new Error("Invalid encrypted session data.");const{blog_id:t,data:{session:s,iv:o,hash:n}}=e,a=new URLSearchParams({checkout_redirect:1,blog_id:t,session:s,iv:o,hash:n});return r("woopayHost")+"/woopay/?"+a.toString()}static getCheckoutButtonElements(){const e=[],t=t=>{const s=document.querySelector(t);s&&e.push(s)};return t(this.redirectElements.CLASSIC_CART_PROCEED_BUTTON),t(this.redirectElements.BLOCKS_CART_PROCEED_BUTTON),t(this.redirectElements.CLASSIC_MINI_CART_PROCEED_BUTTON),e}static getClassicProceedToCheckoutButton(){return document.querySelector(this.redirectElements.CLASSIC_CART_PROCEED_BUTTON)}static getMiniCartProceedToCheckoutButton(){return document.querySelector(this.redirectElements.BLOCKS_MINI_CART_PROCEED_BUTTON)}static getFooterMiniCartProceedToCheckoutButton(){return document.querySelector(this.redirectElements.BLOCKS_FOOTER_MINI_CART_PROCEED_BUTTON)}static addRedirectToWooPayEventListener(e,t=!1){e.forEach((e=>{const s={is_loading:!1};e.addEventListener("click",(async o=>{if(s.is_loading)return void o.preventDefault();let n;if(s.is_loading=!0,(e=>{if(e.classList.contains("wp-block-woocommerce-mini-cart-checkout-button-block")||e.classList.contains("wc-block-mini-cart__footer-checkout"))return!0;const t=e.classList.contains("checkout-button"),s=e.parentElement?.classList?.contains("wc-proceed-to-checkout");return t&&s})(e)&&(e=>{const t=window.getComputedStyle(e,null).getPropertyValue("color"),s=document.createElement("span");s.classList.add("wc-block-components-spinner"),s.style.position="absolute",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.height="100%",s.style.color=t,s.style.fontSize="unset",s.style.display="inline",s.style.lineHeight="0",s.style.margin="0",s.style.border="0",s.style.padding="0",e.style.color="rgba( 0, 0, 0, 0 )",e.style.position="relative",e.appendChild(s)})(e),n="a"===e.tagName.toLowerCase()?e.href:e.querySelector("a")?.href,n){o.preventDefault();try{let e="";if(t)e=await this.getWooPayCheckoutUrl();else{if(!await this.isWooPayReachable())throw new Error("WooPay is currently not available.");e=await this.getWooPayMinimumSessionUrl()}this.teardown(),window.location.href=e}catch(e){console.warn(e),this.teardown(),window.location.href=n}}else this.teardown()}))}))}static async getEncryptedSessionData(){const e=await this.getEncryptedData();return l(y(r("wcAjaxUrl"),"get_woopay_session"),{_ajax_nonce:r("woopaySessionNonce"),...e&&{encrypted_data:e}})}static async getWooPayMinimumSesssionDataFromMerchant(){return r("woopayMinimumSessionData")?r("woopayMinimumSessionData"):l(y(r("wcAjaxUrl"),"get_woopay_minimum_session_data"),{_ajax_nonce:r("woopaySessionNonce")})}static validateRedirectUrl(e,t){try{const s=new URL(e);return!(s.origin!==r("woopayHost")||!s.searchParams.has(t))}catch(e){return!1}}static maybePrefetchEncryptedSessionData(){const e=window?.wcpayWooPayDirectCheckout?.params?.is_product_page;void 0===e||e||(this.encryptedSessionDataPromise=new Promise((e=>{e(this.getEncryptedSessionData())})))}static setEncryptedSessionDataAsNotPrefetched(){this.encryptedSessionDataPromise=null}static isEncryptedSessionDataPrefetched(){return"function"==typeof this.encryptedSessionDataPromise?.then}},v=()=>{const e=document.cookie.split(";").find((e=>e.includes("skip_woopay")));if(!e)return!1;const t=e?.split("=");return"skip_woopay"===t[0].trim()&&"1"===t[1].trim()};let S=!1;const T=async e=>{e&&(S?await E.isUserLoggedIn()&&(E.maybePrefetchEncryptedSessionData(),E.addRedirectToWooPayEventListener(e,!0)):E.addRedirectToWooPayEventListener(e,!1))},D=()=>{const e=E.getMiniCartProceedToCheckoutButton();T([e])},I=()=>{const e=E.getFooterMiniCartProceedToCheckoutButton();T([e])},M=async()=>S&&await E.isUserLoggedIn(),R=async()=>{await M()?E.maybePrefetchEncryptedSessionData():E.setEncryptedSessionDataAsNotPrefetched()},L=(0,o.debounce)((async({product:t})=>{if(!await M())return void E.setEncryptedSessionDataAsNotPrefetched();const s=(0,e.select)(n);(0,e.dispatch)(n).itemIsPendingQuantity(t.key,!0);let o=60;for(;s.isItemPendingQuantity(t.key)&&o>0;)o-=1,await a(100);o>0?E.maybePrefetchEncryptedSessionData():E.setEncryptedSessionDataAsNotPrefetched()}),400),W=async({product:t})=>{if(!await M())return void E.setEncryptedSessionDataAsNotPrefetched();const s=(0,e.select)(n);(0,e.dispatch)(n).itemIsPendingDelete(t.key,!0);let o=60;for(;s.isItemPendingDelete(t.key)&&o>0;)o-=1,await a(100);o>0?E.maybePrefetchEncryptedSessionData():E.setEncryptedSessionDataAsNotPrefetched()};window.addEventListener("load",(async()=>{if(v())return;E.init(),S=await E.isWooPayThirdPartyCookiesEnabled(),await E.initPostMessageTimeout(),(0,t.addAction)("experimental__woocommerce_blocks-cart-add-item","wcpay_woopay_direct_checkout",R),(0,t.addAction)("experimental__woocommerce_blocks-cart-set-item-quantity","wcpay_woopay_direct_checkout",L),(0,t.addAction)("experimental__woocommerce_blocks-cart-remove-item","wcpay_woopay_direct_checkout",W),document.querySelector('[data-block-name="woocommerce/mini-cart"]')&&new MutationObserver((e=>{for(const t of e)if(t?.addedNodes?.length>0)for(const e of t.addedNodes)if(1===e.nodeType&&e.matches(".wc-block-components-drawer__screen-overlay"))return i(E.redirectElements.BLOCKS_MINI_CART_PROCEED_BUTTON,D),void i(E.redirectElements.BLOCKS_FOOTER_MINI_CART_PROCEED_BUTTON,I)})).observe(document.body,{childList:!0});const e=E.getCheckoutButtonElements();T(e)})),jQuery((e=>{e(document.body).on("updated_cart_totals",(async()=>{if(v())return;const e=E.getClassicProceedToCheckoutButton();T([e])}))}))})()})();
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка