@spot-flow/checkout-inline-js 0.2.3 → 0.2.4-dev.2
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/checkout-inline.es.js +22 -12
- package/dist/checkout-inline.js +4 -4
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1685,7 +1685,7 @@ const Fs = new Pl({
|
|
|
1685
1685
|
}), xe = (() => {
|
|
1686
1686
|
let n = navigator == null ? void 0 : navigator.language.split("-")[0].toLowerCase(), e = /* @__PURE__ */ new Map(), t = [], i = 0, s = [], a = !1;
|
|
1687
1687
|
const o = (f) => {
|
|
1688
|
-
n !== f && (n = f,
|
|
1688
|
+
n !== f && (n = f, a = !1, l());
|
|
1689
1689
|
}, l = () => {
|
|
1690
1690
|
t.forEach((f) => f(n));
|
|
1691
1691
|
}, c = () => {
|
|
@@ -1699,7 +1699,7 @@ const Fs = new Pl({
|
|
|
1699
1699
|
i += 1, c();
|
|
1700
1700
|
const x = Array.isArray(f) ? `[${f.join("|")}]:${w}` : `${f}:${w}`;
|
|
1701
1701
|
if (e.has(x))
|
|
1702
|
-
return e.get(x);
|
|
1702
|
+
return i -= 1, c(), e.get(x);
|
|
1703
1703
|
try {
|
|
1704
1704
|
const E = await yl({
|
|
1705
1705
|
text: f,
|
|
@@ -36328,7 +36328,12 @@ const ru = {
|
|
|
36328
36328
|
fr: "Français",
|
|
36329
36329
|
es: "Español",
|
|
36330
36330
|
pt: "Português",
|
|
36331
|
-
ar: "Arabic"
|
|
36331
|
+
ar: "Arabic",
|
|
36332
|
+
zh: "Chinese",
|
|
36333
|
+
hi: "Hindi",
|
|
36334
|
+
nl: "Dutch",
|
|
36335
|
+
et: "Estonian",
|
|
36336
|
+
pl: "Polish"
|
|
36332
36337
|
}, cu = (n) => n == null ? void 0 : n.replace(/_/g, " ");
|
|
36333
36338
|
function Po(n) {
|
|
36334
36339
|
return n.split(" ").map(
|
|
@@ -36616,7 +36621,7 @@ class hu {
|
|
|
36616
36621
|
renderPaymentOptions(e) {
|
|
36617
36622
|
const t = e.querySelector(".payment-options"), i = In(this.currency, this.localCurrency);
|
|
36618
36623
|
if (t) {
|
|
36619
|
-
const s = this.merchantDetail.plan ? [se.
|
|
36624
|
+
const s = this.merchantDetail.plan ? [se.mobile_money] : this.merchantDetail.paymentMethods.filter((a) => a !== "ussd").filter((a) => !(i !== "USD" && a === "stablecoin")).map((a) => se[a]);
|
|
36620
36625
|
if (this.isMobile) {
|
|
36621
36626
|
let a = '<div class="">';
|
|
36622
36627
|
s.forEach((o) => {
|
|
@@ -37303,9 +37308,9 @@ class Su {
|
|
|
37303
37308
|
i && s && (i.classList.remove("hidden"), s.classList.add("hidden"));
|
|
37304
37309
|
const a = ft();
|
|
37305
37310
|
(() => {
|
|
37306
|
-
var l, c;
|
|
37311
|
+
var l, c, p, m;
|
|
37307
37312
|
if (this.retryingPayment) {
|
|
37308
|
-
const
|
|
37313
|
+
const g = {
|
|
37309
37314
|
channel: "mobile_money",
|
|
37310
37315
|
reference: this.reference,
|
|
37311
37316
|
mobileMoney: {
|
|
@@ -37320,19 +37325,24 @@ class Su {
|
|
|
37320
37325
|
};
|
|
37321
37326
|
return mt(
|
|
37322
37327
|
this.token,
|
|
37323
|
-
|
|
37328
|
+
g,
|
|
37324
37329
|
this.rdtCode,
|
|
37325
37330
|
this.url
|
|
37326
37331
|
);
|
|
37327
37332
|
} else {
|
|
37328
|
-
const
|
|
37333
|
+
const g = {
|
|
37329
37334
|
amount: this.amount,
|
|
37330
37335
|
channel: "mobile_money",
|
|
37331
37336
|
currency: this.currency,
|
|
37332
37337
|
customer: this.customer,
|
|
37333
37338
|
reference: this.reference,
|
|
37334
37339
|
callBackUrl: this.callBackUrl,
|
|
37335
|
-
metadata:
|
|
37340
|
+
metadata: {
|
|
37341
|
+
...this.metadata,
|
|
37342
|
+
...((l = this.merchantDetails) == null ? void 0 : l.subscription_id) && {
|
|
37343
|
+
subscription_id: (c = this.merchantDetails) == null ? void 0 : c.subscription_id
|
|
37344
|
+
}
|
|
37345
|
+
},
|
|
37336
37346
|
mobileMoney: {
|
|
37337
37347
|
code: t.code,
|
|
37338
37348
|
// "mtn-gh",
|
|
@@ -37344,8 +37354,8 @@ class Su {
|
|
|
37344
37354
|
},
|
|
37345
37355
|
...this.localCurrency && { localCurrency: this.localCurrency },
|
|
37346
37356
|
isCheckout: !0,
|
|
37347
|
-
...((
|
|
37348
|
-
taxQuoteId: (
|
|
37357
|
+
...((p = this.merchantDetails) == null ? void 0 : p.taxQuoteId) && {
|
|
37358
|
+
taxQuoteId: (m = this.merchantDetails) == null ? void 0 : m.taxQuoteId
|
|
37349
37359
|
},
|
|
37350
37360
|
...this.countryCode && {
|
|
37351
37361
|
countryCode: this.countryCode
|
|
@@ -37354,7 +37364,7 @@ class Su {
|
|
|
37354
37364
|
};
|
|
37355
37365
|
return ul(
|
|
37356
37366
|
this.token,
|
|
37357
|
-
|
|
37367
|
+
g,
|
|
37358
37368
|
this.rdtCode,
|
|
37359
37369
|
this.url
|
|
37360
37370
|
);
|
package/dist/checkout-inline.js
CHANGED
|
@@ -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,
|
|
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,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,x="static")=>{if(o)return Array.isArray(f)?f:[f];if(k==="en"&&x==="static")return Array.isArray(f)?f:[f];i+=1,c();const M=Array.isArray(f)?`[${f.join("|")}]:${k}`:`${f}:${k}`;if(e.has(M))return i-=1,c(),e.get(M);try{const E=await za({text:f,target:k||"en"});return e.set(M,E.translatedText??(Array.isArray(f)?f:[f])),E.translatedText??(Array.isArray(f)?f:[f])}catch(E){return console.error("Translation failed:",E),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,Z)=>(D[x[Z]]=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")},z=async(n,e)=>{const t=await Ae.translate(n,e,"dynamic");return typeof t=="string"?t:t[0]};let rn=Hi;const Os=async n=>(rn=await Ae.translateRecord(Hi,n),rn);let q=Ls;const Us=async n=>{q=await Ae.translateRecord(Ls,n)};let P=Ts;const Vs=async n=>{P=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 q)return q[n];if(n in P)return P[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"),g=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"]),g&&(g.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 y,w,f;b.preventDefault(),this.onAction(b)({pan:Ja(this.cardDetailsValues.number),cvv:this.cardDetailsValues.cvv,expiryMonth:(y=this.cardDetailsValues)==null?void 0:y.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,""),g=this.validateCreditCard(m);this.filterCreditCardType(o);const b=(l=this.creditCardTypes[0])==null?void 0:l.name;b&&Mn.map(y=>{if(y.name===this.currency)if(y.cardTypes.includes(b)){const w=nr[b];if(w.length>1){const f=w.some(k=>m.length===k);this.checkInputValidity(g,i,f,"card-number-invalid")}else m.length===w[0]&&this.checkInputValidity(g,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 g=a.split("/"),b=(c=g[0])==null?void 0:c.trim(),y=(p=g[1])==null?void 0:p.trim(),w=new Date().getFullYear()%100,f=m.getMonth()+1;let k=!0;(parseInt(y)===w&&parseInt(b)<f||parseInt(y)<w)&&(k=!1),(y==null?void 0:y.length)===2&&this.checkInputValidity(k,i,g.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" />
|
|
@@ -1843,7 +1843,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
1843
1843
|
payment</button>
|
|
1844
1844
|
</div>
|
|
1845
1845
|
</div>
|
|
1846
|
-
</div>`;class _c{constructor(e){d(this,"container");d(this,"selected");d(this,"secret");d(this,"onAction");d(this,"paymentService");d(this,"currency");d(this,"amount");d(this,"ussd_detail");d(this,"reference");d(this,"customer");d(this,"activeRef","");d(this,"pageLoader");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"onError");this.container=e.container,this.selected=e.selected,this.onAction=e.onAction,this.secret=e.secret,this.paymentService=new ua({token:this.secret,rdtCode:e.rdtCode,url:e.url}),this.currency=e.currency,this.amount=e.amount||0,this.customer=e.customer,this.reference=e.reference,this.callBackUrl=e.callBackUrl,this.metadata=e.metadata,this.localCurrency=e.localCurrency,this.onError=e.onError??(()=>null),this.pageLoader=new ke(this.container),this.pageLoader.mountLoader("25dvh"),this.pageLoader.updateMessage("Fetching selected bank code detail")}makePayment(){var e;_.track("start_ussdProcess",{payment_method:"USSD"}),this.paymentService.createUssdPayment({amount:this.amount,currency:this.currency,channel:"ussd",customer:this.customer,bank:{code:((e=this.selected)==null?void 0:e.code)||""},reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0}).then(({data:t,headers:i})=>{var s;if(this.ussd_detail=t.ussd,this.activeRef=t.reference||"",t.status==="failed"){this.onError(t.providerMessage||"Payment failed"),_.track("stop_ussdProcess",{payment_method:"USSD"});const o=i.get("spf-redirect-url");this.callBackUrl=o||this.callBackUrl,this.callBackUrl&&setTimeout(()=>{const a=new URL(this.callBackUrl);a.searchParams.append("status",t.status),a.searchParams.append("reference",t.reference),window.location.href=a.toString()},1800);return}else if(t.status!=="success")if(t.ussd){this.container.innerHTML=this.render();const o=this.container.querySelectorAll(".bank-dial-code"),a=this.container.querySelector("#bank-dial-code");a&&(a.innerHTML=((s=t==null?void 0:t.ussd)==null?void 0:s.paymentCode)||"");const l=this.container.querySelector("#bank-name-ussd");l&&(l.innerHTML=this.selected.name),Array.from(o).forEach(p=>{var m;p.innerHTML=((m=t==null?void 0:t.ussd)==null?void 0:m.code)||""}),this.attachListener();return}else if(t.providerMessage){this.onError(t.providerMessage);return}else{this.onError("Unable to fetch bank details");return}this.container.innerHTML=this.render(),this.attachListener()}).catch(t=>{t!=null&&t.message?this.onError(t.message):this.onError("Payment failed")})}attachListener(){const e=this.container.querySelectorAll(".copy-code-button"),t=this.container.querySelectorAll(".copy-code-button-1"),i=this.container.querySelector("#bank-completed-payment");Array.from(e).forEach(a=>{a.addEventListener("click",l=>{var c;_.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((c=this.ussd_detail)==null?void 0:c.code)||"")})}),Array.from(t).forEach(a=>{a.addEventListener("click",l=>{var c;_.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((c=this.ussd_detail)==null?void 0:c.code)||"")})}),i&&i.addEventListener("click",a=>{a.preventDefault(),this.onAction(this.selected,this.activeRef)})}renderComponent(){this.makePayment(),this.attachListener()}render(){return Tc}}var Ec=Object.defineProperty,Pc=(n,e,t,i)=>{for(var s=void 0,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=a(e,t,s)||s);return s&&Ec(e,t,s),s};class ma{constructor({container:e,onSuccess:t,secret:i,amount:s,totalAmount:o,currency:a,customer:l,reference:c,rdtCode:p,url:m,callBackUrl:g,metadata:b,localCurrency:y,hidePaymentMethods:w,showPaymentMethods:f,disablePaymentMethods:k}){d(this,"contents");d(this,"selectedCode");d(this,"secret");d(this,"amount");d(this,"totalAmount");d(this,"currency");d(this,"customer");d(this,"pageLoader");d(this,"reference");d(this,"onSuccess");d(this,"warningScreen");d(this,"bankDetail");d(this,"viewUssdCode");d(this,"_currentStep");d(this,"container");d(this,"paymentService");d(this,"successScreen");d(this,"activeRef","");d(this,"abortController");d(this,"_retry_count",10);d(this,"intervalPayment");d(this,"rdtCode");d(this,"url");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"merchantDetails");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"disablePaymentMethods");this.onSuccess=t||(()=>null),this.container=e,this.secret=i,this.amount=s,this.totalAmount=o,this.currency=a,this.reference=c,this.customer=l,this.rdtCode=p,this.url=m,this.callBackUrl=g,this.metadata=b,this.localCurrency=y,this.merchantDetails={},this.hidePaymentMethods=w,this.showPaymentMethods=f,this.disablePaymentMethods=k,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.paymentService=new ua({token:this.secret,rdtCode:this.rdtCode,url:this.url}),_.track("ussd_opens",{payment_method:"USSD"})}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderUssdContent()}onCodeSelect(e){this.selectedCode=e||"",this.currentStep=2}validate(){let e;if(this.abortController?e=this.abortController.signal:(this.abortController=new AbortController,e=this.abortController.signal),this._retry_count<=0){clearInterval(this.intervalPayment),this.currentStep=3;return}this.paymentService.verifyPayment(this.activeRef,e||this.abortController.signal).then(({data:t,headers:i})=>{t.status==="failed"?(this.currentStep=3,clearInterval(this.intervalPayment),this.redirectTo(t,i,"failed")):["successful","failed"].includes(t.status)?t.status==="inProgress"?this._retry_count-=1:["success","successful"].includes(t.status)&&(this.currentStep=5,clearInterval(this.intervalPayment),_.track("verify_payment",{payment_method:"USSD",verification_status:"Success"}),this.redirectTo(t,i,"success")):this._retry_count-=1}).catch(t=>{t.message?this.warningScreen.setPaymentError(t.message):this.warningScreen.setPaymentError("Payment failed"),this.currentStep=3,clearInterval(this.intervalPayment),_.track("verify_payment",{payment_method:"USSD",verification_status:"Failed"})})}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)}renderUssdContent(e){var t;if(e&&(this.merchantDetails=e),this.currentStep===3||this.currentStep===5?this.hidePaymentMethods():this.showPaymentMethods(),this.currentStep===2&&this.disablePaymentMethods("ussd"),this.currentStep!==1){const i=document.getElementById("go-back");i&&(i.classList.remove("flex","items-center","gap-2","mb-2"),i.innerHTML="")}switch(this.currentStep){case 1:this.bankDetail=new ha({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this),rdtCode:this.rdtCode,url:this.url,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate,amount:this.amount,totalAmount:this.totalAmount}),this.bankDetail.renderContent();break;case 2:this.viewUssdCode=new _c({container:this.contents,onAction:(i,s)=>{this.activeRef=s,this.currentStep=4,this.intervalPayment=setInterval(()=>{this.validate()},5e3)},selected:this.selectedCode||{},secret:this.secret,amount:this.amount,totalAmount:this.totalAmount,currency:this.currency,customer:this.customer,onError:i=>{this.currentStep=3,this.warningScreen.setPaymentError(i)},reference:this.reference,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency}),this.viewUssdCode.renderComponent();break;case 3:this.contents.innerHTML=Js,this.warningScreen=new en({container:this.contents});break;case 4:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader("25vh"),this.pageLoader.updateMessage("We are confirming transaction status. This might take a few seconds.","Please do not refresh this page");break;case 5:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(t=this.merchantDetails)==null?void 0:t.rate.rate}),this.successScreen.renderComponent();break;default:this.bankDetail=new ha({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this),rdtCode:this.rdtCode,url:this.url,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate,amount:this.amount,totalAmount:this.totalAmount}),this.bankDetail.renderContent();break}}handleSelectChange(e){setTimeout(()=>{this.currentStep=2},400),this.currentStep=2}}Pc([da(),da()],ma.prototype,"selectedCode");const Ic={NGN:"Nigerian Naira",USD:"US Dollar",GHS:"Ghanaian Cedi",GBP:"Pounds",ZAF:"South African Rand",USDT:"Tether",KSH:"Kenyan Shilling",EGP:"Egyptian Pound"},Dc={en:"English",fr:"Français",es:"Español",pt:"Português",ar:"Arabic"},Bc=n=>n==null?void 0:n.replace(/_/g," ");function pa(n){return n.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}const Rc=n=>{const e=/(\b[a-z](?!\s))/g;return n?n.toLowerCase().replace(e,t=>pa(t)):""},ui=n=>{if(n){const e=Bc(n);return pa(e)}return""},Hc=`<div>
|
|
1846
|
+
</div>`;class _c{constructor(e){d(this,"container");d(this,"selected");d(this,"secret");d(this,"onAction");d(this,"paymentService");d(this,"currency");d(this,"amount");d(this,"ussd_detail");d(this,"reference");d(this,"customer");d(this,"activeRef","");d(this,"pageLoader");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"onError");this.container=e.container,this.selected=e.selected,this.onAction=e.onAction,this.secret=e.secret,this.paymentService=new ua({token:this.secret,rdtCode:e.rdtCode,url:e.url}),this.currency=e.currency,this.amount=e.amount||0,this.customer=e.customer,this.reference=e.reference,this.callBackUrl=e.callBackUrl,this.metadata=e.metadata,this.localCurrency=e.localCurrency,this.onError=e.onError??(()=>null),this.pageLoader=new ke(this.container),this.pageLoader.mountLoader("25dvh"),this.pageLoader.updateMessage("Fetching selected bank code detail")}makePayment(){var e;_.track("start_ussdProcess",{payment_method:"USSD"}),this.paymentService.createUssdPayment({amount:this.amount,currency:this.currency,channel:"ussd",customer:this.customer,bank:{code:((e=this.selected)==null?void 0:e.code)||""},reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0}).then(({data:t,headers:i})=>{var s;if(this.ussd_detail=t.ussd,this.activeRef=t.reference||"",t.status==="failed"){this.onError(t.providerMessage||"Payment failed"),_.track("stop_ussdProcess",{payment_method:"USSD"});const o=i.get("spf-redirect-url");this.callBackUrl=o||this.callBackUrl,this.callBackUrl&&setTimeout(()=>{const a=new URL(this.callBackUrl);a.searchParams.append("status",t.status),a.searchParams.append("reference",t.reference),window.location.href=a.toString()},1800);return}else if(t.status!=="success")if(t.ussd){this.container.innerHTML=this.render();const o=this.container.querySelectorAll(".bank-dial-code"),a=this.container.querySelector("#bank-dial-code");a&&(a.innerHTML=((s=t==null?void 0:t.ussd)==null?void 0:s.paymentCode)||"");const l=this.container.querySelector("#bank-name-ussd");l&&(l.innerHTML=this.selected.name),Array.from(o).forEach(p=>{var m;p.innerHTML=((m=t==null?void 0:t.ussd)==null?void 0:m.code)||""}),this.attachListener();return}else if(t.providerMessage){this.onError(t.providerMessage);return}else{this.onError("Unable to fetch bank details");return}this.container.innerHTML=this.render(),this.attachListener()}).catch(t=>{t!=null&&t.message?this.onError(t.message):this.onError("Payment failed")})}attachListener(){const e=this.container.querySelectorAll(".copy-code-button"),t=this.container.querySelectorAll(".copy-code-button-1"),i=this.container.querySelector("#bank-completed-payment");Array.from(e).forEach(a=>{a.addEventListener("click",l=>{var c;_.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((c=this.ussd_detail)==null?void 0:c.code)||"")})}),Array.from(t).forEach(a=>{a.addEventListener("click",l=>{var c;_.track("copy_ussdCode",{payment_method:"USSD"}),window.navigator.clipboard.writeText(((c=this.ussd_detail)==null?void 0:c.code)||"")})}),i&&i.addEventListener("click",a=>{a.preventDefault(),this.onAction(this.selected,this.activeRef)})}renderComponent(){this.makePayment(),this.attachListener()}render(){return Tc}}var Ec=Object.defineProperty,Pc=(n,e,t,i)=>{for(var s=void 0,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=a(e,t,s)||s);return s&&Ec(e,t,s),s};class ma{constructor({container:e,onSuccess:t,secret:i,amount:s,totalAmount:o,currency:a,customer:l,reference:c,rdtCode:p,url:m,callBackUrl:g,metadata:b,localCurrency:y,hidePaymentMethods:w,showPaymentMethods:f,disablePaymentMethods:k}){d(this,"contents");d(this,"selectedCode");d(this,"secret");d(this,"amount");d(this,"totalAmount");d(this,"currency");d(this,"customer");d(this,"pageLoader");d(this,"reference");d(this,"onSuccess");d(this,"warningScreen");d(this,"bankDetail");d(this,"viewUssdCode");d(this,"_currentStep");d(this,"container");d(this,"paymentService");d(this,"successScreen");d(this,"activeRef","");d(this,"abortController");d(this,"_retry_count",10);d(this,"intervalPayment");d(this,"rdtCode");d(this,"url");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"merchantDetails");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"disablePaymentMethods");this.onSuccess=t||(()=>null),this.container=e,this.secret=i,this.amount=s,this.totalAmount=o,this.currency=a,this.reference=c,this.customer=l,this.rdtCode=p,this.url=m,this.callBackUrl=g,this.metadata=b,this.localCurrency=y,this.merchantDetails={},this.hidePaymentMethods=w,this.showPaymentMethods=f,this.disablePaymentMethods=k,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.paymentService=new ua({token:this.secret,rdtCode:this.rdtCode,url:this.url}),_.track("ussd_opens",{payment_method:"USSD"})}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderUssdContent()}onCodeSelect(e){this.selectedCode=e||"",this.currentStep=2}validate(){let e;if(this.abortController?e=this.abortController.signal:(this.abortController=new AbortController,e=this.abortController.signal),this._retry_count<=0){clearInterval(this.intervalPayment),this.currentStep=3;return}this.paymentService.verifyPayment(this.activeRef,e||this.abortController.signal).then(({data:t,headers:i})=>{t.status==="failed"?(this.currentStep=3,clearInterval(this.intervalPayment),this.redirectTo(t,i,"failed")):["successful","failed"].includes(t.status)?t.status==="inProgress"?this._retry_count-=1:["success","successful"].includes(t.status)&&(this.currentStep=5,clearInterval(this.intervalPayment),_.track("verify_payment",{payment_method:"USSD",verification_status:"Success"}),this.redirectTo(t,i,"success")):this._retry_count-=1}).catch(t=>{t.message?this.warningScreen.setPaymentError(t.message):this.warningScreen.setPaymentError("Payment failed"),this.currentStep=3,clearInterval(this.intervalPayment),_.track("verify_payment",{payment_method:"USSD",verification_status:"Failed"})})}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)}renderUssdContent(e){var t;if(e&&(this.merchantDetails=e),this.currentStep===3||this.currentStep===5?this.hidePaymentMethods():this.showPaymentMethods(),this.currentStep===2&&this.disablePaymentMethods("ussd"),this.currentStep!==1){const i=document.getElementById("go-back");i&&(i.classList.remove("flex","items-center","gap-2","mb-2"),i.innerHTML="")}switch(this.currentStep){case 1:this.bankDetail=new ha({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this),rdtCode:this.rdtCode,url:this.url,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate,amount:this.amount,totalAmount:this.totalAmount}),this.bankDetail.renderContent();break;case 2:this.viewUssdCode=new _c({container:this.contents,onAction:(i,s)=>{this.activeRef=s,this.currentStep=4,this.intervalPayment=setInterval(()=>{this.validate()},5e3)},selected:this.selectedCode||{},secret:this.secret,amount:this.amount,totalAmount:this.totalAmount,currency:this.currency,customer:this.customer,onError:i=>{this.currentStep=3,this.warningScreen.setPaymentError(i)},reference:this.reference,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency}),this.viewUssdCode.renderComponent();break;case 3:this.contents.innerHTML=Js,this.warningScreen=new en({container:this.contents});break;case 4:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader("25vh"),this.pageLoader.updateMessage("We are confirming transaction status. This might take a few seconds.","Please do not refresh this page");break;case 5:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(t=this.merchantDetails)==null?void 0:t.rate.rate}),this.successScreen.renderComponent();break;default:this.bankDetail=new ha({container:this.contents,merchantKey:this.secret,onAction:this.onCodeSelect.bind(this),rdtCode:this.rdtCode,url:this.url,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate,amount:this.amount,totalAmount:this.totalAmount}),this.bankDetail.renderContent();break}}handleSelectChange(e){setTimeout(()=>{this.currentStep=2},400),this.currentStep=2}}Pc([da(),da()],ma.prototype,"selectedCode");const Ic={NGN:"Nigerian Naira",USD:"US Dollar",GHS:"Ghanaian Cedi",GBP:"Pounds",ZAF:"South African Rand",USDT:"Tether",KSH:"Kenyan Shilling",EGP:"Egyptian Pound"},Dc={en:"English",fr:"Français",es:"Español",pt:"Português",ar:"Arabic",zh:"Chinese",hi:"Hindi",nl:"Dutch",et:"Estonian",pl:"Polish"},Bc=n=>n==null?void 0:n.replace(/_/g," ");function pa(n){return n.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}const Rc=n=>{const e=/(\b[a-z](?!\s))/g;return n?n.toLowerCase().replace(e,t=>pa(t)):""},ui=n=>{if(n){const e=Bc(n);return pa(e)}return""},Hc=`<div>
|
|
1847
1847
|
<div>
|
|
1848
1848
|
<button id="go-back" class="md:hidden" aria-label="Go back">
|
|
1849
1849
|
</button>
|
|
@@ -1991,7 +1991,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
1991
1991
|
<!-- Tab options -->
|
|
1992
1992
|
</div>
|
|
1993
1993
|
</div>
|
|
1994
|
-
</div>`;class Nc{constructor(e){d(this,"container");d(this,"email");d(this,"amount",0);d(this,"metadata");d(this,"currency");d(this,"localCurrency");d(this,"mainLoader");d(this,"trialAmount");d(this,"trial");d(this,"merchantDetail");d(this,"onAction");d(this,"isMobile");d(this,"onClose");d(this,"currentPaymentMethod");d(this,"countryCode");this.container=e.container,this.email=e.email,this.amount=e.amount||0,this.metadata=e.metadata,this.currency=e.currency,this.localCurrency=e.localCurrency,this.merchantDetail=e.merchantDetail,this.onAction=e.onAction,this.isMobile=e.isMobile,this.trial=e.trial,this.onClose=e.onClose,this.trialAmount=e.trialAmount,this.currentPaymentMethod=e.currentPaymentMethod,this.countryCode=this.countryCode=e.currency==="XOF"||e.currency==="XAF"||e.localCurrency==="XOF"||e.localCurrency==="XAF"?e.countryCode:""}attachListeners(){const e=this.container.querySelectorAll(".tab-button");Array.from(e).forEach(o=>{const a=o.dataset.name||"",l=o.querySelector(".tab-button-icon"),c=o.querySelector(".tab-button-label");l&&(l.innerHTML=se[a].icon),c&&(c.textContent=se[a].label),o.addEventListener("click",p=>{p.preventDefault(),this.onAction(a)})});const i=this.container.querySelector("#close-btn");i&&i.addEventListener("click",()=>{this.onClose(!0)});const s=document.getElementById("go-back");s==null||s.addEventListener("click",()=>{this.onAction("")})}renderComponent(){var wn,Wn,On,je,kn,Zn,me,xe,Qe,ze,De,hn,H,ye,te,Ce,qe,ne,Un,Bt,hi,mi,pi,vi,Qn,bi,re,fi,gi,yi,Ci,wi,ki,Si,gt,yt,xi,Ai,Mi,Li,Ct,Je,Ti,Sn,_i,Rt;this.container.innerHTML=this.render(),this.mainLoader=new ke(this.container),this.amount=this.amount;const e=this.container.querySelector("#merchant-logo-container"),t=this.container.querySelector("#merchant-logo"),i=this.container.querySelector("#merchant-email"),s=this.container.querySelector("#merchant-email-mob"),o=this.container.querySelector("#trial-info"),a=this.container.querySelector("#todays-total-amount"),l=this.container.querySelector("#plan-name"),c=this.container.querySelector("#plan-name-mob"),p=this.container.querySelector("#payment-fees"),m=this.container.querySelector("#currency-cursor"),g=this.container.querySelector("#currency-cursor-mob"),b=this.container.querySelector("#payment-rate-display"),y=this.container.querySelector("#payment-rate-display-mob"),w=this.container.querySelector("#designated-rate"),f=this.container.querySelector("#designated-rate-mob"),k=this.container.querySelector("#designated-rate-no-plan"),x=this.container.querySelector("#source-rate"),A=this.container.querySelector("#source-rate-mob"),M=this.container.querySelector("#tax-rate"),E=this.container.querySelector("#tax-rate-mob"),D=this.container.querySelector("#tooltip-localCurrency"),G=this.container.querySelector("#tooltip-localCurrency-mob"),Z=this.container.querySelector("#select-payment-method-text"),K=this.container.querySelector("#amount-text"),Q=this.container.querySelector("#what-is-this"),de=this.container.querySelector("#reflect"),_e=this.container.querySelector("#please-note"),j=this.container.querySelector("#what-is-this-mob"),Oe=this.container.querySelector("#reflect-mob"),ge=this.container.querySelector("#please-note-mob"),Ge=this.container.querySelector("#to-pay-text"),Se=this.container.querySelector("#language-dropdown");if(Se){const an=this.currency==="USD"?this.localCurrency:this.currency,Vn=(wn=Ni(an,this.countryCode))==null?void 0:wn.language,xn=new Set;xn.add("en"),Vn&&Vn!=="en"&&xn.add(Vn),Ae.getTranslationError()||pn&&!xn.has(pn)&&xn.add(pn),xn.size===1?Se.classList.add("hidden"):Se.classList.remove("hidden"),xn.forEach(Ye=>{const mn=new Option(Ye,Ye);mn.value=Ye,mn.text=Dc[Ye]||Ye,Ye===R()&&(mn.selected=!0),Se.appendChild(mn)}),Ae.subscribeToLoading(Ye=>{Se.disabled=Ye}),Se.addEventListener("change",async Ye=>{const Ei=Ye.target.value;it(Ei);try{await Ae.setLanguage(Ei)}catch(Pi){console.error("Failed to change language:",Pi)}finally{}})}if(Z&&(Z.innerHTML=q.select_payment_method_text),K&&(K.innerHTML=`${q.amount}:`),Ge&&(Ge.innerHTML=`${q["to-pay"]}:`),Q&&(Q.innerHTML=P["what-is-this"]),de&&(de.innerHTML=P["rate-reflect-note"]),_e&&(_e.innerHTML=P["rate-please-note"]),j&&(j.innerHTML=P["what-is-this"]),Oe&&(Oe.innerHTML=P["rate-reflect-note"]),ge&&(ge.innerHTML=P["rate-please-note"]),(Wn=this.merchantDetail)!=null&&Wn.merchantLogo?t&&t.setAttribute("src",(On=this.merchantDetail)==null?void 0:On.merchantLogo):e&&(t==null||t.remove(),e.innerHTML=`<div class="font-semibold text-tone-100 rounded-2xl w-8 h-8 bg-tone-10 container-center uppercase">${this.merchantDetail.merchantName[0]}</div>`),i&&(i.innerHTML=this.email),s&&(s.innerHTML=this.email),l){if((kn=(je=this.merchantDetail)==null?void 0:je.plan)!=null&&kn.title){const an=((me=(Zn=this.merchantDetail)==null?void 0:Zn.plan)==null?void 0:me.title)||"";l.textContent=ui(an)}(xe=this.metadata)!=null&&xe.productName&&(l.textContent=ui(this.metadata.productName))}if(c){if((ze=(Qe=this.merchantDetail)==null?void 0:Qe.plan)!=null&&ze.title){const an=((hn=(De=this.merchantDetail)==null?void 0:De.plan)==null?void 0:hn.title)||"";c.textContent=ui(an)}(H=this.metadata)!=null&&H.productName&&(c.textContent=ui(this.metadata.productName))}if(m&&(this.currency==="USD"?b&&(b.innerHTML=`1 ${((te=(ye=this.merchantDetail)==null?void 0:ye.rate)==null?void 0:te.to)||"-"} = ${((qe=(Ce=this.merchantDetail)==null?void 0:Ce.rate)==null?void 0:qe.from)||"-"} ${Te(((ne=this.merchantDetail.rate)==null?void 0:ne.rate)||1,2)} `):m.innerHTML=""),g&&(this.currency==="USD"?y&&(y.innerHTML=`1 ${((Bt=(Un=this.merchantDetail)==null?void 0:Un.rate)==null?void 0:Bt.to)||"-"} = ${((mi=(hi=this.merchantDetail)==null?void 0:hi.rate)==null?void 0:mi.from)||"-"} ${Te(((pi=this.merchantDetail.rate)==null?void 0:pi.rate)||1,2)} `):g.innerHTML=""),(Qn=(vi=this.merchantDetail)==null?void 0:vi.plan)!=null&&Qn.title||(bi=this.metadata)!=null&&bi.productName?w&&(((fi=(re=this.merchantDetail)==null?void 0:re.plan)==null?void 0:fi.trial)?(o==null||o.classList.remove("hidden"),w.innerHTML=`${this.currency} ${Te(this.amount,2)}`):(w.innerHTML=`${this.currency} ${Te(this.amount,2)}`,o==null||o.classList.add("hidden"))):(k&&(k.innerHTML=`<span> ${this.currency} ${Te(this.amount,2)} </span>`),l&&c&&(l.remove(),c==null||c.remove()),this.localCurrency?w==null||w.remove():p&&p.remove()),f){const an=(yi=(gi=this.merchantDetail)==null?void 0:gi.plan)==null?void 0:yi.trial,Vn=(Si=(ki=(wi=(Ci=this.merchantDetail)==null?void 0:Ci.plan)==null?void 0:wi.trial)==null?void 0:ki.pricingList[0])==null?void 0:Si.amount;an&&a?(a.textContent=`${this.currency} ${Te(Vn,2)}`,f.innerHTML=`${this.currency} ${Te(this.amount,2)}`):f.innerHTML=`${this.currency} ${Te(this.amount,2)}`}x&&(this.localCurrency&&this.localCurrency!==this.currency?x.children[1].innerHTML=`${this.localCurrency} ${Te(this.amount*(((yt=(gt=this.merchantDetail)==null?void 0:gt.rate)==null?void 0:yt.rate)||1),2)}`:x.remove()),A&&(this.localCurrency&&this.localCurrency!==this.currency?A.children[1].innerHTML=`${this.localCurrency} ${Te(this.amount*(((Ai=(xi=this.merchantDetail)==null?void 0:xi.rate)==null?void 0:Ai.rate)||1),2)}`:A.remove());const Cn=this.localCurrency!==this.currency?this.amount*(((Li=(Mi=this.merchantDetail)==null?void 0:Mi.rate)==null?void 0:Li.rate)||1):this.amount;M&&(Ct=this.merchantDetail)!=null&&Ct.taxQuoteId&&(Je=this.merchantDetail)!=null&&Je.totalAmount&&(M.classList.remove("hidden"),M.children[1].innerHTML=`${this.localCurrency!==this.currency?this.localCurrency:this.currency} ${Te(((Ti=this.merchantDetail)==null?void 0:Ti.totalAmount)-Cn,2)}`),E&&(Sn=this.merchantDetail)!=null&&Sn.taxQuoteId&&(_i=this.merchantDetail)!=null&&_i.totalAmount&&(E.classList.remove("hidden"),E.children[1].innerHTML=`${this.localCurrency!==this.currency?this.localCurrency:this.currency} ${Te(((Rt=this.merchantDetail)==null?void 0:Rt.totalAmount)-Cn,2)}`);const un=Ic[this.localCurrency];D&&this.localCurrency&&(D.innerHTML=un?`${un} (${this.localCurrency})`:this.localCurrency),G&&this.localCurrency&&(G.innerHTML=un?`${un} (${this.localCurrency})`:this.localCurrency),this.renderPaymentOptions(this.container),this.attachListeners()}renderPaymentOptions(e){const t=e.querySelector(".payment-options"),i=Hn(this.currency,this.localCurrency);if(t){const s=this.merchantDetail.plan?[se.
|
|
1994
|
+
</div>`;class Nc{constructor(e){d(this,"container");d(this,"email");d(this,"amount",0);d(this,"metadata");d(this,"currency");d(this,"localCurrency");d(this,"mainLoader");d(this,"trialAmount");d(this,"trial");d(this,"merchantDetail");d(this,"onAction");d(this,"isMobile");d(this,"onClose");d(this,"currentPaymentMethod");d(this,"countryCode");this.container=e.container,this.email=e.email,this.amount=e.amount||0,this.metadata=e.metadata,this.currency=e.currency,this.localCurrency=e.localCurrency,this.merchantDetail=e.merchantDetail,this.onAction=e.onAction,this.isMobile=e.isMobile,this.trial=e.trial,this.onClose=e.onClose,this.trialAmount=e.trialAmount,this.currentPaymentMethod=e.currentPaymentMethod,this.countryCode=this.countryCode=e.currency==="XOF"||e.currency==="XAF"||e.localCurrency==="XOF"||e.localCurrency==="XAF"?e.countryCode:""}attachListeners(){const e=this.container.querySelectorAll(".tab-button");Array.from(e).forEach(o=>{const a=o.dataset.name||"",l=o.querySelector(".tab-button-icon"),c=o.querySelector(".tab-button-label");l&&(l.innerHTML=se[a].icon),c&&(c.textContent=se[a].label),o.addEventListener("click",p=>{p.preventDefault(),this.onAction(a)})});const i=this.container.querySelector("#close-btn");i&&i.addEventListener("click",()=>{this.onClose(!0)});const s=document.getElementById("go-back");s==null||s.addEventListener("click",()=>{this.onAction("")})}renderComponent(){var wn,Wn,On,je,kn,Zn,me,xe,Qe,ze,De,hn,H,ye,te,Ce,qe,ne,Un,Bt,hi,mi,pi,vi,Qn,bi,re,fi,gi,yi,Ci,wi,ki,Si,gt,yt,xi,Ai,Mi,Li,Ct,Je,Ti,Sn,_i,Rt;this.container.innerHTML=this.render(),this.mainLoader=new ke(this.container),this.amount=this.amount;const e=this.container.querySelector("#merchant-logo-container"),t=this.container.querySelector("#merchant-logo"),i=this.container.querySelector("#merchant-email"),s=this.container.querySelector("#merchant-email-mob"),o=this.container.querySelector("#trial-info"),a=this.container.querySelector("#todays-total-amount"),l=this.container.querySelector("#plan-name"),c=this.container.querySelector("#plan-name-mob"),p=this.container.querySelector("#payment-fees"),m=this.container.querySelector("#currency-cursor"),g=this.container.querySelector("#currency-cursor-mob"),b=this.container.querySelector("#payment-rate-display"),y=this.container.querySelector("#payment-rate-display-mob"),w=this.container.querySelector("#designated-rate"),f=this.container.querySelector("#designated-rate-mob"),k=this.container.querySelector("#designated-rate-no-plan"),x=this.container.querySelector("#source-rate"),A=this.container.querySelector("#source-rate-mob"),M=this.container.querySelector("#tax-rate"),E=this.container.querySelector("#tax-rate-mob"),D=this.container.querySelector("#tooltip-localCurrency"),G=this.container.querySelector("#tooltip-localCurrency-mob"),Z=this.container.querySelector("#select-payment-method-text"),K=this.container.querySelector("#amount-text"),Q=this.container.querySelector("#what-is-this"),de=this.container.querySelector("#reflect"),_e=this.container.querySelector("#please-note"),j=this.container.querySelector("#what-is-this-mob"),Oe=this.container.querySelector("#reflect-mob"),ge=this.container.querySelector("#please-note-mob"),Ge=this.container.querySelector("#to-pay-text"),Se=this.container.querySelector("#language-dropdown");if(Se){const an=this.currency==="USD"?this.localCurrency:this.currency,Vn=(wn=Ni(an,this.countryCode))==null?void 0:wn.language,xn=new Set;xn.add("en"),Vn&&Vn!=="en"&&xn.add(Vn),Ae.getTranslationError()||pn&&!xn.has(pn)&&xn.add(pn),xn.size===1?Se.classList.add("hidden"):Se.classList.remove("hidden"),xn.forEach(Ye=>{const mn=new Option(Ye,Ye);mn.value=Ye,mn.text=Dc[Ye]||Ye,Ye===R()&&(mn.selected=!0),Se.appendChild(mn)}),Ae.subscribeToLoading(Ye=>{Se.disabled=Ye}),Se.addEventListener("change",async Ye=>{const Ei=Ye.target.value;it(Ei);try{await Ae.setLanguage(Ei)}catch(Pi){console.error("Failed to change language:",Pi)}finally{}})}if(Z&&(Z.innerHTML=q.select_payment_method_text),K&&(K.innerHTML=`${q.amount}:`),Ge&&(Ge.innerHTML=`${q["to-pay"]}:`),Q&&(Q.innerHTML=P["what-is-this"]),de&&(de.innerHTML=P["rate-reflect-note"]),_e&&(_e.innerHTML=P["rate-please-note"]),j&&(j.innerHTML=P["what-is-this"]),Oe&&(Oe.innerHTML=P["rate-reflect-note"]),ge&&(ge.innerHTML=P["rate-please-note"]),(Wn=this.merchantDetail)!=null&&Wn.merchantLogo?t&&t.setAttribute("src",(On=this.merchantDetail)==null?void 0:On.merchantLogo):e&&(t==null||t.remove(),e.innerHTML=`<div class="font-semibold text-tone-100 rounded-2xl w-8 h-8 bg-tone-10 container-center uppercase">${this.merchantDetail.merchantName[0]}</div>`),i&&(i.innerHTML=this.email),s&&(s.innerHTML=this.email),l){if((kn=(je=this.merchantDetail)==null?void 0:je.plan)!=null&&kn.title){const an=((me=(Zn=this.merchantDetail)==null?void 0:Zn.plan)==null?void 0:me.title)||"";l.textContent=ui(an)}(xe=this.metadata)!=null&&xe.productName&&(l.textContent=ui(this.metadata.productName))}if(c){if((ze=(Qe=this.merchantDetail)==null?void 0:Qe.plan)!=null&&ze.title){const an=((hn=(De=this.merchantDetail)==null?void 0:De.plan)==null?void 0:hn.title)||"";c.textContent=ui(an)}(H=this.metadata)!=null&&H.productName&&(c.textContent=ui(this.metadata.productName))}if(m&&(this.currency==="USD"?b&&(b.innerHTML=`1 ${((te=(ye=this.merchantDetail)==null?void 0:ye.rate)==null?void 0:te.to)||"-"} = ${((qe=(Ce=this.merchantDetail)==null?void 0:Ce.rate)==null?void 0:qe.from)||"-"} ${Te(((ne=this.merchantDetail.rate)==null?void 0:ne.rate)||1,2)} `):m.innerHTML=""),g&&(this.currency==="USD"?y&&(y.innerHTML=`1 ${((Bt=(Un=this.merchantDetail)==null?void 0:Un.rate)==null?void 0:Bt.to)||"-"} = ${((mi=(hi=this.merchantDetail)==null?void 0:hi.rate)==null?void 0:mi.from)||"-"} ${Te(((pi=this.merchantDetail.rate)==null?void 0:pi.rate)||1,2)} `):g.innerHTML=""),(Qn=(vi=this.merchantDetail)==null?void 0:vi.plan)!=null&&Qn.title||(bi=this.metadata)!=null&&bi.productName?w&&(((fi=(re=this.merchantDetail)==null?void 0:re.plan)==null?void 0:fi.trial)?(o==null||o.classList.remove("hidden"),w.innerHTML=`${this.currency} ${Te(this.amount,2)}`):(w.innerHTML=`${this.currency} ${Te(this.amount,2)}`,o==null||o.classList.add("hidden"))):(k&&(k.innerHTML=`<span> ${this.currency} ${Te(this.amount,2)} </span>`),l&&c&&(l.remove(),c==null||c.remove()),this.localCurrency?w==null||w.remove():p&&p.remove()),f){const an=(yi=(gi=this.merchantDetail)==null?void 0:gi.plan)==null?void 0:yi.trial,Vn=(Si=(ki=(wi=(Ci=this.merchantDetail)==null?void 0:Ci.plan)==null?void 0:wi.trial)==null?void 0:ki.pricingList[0])==null?void 0:Si.amount;an&&a?(a.textContent=`${this.currency} ${Te(Vn,2)}`,f.innerHTML=`${this.currency} ${Te(this.amount,2)}`):f.innerHTML=`${this.currency} ${Te(this.amount,2)}`}x&&(this.localCurrency&&this.localCurrency!==this.currency?x.children[1].innerHTML=`${this.localCurrency} ${Te(this.amount*(((yt=(gt=this.merchantDetail)==null?void 0:gt.rate)==null?void 0:yt.rate)||1),2)}`:x.remove()),A&&(this.localCurrency&&this.localCurrency!==this.currency?A.children[1].innerHTML=`${this.localCurrency} ${Te(this.amount*(((Ai=(xi=this.merchantDetail)==null?void 0:xi.rate)==null?void 0:Ai.rate)||1),2)}`:A.remove());const Cn=this.localCurrency!==this.currency?this.amount*(((Li=(Mi=this.merchantDetail)==null?void 0:Mi.rate)==null?void 0:Li.rate)||1):this.amount;M&&(Ct=this.merchantDetail)!=null&&Ct.taxQuoteId&&(Je=this.merchantDetail)!=null&&Je.totalAmount&&(M.classList.remove("hidden"),M.children[1].innerHTML=`${this.localCurrency!==this.currency?this.localCurrency:this.currency} ${Te(((Ti=this.merchantDetail)==null?void 0:Ti.totalAmount)-Cn,2)}`),E&&(Sn=this.merchantDetail)!=null&&Sn.taxQuoteId&&(_i=this.merchantDetail)!=null&&_i.totalAmount&&(E.classList.remove("hidden"),E.children[1].innerHTML=`${this.localCurrency!==this.currency?this.localCurrency:this.currency} ${Te(((Rt=this.merchantDetail)==null?void 0:Rt.totalAmount)-Cn,2)}`);const un=Ic[this.localCurrency];D&&this.localCurrency&&(D.innerHTML=un?`${un} (${this.localCurrency})`:this.localCurrency),G&&this.localCurrency&&(G.innerHTML=un?`${un} (${this.localCurrency})`:this.localCurrency),this.renderPaymentOptions(this.container),this.attachListeners()}renderPaymentOptions(e){const t=e.querySelector(".payment-options"),i=Hn(this.currency,this.localCurrency);if(t){const s=this.merchantDetail.plan?[se.mobile_money]:this.merchantDetail.paymentMethods.filter(o=>o!=="ussd").filter(o=>!(i!=="USD"&&o==="stablecoin")).map(o=>se[o]);if(this.isMobile){let o='<div class="">';s.forEach(a=>{o+=`
|
|
1995
1995
|
<div key=${a.key}>
|
|
1996
1996
|
<button class="tab-button gap-2 mb-4 group" data-name="${a.key}">
|
|
1997
1997
|
<div class="lg:block">${a.icon}</div>
|
|
@@ -2217,7 +2217,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
2217
2217
|
</div>
|
|
2218
2218
|
</div>
|
|
2219
2219
|
</div>
|
|
2220
|
-
</div>`;class zc{constructor(e){d(this,"container");d(this,"onAction");d(this,"callBackUrl");d(this,"paymentResponse");d(this,"paymentResponseHeaders");d(this,"paymentMethod");this.container=e.container,this.onAction=e.onAction,this.callBackUrl=e.callBackUrl,this.paymentResponse=e.paymentResponse,this.paymentResponseHeaders=e.paymentResponseHeaders,this.paymentMethod=e.paymentMethod}attachListeners(){const e=this.container.querySelector(".details-form-button"),t=this.container.querySelector("#mobile-money-button-text"),i=this.container.querySelector("#long-processing-text"),s=this.container.querySelector("#confirmed-text");i&&(i.innerHTML=P["long-processing"]),s&&(s.innerHTML=P["once-confirmed"]),t&&(t.innerHTML=q["merchant-back"]),e&&e.addEventListener("click",()=>{var o;_.track("redirect_to_merchant",{payment_method:this.paymentMethod,status:(o=this.paymentResponse)==null?void 0:o.status}),Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)})}renderComponent(){var e;this.container.innerHTML=this.render(),_.track("payment_timeout",{payment_method:this.paymentMethod,status:(e=this.paymentResponse)==null?void 0:e.status}),this.attachListeners()}render(){return jc}}class qc{constructor({container:e,merchantKey:t,localCurrency:i,metadata:s,callBackUrl:o,rdtCode:a,reference:l,onSuccess:c,url:p,customer:m,amount:g,totalAmount:b,token:y,currency:w,disablePaymentMethods:f,hidePaymentMethods:k,showPaymentMethods:x,onClose:A,restartTransactionProcess:M,retryingPayment:E,countryCode:D}){d(this,"contents");d(this,"mobileMoneyForm");d(this,"mobileMoneyValidationForm");d(this,"onSuccess");d(this,"mobileMoneyConfirmation");d(this,"mobileMoneyConfirmationEnd");d(this,"transactionIssuesScreen");d(this,"container");d(this,"pageLoader");d(this,"mainLoader");d(this,"_currentStep");d(this,"successScreen");d(this,"customer");d(this,"activeRef");d(this,"warningScreen");d(this,"amount");d(this,"totalAmount");d(this,"url");d(this,"reference");d(this,"metadata");d(this,"currency");d(this,"localCurrency");d(this,"token");d(this,"callBackUrl");d(this,"rdtCode");d(this,"merchantDetails");d(this,"onClose");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"disablePaymentMethods");d(this,"paymentResponse");d(this,"paymentResponseHeaders");d(this,"restartTransactionProcess");d(this,"retryingPayment");d(this,"isMaxRetriesReached");d(this,"isMobile",!1);d(this,"countryCode");d(this,"errorText");d(this,"otpMessage");this.container=e,this.onSuccess=c||(()=>null),this.token=y,this.currency=w,this.amount=g,this.totalAmount=b,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.activeRef="",this.token=t,this.customer=m,this.metadata=s,this.localCurrency=i,this.callBackUrl=o,this.localCurrency=i,this.rdtCode=a,this.url=p,this.reference=l,this.merchantDetails={},this.disablePaymentMethods=f,this.hidePaymentMethods=k,this.showPaymentMethods=x,this.onClose=A,this.paymentResponse={},this.paymentResponseHeaders={},this.restartTransactionProcess=M,this.retryingPayment=E,this.isMaxRetriesReached=!1,this.countryCode=D,this.errorText="",this.otpMessage="",_.track("mobile_money_opens",{payment_method:"Mobile Money"}),this.isMobile=window.matchMedia("(max-width: 767px)").matches}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderMobileMoneyContent()}attachInputListeners(){}async createMobileMoney(e,t){e.stopPropagation(),e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#mobile-money-button-text");i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden"));const o=ft();(()=>{var l,c;if(this.retryingPayment){const p={channel:"mobile_money",reference:this.reference,mobileMoney:{code:t.code,phoneNumber:t.phoneNumber,...t.otp&&{otp:t.otp}}};return et(this.token,p,this.rdtCode,this.url)}else{const p={amount:this.amount,channel:"mobile_money",currency:this.currency,customer:this.customer,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,mobileMoney:{code:t.code,phoneNumber:t.phoneNumber,...t.otp&&{otp:t.otp}},...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((l=this.merchantDetails)==null?void 0:l.taxQuoteId)&&{taxQuoteId:(c=this.merchantDetails)==null?void 0:c.taxQuoteId},...this.countryCode&&{countryCode:this.countryCode},deviceInformation:o};return Na(this.token,p,this.rdtCode,this.url)}})().then(async({data:l,headers:c})=>{var p,m;if(this.paymentResponse=l,this.paymentResponseHeaders=c,l.providerMessage){const g=await z(l.providerMessage,R());this.errorText=g}if(l.status==="failed"){if(l.providerMessage){const g=await z(l.providerMessage,R());this.currentStep=5,this.warningScreen.setPaymentError(g),this.warningScreen.hideReportIssue()}else this.currentStep=5,this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();_.track("start_payment_failed",{payment_method:"Mobile Money",verification_status:"Failed",payment_error:l.providerMessage||"Payment failed"});return}else if(l.status==="success"||l.status==="successful"){this.currentStep=4,_.track("start_payment_success",{payment_method:"Mobile Money",verification_status:"Success"}),Pe(l,c,l==null?void 0:l.callBackUrl);return}else if(((p=l==null?void 0:l.authorization)==null?void 0:p.mode)==="otp"){this.activeRef=l.reference;const g=await z((m=this.paymentResponse)==null?void 0:m.providerMessage,R());this.otpMessage=g,this.currentStep=6;return}else this.currentStep=3}).catch(async l=>{if(_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Null"}),l.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyPaymentProcess(),this.currentStep=5,this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else{const c=await z(l.message,R());this.errorText=c,l.message?(this.currentStep=5,this.warningScreen.setPaymentError(this.errorText)):(this.currentStep=5,this.warningScreen.setPaymentError(P["payment-failed"]))}this.warningScreen.hideReportIssue()}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}showLoader(){this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader()}submitOtp(e,t){e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#mobile-money-button-text"),o={authorization:{otp:t},reference:this.activeRef};_.track("input_MobileMoneyOTP",{payment_method:"Mobile Money",authentication_type:"0TP"}),i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden")),Ot(this.token,o,this.rdtCode,this.url).then(({data:l})=>{l.status==="failed"?(this.activeRef=l.reference,this.currentStep=3):["success","successful","failed"].includes(l.status)?["success","successful"].includes(l.status)&&(this.activeRef=l.reference,this.currentStep=3):(this.activeRef=l.reference,this.currentStep=3)}).catch(async l=>{_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Failed",authentication_type:"OTP"});const c=this.container.querySelector("#otp-error");if(l.code==="invalid_otp"){if(c){const p=await z(l.message,R());c.innerHTML=p}_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Failed",authentication_type:"OTP"})}else this.currentStep=3}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}async verifyPaymentProcess(){try{const e=await Xe(this.token,this.reference,void 0,this.rdtCode,this.url);this.paymentResponse=e.data,this.paymentResponseHeaders=e.headers}catch{this.currentStep=5}}goBackToMerchant(){Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)}renderMobileMoneyContent(e){if(e&&(this.merchantDetails=e),this.currentStep===3&&this.disablePaymentMethods("mobile_money"),this.currentStep!==1){const t=document.getElementById("go-back");t&&(t.classList.remove("flex","items-center","gap-2","mb-2"),t.innerHTML="")}switch(this.currentStep===6?this.hidePaymentMethods():this.showPaymentMethods(),this.isMobile&&this.hidePaymentMethods(),this.currentStep){case 1:this.mobileMoneyForm=new Fc({container:this.contents,merchantKey:this.token,url:this.url,onAction:t=>i=>this.createMobileMoney.bind(this)(t,i),ref:this.activeRef,switchScreen:t=>{this.currentStep=t},rdtCode:this.rdtCode,currency:this.currency,localCurrency:this.localCurrency,amount:this.amount,totalAmount:this.totalAmount,restartTransactionProcess:this.restartTransactionProcess.bind(this),merchantDetails:this.merchantDetails,countryCode:this.countryCode||""}),this.mobileMoneyForm.renderContent();break;case 2:this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),this.mainLoader.updateMessage(Me["please-wait"]);break;case 3:this.mobileMoneyConfirmation=new Uc({container:this.contents,onAction:t=>{this.currentStep=t},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(t,i)=>{this.paymentResponse=t,this.paymentResponseHeaders=i}}),this.mobileMoneyConfirmation.renderComponent();break;case 4:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate}),this.successScreen.renderComponent();break;case 5:this.warningScreen=new en({container:this.contents,onReportIssue:()=>this.currentStep=9,onAction:this.isMaxRetriesReached?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this)}),this.contents.innerHTML=this.warningScreen.render(),this.warningScreen.attachListener();break;case 6:this.mobileMoneyValidationForm=new Gc({container:this.contents,onClose:this.onClose,onAction:t=>i=>this.submitOtp.bind(this)(t,i),otpMessage:this.otpMessage||Me["enter-phone-otp"]}),this.mobileMoneyValidationForm.renderComponent();break;case 7:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Verifying Payment");break;case 8:this.mobileMoneyConfirmationEnd=new zc({container:this.contents,onAction:t=>{this.currentStep=t},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders,paymentMethod:"Mobile Money"}),this.mobileMoneyConfirmationEnd.renderComponent();break;case 9:this.transactionIssuesScreen=new st({container:this.contents,onAction:()=>{var t;this.currentStep=5,this.warningScreen.setPaymentError(((t=this.paymentResponse)==null?void 0:t.providerMessage)||"Payment failed")},url:this.url,rdtCode:this.rdtCode,token:this.token,paymentChannel:"mobile_money",callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break}this.attachInputListeners()}}const Wc=`<div id="eft-authenticate-container" data-section="eft">
|
|
2220
|
+
</div>`;class zc{constructor(e){d(this,"container");d(this,"onAction");d(this,"callBackUrl");d(this,"paymentResponse");d(this,"paymentResponseHeaders");d(this,"paymentMethod");this.container=e.container,this.onAction=e.onAction,this.callBackUrl=e.callBackUrl,this.paymentResponse=e.paymentResponse,this.paymentResponseHeaders=e.paymentResponseHeaders,this.paymentMethod=e.paymentMethod}attachListeners(){const e=this.container.querySelector(".details-form-button"),t=this.container.querySelector("#mobile-money-button-text"),i=this.container.querySelector("#long-processing-text"),s=this.container.querySelector("#confirmed-text");i&&(i.innerHTML=P["long-processing"]),s&&(s.innerHTML=P["once-confirmed"]),t&&(t.innerHTML=q["merchant-back"]),e&&e.addEventListener("click",()=>{var o;_.track("redirect_to_merchant",{payment_method:this.paymentMethod,status:(o=this.paymentResponse)==null?void 0:o.status}),Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)})}renderComponent(){var e;this.container.innerHTML=this.render(),_.track("payment_timeout",{payment_method:this.paymentMethod,status:(e=this.paymentResponse)==null?void 0:e.status}),this.attachListeners()}render(){return jc}}class qc{constructor({container:e,merchantKey:t,localCurrency:i,metadata:s,callBackUrl:o,rdtCode:a,reference:l,onSuccess:c,url:p,customer:m,amount:g,totalAmount:b,token:y,currency:w,disablePaymentMethods:f,hidePaymentMethods:k,showPaymentMethods:x,onClose:A,restartTransactionProcess:M,retryingPayment:E,countryCode:D}){d(this,"contents");d(this,"mobileMoneyForm");d(this,"mobileMoneyValidationForm");d(this,"onSuccess");d(this,"mobileMoneyConfirmation");d(this,"mobileMoneyConfirmationEnd");d(this,"transactionIssuesScreen");d(this,"container");d(this,"pageLoader");d(this,"mainLoader");d(this,"_currentStep");d(this,"successScreen");d(this,"customer");d(this,"activeRef");d(this,"warningScreen");d(this,"amount");d(this,"totalAmount");d(this,"url");d(this,"reference");d(this,"metadata");d(this,"currency");d(this,"localCurrency");d(this,"token");d(this,"callBackUrl");d(this,"rdtCode");d(this,"merchantDetails");d(this,"onClose");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"disablePaymentMethods");d(this,"paymentResponse");d(this,"paymentResponseHeaders");d(this,"restartTransactionProcess");d(this,"retryingPayment");d(this,"isMaxRetriesReached");d(this,"isMobile",!1);d(this,"countryCode");d(this,"errorText");d(this,"otpMessage");this.container=e,this.onSuccess=c||(()=>null),this.token=y,this.currency=w,this.amount=g,this.totalAmount=b,this.contents=this.container.querySelector("#payment-content-view"),this._currentStep=1,this.activeRef="",this.token=t,this.customer=m,this.metadata=s,this.localCurrency=i,this.callBackUrl=o,this.localCurrency=i,this.rdtCode=a,this.url=p,this.reference=l,this.merchantDetails={},this.disablePaymentMethods=f,this.hidePaymentMethods=k,this.showPaymentMethods=x,this.onClose=A,this.paymentResponse={},this.paymentResponseHeaders={},this.restartTransactionProcess=M,this.retryingPayment=E,this.isMaxRetriesReached=!1,this.countryCode=D,this.errorText="",this.otpMessage="",_.track("mobile_money_opens",{payment_method:"Mobile Money"}),this.isMobile=window.matchMedia("(max-width: 767px)").matches}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderMobileMoneyContent()}attachInputListeners(){}async createMobileMoney(e,t){e.stopPropagation(),e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#mobile-money-button-text");i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden"));const o=ft();(()=>{var l,c,p,m;if(this.retryingPayment){const g={channel:"mobile_money",reference:this.reference,mobileMoney:{code:t.code,phoneNumber:t.phoneNumber,...t.otp&&{otp:t.otp}}};return et(this.token,g,this.rdtCode,this.url)}else{const g={amount:this.amount,channel:"mobile_money",currency:this.currency,customer:this.customer,reference:this.reference,callBackUrl:this.callBackUrl,metadata:{...this.metadata,...((l=this.merchantDetails)==null?void 0:l.subscription_id)&&{subscription_id:(c=this.merchantDetails)==null?void 0:c.subscription_id}},mobileMoney:{code:t.code,phoneNumber:t.phoneNumber,...t.otp&&{otp:t.otp}},...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((p=this.merchantDetails)==null?void 0:p.taxQuoteId)&&{taxQuoteId:(m=this.merchantDetails)==null?void 0:m.taxQuoteId},...this.countryCode&&{countryCode:this.countryCode},deviceInformation:o};return Na(this.token,g,this.rdtCode,this.url)}})().then(async({data:l,headers:c})=>{var p,m;if(this.paymentResponse=l,this.paymentResponseHeaders=c,l.providerMessage){const g=await z(l.providerMessage,R());this.errorText=g}if(l.status==="failed"){if(l.providerMessage){const g=await z(l.providerMessage,R());this.currentStep=5,this.warningScreen.setPaymentError(g),this.warningScreen.hideReportIssue()}else this.currentStep=5,this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();_.track("start_payment_failed",{payment_method:"Mobile Money",verification_status:"Failed",payment_error:l.providerMessage||"Payment failed"});return}else if(l.status==="success"||l.status==="successful"){this.currentStep=4,_.track("start_payment_success",{payment_method:"Mobile Money",verification_status:"Success"}),Pe(l,c,l==null?void 0:l.callBackUrl);return}else if(((p=l==null?void 0:l.authorization)==null?void 0:p.mode)==="otp"){this.activeRef=l.reference;const g=await z((m=this.paymentResponse)==null?void 0:m.providerMessage,R());this.otpMessage=g,this.currentStep=6;return}else this.currentStep=3}).catch(async l=>{if(_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Null"}),l.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyPaymentProcess(),this.currentStep=5,this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else{const c=await z(l.message,R());this.errorText=c,l.message?(this.currentStep=5,this.warningScreen.setPaymentError(this.errorText)):(this.currentStep=5,this.warningScreen.setPaymentError(P["payment-failed"]))}this.warningScreen.hideReportIssue()}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}showLoader(){this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader()}submitOtp(e,t){e.preventDefault();const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#mobile-money-button-text"),o={authorization:{otp:t},reference:this.activeRef};_.track("input_MobileMoneyOTP",{payment_method:"Mobile Money",authentication_type:"0TP"}),i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden")),Ot(this.token,o,this.rdtCode,this.url).then(({data:l})=>{l.status==="failed"?(this.activeRef=l.reference,this.currentStep=3):["success","successful","failed"].includes(l.status)?["success","successful"].includes(l.status)&&(this.activeRef=l.reference,this.currentStep=3):(this.activeRef=l.reference,this.currentStep=3)}).catch(async l=>{_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Failed",authentication_type:"OTP"});const c=this.container.querySelector("#otp-error");if(l.code==="invalid_otp"){if(c){const p=await z(l.message,R());c.innerHTML=p}_.track("verify_payment",{payment_method:"Mobile Money",verification_status:"Failed",authentication_type:"OTP"})}else this.currentStep=3}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}async verifyPaymentProcess(){try{const e=await Xe(this.token,this.reference,void 0,this.rdtCode,this.url);this.paymentResponse=e.data,this.paymentResponseHeaders=e.headers}catch{this.currentStep=5}}goBackToMerchant(){Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)}renderMobileMoneyContent(e){if(e&&(this.merchantDetails=e),this.currentStep===3&&this.disablePaymentMethods("mobile_money"),this.currentStep!==1){const t=document.getElementById("go-back");t&&(t.classList.remove("flex","items-center","gap-2","mb-2"),t.innerHTML="")}switch(this.currentStep===6?this.hidePaymentMethods():this.showPaymentMethods(),this.isMobile&&this.hidePaymentMethods(),this.currentStep){case 1:this.mobileMoneyForm=new Fc({container:this.contents,merchantKey:this.token,url:this.url,onAction:t=>i=>this.createMobileMoney.bind(this)(t,i),ref:this.activeRef,switchScreen:t=>{this.currentStep=t},rdtCode:this.rdtCode,currency:this.currency,localCurrency:this.localCurrency,amount:this.amount,totalAmount:this.totalAmount,restartTransactionProcess:this.restartTransactionProcess.bind(this),merchantDetails:this.merchantDetails,countryCode:this.countryCode||""}),this.mobileMoneyForm.renderContent();break;case 2:this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),this.mainLoader.updateMessage(Me["please-wait"]);break;case 3:this.mobileMoneyConfirmation=new Uc({container:this.contents,onAction:t=>{this.currentStep=t},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(t,i)=>{this.paymentResponse=t,this.paymentResponseHeaders=i}}),this.mobileMoneyConfirmation.renderComponent();break;case 4:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:e==null?void 0:e.rate.rate}),this.successScreen.renderComponent();break;case 5:this.warningScreen=new en({container:this.contents,onReportIssue:()=>this.currentStep=9,onAction:this.isMaxRetriesReached?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this)}),this.contents.innerHTML=this.warningScreen.render(),this.warningScreen.attachListener();break;case 6:this.mobileMoneyValidationForm=new Gc({container:this.contents,onClose:this.onClose,onAction:t=>i=>this.submitOtp.bind(this)(t,i),otpMessage:this.otpMessage||Me["enter-phone-otp"]}),this.mobileMoneyValidationForm.renderComponent();break;case 7:this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader(),this.pageLoader.updateMessage("Verifying Payment");break;case 8:this.mobileMoneyConfirmationEnd=new zc({container:this.contents,onAction:t=>{this.currentStep=t},ref:this.reference,onSuccess:this.onSuccess.bind(this),token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders,paymentMethod:"Mobile Money"}),this.mobileMoneyConfirmationEnd.renderComponent();break;case 9:this.transactionIssuesScreen=new st({container:this.contents,onAction:()=>{var t;this.currentStep=5,this.warningScreen.setPaymentError(((t=this.paymentResponse)==null?void 0:t.providerMessage)||"Payment failed")},url:this.url,rdtCode:this.rdtCode,token:this.token,paymentChannel:"mobile_money",callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break}this.attachInputListeners()}}const Wc=`<div id="eft-authenticate-container" data-section="eft">
|
|
2221
2221
|
<div class="pt-3">
|
|
2222
2222
|
<div class="container-center">
|
|
2223
2223
|
<svg width="98" height="32" viewBox="0 0 98 32" fill="none" xmlns="http://www.w3.org/2000/svg"
|
package/dist/types/types.d.ts
CHANGED