@spot-flow/checkout-inline-js 0.2.1 → 0.2.2-dev.1

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.
@@ -1740,10 +1740,13 @@ const it = (n) => {
1740
1740
  }, R = () => _a, Il = (n, e) => {
1741
1741
  const t = is(n, e), i = t == null ? void 0 : t.language, s = xe.getTranslationError();
1742
1742
  i && i !== Cn ? it(s ? "en" : Cn) : i && i === Cn ? it(i) : !Cn && !i && it("en");
1743
- }, Q = async (n, e) => (await xe.translate(
1744
- n,
1745
- e
1746
- ))[0];
1743
+ }, Q = async (n, e) => {
1744
+ const t = await xe.translate(
1745
+ n,
1746
+ e
1747
+ );
1748
+ return typeof t == "string" ? t : t[0];
1749
+ };
1747
1750
  let cn = ts;
1748
1751
  const Ea = async (n) => (cn = await xe.translateRecord(
1749
1752
  ts,
@@ -31595,7 +31598,7 @@ class jd {
31595
31598
  if (((w = o == null ? void 0 : o.authorization) == null ? void 0 : w.mode) === "otp") {
31596
31599
  this.cardResponse = o, R() !== "en" ? (this.showLoader(), this.renderTranslatedText(o == null ? void 0 : o.providerMessage).then(() => {
31597
31600
  this.pageLoader.unmountLoader(), this.currentStep = 3;
31598
- })) : this.currentStep = 3;
31601
+ })) : (this.otpMessage = (o == null ? void 0 : o.providerMessage) || "", this.currentStep = 3);
31599
31602
  return;
31600
31603
  }
31601
31604
  if (((A = o == null ? void 0 : o.authorization) == null ? void 0 : A.mode) === "avs") {
@@ -642,7 +642,7 @@
642
642
  }
643
643
 
644
644
 
