@spot-flow/checkout-inline-js 0.1.23 → 0.1.24
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.
|
@@ -29817,7 +29817,7 @@ class Mt extends Ln {
|
|
|
29817
29817
|
}
|
|
29818
29818
|
return e.json();
|
|
29819
29819
|
} catch (e) {
|
|
29820
|
-
throw e instanceof F ? console.error(`FetchError: ${e.message} (status: ${e.status})`) : e instanceof ge ? console.error(`AuthorizationError: ${e.message}`) : console.error(`Unexpected error: ${e}`), e;
|
|
29820
|
+
throw e instanceof F ? (O.showToast(e.message, "error", 9e3), console.error(`FetchError: ${e.message} (status: ${e.status})`)) : e instanceof ge ? console.error(`AuthorizationError: ${e.message}`) : console.error(`Unexpected error: ${e}`), e;
|
|
29821
29821
|
}
|
|
29822
29822
|
}
|
|
29823
29823
|
}
|
|
@@ -30094,7 +30094,7 @@ class Xo {
|
|
|
30094
30094
|
b(this, "url");
|
|
30095
30095
|
this.onSuccess = n || (() => null), this.container = e, this.secret = o, this.amount = a, this.currency = s, this.fullname = d, this.reference = r, this.email = t, this.rdtCode = l, this.url = c, this.closeModal = h, this.switchTab = m, this.contents = this.container.querySelector(
|
|
30096
30096
|
"#payment-content-view"
|
|
30097
|
-
), this._currentStep = 1, this.
|
|
30097
|
+
), this._currentStep = 1, this.paymentService = new Zo({
|
|
30098
30098
|
token: this.secret,
|
|
30099
30099
|
rdtCode: this.rdtCode,
|
|
30100
30100
|
url: this.url
|
package/dist/checkout-inline.js
CHANGED
|
@@ -653,7 +653,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
653
653
|
fill="white" />
|
|
654
654
|
</svg>
|
|
655
655
|
<span id="custom-toast-msg"></span>
|
|
656
|
-
`;class Cs{constructor(e){b(this,"container");this.container=e.container}attachListeners(){}renderComponent(){this.container.innerHTML=this.render()}render(){return ys}}class Ss{constructor({amount:e,closeModal:n,container:o,email:a,token:t,currency:s,rdtCode:d,url:r,reference:u,onSuccess:c}){b(this,"container");b(this,"contents");b(this,"closeModal");b(this,"onSuccess");b(this,"email");b(this,"transferDetails");b(this,"transferConfirmationOne");b(this,"transferConfirmationTwo");b(this,"transferConfirmationProgress");b(this,"transferExpired");b(this,"mainLoader");b(this,"token");b(this,"currency");b(this,"amount");b(this,"rdtCode");b(this,"url");b(this,"reference");b(this,"_currentStep");b(this,"activeRef");b(this,"paymentResponse");b(this,"initialTime");b(this,"timeLeft");b(this,"timerId");b(this,"abortController",null);var m;this.currency=s,this.onSuccess=c||(()=>null),this.container=o,this.contents=this.container.querySelector("#payment-content-view"),this.closeModal=n,this.token=t,this.email=a,this.amount=e,this.rdtCode=d,this.url=r,this.reference=u,this._currentStep=1,this.renderTransferContent(),this.paymentResponse=null,this.activeRef="",this.initialTime=1800,this.timeLeft=this.initialTime,this.timerId=null,this.mainLoader=new Ai(this.contents),this.mainLoader.mountLoader();const h=this.contents.querySelector("#loader");w.track("transfer_opens",{payment_method:"Transfer"}),h&&(h.classList.remove("hidden"),h.parentElement.classList.add("mx-auto"),(m=h.querySelector("img"))==null||m.setAttribute("src",Si)),this.currentStep===1&&(this.abortController=new AbortController,this.createTransfer())}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderTransferContent(),e===1&&this.createTransfer()}attachInputListeners(){const e=this.container.querySelector("#transfer-try-again"),n=this.container.querySelector("#transfer-sent"),o=this.container.querySelector(".success-button");e&&e.addEventListener("click",()=>{this.currentStep=1}),n&&n.addEventListener("click",()=>{this.abortController&&(this.abortController.abort(),this.currentStep=5)}),o&&o.addEventListener("click",()=>{this.closeModal(),w.track("checkout_closes")})}onSentVerify(e){e===5?this.abortController&&(this.abortController.abort(),this.currentStep=5):this.currentStep=3}async createTransfer(){requestAnimationFrame(()=>{var t;const e=this.container.querySelector("#loader"),n=this.container.querySelector("#details-content");e&&n&&(e.classList.remove("hidden"),(t=e.querySelector("img"))==null||t.setAttribute("src",Si),n.classList.add("hidden")),w.track("start_transferProcess",{payment_method:"Transfer"});const o={amount:this.amount,channel:"bank_transfer",currency:this.currency||"USD",customer:{email:this.email},reference:this.reference||oi()};ta(this.token,o,this.rdtCode,this.url).then(s=>{s.status==="failed"?(s.providerMessage?D.showToast(s.providerMessage,"error"):D.showToast("Payment failed","error"),this.currentStep=2,w.track("stop_transferProcess",{payment_method:"Transfer"})):(e&&n&&(e.classList.add("hidden"),n.classList.remove("hidden")),this.activeRef=s.reference,this.paymentResponse=s,this.transferDetails=new Mn({container:this.contents,onAction:d=>{this.onSentVerify.bind(this)(d)}}),this.transferDetails.renderComponent(this.paymentResponse))}).catch(s=>{D.showToast(s.message,"error")})})}async verifyTransfer(e,n,o,a){let t,s=0,d=n,r=!0,u;this.abortController&&(u=this.abortController.signal);const c=async()=>{if(this.timeLeft<=0){r=!1,a(new Error("Max polling time reached")),w.track("verify_transferPayment",{payment_method:"Transfer",verification_status:"Pending"}),this.currentStep=2;return}s+=1;try{const h=await Yi(e,this.activeRef,u,this.rdtCode,this.url);h.status==="failed"?r&&(d=n*(s+1),t=setTimeout(c,d)):!["success","successful"].includes(h.status)&&h.status!=="failed"||(r=!1,clearTimeout(t),w.track("verify_transferPayment",{payment_method:"Transfer",verification_status:"Success"}),o(h))}catch{r&&(d=n*(s+1),t=setTimeout(c,d))}};c()}renderTransferContent(){if(this.contents){switch(this.currentStep){case 1:this.transferDetails=new Mn({container:this.contents,onAction:()=>this.createTransfer.bind(this)()});break;case 2:this.transferExpired=new Cs({container:this.contents}),this.transferExpired.renderComponent();break;case 3:this.transferConfirmationOne=new vs({container:this.contents,onAction:e=>{this.currentStep=e}}),this.transferConfirmationOne.renderComponent();break;case 4:this.transferConfirmationTwo=new As({container:this.contents,onClose:()=>this.closeModal.bind(this)()}),this.transferConfirmationTwo.renderComponent();break;case 5:this.transferConfirmationProgress=new fs({container:this.contents,onAction:e=>{this.currentStep=e},ref:this.activeRef,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url}),this.transferConfirmationProgress.renderComponent();break;case 6:this.contents.innerHTML=Dn;break;default:return this.transferDetails=new Mn({container:this.contents,onAction:()=>this.createTransfer.bind(this)()}),this.transferDetails.render()}this.attachInputListeners()}}stopTimer(){this.timerId!==null&&(clearInterval(this.timerId),this.timerId=null)}stopProgressBar(){const e=this.container.querySelector(".progress-bar");e&&(e.style.animationPlayState="paused")}copyToClipboard(e,n){navigator.clipboard.writeText(e).then(()=>{n.innerHTML="Copied!"}).catch(()=>{n.innerHTML="Failed to copy"})}destroyTimer(){this.stopTimer()}stopPolling(){this.abortController&&this.abortController.abort()}}function jo(){return function(i,e){let n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:()=>n,set:t=>{n=t}})}}class F extends Error{constructor(e,n){super(e),this.status=n,this.name="FetchError"}}class ke extends Error{constructor(e){super(e),this.name="AuthorizationError"}}class Bn{constructor(e){b(this,"token");b(this,"baseurl","https://api.spotflow.co/api/v1");b(this,"headers");b(this,"rdtCode");b(this,"url");b(this,"getHeaders",(e,n)=>{if(!e)throw new ke("Missing authorization token");const o=new Headers;return o.append("Content-Type","application/json"),o.append("Authorization",`Bearer ${e}`),n&&o.append("Spotflow-Payment-Code",n),o});this.token=e.token,this.rdtCode=e.rdtCode,this.url=e.url,this.headers=this.getHeaders(this.token,this.rdtCode)}}class Jo extends Bn{constructor(e){super(e)}async createCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async createUssdPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async validateCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments/validate`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async authorizeCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments/authorize`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async createTransferPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async verifyPayment(e,n){try{const o=await fetch(`${te(this.baseurl,this.url)}/payments/verify?reference=${e}`,{method:"GET",headers:this.headers,signal:n});if(!o.ok){const t=await o.json();throw t.message?new F(t.message,o.status):new F("Network response was not ok",o.status)}return await o.json()}catch(o){throw o instanceof F?console.error(`FetchError: ${o.message} (status: ${o.status})`):o instanceof ke?console.error(`AuthorizationError: ${o.message}`):console.error(`Unexpected error: ${o}`),o}}}class ks extends Bn{constructor(e){super(e)}async getMerchantConfig(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/checkout-configurations?planId=${e||""}`,{headers:this.headers,method:"GET"});if(!n.ok){const o=await n.json();throw o.message?new F(o.message,n.status):new F("Network response was not ok",n.status)}return n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}}class ws extends Bn{constructor(e){super(e)}async getBankList(){try{const e=await fetch(`${te(this.baseurl,this.url)}/banks?ussd=true`,{headers:this.headers,method:"GET"});if(!e.ok){const n=await e.json();throw n.message?new F(n.message,e.status):new F("Network response was not ok",e.status)}return e.json()}catch(e){throw e instanceof F?console.error(`FetchError: ${e.message} (status: ${e.status})`):e instanceof ke?console.error(`AuthorizationError: ${e.message}`):console.error(`Unexpected error: ${e}`),e}}}const Es=`<div id="ussdBanks">
|
|
656
|
+
`;class Cs{constructor(e){b(this,"container");this.container=e.container}attachListeners(){}renderComponent(){this.container.innerHTML=this.render()}render(){return ys}}class Ss{constructor({amount:e,closeModal:n,container:o,email:a,token:t,currency:s,rdtCode:d,url:r,reference:u,onSuccess:c}){b(this,"container");b(this,"contents");b(this,"closeModal");b(this,"onSuccess");b(this,"email");b(this,"transferDetails");b(this,"transferConfirmationOne");b(this,"transferConfirmationTwo");b(this,"transferConfirmationProgress");b(this,"transferExpired");b(this,"mainLoader");b(this,"token");b(this,"currency");b(this,"amount");b(this,"rdtCode");b(this,"url");b(this,"reference");b(this,"_currentStep");b(this,"activeRef");b(this,"paymentResponse");b(this,"initialTime");b(this,"timeLeft");b(this,"timerId");b(this,"abortController",null);var m;this.currency=s,this.onSuccess=c||(()=>null),this.container=o,this.contents=this.container.querySelector("#payment-content-view"),this.closeModal=n,this.token=t,this.email=a,this.amount=e,this.rdtCode=d,this.url=r,this.reference=u,this._currentStep=1,this.renderTransferContent(),this.paymentResponse=null,this.activeRef="",this.initialTime=1800,this.timeLeft=this.initialTime,this.timerId=null,this.mainLoader=new Ai(this.contents),this.mainLoader.mountLoader();const h=this.contents.querySelector("#loader");w.track("transfer_opens",{payment_method:"Transfer"}),h&&(h.classList.remove("hidden"),h.parentElement.classList.add("mx-auto"),(m=h.querySelector("img"))==null||m.setAttribute("src",Si)),this.currentStep===1&&(this.abortController=new AbortController,this.createTransfer())}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderTransferContent(),e===1&&this.createTransfer()}attachInputListeners(){const e=this.container.querySelector("#transfer-try-again"),n=this.container.querySelector("#transfer-sent"),o=this.container.querySelector(".success-button");e&&e.addEventListener("click",()=>{this.currentStep=1}),n&&n.addEventListener("click",()=>{this.abortController&&(this.abortController.abort(),this.currentStep=5)}),o&&o.addEventListener("click",()=>{this.closeModal(),w.track("checkout_closes")})}onSentVerify(e){e===5?this.abortController&&(this.abortController.abort(),this.currentStep=5):this.currentStep=3}async createTransfer(){requestAnimationFrame(()=>{var t;const e=this.container.querySelector("#loader"),n=this.container.querySelector("#details-content");e&&n&&(e.classList.remove("hidden"),(t=e.querySelector("img"))==null||t.setAttribute("src",Si),n.classList.add("hidden")),w.track("start_transferProcess",{payment_method:"Transfer"});const o={amount:this.amount,channel:"bank_transfer",currency:this.currency||"USD",customer:{email:this.email},reference:this.reference||oi()};ta(this.token,o,this.rdtCode,this.url).then(s=>{s.status==="failed"?(s.providerMessage?D.showToast(s.providerMessage,"error"):D.showToast("Payment failed","error"),this.currentStep=2,w.track("stop_transferProcess",{payment_method:"Transfer"})):(e&&n&&(e.classList.add("hidden"),n.classList.remove("hidden")),this.activeRef=s.reference,this.paymentResponse=s,this.transferDetails=new Mn({container:this.contents,onAction:d=>{this.onSentVerify.bind(this)(d)}}),this.transferDetails.renderComponent(this.paymentResponse))}).catch(s=>{D.showToast(s.message,"error")})})}async verifyTransfer(e,n,o,a){let t,s=0,d=n,r=!0,u;this.abortController&&(u=this.abortController.signal);const c=async()=>{if(this.timeLeft<=0){r=!1,a(new Error("Max polling time reached")),w.track("verify_transferPayment",{payment_method:"Transfer",verification_status:"Pending"}),this.currentStep=2;return}s+=1;try{const h=await Yi(e,this.activeRef,u,this.rdtCode,this.url);h.status==="failed"?r&&(d=n*(s+1),t=setTimeout(c,d)):!["success","successful"].includes(h.status)&&h.status!=="failed"||(r=!1,clearTimeout(t),w.track("verify_transferPayment",{payment_method:"Transfer",verification_status:"Success"}),o(h))}catch{r&&(d=n*(s+1),t=setTimeout(c,d))}};c()}renderTransferContent(){if(this.contents){switch(this.currentStep){case 1:this.transferDetails=new Mn({container:this.contents,onAction:()=>this.createTransfer.bind(this)()});break;case 2:this.transferExpired=new Cs({container:this.contents}),this.transferExpired.renderComponent();break;case 3:this.transferConfirmationOne=new vs({container:this.contents,onAction:e=>{this.currentStep=e}}),this.transferConfirmationOne.renderComponent();break;case 4:this.transferConfirmationTwo=new As({container:this.contents,onClose:()=>this.closeModal.bind(this)()}),this.transferConfirmationTwo.renderComponent();break;case 5:this.transferConfirmationProgress=new fs({container:this.contents,onAction:e=>{this.currentStep=e},ref:this.activeRef,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url}),this.transferConfirmationProgress.renderComponent();break;case 6:this.contents.innerHTML=Dn;break;default:return this.transferDetails=new Mn({container:this.contents,onAction:()=>this.createTransfer.bind(this)()}),this.transferDetails.render()}this.attachInputListeners()}}stopTimer(){this.timerId!==null&&(clearInterval(this.timerId),this.timerId=null)}stopProgressBar(){const e=this.container.querySelector(".progress-bar");e&&(e.style.animationPlayState="paused")}copyToClipboard(e,n){navigator.clipboard.writeText(e).then(()=>{n.innerHTML="Copied!"}).catch(()=>{n.innerHTML="Failed to copy"})}destroyTimer(){this.stopTimer()}stopPolling(){this.abortController&&this.abortController.abort()}}function jo(){return function(i,e){let n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:()=>n,set:t=>{n=t}})}}class F extends Error{constructor(e,n){super(e),this.status=n,this.name="FetchError"}}class ke extends Error{constructor(e){super(e),this.name="AuthorizationError"}}class Bn{constructor(e){b(this,"token");b(this,"baseurl","https://api.spotflow.co/api/v1");b(this,"headers");b(this,"rdtCode");b(this,"url");b(this,"getHeaders",(e,n)=>{if(!e)throw new ke("Missing authorization token");const o=new Headers;return o.append("Content-Type","application/json"),o.append("Authorization",`Bearer ${e}`),n&&o.append("Spotflow-Payment-Code",n),o});this.token=e.token,this.rdtCode=e.rdtCode,this.url=e.url,this.headers=this.getHeaders(this.token,this.rdtCode)}}class Jo extends Bn{constructor(e){super(e)}async createCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async createUssdPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async validateCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments/validate`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async authorizeCardPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments/authorize`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async createTransferPayment(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!n.ok){const a=await n.json();throw a.message?new F(a.message,n.status):new F("Network response was not ok",n.status)}return await n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}async verifyPayment(e,n){try{const o=await fetch(`${te(this.baseurl,this.url)}/payments/verify?reference=${e}`,{method:"GET",headers:this.headers,signal:n});if(!o.ok){const t=await o.json();throw t.message?new F(t.message,o.status):new F("Network response was not ok",o.status)}return await o.json()}catch(o){throw o instanceof F?console.error(`FetchError: ${o.message} (status: ${o.status})`):o instanceof ke?console.error(`AuthorizationError: ${o.message}`):console.error(`Unexpected error: ${o}`),o}}}class ks extends Bn{constructor(e){super(e)}async getMerchantConfig(e){try{const n=await fetch(`${te(this.baseurl,this.url)}/checkout-configurations?planId=${e||""}`,{headers:this.headers,method:"GET"});if(!n.ok){const o=await n.json();throw o.message?new F(o.message,n.status):new F("Network response was not ok",n.status)}return n.json()}catch(n){throw n instanceof F?console.error(`FetchError: ${n.message} (status: ${n.status})`):n instanceof ke?console.error(`AuthorizationError: ${n.message}`):console.error(`Unexpected error: ${n}`),n}}}class ws extends Bn{constructor(e){super(e)}async getBankList(){try{const e=await fetch(`${te(this.baseurl,this.url)}/banks?ussd=true`,{headers:this.headers,method:"GET"});if(!e.ok){const n=await e.json();throw n.message?new F(n.message,e.status):new F("Network response was not ok",e.status)}return e.json()}catch(e){throw e instanceof F?(D.showToast(e.message,"error",9e3),console.error(`FetchError: ${e.message} (status: ${e.status})`)):e instanceof ke?console.error(`AuthorizationError: ${e.message}`):console.error(`Unexpected error: ${e}`),e}}}const Es=`<div id="ussdBanks">
|
|
657
657
|
<div class="px-0 md:px-5 lg:px-7 grid gap-4 md:gap-6">
|
|
658
658
|
<div class="text-center my-6">
|
|
659
659
|
<svg class="mx-auto w-5 h-5 md:w-8 md:h-8 mb-1" width="18" height="18" viewBox="0 0 18 18" fill="none"
|
|
@@ -731,7 +731,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
731
731
|
</div>
|
|
732
732
|
</div>
|
|
733
733
|
</div>
|
|
734
|
-
`;class Bs{constructor(e){b(this,"container");b(this,"selected");b(this,"secret");b(this,"onAction");b(this,"paymentService");b(this,"currency");b(this,"amount");b(this,"ussd_detail");b(this,"fullname");b(this,"reference");b(this,"email");b(this,"abortController");b(this,"activeRef","");b(this,"pageLoader");b(this,"onError");this.container=e.container,this.selected=e.selected,this.onAction=e.onAction,this.secret=e.secret,this.abortController=new AbortController,this.paymentService=new Jo({token:this.secret,rdtCode:e.rdtCode,url:e.url}),this.currency=e.currency,this.amount=e.amount||0,this.email=e.email,this.fullname=e.fullname,this.reference=e.reference,this.onError=e.onError??(()=>null),this.pageLoader=new Ai(this.container),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Fetching selected bank code detail")}makePayment(){var e;w.track("start_ussdProcess",{payment_method:"USSD"}),this.paymentService.createUssdPayment({amount:this.amount,currency:this.currency,channel:"ussd",customer:{email:this.email,name:this.fullname},bank:{code:((e=this.selected)==null?void 0:e.code)||""},reference:this.reference||oi()}).then(n=>{var o;if(this.ussd_detail=n.ussd,this.activeRef=n.reference||"",n.status==="failed"){D.showToast(n.providerMessage||"Payment failed","error"),this.onError(n.providerMessage||"Payment failed"),w.track("stop_ussdProcess",{payment_method:"USSD"});return}else if(n.status!=="success"){this.container.innerHTML=this.render();const a=this.container.querySelectorAll(".bank-dial-code"),t=this.container.querySelector("#bank-dial-code");t&&(t.innerHTML=((o=n==null?void 0:n.ussd)==null?void 0:o.paymentCode)||""),Array.from(a).forEach(d=>{var r;d.innerHTML=((r=n==null?void 0:n.ussd)==null?void 0:r.code)||""}),this.attachListener();return}this.container.innerHTML=this.render(),this.attachListener()}).catch(n=>{D.showToast("Payment failed","error"),this.onError("Payment failed")})}attachListener(){const e=this.container.querySelectorAll(".copy-code-button"),n=this.container.querySelectorAll(".copy-code-button-1"),o=this.container.querySelector("#bank-completed-payment");Array.from(e).forEach(s=>{s.addEventListener("click",d=>{var r;w.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((r=this.ussd_detail)==null?void 0:r.code)||"")})}),Array.from(n).forEach(s=>{s.addEventListener("click",d=>{var r;w.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((r=this.ussd_detail)==null?void 0:r.code)||"")})}),o&&o.addEventListener("click",s=>{s.preventDefault(),this.onAction(this.selected,this.activeRef)})}verifyPayment(){let e;this.abortController?e=this.abortController.signal:e=new AbortController().signal,console.log({signal:e})}renderComponent(){this.makePayment();const e=this.container.querySelectorAll(".bank-name-ussd"),n=this.container.querySelectorAll(".bank-dial-code");Array.from(e).forEach(t=>{t.innerHTML=this.selected.name||""}),Array.from(n).forEach(t=>{t.innerHTML=this.selected.code||""}),this.attachListener()}render(){return Ms}}var Is=Object.defineProperty,Ls=(i,e,n,o)=>{for(var a=void 0,t=i.length-1,s;t>=0;t--)(s=i[t])&&(a=s(e,n,a)||a);return a&&Is(e,n,a),a};class Zo{constructor({container:e,onSuccess:n,secret:o,amount:a,currency:t,email:s,fullname:d,reference:r,rdtCode:u,url:c,closeModal:h,switchTab:m}){b(this,"contents");b(this,"selectedCode");b(this,"secret");b(this,"amount");b(this,"currency");b(this,"fullname");b(this,"email");b(this,"pageLoader");b(this,"reference");b(this,"onSuccess");b(this,"closeModal");b(this,"warningScreen");b(this,"switchTab");b(this,"bankDetail");b(this,"viewUssdCode");b(this,"_currentStep");b(this,"container");b(this,"paymentService");b(this,"successScreen");b(this,"activeRef","");b(this,"abortController");b(this,"_retry_count",10);b(this,"intervalPayment");b(this,"rdtCode");b(this,"url");this.onSuccess=n||(()=>null),this.container=e,this.secret=o,this.amount=a,this.currency=t,this.fullname=d,this.reference=r,this.email=s,this.rdtCode=u,this.url=c,this.closeModal=h,this.switchTab=m,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.
|
|
734
|
+
`;class Bs{constructor(e){b(this,"container");b(this,"selected");b(this,"secret");b(this,"onAction");b(this,"paymentService");b(this,"currency");b(this,"amount");b(this,"ussd_detail");b(this,"fullname");b(this,"reference");b(this,"email");b(this,"abortController");b(this,"activeRef","");b(this,"pageLoader");b(this,"onError");this.container=e.container,this.selected=e.selected,this.onAction=e.onAction,this.secret=e.secret,this.abortController=new AbortController,this.paymentService=new Jo({token:this.secret,rdtCode:e.rdtCode,url:e.url}),this.currency=e.currency,this.amount=e.amount||0,this.email=e.email,this.fullname=e.fullname,this.reference=e.reference,this.onError=e.onError??(()=>null),this.pageLoader=new Ai(this.container),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Fetching selected bank code detail")}makePayment(){var e;w.track("start_ussdProcess",{payment_method:"USSD"}),this.paymentService.createUssdPayment({amount:this.amount,currency:this.currency,channel:"ussd",customer:{email:this.email,name:this.fullname},bank:{code:((e=this.selected)==null?void 0:e.code)||""},reference:this.reference||oi()}).then(n=>{var o;if(this.ussd_detail=n.ussd,this.activeRef=n.reference||"",n.status==="failed"){D.showToast(n.providerMessage||"Payment failed","error"),this.onError(n.providerMessage||"Payment failed"),w.track("stop_ussdProcess",{payment_method:"USSD"});return}else if(n.status!=="success"){this.container.innerHTML=this.render();const a=this.container.querySelectorAll(".bank-dial-code"),t=this.container.querySelector("#bank-dial-code");t&&(t.innerHTML=((o=n==null?void 0:n.ussd)==null?void 0:o.paymentCode)||""),Array.from(a).forEach(d=>{var r;d.innerHTML=((r=n==null?void 0:n.ussd)==null?void 0:r.code)||""}),this.attachListener();return}this.container.innerHTML=this.render(),this.attachListener()}).catch(n=>{D.showToast("Payment failed","error"),this.onError("Payment failed")})}attachListener(){const e=this.container.querySelectorAll(".copy-code-button"),n=this.container.querySelectorAll(".copy-code-button-1"),o=this.container.querySelector("#bank-completed-payment");Array.from(e).forEach(s=>{s.addEventListener("click",d=>{var r;w.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((r=this.ussd_detail)==null?void 0:r.code)||"")})}),Array.from(n).forEach(s=>{s.addEventListener("click",d=>{var r;w.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((r=this.ussd_detail)==null?void 0:r.code)||"")})}),o&&o.addEventListener("click",s=>{s.preventDefault(),this.onAction(this.selected,this.activeRef)})}verifyPayment(){let e;this.abortController?e=this.abortController.signal:e=new AbortController().signal,console.log({signal:e})}renderComponent(){this.makePayment();const e=this.container.querySelectorAll(".bank-name-ussd"),n=this.container.querySelectorAll(".bank-dial-code");Array.from(e).forEach(t=>{t.innerHTML=this.selected.name||""}),Array.from(n).forEach(t=>{t.innerHTML=this.selected.code||""}),this.attachListener()}render(){return Ms}}var Is=Object.defineProperty,Ls=(i,e,n,o)=>{for(var a=void 0,t=i.length-1,s;t>=0;t--)(s=i[t])&&(a=s(e,n,a)||a);return a&&Is(e,n,a),a};class Zo{constructor({container:e,onSuccess:n,secret:o,amount:a,currency:t,email:s,fullname:d,reference:r,rdtCode:u,url:c,closeModal:h,switchTab:m}){b(this,"contents");b(this,"selectedCode");b(this,"secret");b(this,"amount");b(this,"currency");b(this,"fullname");b(this,"email");b(this,"pageLoader");b(this,"reference");b(this,"onSuccess");b(this,"closeModal");b(this,"warningScreen");b(this,"switchTab");b(this,"bankDetail");b(this,"viewUssdCode");b(this,"_currentStep");b(this,"container");b(this,"paymentService");b(this,"successScreen");b(this,"activeRef","");b(this,"abortController");b(this,"_retry_count",10);b(this,"intervalPayment");b(this,"rdtCode");b(this,"url");this.onSuccess=n||(()=>null),this.container=e,this.secret=o,this.amount=a,this.currency=t,this.fullname=d,this.reference=r,this.email=s,this.rdtCode=u,this.url=c,this.closeModal=h,this.switchTab=m,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.paymentService=new Jo({token:this.secret,rdtCode:this.rdtCode,url:this.url}),w.track("ussd_opens",{payment_method:"USSD"})}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderUssdContent()}onCodeSelect(e){this.selectedCode=e||"",setTimeout(()=>{this.currentStep=2},1e3)}validate(){let e;if(this.abortController?e=this.abortController.signal:(this.abortController=new AbortController,e=this.abortController.signal),this._retry_count<=0){D.showToast("Max polling time reached","error"),clearInterval(this.intervalPayment),this.currentStep=3,w.track("verify_ussdPayment",{payment_method:"USSD",verification_status:"Pending"});return}this.paymentService.verifyPayment(this.activeRef,e||this.abortController.signal).then(n=>{n.status==="failed"?this._retry_count-=1:["successful","failed"].includes(n.status)?["success","successful"].includes(n.status)&&(this.onSuccess(n),this.currentStep=5,clearInterval(this.intervalPayment),w.track("verify_ussdPayment",{payment_method:"USSD",verification_status:"Success"})):this._retry_count-=1}).catch(n=>{D.showToast(n.message,"error"),this.currentStep=3,clearInterval(this.intervalPayment),w.track("verify_ussdPayment",{payment_method:"USSD",verification_status:"Pending"})})}renderUssdContent(){switch(this.currentStep){case 1:this.bankDetail=new Yo({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this),rdtCode:this.rdtCode,url:this.url}),this.bankDetail.renderContent();break;case 2:this.reference||oi(),this.viewUssdCode=new Bs({container:this.contents,onAction:(e,n)=>{this.activeRef=n,this.currentStep=4,this.intervalPayment=setInterval(()=>{this.validate()},5e3)},selected:this.selectedCode||{},secret:this.secret,amount:this.amount,currency:this.currency,email:this.email||"",fullname:this.fullname||void 0,onError:e=>{this.currentStep=3,this.warningScreen.setPaymentError(e,!0)},rdtCode:this.rdtCode,url:this.url}),this.viewUssdCode.renderComponent();break;case 3:this.contents.innerHTML=Wo,this.warningScreen=new Vo({container:this.contents,switchTab:this.switchTab.bind(this),setCurrentTab:this.switchTab.bind(this),msg:""});break;case 4:this.pageLoader=new Ai(this.contents),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Verifying Payment");break;case 5:this.successScreen=new zo(this.contents,this.closeModal.bind(this)),this.contents.innerHTML=this.successScreen.render(),this.successScreen.attachListener();break;default:this.bankDetail=new Yo({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this)}),this.bankDetail.renderContent();break}}handleSelectChange(e){setTimeout(()=>{this.currentStep=2},400),this.currentStep=2}}Ls([jo(),jo()],Zo.prototype,"selectedCode");const Xo="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='40'%20height='40'%20rx='8'%20fill='%2301008E'/%3e%3cpath%20d='M13.0056%2026.2977C13.6398%2024.8735%2014.2552%2023.4941%2014.9174%2022.0054C15.1257%2022.3264%2015.2645%2022.5363%2015.3977%2022.748C16.4897%2024.4753%2017.8837%2025.9103%2019.7673%2026.8699C20.9305%2027.4618%2022.1632%2027.7721%2023.4877%2027.7219C24.5459%2027.6824%2025.15%2027.0295%2025.0412%2026.0286C24.9887%2025.5479%2024.8198%2025.0977%2024.4296%2024.7946C23.8855%2024.3713%2023.3339%2023.921%2022.7091%2023.6358C21.2814%2022.9829%2019.7936%2022.4538%2018.3602%2021.8134C17.4146%2021.3919%2016.4728%2020.9309%2015.6135%2020.3677C14.3546%2019.5408%2013.5628%2018.3982%2013.4859%2016.8772C13.3996%2015.1444%2014.1576%2013.8673%2015.7167%2013.0063C16.7054%2012.4593%2017.7936%2012.1992%2018.9099%2012.0754C21.3864%2011.801%2023.7091%2012.2763%2025.8592%2013.4906C25.9605%2013.548%2026.0506%2013.627%2026.2044%2013.7364C25.5797%2014.9238%2024.9587%2016.1005%2024.2983%2017.3561C24.0675%2017.139%2023.8817%2016.9722%2023.7073%2016.7964C22.5891%2015.679%2021.3921%2014.6601%2019.9418%2013.9444C18.9268%2013.444%2017.8536%2013.1678%2016.711%2013.1929C15.4915%2013.218%2014.8293%2014.0664%2015.0619%2015.2216C15.1914%2015.8583%2015.5272%2016.3695%2016.06%2016.7139C16.7617%2017.1677%2017.499%2017.5928%2018.2683%2017.9265C19.4427%2018.4341%2020.6622%2018.8484%2021.8592%2019.3112C22.9493%2019.7327%2023.9906%2020.2404%2024.893%2020.9704C26.3376%2022.1399%2026.9024%2023.6179%2026.5346%2025.4044C26.3132%2026.4771%2025.6547%2027.2537%2024.7166%2027.8349C23.8817%2028.3515%2022.9512%2028.6259%2021.9793%2028.7569C19.9756%2029.0277%2017.9925%2028.9685%2016.0732%2028.2708C14.9193%2027.851%2013.9043%2027.225%2013%2026.2995L13.0056%2026.2977Z'%20fill='white'/%3e%3c/svg%3e",Ts=i=>i==null?void 0:i.replace(/_/g," ");function xs(i){return i.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}const Ns=i=>{if(i){const e=Ts(i);return xs(e)}return""},Rs=`<div class="grid grid-cols-[auto_1fr] gap-3 border-b border-b-white pb-[9.6px] py-2">
|
|
735
735
|
<p class="text-xs text-left" id="merchant-email"></p>
|
|
736
736
|
<p class="text-xs justify-self-end break-words whitespace-normal" id="plan-name">-</p>
|
|
737
737
|
</div>
|