@zonos/elements 1.3.258 → 1.3.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +439 -14
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +6 -6
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +72 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +6 -6
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +6 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceLoginUrl.js +65 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +12 -7
- package/dist/collection/components/utils/checkout/checkBigCommerceForceLogin.js +116 -0
- package/dist/collection/components/utils/checkout/fetchBigCommerceCheckoutSettings.js +92 -0
- package/dist/collection/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.js +53 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +40 -7
- package/dist/collection/types/checkout/api/BigCommerceCheckoutSettings.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +39 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/zonos-checkout.entry.js +440 -15
- package/dist/esm/zonos-hello-dialog.entry.js +6 -6
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/scripts/index.d.ts +21 -5
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +16 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +6 -0
- package/dist/types/components/utils/checkout/buildBigcommerceLoginUrl.d.ts +27 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +12 -0
- package/dist/types/components/utils/checkout/checkBigCommerceForceLogin.d.ts +50 -0
- package/dist/types/components/utils/checkout/fetchBigCommerceCheckoutSettings.d.ts +18 -0
- package/dist/types/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.d.ts +17 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +6 -5
- package/dist/types/types/checkout/CheckoutConfig.d.ts +9 -0
- package/dist/types/types/checkout/api/BigCommerceCheckoutSettings.d.ts +12 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +3 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +3 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +58 -9
- package/dist/types/types/generated/graphql.internal.types.ts +69 -9
- package/dist/types/types/index.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/p-439dc620.system.entry.js +1 -0
- package/dist/zonos-elements/{p-5182e492.entry.js → p-9cbac993.entry.js} +1 -1
- package/dist/zonos-elements/{p-867d05d7.system.js → p-cc645667.system.js} +1 -1
- package/dist/zonos-elements/p-d13120f6.entry.js +1 -0
- package/dist/zonos-elements/{p-9c97671b.system.entry.js → p-f4e54f09.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-50b32476.system.entry.js +0 -1
- package/dist/zonos-elements/p-733f118d.entry.js +0 -1
package/dist/scripts/zonos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),O=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:O,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),O?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.258.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let O=null;const I=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var R;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),x=Date.now(),B="https://v1.3.258.js.zonos.com",q=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.258",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}R=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1776786575498",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.startLoadTime=x,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.258",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(R.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),R.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${R.version}) ======`),R.zonosApiKey=p,R.storeId=u,"undefined"!=typeof window&&window.parent===window&&(R.googleAnalyticReady=!0),R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=R.isNpm,window.Zonos.isBigCommerce=R.isBigCommerce,window.Zonos.isLegacyCheckout=R.isLegacyCheckout,window.Zonos.zonosMode=R.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!R.cartData&&R.cartId){r("Initialize cart data");const e=await D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(R.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=R.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=R.zonosController)||void 0===o||o.updateOrganizationName(e)},G.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${R.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&R.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.258";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.258";case"vercel":return B}};if(R.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&R.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=R.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=G)})();
|
|
1
|
+
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),O=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:O,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),O?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.259.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let O=null;const I=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var R;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),x=Date.now(),B="https://v1.3.259.js.zonos.com",q=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.259",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}R=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1776888365876",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.startLoadTime=x,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.259",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(R.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),R.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${R.version}) ======`),R.zonosApiKey=p,R.storeId=u,"undefined"!=typeof window&&window.parent===window&&(R.googleAnalyticReady=!0),R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=R.isNpm,window.Zonos.isBigCommerce=R.isBigCommerce,window.Zonos.isLegacyCheckout=R.isLegacyCheckout,window.Zonos.zonosMode=R.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!R.cartData&&R.cartId){r("Initialize cart data");const e=await D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(R.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=R.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=R.zonosController)||void 0===o||o.updateOrganizationName(e)},G.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${R.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&R.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.259";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.259";case"vercel":return B}};if(R.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&R.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=R.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=G)})();
|
|
@@ -170,6 +170,22 @@ export declare class ZonosCheckout {
|
|
|
170
170
|
* Setup all of the event listeners for the component on first load
|
|
171
171
|
*/
|
|
172
172
|
init(): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* After BigCommerce's `/login.php` round trip, the shopper lands back on
|
|
175
|
+
* `cart.php?isInternationalCheckout=true`. Detect the flag, strip it from
|
|
176
|
+
* the URL (so refreshing doesn't re-open the dialog), then fire the
|
|
177
|
+
* international-checkout trigger once three preconditions are all met:
|
|
178
|
+
* 1. Hello localization finished loading (`localizationLoaded`).
|
|
179
|
+
* 2. A country code is selected — otherwise `buildCartDetail` runs
|
|
180
|
+
* without a `countryCode` / `currencyCode` and never builds a cart.
|
|
181
|
+
* 3. The hidden trigger button has mounted.
|
|
182
|
+
*
|
|
183
|
+
* Without the first two gates we race Hello's own init and the click
|
|
184
|
+
* fires against a half-initialized store, which is what happens when
|
|
185
|
+
* the shopper refreshes back into cart.php straight from the login
|
|
186
|
+
* round trip.
|
|
187
|
+
*/
|
|
188
|
+
private handleBigcommerceInternationalResumeFlag;
|
|
173
189
|
/**
|
|
174
190
|
* For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish
|
|
175
191
|
*/
|
|
@@ -4,7 +4,7 @@ export declare const getLocaleMessages: ({ countryCode, localeTo, storeId, }: {
|
|
|
4
4
|
localeTo?: string;
|
|
5
5
|
storeId: number;
|
|
6
6
|
}) => Promise<{
|
|
7
|
-
countryCodes: Array<string
|
|
7
|
+
countryCodes: Array<string> | null;
|
|
8
8
|
countryCodesPageMessageLinks: Array<{
|
|
9
9
|
id: number;
|
|
10
10
|
message: {
|
|
@@ -34,3 +34,9 @@ export declare const fetchCheckoutId: () => Promise<string | null>;
|
|
|
34
34
|
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
35
35
|
*/
|
|
36
36
|
export declare const fetchBigCommerceCheckout: (checkoutId: string) => Promise<BigCommerceCheckoutResponse | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
39
|
+
* customer's numeric `id` since the storefront API populates it only for
|
|
40
|
+
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
41
|
+
*/
|
|
42
|
+
export declare const isBigCommerceCustomerLoggedIn: (checkout: BigCommerceCheckoutResponse | null) => boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The query flag that BigCommerce carries back to `cart.php` after the
|
|
3
|
+
* shopper logs in. When present, Zonos-elements knows to resume the
|
|
4
|
+
* international checkout flow instead of letting BC's native cart UX
|
|
5
|
+
* take over.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG = "isInternationalCheckout";
|
|
8
|
+
type Options = {
|
|
9
|
+
/**
|
|
10
|
+
* When set, builds a link to the BC "Create account" action
|
|
11
|
+
* (`login.php?action=create_account`) — same `from` payload, but a
|
|
12
|
+
* different initial tab.
|
|
13
|
+
*/
|
|
14
|
+
action?: 'create_account';
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Build an absolute URL to BigCommerce's `/login.php` with the
|
|
18
|
+
* `from=cart.php?isInternationalCheckout=true` round-trip encoded so the
|
|
19
|
+
* shopper resumes Zonos international checkout after authenticating.
|
|
20
|
+
*
|
|
21
|
+
* Preserves `zonosTestMode` / `zonosQaUrl` / `zonosQaUrlApi` from the current
|
|
22
|
+
* URL across the redirect — the login round trip leaves BC's frontend, so
|
|
23
|
+
* without this the returning `cart.php` would drop back to the production
|
|
24
|
+
* build / API host.
|
|
25
|
+
*/
|
|
26
|
+
export declare const buildBigcommerceLoginUrl: ({ action }?: Options) => string;
|
|
27
|
+
export {};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import type { BigCommerceCheckoutResponse } from "./bigcommerceStorefrontApi";
|
|
1
2
|
type BypassResult = {
|
|
2
3
|
customerGroupId: number | null;
|
|
3
4
|
shouldBypass: boolean;
|
|
4
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Optional pre-fetched Storefront API data that callers can pass through to
|
|
8
|
+
* avoid duplicating `/api/storefront/cart` + `/api/storefront/checkouts/{id}`
|
|
9
|
+
* round trips. Used by the domestic-checkout redirect watcher where the same
|
|
10
|
+
* checkout data feeds bypass + force-login decisions on each poll tick.
|
|
11
|
+
*/
|
|
12
|
+
type BypassPreFetched = {
|
|
13
|
+
checkout: BigCommerceCheckoutResponse | null;
|
|
14
|
+
checkoutId: string | null;
|
|
15
|
+
};
|
|
5
16
|
/**
|
|
6
17
|
* Start fetching the BigCommerce customer group on page load.
|
|
7
18
|
* Call this once during initialization (e.g. in `zonos-checkout.init()`).
|
|
@@ -26,5 +37,6 @@ export declare const initBigCommerceBypassCheck: () => void;
|
|
|
26
37
|
*/
|
|
27
38
|
export declare const checkBigCommerceBypassCustomerGroup: (options?: {
|
|
28
39
|
forceRefresh?: boolean;
|
|
40
|
+
preFetched?: BypassPreFetched;
|
|
29
41
|
}) => Promise<BypassResult>;
|
|
30
42
|
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BigCommerceCheckoutResponse } from "./bigcommerceStorefrontApi";
|
|
2
|
+
export type BigCommerceForceLoginDecision = {
|
|
3
|
+
/**
|
|
4
|
+
* When `shouldForceLogin` is true, the caller should redirect the browser
|
|
5
|
+
* to this URL (BigCommerce `/login.php` with the round-trip `from` query
|
|
6
|
+
* already encoded). `null` otherwise.
|
|
7
|
+
*/
|
|
8
|
+
redirectUrl: string | null;
|
|
9
|
+
shouldForceLogin: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Optional pre-fetched Storefront API data that callers can pass in to avoid
|
|
13
|
+
* a duplicate `/api/storefront/cart` + `/api/storefront/checkouts/{id}` round
|
|
14
|
+
* trip when they've already fetched it (e.g. the domestic-checkout-redirect
|
|
15
|
+
* watcher). When omitted, `checkBigCommerceForceLogin` fetches them itself.
|
|
16
|
+
*/
|
|
17
|
+
export type BigCommerceForceLoginPreFetched = {
|
|
18
|
+
checkout: BigCommerceCheckoutResponse | null;
|
|
19
|
+
checkoutId: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Kick off the `/checkouts/settings` fetch in the background on page load
|
|
23
|
+
* so the result is warm by the time the shopper opens checkout. Safe to
|
|
24
|
+
* call more than once — re-invocations reuse the in-flight/resolved
|
|
25
|
+
* promise.
|
|
26
|
+
*/
|
|
27
|
+
export declare const initBigCommerceForceLoginCheck: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Decide whether the current BigCommerce shopper must sign in before the
|
|
30
|
+
* Zonos international checkout is allowed to open.
|
|
31
|
+
*
|
|
32
|
+
* Required conditions (all must hold):
|
|
33
|
+
* 1. Running on a BigCommerce storefront.
|
|
34
|
+
* 2. BC merchant has `guest_checkout_type === 'no_guest_checkout'` in their
|
|
35
|
+
* live `/v3/checkouts/settings` response.
|
|
36
|
+
* 3. Shopper has an active cart.
|
|
37
|
+
* 4. Shopper is not already logged in to BigCommerce.
|
|
38
|
+
*
|
|
39
|
+
* Returning a `redirectUrl` is an instruction, not an action: callers drive
|
|
40
|
+
* the navigation themselves so they can short-circuit any UI state (loading
|
|
41
|
+
* overlays, dialog open flags) before `window.location.href` flips.
|
|
42
|
+
*/
|
|
43
|
+
export declare const checkBigCommerceForceLogin: ({ preFetched, }?: {
|
|
44
|
+
preFetched?: BigCommerceForceLoginPreFetched;
|
|
45
|
+
}) => Promise<BigCommerceForceLoginDecision>;
|
|
46
|
+
/**
|
|
47
|
+
* Test-only — resets the module-level cache so each test case starts
|
|
48
|
+
* against a clean state.
|
|
49
|
+
*/
|
|
50
|
+
export declare const _resetBigCommerceForceLoginCacheForTesting: () => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BcGuestCheckoutType } from "../../../types/checkout/api/BigCommerceCheckoutSettings";
|
|
2
|
+
export type BigCommerceCheckoutSettingsResult = {
|
|
3
|
+
/**
|
|
4
|
+
* Live value of BigCommerce's `guest_checkout_type` store setting.
|
|
5
|
+
* `null` when the store hash is unknown or the proxy call failed.
|
|
6
|
+
*/
|
|
7
|
+
guestCheckoutType: BcGuestCheckoutType | null;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Fetch the merchant's BigCommerce `/checkouts/settings` (via the demo-app
|
|
11
|
+
* proxy) so we can inspect `guest_checkout_type` from the storefront. The
|
|
12
|
+
* Store API is auth-gated, which is why we don't call it directly.
|
|
13
|
+
*
|
|
14
|
+
* Results are cached in `localStorage` for `CACHE_TTL_MS` so navigations
|
|
15
|
+
* inside the same store don't all pay the proxy round trip — the setting
|
|
16
|
+
* is merchant-level and rarely changes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const fetchBigCommerceCheckoutSettings: () => Promise<BigCommerceCheckoutSettingsResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On BigCommerce's `/login.php`, the default **Create account** button links
|
|
3
|
+
* to `login.php?action=create_account` without the `from=cart.php...`
|
|
4
|
+
* parameter that the shopper had when they arrived. Without this, completing
|
|
5
|
+
* signup would drop them on the account home page instead of resuming Zonos
|
|
6
|
+
* international checkout.
|
|
7
|
+
*
|
|
8
|
+
* This watcher finds any create-account anchor on the page (including ones
|
|
9
|
+
* that the BC theme renders later via Stencil bundle load) and rewrites the
|
|
10
|
+
* `href` so the account-creation round trip preserves the
|
|
11
|
+
* `isInternationalCheckout=true` flag as well as `zonosTestMode` /
|
|
12
|
+
* `zonosQaUrl`.
|
|
13
|
+
*
|
|
14
|
+
* Safe to call more than once — idempotent thanks to the `data-zonos-…`
|
|
15
|
+
* attribute on rewritten anchors.
|
|
16
|
+
*/
|
|
17
|
+
export declare const fixBigCommerceLoginCreateAccountLink: () => void;
|
|
@@ -147,24 +147,25 @@ export declare const setupCartDataWithSettings: (cartId: string) => Promise<{
|
|
|
147
147
|
includedCountries: Array<import("../..").CountryCode>;
|
|
148
148
|
};
|
|
149
149
|
};
|
|
150
|
+
countryOverrideBehavior: import("../../types/generated/graphql.internal.types").HelloCountryOverrideBehavior;
|
|
150
151
|
createdAt: string;
|
|
151
|
-
|
|
152
|
+
createdBy: string;
|
|
152
153
|
currencyBehavior: import("../../types/generated/graphql.internal.types").HelloCurrencyBehavior;
|
|
153
154
|
currencyElementSelector: string;
|
|
154
155
|
desktopLocation: import("../../types/generated/graphql.internal.types").HelloDesktopLocation;
|
|
155
156
|
dutyTaxEstimationBehavior: import("../../types/generated/graphql.internal.types").HelloEstimateBehavior;
|
|
156
157
|
excludedUrlPatterns: Array<string>;
|
|
157
|
-
|
|
158
|
+
organization: string;
|
|
158
159
|
id: string;
|
|
159
160
|
mobileLocation: import("../..").HelloMobileLocation;
|
|
160
161
|
mode: import("../../types/generated/graphql.internal.types").Mode;
|
|
161
|
-
|
|
162
|
+
homepageUrlPattern: string | null;
|
|
162
163
|
peekMessageBehavior: import("../../types/generated/graphql.internal.types").HelloPeekMessageBehavior;
|
|
163
164
|
peekMessageDelay: number;
|
|
164
|
-
productAddToCartElementSelector: string | null;
|
|
165
165
|
productListUrlPattern: string | null;
|
|
166
|
+
productAddToCartElementSelector: string | null;
|
|
166
167
|
productDetailUrlPattern: string | null;
|
|
167
|
-
|
|
168
|
+
productTitleElementSelector: string | null;
|
|
168
169
|
productPriceElementSelector: string | null;
|
|
169
170
|
productDescriptionElementSelector: string | null;
|
|
170
171
|
restrictionBehavior: import("../../types/generated/graphql.internal.types").HelloRestrictionBehavior;
|
|
@@ -62,6 +62,15 @@ export type CheckoutConfig = {
|
|
|
62
62
|
status: AnalyticsProviderStatus;
|
|
63
63
|
type: AnalyticsProviderType;
|
|
64
64
|
}>;
|
|
65
|
+
/**
|
|
66
|
+
* BigCommerce-specific identifiers forwarded by the Zonos loader script.
|
|
67
|
+
* Consumed by runtime code that needs to hit the demo-app proxy on behalf
|
|
68
|
+
* of a specific BigCommerce store (e.g. the `/checkouts/settings`
|
|
69
|
+
* force-login check).
|
|
70
|
+
*/
|
|
71
|
+
bigCommerceConfig?: {
|
|
72
|
+
storeHash: string;
|
|
73
|
+
};
|
|
65
74
|
/**
|
|
66
75
|
* Time that payment will be captured after the order is placed. Can't be overridden in Zonos.init
|
|
67
76
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value surfaced by BigCommerce's `/v3/checkouts/settings` endpoint for the
|
|
3
|
+
* `guest_checkout_type` field. `no_guest_checkout` is the signal Zonos uses
|
|
4
|
+
* to require login before opening the international checkout.
|
|
5
|
+
*/
|
|
6
|
+
export type BcGuestCheckoutType = 'allow_guest' | 'guest_checkout' | 'no_guest_checkout' | (string & {});
|
|
7
|
+
export type BigCommerceCheckoutSettingsPayload = {
|
|
8
|
+
storeHash: string;
|
|
9
|
+
};
|
|
10
|
+
export type BigCommerceCheckoutSettingsResponse = {
|
|
11
|
+
guestCheckoutType: BcGuestCheckoutType | null;
|
|
12
|
+
};
|
|
@@ -106,6 +106,7 @@ export declare const featureAspectKeyEnum: {
|
|
|
106
106
|
readonly NewCheckoutBeta: "new_checkout_beta";
|
|
107
107
|
readonly NewPayoutReport: "new_payout_report";
|
|
108
108
|
readonly NewRefundsUx: "new_refunds_ux";
|
|
109
|
+
readonly OnboardingBeta: "onboarding_beta";
|
|
109
110
|
readonly PageAuditor: "page_auditor";
|
|
110
111
|
readonly PromptExplorer: "prompt_explorer";
|
|
111
112
|
readonly RulesUiCreate: "rules_ui_create";
|
|
@@ -139,6 +140,7 @@ export declare const featureAudienceNameEnum: {
|
|
|
139
140
|
readonly NewPayoutReportMerchant: "new_payout_report_merchant";
|
|
140
141
|
readonly NewRefundsUxMerchant: "new_refunds_ux_merchant";
|
|
141
142
|
readonly Onboarding: "onboarding";
|
|
143
|
+
readonly OnboardingBetaMerchant: "onboarding_beta_merchant";
|
|
142
144
|
readonly PrincipalEngineer: "principal_engineer";
|
|
143
145
|
readonly ProServeHead: "pro_serve_head";
|
|
144
146
|
readonly ProductManager: "product_manager";
|
|
@@ -727,7 +729,7 @@ export type FailToGetQuoteErrorsQuery = {
|
|
|
727
729
|
};
|
|
728
730
|
export type LocaleCountryMessagesQuery = {
|
|
729
731
|
locale_countryCodesPage: Array<{
|
|
730
|
-
countryCodes: Array<string
|
|
732
|
+
countryCodes: Array<string> | null;
|
|
731
733
|
countryCodesPageMessageLinks: Array<{
|
|
732
734
|
id: number;
|
|
733
735
|
message: {
|
|
@@ -85,6 +85,7 @@ export const featureAspectKeyEnum = {
|
|
|
85
85
|
NewCheckoutBeta: 'new_checkout_beta',
|
|
86
86
|
NewPayoutReport: 'new_payout_report',
|
|
87
87
|
NewRefundsUx: 'new_refunds_ux',
|
|
88
|
+
OnboardingBeta: 'onboarding_beta',
|
|
88
89
|
PageAuditor: 'page_auditor',
|
|
89
90
|
PromptExplorer: 'prompt_explorer',
|
|
90
91
|
RulesUiCreate: 'rules_ui_create',
|
|
@@ -123,6 +124,7 @@ export const featureAudienceNameEnum = {
|
|
|
123
124
|
NewPayoutReportMerchant: 'new_payout_report_merchant',
|
|
124
125
|
NewRefundsUxMerchant: 'new_refunds_ux_merchant',
|
|
125
126
|
Onboarding: 'onboarding',
|
|
127
|
+
OnboardingBetaMerchant: 'onboarding_beta_merchant',
|
|
126
128
|
PrincipalEngineer: 'principal_engineer',
|
|
127
129
|
ProServeHead: 'pro_serve_head',
|
|
128
130
|
ProductManager: 'product_manager',
|
|
@@ -684,7 +686,7 @@ export type FailToGetQuoteErrorsQuery = {
|
|
|
684
686
|
|
|
685
687
|
export type LocaleCountryMessagesQuery = {
|
|
686
688
|
locale_countryCodesPage: Array<{
|
|
687
|
-
countryCodes: Array<string
|
|
689
|
+
countryCodes: Array<string> | null;
|
|
688
690
|
countryCodesPageMessageLinks: Array<{
|
|
689
691
|
id: number;
|
|
690
692
|
message: {
|
|
@@ -1906,6 +1906,20 @@ export declare const customsDocumentType: {
|
|
|
1906
1906
|
readonly UsmcaCertificate: "USMCA_CERTIFICATE";
|
|
1907
1907
|
};
|
|
1908
1908
|
export type CustomsDocumentType = (typeof customsDocumentType)[keyof typeof customsDocumentType];
|
|
1909
|
+
export declare const customsHoldReason: {
|
|
1910
|
+
readonly Abandonment: "ABANDONMENT";
|
|
1911
|
+
readonly Confiscated: "CONFISCATED";
|
|
1912
|
+
readonly DutyNonpayment: "DUTY_NONPAYMENT";
|
|
1913
|
+
readonly Examination: "EXAMINATION";
|
|
1914
|
+
readonly GoodsNotCompliant: "GOODS_NOT_COMPLIANT";
|
|
1915
|
+
readonly GovernmentHold: "GOVERNMENT_HOLD";
|
|
1916
|
+
readonly MissingData: "MISSING_DATA";
|
|
1917
|
+
readonly MissingDocs: "MISSING_DOCS";
|
|
1918
|
+
readonly RefusedEntry: "REFUSED_ENTRY";
|
|
1919
|
+
readonly SecurityFail: "SECURITY_FAIL";
|
|
1920
|
+
readonly Unknown: "UNKNOWN";
|
|
1921
|
+
};
|
|
1922
|
+
export type CustomsHoldReason = (typeof customsHoldReason)[keyof typeof customsHoldReason];
|
|
1909
1923
|
export declare const customsIntelBucketGranularity: {
|
|
1910
1924
|
readonly Day: "DAY";
|
|
1911
1925
|
readonly Hour: "HOUR";
|
|
@@ -1982,6 +1996,14 @@ export declare const customsSpecSourceType: {
|
|
|
1982
1996
|
readonly OrganizationSetting: "ORGANIZATION_SETTING";
|
|
1983
1997
|
};
|
|
1984
1998
|
export type CustomsSpecSourceType = (typeof customsSpecSourceType)[keyof typeof customsSpecSourceType];
|
|
1999
|
+
export declare const customsStage: {
|
|
2000
|
+
readonly CustomsCleared: "CUSTOMS_CLEARED";
|
|
2001
|
+
readonly CustomsFailed: "CUSTOMS_FAILED";
|
|
2002
|
+
readonly CustomsHold: "CUSTOMS_HOLD";
|
|
2003
|
+
readonly InCustoms: "IN_CUSTOMS";
|
|
2004
|
+
readonly PreCustoms: "PRE_CUSTOMS";
|
|
2005
|
+
};
|
|
2006
|
+
export type CustomsStage = (typeof customsStage)[keyof typeof customsStage];
|
|
1985
2007
|
export declare const dashboardUnit: {
|
|
1986
2008
|
readonly Imperial: "IMPERIAL";
|
|
1987
2009
|
readonly Metric: "METRIC";
|
|
@@ -2281,6 +2303,7 @@ export declare const entryStatus: {
|
|
|
2281
2303
|
readonly Archived: "ARCHIVED";
|
|
2282
2304
|
readonly Draft: "DRAFT";
|
|
2283
2305
|
readonly Error: "ERROR";
|
|
2306
|
+
readonly Filed: "FILED";
|
|
2284
2307
|
readonly Rejected: "REJECTED";
|
|
2285
2308
|
readonly Submitted: "SUBMITTED";
|
|
2286
2309
|
};
|
|
@@ -2296,6 +2319,7 @@ export declare const errorDetail: {
|
|
|
2296
2319
|
readonly TcpFailure: "TCP_FAILURE";
|
|
2297
2320
|
readonly ThrottledConcurrency: "THROTTLED_CONCURRENCY";
|
|
2298
2321
|
readonly ThrottledCpu: "THROTTLED_CPU";
|
|
2322
|
+
readonly TooManyRequests: "TOO_MANY_REQUESTS";
|
|
2299
2323
|
readonly Unimplemented: "UNIMPLEMENTED";
|
|
2300
2324
|
readonly Unknown: "UNKNOWN";
|
|
2301
2325
|
};
|
|
@@ -2399,6 +2423,11 @@ export declare const helloCountryDisplayBehavior: {
|
|
|
2399
2423
|
readonly OnlyShippable: "ONLY_SHIPPABLE";
|
|
2400
2424
|
};
|
|
2401
2425
|
export type HelloCountryDisplayBehavior = (typeof helloCountryDisplayBehavior)[keyof typeof helloCountryDisplayBehavior];
|
|
2426
|
+
export declare const helloCountryOverrideBehavior: {
|
|
2427
|
+
readonly Session: "SESSION";
|
|
2428
|
+
readonly UrlParam: "URL_PARAM";
|
|
2429
|
+
};
|
|
2430
|
+
export type HelloCountryOverrideBehavior = (typeof helloCountryOverrideBehavior)[keyof typeof helloCountryOverrideBehavior];
|
|
2402
2431
|
export declare const helloCurrencyBehavior: {
|
|
2403
2432
|
readonly Disabled: "DISABLED";
|
|
2404
2433
|
readonly Enabled: "ENABLED";
|
|
@@ -4966,6 +4995,12 @@ export declare const reverseAmountType: {
|
|
|
4966
4995
|
readonly TaxFee: "TAX_FEE";
|
|
4967
4996
|
};
|
|
4968
4997
|
export type ReverseAmountType = (typeof reverseAmountType)[keyof typeof reverseAmountType];
|
|
4998
|
+
export declare const riskLevel: {
|
|
4999
|
+
readonly High: "HIGH";
|
|
5000
|
+
readonly Low: "LOW";
|
|
5001
|
+
readonly Medium: "MEDIUM";
|
|
5002
|
+
};
|
|
5003
|
+
export type RiskLevel = (typeof riskLevel)[keyof typeof riskLevel];
|
|
4969
5004
|
export declare const roundingMethod: {
|
|
4970
5005
|
readonly Custom: "CUSTOM";
|
|
4971
5006
|
readonly Hundredth: "HUNDREDTH";
|
|
@@ -5184,6 +5219,10 @@ export declare const shipmentPackagingTypeCode: {
|
|
|
5184
5219
|
readonly YourPackaging: "YOUR_PACKAGING";
|
|
5185
5220
|
};
|
|
5186
5221
|
export type ShipmentPackagingTypeCode = (typeof shipmentPackagingTypeCode)[keyof typeof shipmentPackagingTypeCode];
|
|
5222
|
+
export declare const shipmentRatingAdjustmentType: {
|
|
5223
|
+
readonly CartTotal: "CART_TOTAL";
|
|
5224
|
+
};
|
|
5225
|
+
export type ShipmentRatingAdjustmentType = (typeof shipmentRatingAdjustmentType)[keyof typeof shipmentRatingAdjustmentType];
|
|
5187
5226
|
export declare const shipmentRatingAmountTargetType: {
|
|
5188
5227
|
readonly BillingCompany: "BILLING_COMPANY";
|
|
5189
5228
|
readonly MerchantBase: "MERCHANT_BASE";
|
|
@@ -5758,6 +5797,12 @@ export declare const volumeUnitCode: {
|
|
|
5758
5797
|
readonly QuartUsDry: "QUART_US_DRY";
|
|
5759
5798
|
};
|
|
5760
5799
|
export type VolumeUnitCode = (typeof volumeUnitCode)[keyof typeof volumeUnitCode];
|
|
5800
|
+
export declare const watchStatus: {
|
|
5801
|
+
readonly Active: "ACTIVE";
|
|
5802
|
+
readonly Completed: "COMPLETED";
|
|
5803
|
+
readonly Expired: "EXPIRED";
|
|
5804
|
+
};
|
|
5805
|
+
export type WatchStatus = (typeof watchStatus)[keyof typeof watchStatus];
|
|
5761
5806
|
export declare const wcoVersion: {
|
|
5762
5807
|
readonly Wco_1997: "WCO_1997";
|
|
5763
5808
|
readonly Wco_2002: "WCO_2002";
|
|
@@ -7176,24 +7221,25 @@ export type CartCheckoutWorkflowQuery = {
|
|
|
7176
7221
|
includedCountries: Array<CountryCode>;
|
|
7177
7222
|
};
|
|
7178
7223
|
};
|
|
7224
|
+
countryOverrideBehavior: HelloCountryOverrideBehavior;
|
|
7179
7225
|
createdAt: string;
|
|
7180
|
-
|
|
7226
|
+
createdBy: string;
|
|
7181
7227
|
currencyBehavior: HelloCurrencyBehavior;
|
|
7182
7228
|
currencyElementSelector: string;
|
|
7183
7229
|
desktopLocation: HelloDesktopLocation;
|
|
7184
7230
|
dutyTaxEstimationBehavior: HelloEstimateBehavior;
|
|
7185
7231
|
excludedUrlPatterns: Array<string>;
|
|
7186
|
-
|
|
7232
|
+
organization: string;
|
|
7187
7233
|
id: string;
|
|
7188
7234
|
mobileLocation: HelloMobileLocation;
|
|
7189
7235
|
mode: Mode;
|
|
7190
|
-
|
|
7236
|
+
homepageUrlPattern: string | null;
|
|
7191
7237
|
peekMessageBehavior: HelloPeekMessageBehavior;
|
|
7192
7238
|
peekMessageDelay: number;
|
|
7193
|
-
productAddToCartElementSelector: string | null;
|
|
7194
7239
|
productListUrlPattern: string | null;
|
|
7240
|
+
productAddToCartElementSelector: string | null;
|
|
7195
7241
|
productDetailUrlPattern: string | null;
|
|
7196
|
-
|
|
7242
|
+
productTitleElementSelector: string | null;
|
|
7197
7243
|
productPriceElementSelector: string | null;
|
|
7198
7244
|
productDescriptionElementSelector: string | null;
|
|
7199
7245
|
restrictionBehavior: HelloRestrictionBehavior;
|
|
@@ -7876,8 +7922,9 @@ export type ZonosSettingsQuery = {
|
|
|
7876
7922
|
includedCountries: Array<CountryCode>;
|
|
7877
7923
|
};
|
|
7878
7924
|
};
|
|
7925
|
+
countryOverrideBehavior: HelloCountryOverrideBehavior;
|
|
7879
7926
|
createdAt: string;
|
|
7880
|
-
|
|
7927
|
+
createdBy: string;
|
|
7881
7928
|
currencyBehavior: HelloCurrencyBehavior;
|
|
7882
7929
|
currencyElementSelector: string;
|
|
7883
7930
|
desktopLocation: HelloDesktopLocation;
|
|
@@ -7891,11 +7938,11 @@ export type ZonosSettingsQuery = {
|
|
|
7891
7938
|
peekMessageBehavior: HelloPeekMessageBehavior;
|
|
7892
7939
|
peekMessageDelay: number;
|
|
7893
7940
|
productAddToCartElementSelector: string | null;
|
|
7894
|
-
createdBy: string;
|
|
7895
|
-
productDetailUrlPattern: string | null;
|
|
7896
7941
|
productListUrlPattern: string | null;
|
|
7897
|
-
|
|
7942
|
+
productDetailUrlPattern: string | null;
|
|
7898
7943
|
productDescriptionElementSelector: string | null;
|
|
7944
|
+
productPriceElementSelector: string | null;
|
|
7945
|
+
productTitleElementSelector: string | null;
|
|
7899
7946
|
restrictionBehavior: HelloRestrictionBehavior;
|
|
7900
7947
|
updatedAt: string;
|
|
7901
7948
|
updatedBy: string;
|
|
@@ -7930,6 +7977,7 @@ export type HelloSettingsQuery = {
|
|
|
7930
7977
|
includedCountries: Array<CountryCode>;
|
|
7931
7978
|
};
|
|
7932
7979
|
};
|
|
7980
|
+
countryOverrideBehavior: HelloCountryOverrideBehavior;
|
|
7933
7981
|
createdAt: string;
|
|
7934
7982
|
createdBy: string;
|
|
7935
7983
|
currencyBehavior: HelloCurrencyBehavior;
|
|
@@ -8108,6 +8156,7 @@ export type HelloSettingFragment = {
|
|
|
8108
8156
|
includedCountries: Array<CountryCode>;
|
|
8109
8157
|
};
|
|
8110
8158
|
};
|
|
8159
|
+
countryOverrideBehavior: HelloCountryOverrideBehavior;
|
|
8111
8160
|
createdAt: string;
|
|
8112
8161
|
createdBy: string;
|
|
8113
8162
|
currencyBehavior: HelloCurrencyBehavior;
|