645
- `,document.head.appendChild(e)}isLoading(){return this.activeSections.size>0||this.loadingElements.size>0}getLoadingSections(){return Array.from(this.activeSections)}clearAll(){this.stopGlobalLoading(),this.activeSections.clear()}}const Hs=new ir({defaultStyle:"skeleton",fadeOpacity:.5}),Ae=(()=>{let n=navigator==null?void 0:navigator.language.split("-")[0].toLowerCase(),e=new Map,t=[],i=0,s=[],o=!1;const a=f=>{n!==f&&(n=f,e.clear(),o=!1,l())},l=()=>{t.forEach(f=>f(n))},c=()=>{s.forEach(f=>f(i>0))},p=f=>(t.push(f),()=>{t=t.filter(k=>k!==f)}),m=async(f,k=n)=>{if(o)return Array.isArray(f)?f:[f];if(k==="en")return Array.isArray(f)?f:[f];i+=1,c();const A=Array.isArray(f)?`[${f.join("|")}]:${k}`:`${f}:${k}`;if(e.has(A))return e.get(A);try{const M=await za({text:f,target:k||"en"});return e.set(A,M.translatedText??(Array.isArray(f)?f:[f])),M.translatedText??(Array.isArray(f)?f:[f])}catch(M){return console.error("Translation failed:",M),a("en"),o=!0,Array.isArray(f)?f:[f]}finally{i-=1,c()}};return{setLanguage:a,getLanguage:()=>n,translate:m,translateRecord:async(f,k=n)=>{if(k==="en"||o)return f;const x=Object.keys(f),A=Object.values(f);return(await m(A,k)).reduce((D,G,W)=>(D[x[W]]=G,D),{})},subscribe:p,subscribeToLoading:f=>(s.push(f),()=>{s=s.filter(k=>k!==f)}),getIsLoading:()=>i>0,getTranslationError:()=>o}})(),pn=navigator==null?void 0:navigator.language.split("-")[0].toLowerCase();let Ns=pn;const it=n=>{Ns=n},R=()=>Ns,sr=(n,e)=>{const t=Ni(n,e),i=t==null?void 0:t.language,s=Ae.getTranslationError();i&&i!==pn?it(s?"en":pn):i&&i===pn?it(i):!pn&&!i&&it("en")},Q=async(n,e)=>(await Ae.translate(n,e))[0];let rn=Hi;const Os=async n=>(rn=await Ae.translateRecord(Hi,n),rn);let z=Ls;const Us=async n=>{z=await Ae.translateRecord(Ls,n)};let E=Ts;const Vs=async n=>{E=await Ae.translateRecord(Ts,n)};let pe=_s;const Fs=async n=>{pe=await Ae.translateRecord(_s,n)};let $e=Es;const Ks=async n=>{$e=await Ae.translateRecord(Es,n)};let Ve=Ps;const Gs=async n=>{Ve=await Ae.translateRecord(Ps,n)};let Me=Is;const js=async n=>{Me=await Ae.translateRecord(Is,n)};let Ln=Ds;const zs=async n=>{Ln=await Ae.translateRecord(Ds,n)};let Fe=Rs;const qs=async n=>{Fe=await Ae.translateRecord(Rs,n)};let Tn=Bs;const Ws=async n=>{Tn=await Ae.translateRecord(Bs,n)};function Zs(n){if(n in z)return z[n];if(n in E)return E[n];if(n in rn)return rn[n];if(n in pe)return pe[n];if(n in $e)return $e[n];if(n in Ve)return Ve[n];if(n in Me)return Me[n];if(n in Ln)return Ln[n];if(n in Tn)return Tn[n];if(n in Fe)return Fe[n]}function Oi(){document.querySelectorAll("[data-translate]").forEach(n=>{const e=n.getAttribute("data-translate");if(!e)return;const t=Zs(e);t&&(n.textContent=t)}),document.querySelectorAll("[data-translate-placeholder]").forEach(n=>{const e=n.getAttribute("data-translate-placeholder");if(!e)return;const t=Zs(e);t&&(n.placeholder=t)})}Ae.subscribe(async n=>{Hs.startSmartLoading({});try{await Promise.all([Us(n),Vs(n),Os(n),(()=>{const e=or();if(e){if(e==="card")return Fs(n);e==="transfer"?Gs(n):e==="mobile_money"?js(n):e==="eft"?zs(n):e==="opay"?Ws(n):e==="test_cards"?Ks(n):e==="stablecoin"&&qs(n)}return Promise.resolve()})()]),Oi()}catch(e){console.error("Translation error:",e),Oi()}finally{Hs.stopGlobalLoading()}Oi()});function or(){const n=Array.from(document.querySelectorAll("[data-section]")).map(e=>e.dataset.section);for(const e of n)return e;return null}class Qs{constructor(e){d(this,"container");d(this,"onAction");d(this,"cardDetailsValues");d(this,"creditCardTypes");d(this,"merchantName");d(this,"currency");this.container=e.container,this.onAction=e.onAction,this.creditCardTypes=[...As],this.cardDetailsValues={number:"",expiry:"",cvv:"",name:""},this.merchantName=e.merchantName,this.currency=e.currency}attachListener(){const e=document.querySelector("#pci-dss");e&&e.classList.remove("hidden");const t=document.querySelector('input[name="number"]'),i=document.querySelector('input[name="expiry"]'),s=document.querySelector('input[name="cvv"]'),o=document.querySelector('input[name="name"]'),a=document.querySelector(".details-form-button"),l=document.querySelector("#checkoutcard"),c=this.container.querySelector("#enter-details-text"),p=this.container.querySelector("#certified-text"),m=this.container.querySelector("#card-confirmation-text-one"),y=this.container.querySelector("#card-confirmation-text-two");c&&(c.innerHTML=pe["enter-card-details"]),p&&(p.innerHTML=pe.certified),m&&(m.innerHTML=pe["card-confirmation-one"]),y&&(y.innerHTML=pe["card-confirmation-two"]),t&&(t.setAttribute("placeholder",pe["card-number"]),t.addEventListener("input",b=>this.handleInputChange(b,a))),i&&i.addEventListener("input",b=>this.handleInputChange(b,a)),s&&s.addEventListener("input",b=>this.handleInputChange(b,a)),o&&(o.setAttribute("placeholder",pe["card-holder-name"]),o.addEventListener("input",b=>this.handleInputChange(b,a))),l&&l.addEventListener("submit",b=>{var g,w,f;b.preventDefault(),this.onAction(b)({pan:Ja(this.cardDetailsValues.number),cvv:this.cardDetailsValues.cvv,expiryMonth:(g=this.cardDetailsValues)==null?void 0:g.expiry.split("/")[0].trim(),expiryYear:(w=this.cardDetailsValues)==null?void 0:w.expiry.split("/")[1].trim(),...this.currency==="ZAR"&&{cardHolderName:(f=this.cardDetailsValues)==null?void 0:f.name}})})}validateCreditCard(e){if(e=e.replace(/\D/g,""),!e||e.length===0||e.length<13||e.length>19)return!1;const t=e.split("").map(s=>parseInt(s,10));for(let s=t.length-2;s>=0;s-=2){let o=t[s]*2;o>9&&(o-=9),t[s]=o}return t.reduce((s,o)=>s+o,0)%10===0}handleInputChange(e,t){var l,c,p;const i=e.target,{name:s,value:o}=i;let a=o;if(o.trim()===""){this.emptyCardState(i,s);return}if(s==="number"){a=Ya(o);const m=a.replace(/\s+/g,""),y=this.validateCreditCard(m);this.filterCreditCardType(o);const b=(l=this.creditCardTypes[0])==null?void 0:l.name;b&&Mn.map(g=>{if(g.name===this.currency)if(g.cardTypes.includes(b)){const w=nr[b];if(w.length>1){const f=w.some(k=>m.length===k);this.checkInputValidity(y,i,f,"card-number-invalid")}else m.length===w[0]&&this.checkInputValidity(y,i,m.length>=14&&m.length<=19,"card-number-invalid")}else this.checkInputValidity(!1,i,o.trim().length>=14&&o.trim().length<=19,"invalid-issue-card")})}else if(s==="expiry"){const m=new Date;a=$a(o);const y=a.split("/"),b=(c=y[0])==null?void 0:c.trim(),g=(p=y[1])==null?void 0:p.trim(),w=new Date().getFullYear()%100,f=m.getMonth()+1;let k=!0;(parseInt(g)===w&&parseInt(b)<f||parseInt(g)<w)&&(k=!1),(g==null?void 0:g.length)===2&&this.checkInputValidity(k,i,y.join("").length===4,"card-expired")}else s==="cvv"?a=Xa(o):s==="name"&&(a=o);if(this.cardDetailsValues={...this.cardDetailsValues,[s]:a},i.value=a,this.validateCard())t&&t.removeAttribute("disabled");else if(t){if(t.disabled)return;t.setAttribute("disabled","")}}hideCardHolderInput(){const e=document.querySelector("#card-name");this.currency==="ZAR"?e&&(e.style.display="block"):e&&(e.style.display="none")}validateCard(){if(this.cardDetailsValues.expiry.split("/").length===2){const e=this.cardDetailsValues.expiry.split("/")[1].trim();return!!this.cardDetailsValues.number&&this.cardDetailsValues.number.length>15&&!!this.cardDetailsValues.expiry&&this.cardDetailsValues.expiry.length>3&&!!this.cardDetailsValues.cvv&&this.cardDetailsValues.cvv.length>2&&e.length===2&&(this.currency==="ZAR"?this.cardDetailsValues.name.trim()!=="":!0)}}displayCardTypes(){requestAnimationFrame(()=>{const e=this.container.querySelector("#card-type");e.innerHTML="",this.creditCardTypes.length>0?this.creditCardTypes.forEach(t=>{const i=document.createElement("div");i.classList.add("card-type"),i.innerHTML=t.icon,e.appendChild(i)}):e.innerHTML=`<svg width="25" height="16" viewBox="0 0 25 16" fill="none" xmlns="http://www.w3.org/2000/svg">
645
+ `,document.head.appendChild(e)}isLoading(){return this.activeSections.size>0||this.loadingElements.size>0}getLoadingSections(){return Array.from(this.activeSections)}clearAll(){this.stopGlobalLoading(),this.activeSections.clear()}}const Hs=new ir({defaultStyle:"skeleton",fadeOpacity:.5}),Ae=(()=>{let n=navigator==null?void 0:navigator.language.split("-")[0].toLowerCase(),e=new Map,t=[],i=0,s=[],o=!1;const a=f=>{n!==f&&(n=f,e.clear(),o=!1,l())},l=()=>{t.forEach(f=>f(n))},c=()=>{s.forEach(f=>f(i>0))},p=f=>(t.push(f),()=>{t=t.filter(k=>k!==f)}),m=async(f,k=n)=>{if(o)return Array.isArray(f)?f:[f];if(k==="en")return Array.isArray(f)?f:[f];i+=1,c();const A=Array.isArray(f)?`[${f.join("|")}]:${k}`:`${f}:${k}`;if(e.has(A))return e.get(A);try{const M=await za({text:f,target:k||"en"});return e.set(A,M.translatedText??(Array.isArray(f)?f:[f])),M.translatedText??(Array.isArray(f)?f:[f])}catch(M){return console.error("Translation failed:",M),a("en"),o=!0,Array.isArray(f)?f:[f]}finally{i-=1,c()}};return{setLanguage:a,getLanguage:()=>n,translate:m,translateRecord:async(f,k=n)=>{if(k==="en"||o)return f;const x=Object.keys(f),A=Object.values(f);return(await m(A,k)).reduce((D,G,W)=>(D[x[W]]=G,D),{})},subscribe:p,subscribeToLoading:f=>(s.push(f),()=>{s=s.filter(k=>k!==f)}),getIsLoading:()=>i>0,getTranslationError:()=>o}})(),pn=navigator==null?void 0:navigator.language.split("-")[0].toLowerCase();let Ns=pn;const it=n=>{Ns=n},R=()=>Ns,sr=(n,e)=>{const t=Ni(n,e),i=t==null?void 0:t.language,s=Ae.getTranslationError();i&&i!==pn?it(s?"en":pn):i&&i===pn?it(i):!pn&&!i&&it("en")},Q=async(n,e)=>{const t=await Ae.translate(n,e);return typeof t=="string"?t:t[0]};let rn=Hi;const Os=async n=>(rn=await Ae.translateRecord(Hi,n),rn);let z=Ls;const Us=async n=>{z=await Ae.translateRecord(Ls,n)};let E=Ts;const Vs=async n=>{E=await Ae.translateRecord(Ts,n)};let pe=_s;const Fs=async n=>{pe=await Ae.translateRecord(_s,n)};let $e=Es;const Ks=async n=>{$e=await Ae.translateRecord(Es,n)};let Ve=Ps;const Gs=async n=>{Ve=await Ae.translateRecord(Ps,n)};let Me=Is;const js=async n=>{Me=await Ae.translateRecord(Is,n)};let Ln=Ds;const zs=async n=>{Ln=await Ae.translateRecord(Ds,n)};let Fe=Rs;const qs=async n=>{Fe=await Ae.translateRecord(Rs,n)};let Tn=Bs;const Ws=async n=>{Tn=await Ae.translateRecord(Bs,n)};function Zs(n){if(n in z)return z[n];if(n in E)return E[n];if(n in rn)return rn[n];if(n in pe)return pe[n];if(n in $e)return $e[n];if(n in Ve)return Ve[n];if(n in Me)return Me[n];if(n in Ln)return Ln[n];if(n in Tn)return Tn[n];if(n in Fe)return Fe[n]}function Oi(){document.querySelectorAll("[data-translate]").forEach(n=>{const e=n.getAttribute("data-translate");if(!e)return;const t=Zs(e);t&&(n.textContent=t)}),document.querySelectorAll("[data-translate-placeholder]").forEach(n=>{const e=n.getAttribute("data-translate-placeholder");if(!e)return;const t=Zs(e);t&&(n.placeholder=t)})}Ae.subscribe(async n=>{Hs.startSmartLoading({});try{await Promise.all([Us(n),Vs(n),Os(n),(()=>{const e=or();if(e){if(e==="card")return Fs(n);e==="transfer"?Gs(n):e==="mobile_money"?js(n):e==="eft"?zs(n):e==="opay"?Ws(n):e==="test_cards"?Ks(n):e==="stablecoin"&&qs(n)}return Promise.resolve()})()]),Oi()}catch(e){console.error("Translation error:",e),Oi()}finally{Hs.stopGlobalLoading()}Oi()});function or(){const n=Array.from(document.querySelectorAll("[data-section]")).map(e=>e.dataset.section);for(const e of n)return e;return null}class Qs{constructor(e){d(this,"container");d(this,"onAction");d(this,"cardDetailsValues");d(this,"creditCardTypes");d(this,"merchantName");d(this,"currency");this.container=e.container,this.onAction=e.onAction,this.creditCardTypes=[...As],this.cardDetailsValues={number:"",expiry:"",cvv:"",name:""},this.merchantName=e.merchantName,this.currency=e.currency}attachListener(){const e=document.querySelector("#pci-dss");e&&e.classList.remove("hidden");const t=document.querySelector('input[name="number"]'),i=document.querySelector('input[name="expiry"]'),s=document.querySelector('input[name="cvv"]'),o=document.querySelector('input[name="name"]'),a=document.querySelector(".details-form-button"),l=document.querySelector("#checkoutcard"),c=this.container.querySelector("#enter-details-text"),p=this.container.querySelector("#certified-text"),m=this.container.querySelector("#card-confirmation-text-one"),y=this.container.querySelector("#card-confirmation-text-two");c&&(c.innerHTML=pe["enter-card-details"]),p&&(p.innerHTML=pe.certified),m&&(m.innerHTML=pe["card-confirmation-one"]),y&&(y.innerHTML=pe["card-confirmation-two"]),t&&(t.setAttribute("placeholder",pe["card-number"]),t.addEventListener("input",b=>this.handleInputChange(b,a))),i&&i.addEventListener("input",b=>this.handleInputChange(b,a)),s&&s.addEventListener("input",b=>this.handleInputChange(b,a)),o&&(o.setAttribute("placeholder",pe["card-holder-name"]),o.addEventListener("input",b=>this.handleInputChange(b,a))),l&&l.addEventListener("submit",b=>{var g,w,f;b.preventDefault(),this.onAction(b)({pan:Ja(this.cardDetailsValues.number),cvv:this.cardDetailsValues.cvv,expiryMonth:(g=this.cardDetailsValues)==null?void 0:g.expiry.split("/")[0].trim(),expiryYear:(w=this.cardDetailsValues)==null?void 0:w.expiry.split("/")[1].trim(),...this.currency==="ZAR"&&{cardHolderName:(f=this.cardDetailsValues)==null?void 0:f.name}})})}validateCreditCard(e){if(e=e.replace(/\D/g,""),!e||e.length===0||e.length<13||e.length>19)return!1;const t=e.split("").map(s=>parseInt(s,10));for(let s=t.length-2;s>=0;s-=2){let o=t[s]*2;o>9&&(o-=9),t[s]=o}return t.reduce((s,o)=>s+o,0)%10===0}handleInputChange(e,t){var l,c,p;const i=e.target,{name:s,value:o}=i;let a=o;if(o.trim()===""){this.emptyCardState(i,s);return}if(s==="number"){a=Ya(o);const m=a.replace(/\s+/g,""),y=this.validateCreditCard(m);this.filterCreditCardType(o);const b=(l=this.creditCardTypes[0])==null?void 0:l.name;b&&Mn.map(g=>{if(g.name===this.currency)if(g.cardTypes.includes(b)){const w=nr[b];if(w.length>1){const f=w.some(k=>m.length===k);this.checkInputValidity(y,i,f,"card-number-invalid")}else m.length===w[0]&&this.checkInputValidity(y,i,m.length>=14&&m.length<=19,"card-number-invalid")}else this.checkInputValidity(!1,i,o.trim().length>=14&&o.trim().length<=19,"invalid-issue-card")})}else if(s==="expiry"){const m=new Date;a=$a(o);const y=a.split("/"),b=(c=y[0])==null?void 0:c.trim(),g=(p=y[1])==null?void 0:p.trim(),w=new Date().getFullYear()%100,f=m.getMonth()+1;let k=!0;(parseInt(g)===w&&parseInt(b)<f||parseInt(g)<w)&&(k=!1),(g==null?void 0:g.length)===2&&this.checkInputValidity(k,i,y.join("").length===4,"card-expired")}else s==="cvv"?a=Xa(o):s==="name"&&(a=o);if(this.cardDetailsValues={...this.cardDetailsValues,[s]:a},i.value=a,this.validateCard())t&&t.removeAttribute("disabled");else if(t){if(t.disabled)return;t.setAttribute("disabled","")}}hideCardHolderInput(){const e=document.querySelector("#card-name");this.currency==="ZAR"?e&&(e.style.display="block"):e&&(e.style.display="none")}validateCard(){if(this.cardDetailsValues.expiry.split("/").length===2){const e=this.cardDetailsValues.expiry.split("/")[1].trim();return!!this.cardDetailsValues.number&&this.cardDetailsValues.number.length>15&&!!this.cardDetailsValues.expiry&&this.cardDetailsValues.expiry.length>3&&!!this.cardDetailsValues.cvv&&this.cardDetailsValues.cvv.length>2&&e.length===2&&(this.currency==="ZAR"?this.cardDetailsValues.name.trim()!=="":!0)}}displayCardTypes(){requestAnimationFrame(()=>{const e=this.container.querySelector("#card-type");e.innerHTML="",this.creditCardTypes.length>0?this.creditCardTypes.forEach(t=>{const i=document.createElement("div");i.classList.add("card-type"),i.innerHTML=t.icon,e.appendChild(i)}):e.innerHTML=`<svg width="25" height="16" viewBox="0 0 25 16" fill="none" xmlns="http://www.w3.org/2000/svg">
646
646
  <path
