@zonos/elements 1.3.188 → 1.3.190
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/{CheckoutConfig-f1442a60.js → CheckoutConfig-4afc683b.js} +2 -0
- package/dist/cjs/TaxId-12acedde.js +94 -0
- package/dist/cjs/{cart-f9df3ac8.js → cart-27f6c7a4.js} +60 -0
- package/dist/cjs/index.cjs.js +35 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{paypal-5e73c8f5.js → paypal-84d83a76.js} +1 -1
- package/dist/cjs/zonos-address_11.cjs.entry.js +61 -4
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +37 -31
- package/dist/cjs/zonos-checkout.cjs.entry.js +16 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +31 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +14 -28
- package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +1 -1
- package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
- package/dist/collection/components/store/translationStore/strings.base.js +3 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
- package/dist/collection/components/store/translationStore/strings.french.js +3 -0
- package/dist/collection/components/store/translationStore/strings.german.js +3 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +65 -1
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +50 -2
- package/dist/collection/components/utils/taxIdValidationResult.js +23 -2
- package/dist/collection/scripts/_zonosBase.js +25 -1
- package/dist/collection/types/checkout/CheckoutConfig.js +1 -0
- package/dist/collection/types/checkout/TaxId.js +64 -0
- package/dist/esm/{CheckoutConfig-5479d192.js → CheckoutConfig-eb7d6954.js} +2 -1
- package/dist/esm/TaxId-50d72254.js +90 -0
- package/dist/esm/{cart-4725a63b.js → cart-f5c12be6.js} +60 -0
- package/dist/esm/index.js +34 -10
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{paypal-a09943f4.js → paypal-594f49e9.js} +1 -1
- package/dist/esm/zonos-address_11.entry.js +61 -4
- package/dist/esm/zonos-cart-items_13.entry.js +37 -31
- package/dist/esm/zonos-checkout.entry.js +16 -3
- package/dist/esm/zonos-controller.entry.js +1 -1
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-empty-state-payment_4.entry.js +2 -2
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/{CheckoutConfig-5479d192.js → CheckoutConfig-eb7d6954.js} +1 -1
- package/dist/esm-es5/TaxId-50d72254.js +1 -0
- package/dist/esm-es5/cart-f5c12be6.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{paypal-a09943f4.js → paypal-594f49e9.js} +1 -1
- package/dist/esm-es5/zonos-address_11.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/scripts/index.d.ts +34 -0
- 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 +4 -0
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -5
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +13 -0
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +9 -0
- package/dist/types/components/utils/taxIdValidationResult.d.ts +2 -1
- package/dist/types/components.d.ts +25 -0
- package/dist/types/scripts/_zonosBase.d.ts +9 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -0
- package/dist/types/types/checkout/TaxId.d.ts +123 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-01eda7f2.entry.js +1 -0
- package/dist/zonos-elements/p-03bbd1af.entry.js +1 -0
- package/dist/zonos-elements/p-04a0e38b.system.entry.js +1 -0
- package/dist/zonos-elements/{p-e90cb997.entry.js → p-0dae66d2.entry.js} +1 -1
- package/dist/zonos-elements/{p-aaff5dcc.entry.js → p-1146b6e0.entry.js} +1 -1
- package/dist/zonos-elements/{p-8721bd47.system.entry.js → p-23975acb.system.entry.js} +1 -1
- package/dist/zonos-elements/p-2b8345d8.system.js +1 -0
- package/dist/zonos-elements/{p-04303b56.system.entry.js → p-315d8e78.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-175e242e.entry.js → p-3707564c.entry.js} +1 -1
- package/dist/zonos-elements/p-3831dab5.system.js +1 -0
- package/dist/zonos-elements/{p-341f40c2.system.entry.js → p-3d130579.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3f1a2d31.js +1 -0
- package/dist/zonos-elements/{p-0104d3ba.entry.js → p-4d1269a7.entry.js} +1 -1
- package/dist/zonos-elements/p-54fdf40b.entry.js +1 -0
- package/dist/zonos-elements/{p-8ee34712.system.js → p-5e1b2654.system.js} +1 -1
- package/dist/zonos-elements/{p-de462b9b.js → p-657390e6.js} +2 -2
- package/dist/zonos-elements/p-682e09fc.system.entry.js +1 -0
- package/dist/zonos-elements/p-6b361d2b.js +1 -0
- package/dist/zonos-elements/{p-fd348fd4.system.entry.js → p-751bfce8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9a7a9b1c.entry.js → p-77654589.entry.js} +1 -1
- package/dist/zonos-elements/{p-e5d081d8.entry.js → p-7bed199d.entry.js} +1 -1
- package/dist/zonos-elements/{p-995761ea.system.entry.js → p-83a7ece6.system.entry.js} +1 -1
- package/dist/zonos-elements/p-86d29d50.system.entry.js +1 -0
- package/dist/zonos-elements/p-97e330cd.entry.js +1 -0
- package/dist/zonos-elements/{p-98e4a965.system.entry.js → p-9aa94d71.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-818d6f17.entry.js → p-a09f64e1.entry.js} +1 -1
- package/dist/zonos-elements/p-c1458d16.system.js +1 -0
- package/dist/zonos-elements/p-d7b5b237.js +1 -0
- package/dist/zonos-elements/{p-6fd6af48.system.entry.js → p-db3f6d6e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9913c186.system.js → p-e2d45b2e.system.js} +1 -1
- package/dist/zonos-elements/p-ea6d87a1.system.js +1 -1
- package/dist/zonos-elements/{p-9f7b9d66.system.entry.js → p-eeaff898.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/TaxId-4632639d.js +0 -29
- package/dist/esm/TaxId-915ef042.js +0 -26
- package/dist/esm-es5/TaxId-915ef042.js +0 -1
- package/dist/esm-es5/cart-4725a63b.js +0 -1
- package/dist/zonos-elements/p-12a6b7bd.system.js +0 -1
- package/dist/zonos-elements/p-25c47bf9.system.entry.js +0 -1
- package/dist/zonos-elements/p-33bdbcfd.entry.js +0 -1
- package/dist/zonos-elements/p-36bb3cbb.entry.js +0 -1
- package/dist/zonos-elements/p-5bd927f2.js +0 -1
- package/dist/zonos-elements/p-64ea232c.system.entry.js +0 -1
- package/dist/zonos-elements/p-6b40da70.system.js +0 -1
- package/dist/zonos-elements/p-70d4d436.entry.js +0 -1
- package/dist/zonos-elements/p-92d83e23.system.entry.js +0 -1
- package/dist/zonos-elements/p-f6038af5.entry.js +0 -1
- package/dist/zonos-elements/p-f927fd7a.system.js +0 -1
- package/dist/zonos-elements/p-fa6de0f3.js +0 -1
- package/dist/zonos-elements/p-fe253cc1.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 void("error"===o&&console.error(e,...l));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}}},z=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 C=y(i),O=!!d.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),Z=C&&O;return O&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{if(r("sendErrorLog","warn",e,t,o),n){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:C,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()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),Z?(r(`=== "${t}" failed to fetch, trying next fallback ${C}`),z({basePathType:C,options:o,path:t})):Object.assign({errors:d,response:c},p)},C=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 z({basePathType:a||m,options:i,path:e})},O=()=>{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.188.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.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\/?(\?.*)?$/,k="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let A=null;const I=e=>(null!==A||(A=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(k),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(k):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)}))),A),E=Promise.resolve().then((()=>I(null)));let T=!1;E.catch((e=>{T||console.warn(e)}));const L=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=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&s.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:i,json:a,zonosMode:l}=await C(`/api/zonos-elements/get-cart?${s.toString()}`,{body:{isTestMode:t,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),d=!a||i.length;return d&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),L({cartId:e,retries:o-1})):d?null:Object.assign(Object.assign({},a),{zonosMode:l})},P=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${P.source}$`),U=new RegExp(`^cart_${P.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,F=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:U.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 L({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)};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="https://v1.3.188.js.zonos.com",B=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.188",q="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class K{}R=K,K.doneInit=!1,K.cartSettings=null,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,K.isBigCommerce=!1,K.releaseDate="1745616884888",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.overrideUseCustomAddressForm=!1,K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.trackEventLogs=[],K.version="v1.3.188",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.zonosMode=null,K.IframeService=o,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.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,R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=O();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.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 F(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 C("/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.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},K.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})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},K.showNotification=e=>{var o;null===(o=R.zonosController)||void 0===o||o.showNotification(e)},K.updateOrganizationName=e=>{var o;null===(o=R.zonosController)||void 0===o||o.updateOrganizationName(e)},K.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)}},K.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)},K.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)=>{T=!0;const o=Date.now();return E.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,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!")},K.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)},K.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return B;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.188";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.188";case"vercel":return x}};if(R.isNpm){return O()||o()}return o()},K.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!")},K.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${x}/`,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)},K.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!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${q}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!W.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=q,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${q}/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!")},K.setupGoogleFont=e=>{var o;null===(o=R.zonosController)||void 0===o||o.setupGoogleFont(e)},K.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^="${q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=q,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=K)})();
|
|
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 void("error"===o&&console.error(e,...l));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),j=!!d.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),O=z&&j;return j&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{if(r("sendErrorLog","warn",e,t,o),n){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()),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})},j=()=>{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.190.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.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},O="https://js.stripe.com/v3",k=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let I=null;const A=e=>(null!==I||(I=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Z),window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${O}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&k.test(t.src))return t}return null})();n&&e?console.warn(Z):n||(n=(e=>{const o=document.createElement("script");o.src=`${O}`;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)}))),I),E=Promise.resolve().then((()=>A(null)));let T=!1;E.catch((e=>{T||console.warn(e)}));const L=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=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&s.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:i,json:a,zonosMode:l}=await z(`/api/zonos-elements/get-cart?${s.toString()}`,{body:{isTestMode:t,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),d=!a||i.length;return d&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),L({cartId:e,retries:o-1})):d?null:Object.assign(Object.assign({},a),{zonosMode:l})},$=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,P=new RegExp(`^${$.source}$`),U=new RegExp(`^cart_${$.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,F=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:U.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:P.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 L({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)},R="zonos--checkout-hidden-international-button";var M;const x=(()=>{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})(),B="https://v1.3.190.js.zonos.com",q=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.190",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}M=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="1745855547087",G.isLegacyCheckout=!1,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.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.190",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(M.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),M.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${M.version}) ======`),M.zonosApiKey=p,M.storeId=u,M.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=j();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=M.isNpm,window.Zonos.isBigCommerce=M.isBigCommerce,window.Zonos.isLegacyCheckout=M.isLegacyCheckout,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!M.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!M.cartData&&M.cartId){r("Initialize cart data");const e=await F(M.cartId);if(!e)return void s("Failed to get cart data");M.cartData=e.cartData,M.zonosApiKey=e.zonosApiKey,M.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&&(M.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(M.cartId&&M.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"),M.restoreNativeBrowserFunctions(),M.injectCustomScriptForHostedCheckout(),M.injectZonosCdn(),M.injectZonosCss(),M.injectFonts(),M.injectCheckoutInternationalButton(),M.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),M.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${R}`)){const e=document.createElement("button");e.id=R,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=M.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(`#${R}`);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=M.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=M.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;M.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{M.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;M.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{M.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=M.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{T=!0;const o=Date.now();return E.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,n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),M.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${M.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&&M.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.190";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.190";case"vercel":return B}};if(M.isNpm){return j()||o()}return o()},G.injectZonosCdn=()=>{M.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),M.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=M.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&&M.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"):(M.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=M.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)})();
|
|
@@ -149,6 +149,10 @@ export declare class ZonosCheckout {
|
|
|
149
149
|
* For usage in storybook for a mocked flow.
|
|
150
150
|
*/
|
|
151
151
|
mockCheckoutSession(session: CheckoutSessionDetailsFragment): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Trigger the checkout international button
|
|
154
|
+
*/
|
|
155
|
+
triggerCheckoutInternational(): Promise<void>;
|
|
152
156
|
private handleCustomerInfoContinue;
|
|
153
157
|
private handleShippingContinue;
|
|
154
158
|
private handleInventoryCheckDialogConfirm;
|
package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts
CHANGED
|
@@ -78,6 +78,10 @@ export declare class ZonosCustomerInfo {
|
|
|
78
78
|
* Handler for the email error state
|
|
79
79
|
*/
|
|
80
80
|
isEmailError: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether or not the custom address form is used
|
|
83
|
+
*/
|
|
84
|
+
recordedFormTypeUsed: boolean;
|
|
81
85
|
watchShowErrorBanner(): void;
|
|
82
86
|
private checkInvalidCharacters;
|
|
83
87
|
/**
|
|
@@ -96,11 +100,6 @@ export declare class ZonosCustomerInfo {
|
|
|
96
100
|
private handleValidate;
|
|
97
101
|
private handleEmailValidation;
|
|
98
102
|
private prepareAddressObject;
|
|
99
|
-
private isInTaxIdCountry;
|
|
100
|
-
/**
|
|
101
|
-
* Render tax id input based on ship to country code
|
|
102
|
-
*/
|
|
103
|
-
private renderTaxIdInput;
|
|
104
103
|
private renderAddressComponent;
|
|
105
104
|
render(): any;
|
|
106
105
|
}
|
|
@@ -17,6 +17,10 @@ export declare class ZonosAddress {
|
|
|
17
17
|
* Default address for stripe
|
|
18
18
|
*/
|
|
19
19
|
defaultAddress: ContactOption[];
|
|
20
|
+
/**
|
|
21
|
+
* Error message for tax id input
|
|
22
|
+
*/
|
|
23
|
+
taxIdErrorMessage: string;
|
|
20
24
|
/**
|
|
21
25
|
* Event to emit when address is not containing allowed character sets
|
|
22
26
|
*/
|
|
@@ -34,6 +38,10 @@ export declare class ZonosAddress {
|
|
|
34
38
|
* Local checkout session id to check if the address is filled after checkout is loaded
|
|
35
39
|
*/
|
|
36
40
|
checkoutSessionId: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Event to emit when tax id is changed
|
|
43
|
+
*/
|
|
44
|
+
taxIdChanged: EventEmitter<string>;
|
|
37
45
|
/**
|
|
38
46
|
* Check if the tracking event is sent
|
|
39
47
|
*/
|
|
@@ -45,6 +53,11 @@ export declare class ZonosAddress {
|
|
|
45
53
|
private updateAddressElement;
|
|
46
54
|
watchInitStripe(): Promise<void>;
|
|
47
55
|
defaultAddressChanged(newAddress: ContactOption[], oldAddress: ContactOption[]): void;
|
|
56
|
+
private isInTaxIdCountry;
|
|
57
|
+
/**
|
|
58
|
+
* Render tax id input based on ship to country code
|
|
59
|
+
*/
|
|
60
|
+
private renderTaxIdInput;
|
|
48
61
|
private renderCompanyNameInput;
|
|
49
62
|
disconnectedCallback(): void;
|
|
50
63
|
componentDidLoad(): void;
|
|
@@ -18,6 +18,10 @@ export declare class ZonosAddress {
|
|
|
18
18
|
* Default address for stripe
|
|
19
19
|
*/
|
|
20
20
|
defaultAddress: ContactOption[];
|
|
21
|
+
/**
|
|
22
|
+
* Error message for tax id input
|
|
23
|
+
*/
|
|
24
|
+
taxIdErrorMessage: string;
|
|
21
25
|
/**
|
|
22
26
|
* Event to emit when address is not containing allowed character sets
|
|
23
27
|
*/
|
|
@@ -127,6 +131,11 @@ export declare class ZonosAddress {
|
|
|
127
131
|
private getIsComplete;
|
|
128
132
|
private throttledGetAddressSuggestions;
|
|
129
133
|
private setCustomAddressFormToStripeAddressEventData;
|
|
134
|
+
private isInTaxIdCountry;
|
|
135
|
+
/**
|
|
136
|
+
* Render tax id input based on ship to country code
|
|
137
|
+
*/
|
|
138
|
+
private renderTaxIdInput;
|
|
130
139
|
private renderCompanyNameInput;
|
|
131
140
|
private initCountryField;
|
|
132
141
|
private initDefaultCustomAddressForm;
|
|
@@ -5,7 +5,8 @@ type TaxIdValidationResult = {
|
|
|
5
5
|
error: null;
|
|
6
6
|
valid: true;
|
|
7
7
|
};
|
|
8
|
-
export declare const taxIdValidationResult: ({ shippingCountry, taxId, }: {
|
|
8
|
+
export declare const taxIdValidationResult: ({ companyName, shippingCountry, taxId, }: {
|
|
9
|
+
companyName: string;
|
|
9
10
|
shippingCountry: string;
|
|
10
11
|
taxId: string;
|
|
11
12
|
}) => TaxIdValidationResult;
|
|
@@ -59,6 +59,10 @@ export namespace Components {
|
|
|
59
59
|
* Default address for stripe
|
|
60
60
|
*/
|
|
61
61
|
"defaultAddress": ContactOption[];
|
|
62
|
+
/**
|
|
63
|
+
* Error message for tax id input
|
|
64
|
+
*/
|
|
65
|
+
"taxIdErrorMessage": string;
|
|
62
66
|
/**
|
|
63
67
|
* The title text for the address element
|
|
64
68
|
*/
|
|
@@ -410,6 +414,10 @@ export namespace Components {
|
|
|
410
414
|
* For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish
|
|
411
415
|
*/
|
|
412
416
|
"setToFinishStep": (forcePaymentStatus?: PaymentIntent["status"]) => Promise<void>;
|
|
417
|
+
/**
|
|
418
|
+
* Trigger the checkout international button
|
|
419
|
+
*/
|
|
420
|
+
"triggerCheckoutInternational": () => Promise<void>;
|
|
413
421
|
}
|
|
414
422
|
interface ZonosCheckoutFinish {
|
|
415
423
|
/**
|
|
@@ -624,6 +632,10 @@ export namespace Components {
|
|
|
624
632
|
* Default address for stripe
|
|
625
633
|
*/
|
|
626
634
|
"defaultAddress": ContactOption[];
|
|
635
|
+
/**
|
|
636
|
+
* Error message for tax id input
|
|
637
|
+
*/
|
|
638
|
+
"taxIdErrorMessage": string;
|
|
627
639
|
/**
|
|
628
640
|
* The title text for the address element
|
|
629
641
|
*/
|
|
@@ -1350,6 +1362,7 @@ export interface ZonosToggleCustomEvent<T> extends CustomEvent<T> {
|
|
|
1350
1362
|
declare global {
|
|
1351
1363
|
interface HTMLZonosAddressElementEventMap {
|
|
1352
1364
|
"invalidCharacters": boolean;
|
|
1365
|
+
"taxIdChanged": string;
|
|
1353
1366
|
}
|
|
1354
1367
|
interface HTMLZonosAddressElement extends Components.ZonosAddress, HTMLStencilElement {
|
|
1355
1368
|
addEventListener<K extends keyof HTMLZonosAddressElementEventMap>(type: K, listener: (this: HTMLZonosAddressElement, ev: ZonosAddressCustomEvent<HTMLZonosAddressElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -2029,6 +2042,14 @@ declare namespace LocalJSX {
|
|
|
2029
2042
|
* Event to emit when address is not containing allowed character sets
|
|
2030
2043
|
*/
|
|
2031
2044
|
"onInvalidCharacters"?: (event: ZonosAddressCustomEvent<boolean>) => void;
|
|
2045
|
+
/**
|
|
2046
|
+
* Event to emit when tax id is changed
|
|
2047
|
+
*/
|
|
2048
|
+
"onTaxIdChanged"?: (event: ZonosAddressCustomEvent<string>) => void;
|
|
2049
|
+
/**
|
|
2050
|
+
* Error message for tax id input
|
|
2051
|
+
*/
|
|
2052
|
+
"taxIdErrorMessage"?: string;
|
|
2032
2053
|
/**
|
|
2033
2054
|
* The title text for the address element
|
|
2034
2055
|
*/
|
|
@@ -2601,6 +2622,10 @@ declare namespace LocalJSX {
|
|
|
2601
2622
|
* Event to emit when address is not containing allowed character sets
|
|
2602
2623
|
*/
|
|
2603
2624
|
"onInvalidCharacters"?: (event: ZonosCustomAddressCustomEvent<boolean>) => void;
|
|
2625
|
+
/**
|
|
2626
|
+
* Error message for tax id input
|
|
2627
|
+
*/
|
|
2628
|
+
"taxIdErrorMessage"?: string;
|
|
2604
2629
|
/**
|
|
2605
2630
|
* The title text for the address element
|
|
2606
2631
|
*/
|
|
@@ -255,6 +255,10 @@ export interface Zonos {
|
|
|
255
255
|
openHelloDialog: (state?: boolean) => void;
|
|
256
256
|
setupGoogleFont: (fontFamily: string) => void;
|
|
257
257
|
showNotification: (props: NotificationInit) => void;
|
|
258
|
+
/**
|
|
259
|
+
* Trigger the checkout international button, always trigger Checkout even user are not in shipping zone
|
|
260
|
+
*/
|
|
261
|
+
triggerCheckoutInternational: () => void;
|
|
258
262
|
updateOrganizationName: (organizationName: string) => void;
|
|
259
263
|
}
|
|
260
264
|
export declare abstract class Zonos {
|
|
@@ -292,8 +296,13 @@ export declare abstract class Zonos {
|
|
|
292
296
|
static loadTimeApiInfoList: LoadTimeApiLogInfo[];
|
|
293
297
|
static logIntervalId: NodeJS.Timeout | null;
|
|
294
298
|
static init: (params: LoadZonosParams) => Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Inject the hidden international checkout button to trigger checkout regardless of shipping zones
|
|
301
|
+
*/
|
|
302
|
+
private static injectCheckoutInternationalButton;
|
|
295
303
|
private static injectCustomScriptForHostedCheckout;
|
|
296
304
|
static displayCurrency: () => void;
|
|
305
|
+
static triggerCheckoutInternational: () => Promise<void>;
|
|
297
306
|
static openHelloDialog: (value?: boolean) => void;
|
|
298
307
|
static showNotification: (notification: NotificationInit) => void;
|
|
299
308
|
static updateOrganizationName: (organizationName: string) => void;
|
|
@@ -2,6 +2,7 @@ import type { CartItem } from "../../components/store/checkout/cart";
|
|
|
2
2
|
import type { BuildLandedCostParams, BuildLandedCostResponse } from "../../components/utils/api/triggerBuildLandedCost";
|
|
3
3
|
import type { AllowedSettlementCurrencies, AnalyticsProviderStatus, AnalyticsProviderType, CheckoutSubscriptionStatus, CheckoutSuccessBehavior, CheckoutVisibilityStatus, CountryCode, CurrencyCode, ExternalPaymentMethodStatus, ExternalPaymentMethodType, ExternalServiceTokenType, GetOrderQuery, Mode, NotificationActiveStatus } from "../generated/graphql.internal.types";
|
|
4
4
|
export declare const checkoutHiddenBtnSelector = "zonos--checkout-hidden-button";
|
|
5
|
+
export declare const checkoutHiddenInternationalBtnSelector = "zonos--checkout-hidden-international-button";
|
|
5
6
|
export declare const domesticRedirectedBtnSelector = "zonos--domestic-redirected-checkout-button";
|
|
6
7
|
export type ZonosOrder = GetOrderQuery['order'];
|
|
7
8
|
export type { BuildLandedCostParams, BuildLandedCostResponse };
|