647
647
  d="M24.5827 6.33333V14.6667C24.5827 14.8877 24.4554 15.0996 24.2288 15.2559C24.0022 15.4122 23.6948 15.5 23.3743 15.5H1.62435C1.30388 15.5 0.996535 15.4122 0.769928 15.2559C0.543322 15.0996 0.416016 14.8877 0.416016 14.6667V6.33333H24.5827ZM24.5827 4.66667H0.416016V1.33333C0.416016 1.11232 0.543322 0.900358 0.769928 0.744078C0.996535 0.587797 1.30388 0.5 1.62435 0.5H23.3743C23.6948 0.5 24.0022 0.587797 24.2288 0.744078C24.4554 0.900358 24.5827 1.11232 24.5827 1.33333V4.66667ZM16.1243 11.3333V13H20.9577V11.3333H16.1243Z"
648
648
  fill="#B6B4B9" />
@@ -1569,7 +1569,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
1569
1569
  <path
1570
1570
  d="M62 32C62 38.6156 59.8132 45.0457 55.78 50.2897C51.7468 55.5336 46.0932 59.2974 39.6992 60.9952C33.3052 62.693 26.5293 62.2297 20.4258 59.6774C14.3224 57.1251 9.2338 52.6268 5.95186 46.8827C2.66993 41.1385 1.37873 34.4707 2.2792 27.9166C3.17967 21.3626 6.22129 15.29 10.9308 10.6438C15.6402 5.9976 21.7534 3.0384 28.3191 2.22668C34.8847 1.41496 41.5345 2.79623 47.2337 6.15557"
1571
1571
  stroke="black" stroke-width="4" stroke-linejoin="round" />
1572
- </svg>`),s&&s.classList.add("hidden"),Ot(this.token,t,this.rdtCode,this.url).then(async({data:a,headers:l})=>{var c,p,m,y,b,g,w,f,k,x;if(a.providerMessage){const A=await Q(a.providerMessage,R());this.errorText=A}if(a.status==="failed")_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN"}),this.currentStep=4,a.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(a.status))this.currentStep=5,this.redirectTo(a,l,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN"});else{if(((c=a==null?void 0:a.authorization)==null?void 0:c.mode)==="3DS"){(p=a==null?void 0:a.authorization)!=null&&p.redirectUrl&&this.redirectTo3DS((m=a==null?void 0:a.authorization)==null?void 0:m.redirectUrl),(y=a==null?void 0:a.authorization)!=null&&y.embeddedHtml&&this.redirectToPreciumDoc((b=a==null?void 0:a.authorization)==null?void 0:b.embeddedHtml),(g=a==null?void 0:a.authorization)!=null&&g.jwt&&((w=a==null?void 0:a.authorization)!=null&&w.acsUrl)&&((f=a==null?void 0:a.authorization)!=null&&f.md)&&(this.cardResponse=a,this.currentStep=11);return}if(((k=a==null?void 0:a.authorization)==null?void 0:k.mode)==="otp"){this.cardResponse=a,R()!=="en"?(this.showLoader(),this.renderTranslatedText(a==null?void 0:a.providerMessage).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=3})):this.currentStep=3;return}if(((x=a==null?void 0:a.authorization)==null?void 0:x.mode)==="avs"){if(R()!=="en"){this.showLoader();const A=Object.values(this.rawAvsData);this.renderTranslatedText(A).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}this.currentStep=10}}).catch(async a=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"PIN"}),a.message){const l=await Q(a.message,R());this.errorText=l,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})},300)}}validatedAVS(e,t){e.stopPropagation(),e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#avs-form-button-text"),o={authorization:{avs:{state:t==null?void 0:t.state,city:t==null?void 0:t.city,country:t==null?void 0:t.country,address:t==null?void 0:t.address,zipCode:(t==null?void 0:t.code)||"-"}},reference:this.activeRef};_.track("input_address",{payment_method:"Card",authentication_type:"AVS"}),i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden")),Ot(this.token,o,this.rdtCode,this.url).then(async({data:l,headers:c})=>{var p,m,y,b,g,w,f;if(l.providerMessage){const k=await Q(l.providerMessage,R());this.errorText=k}if(l.status==="failed")this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"AVS"}),l.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(l.status))["success","successful"].includes(l.status)&&(this.currentStep=5,this.redirectTo(l,c,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"AVS"}));else{if(((p=l==null?void 0:l.authorization)==null?void 0:p.mode)==="pin"){this.currentStep=2;return}if(((m=l==null?void 0:l.authorization)==null?void 0:m.mode)==="3DS"){(y=l==null?void 0:l.authorization)!=null&&y.redirectUrl&&this.redirectTo3DS((b=l==null?void 0:l.authorization)==null?void 0:b.redirectUrl),(g=l==null?void 0:l.authorization)!=null&&g.embeddedHtml&&this.redirectToPreciumDoc((w=l==null?void 0:l.authorization)==null?void 0:w.embeddedHtml);return}if(((f=l==null?void 0:l.authorization)==null?void 0:f.mode)==="otp"){this.cardResponse=l,this.currentStep=3;return}this.currentStep=10}}).catch(async l=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"AVS"}),l.message){const c=await Q(l.message,R());this.errorText=c,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}submitOtp(e,t){e.preventDefault();const i={authorization:{otp:t},reference:this.activeRef};this.currentStep=6,this.showLoader(),_.track("input_cardOTP",{payment_method:"Card",authentication_type:"PIN+0TP"}),Ot(this.token,i,this.rdtCode,this.url).then(async({data:o,headers:a})=>{var l,c,p,m,y,b,g;if(o.providerMessage){const w=await Q(o.providerMessage,R());this.errorText=w}if(o.status==="failed")this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN+0TP"}),o.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(o.status))["success","successful"].includes(o.status)&&(this.currentStep=5,this.redirectTo(o,a,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN+0TP"}));else{if(this.activeRef=o.reference,((l=o==null?void 0:o.authorization)==null?void 0:l.mode)==="pin"){this.currentStep=2;return}if(((c=o==null?void 0:o.authorization)==null?void 0:c.mode)==="3DS"){(p=o==null?void 0:o.authorization)!=null&&p.redirectUrl&&this.redirectTo3DS((m=o==null?void 0:o.authorization)==null?void 0:m.redirectUrl),(y=o==null?void 0:o.authorization)!=null&&y.embeddedHtml&&this.redirectToPreciumDoc((b=o==null?void 0:o.authorization)==null?void 0:b.embeddedHtml);return}if(((g=o==null?void 0:o.authorization)==null?void 0:g.mode)==="avs"){if(R()!=="en"){this.showLoader();const w=Object.values(this.rawAvsData);this.renderTranslatedText(w).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}this.currentStep=10}}).catch(async o=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN+0TP"}),o!=null&&o.message){const a=await Q(o.message,R());this.errorText=a,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})}redirectTo3DS(e){const t=window.open("","_blank");if(!t){alert(pe["enable-popup"]);return}t.location.href=e,_.track("auth_redirect",{payment_method:"Card",authentication_type:"3DS"}),this.currentStep=6,this.showLoader();const i=setInterval(()=>{t.closed&&(clearInterval(i),this.verifyPayment(({data:s,headers:o})=>{this.currentStep=5,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"3DS"}),this.redirectTo(s,o,"success")},async({data:s})=>{if(s.providerMessage){const o=await Q(s.providerMessage,R());this.errorText=o}this.currentStep=4,s.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue(),_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"3DS"})}))},2e3)}redirectToPreciumDoc(e){const t=atob(e),i=new Blob([t],{type:"text/html"}),s=URL.createObjectURL(i),o=window.open(s,"_blank");if(o){o.document.close(),_.track("auth_redirect",{payment_method:"Card",authentication_type:"3DS"}),this.currentStep=6,this.showLoader();const a=setInterval(()=>{o.closed&&(clearInterval(a),this.verifyPayment(({data:l,headers:c})=>{this.currentStep=5,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"3DS"}),this.redirectTo(l,c,"success")},async({data:l})=>{if(l.providerMessage){const c=await Q(l.providerMessage,R());this.errorText=c}this.currentStep=4,l.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue(),_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"3DS"})}))},2e3)}else alert(pe["enable-popup"])}async verifyPayment(e,t){try{const i=await Xe(this.token,this.activeRef,void 0,this.rdtCode,this.url);i.data.status==="failed"?t(i):(["success","successful"].includes(i.data.status)&&e(i),i.data.status==="inProgress"&&(this.currentStep=10))}catch{this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"3DS"}),this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue()}}async verifyPaymentProcess(){try{const e=await Xe(this.token,this.reference,void 0,this.rdtCode,this.url);this.cardResponse=e.data,this.cardResponseHeader=e.headers}catch{this.currentStep=4}}charge3DSPayment(){const e=ja(this.token,this.reference,this.rdtCode,this.url);_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS"}),e.then(async({data:t,headers:i})=>{if(this.cardResponse=t,this.cardResponseHeader=i,t.providerMessage){const s=await Q(t.providerMessage,R());this.errorText=s}t.status==="failed"?(this.currentStep=4,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Failed"}),t.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue()):["success","successful"].includes(t.status)?(this.currentStep=5,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Success"}),this.redirectTo(t,i,"success")):t.status==="inProgress"?this.currentStep=10:(this.currentStep=4,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Null"}),t.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue())}).catch(async t=>{if(_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Null"}),t.message){const i=await Q(t.message,R());this.errorText=i,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})}goBackToMerchant(){if(this.isCancelledPlan){this.cancellledPlanAction();return}this.redirectTo(this.cardResponse,this.cardResponseHeader,this.callBackUrl)}renderCardContent(e){var o,a,l,c,p,m,y,b,g,w,f;e&&(this.merchantPlanDetail=e);const t=document.getElementById("test-container"),i=this.container.querySelector("#test-cards-link"),s=document.getElementById("go-back");if(this.currentStep!==1?(this.hidePaymentMethods(),s==null||s.classList.add("hidden")):this.showPaymentMethods(),this.isMobile&&this.hidePaymentMethods(),this.contents){switch(this.currentStep){case 1:this.cardDetailForm=new Qs({container:this.contents,onAction:x=>A=>this.submitCardDetails.bind(this)(x,A),merchantName:this.merchantPlanDetail.merchantName,currency:Hn(this.currency,this.localCurrency)}),this.cardDetailForm.renderContent();break;case 2:this.cardPinForm=new ur({container:this.contents,onClose:this.onClose,onAction:x=>this.handlePinRequest.bind(this)(x)}),this.cardPinForm.renderComponent();break;case 3:this.cardOtpValidationForm=new cr({container:this.contents,onClose:this.onClose,onAction:x=>A=>this.submitOtp.bind(this)(x,A),otpMessage:this.otpMessage||E["Payment failed"]}),this.cardOtpValidationForm.renderComponent();break;case 4:this.warningScreen=new en({container:this.contents,onAction:this.isMaxRetriesReached||this.isCancelledPlan?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this),onReportIssue:()=>this.currentStep=8}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.contents.innerHTML=this.warningScreen.render(),this.warningScreen.attachListener();break;case 5:this.successScreen=new Fn({container:this.contents,amount:((c=(l=(a=(o=this.merchantPlanDetail)==null?void 0:o.plan)==null?void 0:a.trial)==null?void 0:l.pricingList[0])==null?void 0:c.amount)??this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(p=this.merchantPlanDetail)==null?void 0:p.rate.rate}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.successScreen.renderComponent();break;case 6:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Verifying Payment");break;case 7:this.avsForm=new pr({container:this.contents,onAction:x=>A=>this.validatedAVS.bind(this)(x,A),translatedTexts:this.translatedAvsData}),this.avsForm.renderComponent();break;case 8:this.transactionIssuesScreen=new st({container:this.contents,onAction:async()=>{var x,A;if((x=this.cardResponse)!=null&&x.providerMessage){const M=await Q((A=this.cardResponse)==null?void 0:A.providerMessage,R());this.errorText=M}this.currentStep=4,this.warningScreen.setPaymentError(this.errorText||E["payment-failed"])},url:this.url,rdtCode:this.rdtCode,token:this.token,paymentChannel:"card",callBackUrl:this.callBackUrl,paymentResponse:this.cardResponse,paymentResponseHeaders:this.cardResponseHeader}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break;case 9:this.confirmationEnd=new oa({container:this.contents,onAction:x=>{this.currentStep=x},ref:this.reference,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.cardResponse,paymentResponseHeaders:this.cardResponseHeader,paymentMethod:"Card"}),this.confirmationEnd.renderComponent();break;case 10:this.confirmationProgress=new uc({container:this.contents,onAction:x=>{this.currentStep=x},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(x,A)=>{this.cardResponse=x,this.cardResponseHeader=A},step:{failed:4,success:5,end:9},paymentMethod:"Card"}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.confirmationProgress.renderComponent();break;case 11:this.isw3dsForm=new vr({container:this.contents,threeDSecureDetails:{jwt:((y=(m=this.cardResponse)==null?void 0:m.authorization)==null?void 0:y.jwt)||"",md:((g=(b=this.cardResponse)==null?void 0:b.authorization)==null?void 0:g.md)||"",acsUrl:((f=(w=this.cardResponse)==null?void 0:w.authorization)==null?void 0:f.acsUrl)||""},onAction:x=>{this.currentStep=x,x===6&&this.showLoader()},onSuccess:this.charge3DSPayment.bind(this)}),this.isw3dsForm.renderComponent();break;default:this.cardDetailForm=new Qs({container:this.contents,onAction:x=>A=>this.submitCardDetails.bind(this)(x,A),merchantName:this.merchantPlanDetail.merchantName,currency:Hn(this.currency,this.localCurrency)}),this.cardDetailForm.renderContent();break}this.displayButtonText();const k=this.container.querySelector("#card-currency");k&&(k.textContent=`${Hn(this.currency,this.localCurrency)} ${pe.card}`)}}redirectTo(e,t,i){const s=t.get("spf-redirect-url");this.callBackUrl=s||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const o=new URL(this.callBackUrl);o.searchParams.append("status",e.status),o.searchParams.append("reference",e.reference),window.location.href=o.toString()},1800):i==="success"&&this.onSuccess(e)}displayButtonText(e){var i,s,o,a,l,c,p,m,y,b;const t=this.container.querySelector("#details-form-button-text");if(t){const g=(s=(i=this==null?void 0:this.merchantPlanDetail)==null?void 0:i.plan)==null?void 0:s.trial,w=(c=(l=(a=(o=this==null?void 0:this.merchantPlanDetail)==null?void 0:o.plan)==null?void 0:a.trial)==null?void 0:l.pricingList[0])==null?void 0:c.amount,f=Hn(this.currency,this.localCurrency),k=f==="USD"?(m=(p=this.merchantPlanDetail)==null?void 0:p.rate)==null?void 0:m.from:f;e?t.textContent=e:t.textContent=`${pe["continue-to"]} ${k} ${Te(g&&w!=null?w:this.totalAmount!==this.amount?this.totalAmount:(this.amount||0)*(this.currency==="USD"?(b=(y=this.merchantPlanDetail)==null?void 0:y.rate)==null?void 0:b.rate:1),2)}`}}}const bc=`<div data-section="transfer" data-section="transfer">
1572
+ </svg>`),s&&s.classList.add("hidden"),Ot(this.token,t,this.rdtCode,this.url).then(async({data:a,headers:l})=>{var c,p,m,y,b,g,w,f,k,x;if(a.providerMessage){const A=await Q(a.providerMessage,R());this.errorText=A}if(a.status==="failed")_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN"}),this.currentStep=4,a.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(a.status))this.currentStep=5,this.redirectTo(a,l,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN"});else{if(((c=a==null?void 0:a.authorization)==null?void 0:c.mode)==="3DS"){(p=a==null?void 0:a.authorization)!=null&&p.redirectUrl&&this.redirectTo3DS((m=a==null?void 0:a.authorization)==null?void 0:m.redirectUrl),(y=a==null?void 0:a.authorization)!=null&&y.embeddedHtml&&this.redirectToPreciumDoc((b=a==null?void 0:a.authorization)==null?void 0:b.embeddedHtml),(g=a==null?void 0:a.authorization)!=null&&g.jwt&&((w=a==null?void 0:a.authorization)!=null&&w.acsUrl)&&((f=a==null?void 0:a.authorization)!=null&&f.md)&&(this.cardResponse=a,this.currentStep=11);return}if(((k=a==null?void 0:a.authorization)==null?void 0:k.mode)==="otp"){this.cardResponse=a,R()!=="en"?(this.showLoader(),this.renderTranslatedText(a==null?void 0:a.providerMessage).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=3})):(this.otpMessage=(a==null?void 0:a.providerMessage)||"",this.currentStep=3);return}if(((x=a==null?void 0:a.authorization)==null?void 0:x.mode)==="avs"){if(R()!=="en"){this.showLoader();const A=Object.values(this.rawAvsData);this.renderTranslatedText(A).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}this.currentStep=10}}).catch(async a=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"PIN"}),a.message){const l=await Q(a.message,R());this.errorText=l,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})},300)}}validatedAVS(e,t){e.stopPropagation(),e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#avs-form-button-text"),o={authorization:{avs:{state:t==null?void 0:t.state,city:t==null?void 0:t.city,country:t==null?void 0:t.country,address:t==null?void 0:t.address,zipCode:(t==null?void 0:t.code)||"-"}},reference:this.activeRef};_.track("input_address",{payment_method:"Card",authentication_type:"AVS"}),i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden")),Ot(this.token,o,this.rdtCode,this.url).then(async({data:l,headers:c})=>{var p,m,y,b,g,w,f;if(l.providerMessage){const k=await Q(l.providerMessage,R());this.errorText=k}if(l.status==="failed")this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"AVS"}),l.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(l.status))["success","successful"].includes(l.status)&&(this.currentStep=5,this.redirectTo(l,c,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"AVS"}));else{if(((p=l==null?void 0:l.authorization)==null?void 0:p.mode)==="pin"){this.currentStep=2;return}if(((m=l==null?void 0:l.authorization)==null?void 0:m.mode)==="3DS"){(y=l==null?void 0:l.authorization)!=null&&y.redirectUrl&&this.redirectTo3DS((b=l==null?void 0:l.authorization)==null?void 0:b.redirectUrl),(g=l==null?void 0:l.authorization)!=null&&g.embeddedHtml&&this.redirectToPreciumDoc((w=l==null?void 0:l.authorization)==null?void 0:w.embeddedHtml);return}if(((f=l==null?void 0:l.authorization)==null?void 0:f.mode)==="otp"){this.cardResponse=l,this.currentStep=3;return}this.currentStep=10}}).catch(async l=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"AVS"}),l.message){const c=await Q(l.message,R());this.errorText=c,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}submitOtp(e,t){e.preventDefault();const i={authorization:{otp:t},reference:this.activeRef};this.currentStep=6,this.showLoader(),_.track("input_cardOTP",{payment_method:"Card",authentication_type:"PIN+0TP"}),Ot(this.token,i,this.rdtCode,this.url).then(async({data:o,headers:a})=>{var l,c,p,m,y,b,g;if(o.providerMessage){const w=await Q(o.providerMessage,R());this.errorText=w}if(o.status==="failed")this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN+0TP"}),o.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful","failed"].includes(o.status))["success","successful"].includes(o.status)&&(this.currentStep=5,this.redirectTo(o,a,"success"),_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN+0TP"}));else{if(this.activeRef=o.reference,((l=o==null?void 0:o.authorization)==null?void 0:l.mode)==="pin"){this.currentStep=2;return}if(((c=o==null?void 0:o.authorization)==null?void 0:c.mode)==="3DS"){(p=o==null?void 0:o.authorization)!=null&&p.redirectUrl&&this.redirectTo3DS((m=o==null?void 0:o.authorization)==null?void 0:m.redirectUrl),(y=o==null?void 0:o.authorization)!=null&&y.embeddedHtml&&this.redirectToPreciumDoc((b=o==null?void 0:o.authorization)==null?void 0:b.embeddedHtml);return}if(((g=o==null?void 0:o.authorization)==null?void 0:g.mode)==="avs"){if(R()!=="en"){this.showLoader();const w=Object.values(this.rawAvsData);this.renderTranslatedText(w).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}this.currentStep=10}}).catch(async o=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"PIN+0TP"}),o!=null&&o.message){const a=await Q(o.message,R());this.errorText=a,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})}redirectTo3DS(e){const t=window.open("","_blank");if(!t){alert(pe["enable-popup"]);return}t.location.href=e,_.track("auth_redirect",{payment_method:"Card",authentication_type:"3DS"}),this.currentStep=6,this.showLoader();const i=setInterval(()=>{t.closed&&(clearInterval(i),this.verifyPayment(({data:s,headers:o})=>{this.currentStep=5,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"3DS"}),this.redirectTo(s,o,"success")},async({data:s})=>{if(s.providerMessage){const o=await Q(s.providerMessage,R());this.errorText=o}this.currentStep=4,s.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue(),_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"3DS"})}))},2e3)}redirectToPreciumDoc(e){const t=atob(e),i=new Blob([t],{type:"text/html"}),s=URL.createObjectURL(i),o=window.open(s,"_blank");if(o){o.document.close(),_.track("auth_redirect",{payment_method:"Card",authentication_type:"3DS"}),this.currentStep=6,this.showLoader();const a=setInterval(()=>{o.closed&&(clearInterval(a),this.verifyPayment(({data:l,headers:c})=>{this.currentStep=5,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"3DS"}),this.redirectTo(l,c,"success")},async({data:l})=>{if(l.providerMessage){const c=await Q(l.providerMessage,R());this.errorText=c}this.currentStep=4,l.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue(),_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"3DS"})}))},2e3)}else alert(pe["enable-popup"])}async verifyPayment(e,t){try{const i=await Xe(this.token,this.activeRef,void 0,this.rdtCode,this.url);i.data.status==="failed"?t(i):(["success","successful"].includes(i.data.status)&&e(i),i.data.status==="inProgress"&&(this.currentStep=10))}catch{this.currentStep=4,_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"3DS"}),this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue()}}async verifyPaymentProcess(){try{const e=await Xe(this.token,this.reference,void 0,this.rdtCode,this.url);this.cardResponse=e.data,this.cardResponseHeader=e.headers}catch{this.currentStep=4}}charge3DSPayment(){const e=ja(this.token,this.reference,this.rdtCode,this.url);_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS"}),e.then(async({data:t,headers:i})=>{if(this.cardResponse=t,this.cardResponseHeader=i,t.providerMessage){const s=await Q(t.providerMessage,R());this.errorText=s}t.status==="failed"?(this.currentStep=4,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Failed"}),t.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue()):["success","successful"].includes(t.status)?(this.currentStep=5,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Success"}),this.redirectTo(t,i,"success")):t.status==="inProgress"?this.currentStep=10:(this.currentStep=4,_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Null"}),t.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(E["payment-failed"]),this.warningScreen.hideReportIssue())}).catch(async t=>{if(_.track("charge_3ds_payment",{payment_method:"Card",authentication_type:"3DS",verification_status:"Null"}),t.message){const i=await Q(t.message,R());this.errorText=i,this.currentStep=4,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=4,this.warningScreen.setPaymentError(E["payment-failed"]);this.warningScreen.hideReportIssue()})}goBackToMerchant(){if(this.isCancelledPlan){this.cancellledPlanAction();return}this.redirectTo(this.cardResponse,this.cardResponseHeader,this.callBackUrl)}renderCardContent(e){var o,a,l,c,p,m,y,b,g,w,f;e&&(this.merchantPlanDetail=e);const t=document.getElementById("test-container"),i=this.container.querySelector("#test-cards-link"),s=document.getElementById("go-back");if(this.currentStep!==1?(this.hidePaymentMethods(),s==null||s.classList.add("hidden")):this.showPaymentMethods(),this.isMobile&&this.hidePaymentMethods(),this.contents){switch(this.currentStep){case 1:this.cardDetailForm=new Qs({container:this.contents,onAction:x=>A=>this.submitCardDetails.bind(this)(x,A),merchantName:this.merchantPlanDetail.merchantName,currency:Hn(this.currency,this.localCurrency)}),this.cardDetailForm.renderContent();break;case 2:this.cardPinForm=new ur({container:this.contents,onClose:this.onClose,onAction:x=>this.handlePinRequest.bind(this)(x)}),this.cardPinForm.renderComponent();break;case 3:this.cardOtpValidationForm=new cr({container:this.contents,onClose:this.onClose,onAction:x=>A=>this.submitOtp.bind(this)(x,A),otpMessage:this.otpMessage||E["Payment failed"]}),this.cardOtpValidationForm.renderComponent();break;case 4:this.warningScreen=new en({container:this.contents,onAction:this.isMaxRetriesReached||this.isCancelledPlan?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this),onReportIssue:()=>this.currentStep=8}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.contents.innerHTML=this.warningScreen.render(),this.warningScreen.attachListener();break;case 5:this.successScreen=new Fn({container:this.contents,amount:((c=(l=(a=(o=this.merchantPlanDetail)==null?void 0:o.plan)==null?void 0:a.trial)==null?void 0:l.pricingList[0])==null?void 0:c.amount)??this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(p=this.merchantPlanDetail)==null?void 0:p.rate.rate}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.successScreen.renderComponent();break;case 6:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Verifying Payment");break;case 7:this.avsForm=new pr({container:this.contents,onAction:x=>A=>this.validatedAVS.bind(this)(x,A),translatedTexts:this.translatedAvsData}),this.avsForm.renderComponent();break;case 8:this.transactionIssuesScreen=new st({container:this.contents,onAction:async()=>{var x,A;if((x=this.cardResponse)!=null&&x.providerMessage){const M=await Q((A=this.cardResponse)==null?void 0:A.providerMessage,R());this.errorText=M}this.currentStep=4,this.warningScreen.setPaymentError(this.errorText||E["payment-failed"])},url:this.url,rdtCode:this.rdtCode,token:this.token,paymentChannel:"card",callBackUrl:this.callBackUrl,paymentResponse:this.cardResponse,paymentResponseHeaders:this.cardResponseHeader}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break;case 9:this.confirmationEnd=new oa({container:this.contents,onAction:x=>{this.currentStep=x},ref:this.reference,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.cardResponse,paymentResponseHeaders:this.cardResponseHeader,paymentMethod:"Card"}),this.confirmationEnd.renderComponent();break;case 10:this.confirmationProgress=new uc({container:this.contents,onAction:x=>{this.currentStep=x},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(x,A)=>{this.cardResponse=x,this.cardResponseHeader=A},step:{failed:4,success:5,end:9},paymentMethod:"Card"}),this.testcardIsVisible&&(di(t),i.classList.remove("text-tone-100","font-bold")),this.confirmationProgress.renderComponent();break;case 11:this.isw3dsForm=new vr({container:this.contents,threeDSecureDetails:{jwt:((y=(m=this.cardResponse)==null?void 0:m.authorization)==null?void 0:y.jwt)||"",md:((g=(b=this.cardResponse)==null?void 0:b.authorization)==null?void 0:g.md)||"",acsUrl:((f=(w=this.cardResponse)==null?void 0:w.authorization)==null?void 0:f.acsUrl)||""},onAction:x=>{this.currentStep=x,x===6&&this.showLoader()},onSuccess:this.charge3DSPayment.bind(this)}),this.isw3dsForm.renderComponent();break;default:this.cardDetailForm=new Qs({container:this.contents,onAction:x=>A=>this.submitCardDetails.bind(this)(x,A),merchantName:this.merchantPlanDetail.merchantName,currency:Hn(this.currency,this.localCurrency)}),this.cardDetailForm.renderContent();break}this.displayButtonText();const k=this.container.querySelector("#card-currency");k&&(k.textContent=`${Hn(this.currency,this.localCurrency)} ${pe.card}`)}}redirectTo(e,t,i){const s=t.get("spf-redirect-url");this.callBackUrl=s||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const o=new URL(this.callBackUrl);o.searchParams.append("status",e.status),o.searchParams.append("reference",e.reference),window.location.href=o.toString()},1800):i==="success"&&this.onSuccess(e)}displayButtonText(e){var i,s,o,a,l,c,p,m,y,b;const t=this.container.querySelector("#details-form-button-text");if(t){const g=(s=(i=this==null?void 0:this.merchantPlanDetail)==null?void 0:i.plan)==null?void 0:s.trial,w=(c=(l=(a=(o=this==null?void 0:this.merchantPlanDetail)==null?void 0:o.plan)==null?void 0:a.trial)==null?void 0:l.pricingList[0])==null?void 0:c.amount,f=Hn(this.currency,this.localCurrency),k=f==="USD"?(m=(p=this.merchantPlanDetail)==null?void 0:p.rate)==null?void 0:m.from:f;e?t.textContent=e:t.textContent=`${pe["continue-to"]} ${k} ${Te(g&&w!=null?w:this.totalAmount!==this.amount?this.totalAmount:(this.amount||0)*(this.currency==="USD"?(b=(y=this.merchantPlanDetail)==null?void 0:y.rate)==null?void 0:b.rate:1),2)}`}}}const bc=`<div data-section="transfer" data-section="transfer">
1573
1573
  <div class="container-center h-[40vh] hidden" id="loader">
1574
1574
  <img src="" alt="loader gif" />
1575
1575
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spot-flow/checkout-inline-js",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-dev.1",
4
4
  "description": "",
5
5
  "main": "dist/checkout-inline.js",
6
6
  "module": "dist/checkout-inline.es.js",