@spot-flow/checkout-inline-js 0.2.5 → 0.2.6

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.
@@ -41,7 +41,7 @@ export declare class MerchantConfigService extends BaseService {
41
41
  * @param planId this is the planId for the subscriptions
42
42
  * @returns {Promise<GetMerchantPlanDetail>}
43
43
  */
44
- getMerchantConfig(planId: string, currency: string): Promise<GetMerchantPlanDetail>;
44
+ getMerchantConfig(planId: string, currency: string, subscriptionId?: string): Promise<GetMerchantPlanDetail>;
45
45
  }
46
46
  type BankServiceProps = Props;
47
47
  export declare class BankService extends BaseService {
@@ -30,6 +30,7 @@ declare class CheckoutForm {
30
30
  mode?: "test" | "live";
31
31
  rawPaymentMethodTexts: Record<string, string>;
32
32
  currentLanguage: string;
33
+ subscriptionId?: string;
33
34
  constructor();
34
35
  closePayment(): void;
35
36
  getDeviceType(): "Mobile" | "Tablet" | "Desktop";
@@ -31344,6 +31344,7 @@ class jd {
31344
31344
  d(this, "confirmationProgress");
31345
31345
  d(this, "restartTransactionProcess");
31346
31346
  d(this, "retryingPayment");
31347
+ d(this, "merchantDetails");
31347
31348
  d(this, "isMaxRetriesReached");
31348
31349
  d(this, "isCancelledPlan");
31349
31350
  d(this, "isMobile", !1);
@@ -31353,7 +31354,7 @@ class jd {
31353
31354
  d(this, "otpMessage");
31354
31355
  d(this, "rawAvsData");
31355
31356
  d(this, "translatedAvsData");
31356
- this.currency = c, this.onSuccess = b || (() => null), this.keys = D, this.testcardIsVisible = F, this.container = i, this.encryption = a, this.token = l, this.customer = s, this.planId = o, this.amount = e, this.totalAmount = t, this.rdtCode = p, this.url = m, this.reference = g, this.callBackUrl = y, this.metadata = S, this.localCurrency = f, this._currentStep = 1, this.activeRef = "", this.contents = this.container.querySelector(
31357
+ this.currency = c, this.onSuccess = b || (() => null), this.keys = D, this.testcardIsVisible = F, this.metadata = S, this.container = i, this.encryption = a, this.token = l, this.customer = s, this.planId = o, this.merchantDetails = {}, this.amount = e, this.totalAmount = t, this.rdtCode = p, this.url = m, this.reference = g, this.callBackUrl = y, this.metadata = S, this.localCurrency = f, this._currentStep = 1, this.activeRef = "", this.contents = this.container.querySelector(
31357
31358
  "#payment-content-view"
31358
31359
  ), this.cardResponse = {}, this.cardResponseHeader = {}, this.hidePaymentMethods = w, this.showPaymentMethods = A, this.onClose = M, this.restartTransactionProcess = x, this.retryingPayment = E, this.isMaxRetriesReached = !1, this.isCancelledPlan = !1, this.errorText = "", this.otpMessage = "", this.renderCardContent(), this.rawAvsData = {
31359
31360
  "billing-address": "Billing address",
@@ -31418,21 +31419,21 @@ class jd {
31418
31419
  i && s && (i.classList.remove("hidden"), s.classList.add("hidden"));
31419
31420
  const o = ft();
31420
31421
  (() => {
31421
- var c, p, m, g, b;
31422
+ var c, p, m, g, b, y, S;
31422
31423
  if (this.retryingPayment) {
31423
- const y = {
31424
+ const f = {
31424
31425
  channel: "card",
31425
31426
  reference: this.reference,
31426
31427
  encryptedCard: a
31427
31428
  };
31428
31429
  return mt(
31429
31430
  this.token,
31430
- y,
31431
+ f,
31431
31432
  this.rdtCode,
31432
31433
  this.url
31433
31434
  );
31434
31435
  } else {
31435
- const y = {
31436
+ const f = {
31436
31437
  amount: ((g = (m = (p = (c = this.merchantPlanDetail) == null ? void 0 : c.plan) == null ? void 0 : p.trial) == null ? void 0 : m.pricingList[0]) == null ? void 0 : g.amount) ?? this.amount,
31437
31438
  // send trial amount if available
31438
31439
  channel: "card",
@@ -31443,17 +31444,22 @@ class jd {
31443
31444
  reference: this.reference,
31444
31445
  encryptedCard: a,
31445
31446
  callBackUrl: this.callBackUrl,
31446
- metadata: this.metadata,
31447
+ metadata: {
31448
+ ...this.metadata,
31449
+ ...((b = this.merchantDetails) == null ? void 0 : b.subscription_id) && {
31450
+ subscription_id: (y = this.merchantDetails) == null ? void 0 : y.subscription_id
31451
+ }
31452
+ },
31447
31453
  ...this.localCurrency && { localCurrency: this.localCurrency },
31448
31454
  isCheckout: !0,
31449
- ...((b = this.merchantPlanDetail) == null ? void 0 : b.taxQuoteId) && {
31455
+ ...((S = this.merchantPlanDetail) == null ? void 0 : S.taxQuoteId) && {
31450
31456
  taxQuoteId: this.merchantPlanDetail.taxQuoteId
31451
31457
  },
31452
31458
  deviceInformation: o
31453
31459
  };
31454
31460
  return dl(
31455
31461
  this.token,
31456
- y,
31462
+ f,
31457
31463
  this.rdtCode,
31458
31464
  this.url
31459
31465
  );
@@ -35801,22 +35807,24 @@ class eu extends Ss {
35801
35807
  * @param planId this is the planId for the subscriptions
35802
35808
  * @returns {Promise<GetMerchantPlanDetail>}
35803
35809
  */
35804
- async getMerchantConfig(e, t) {
35810
+ async getMerchantConfig(e, t, i) {
35805
35811
  try {
35806
- const i = await fetch(
35807
- `${ue(this.baseurl, this.url)}/checkout-configurations?currency=${t}&planId=${e || ""}`,
35812
+ const s = new URLSearchParams();
35813
+ t && s.append("currency", t), e && s.append("planId", e), i && s.append("subscriptionId", i);
35814
+ const a = await fetch(
35815
+ `${ue(this.baseurl, this.url)}/checkout-configurations?${s.toString()}`,
35808
35816
  {
35809
35817
  headers: this.headers,
35810
35818
  method: "GET"
35811
35819
  }
35812
35820
  );
35813
- if (!i.ok) {
35814
- const s = await i.json();
35815
- throw s.message ? new de(s.message, i.status) : new de("Network response was not ok", i.status);
35821
+ if (!a.ok) {
35822
+ const o = await a.json();
35823
+ throw o.message ? new de(o.message, a.status) : new de("Network response was not ok", a.status);
35816
35824
  }
35817
- return i.json();
35818
- } catch (i) {
35819
- throw i instanceof de ? console.error(`FetchError: ${i.message} (status: ${i.status})`) : i instanceof yn ? console.error(`AuthorizationError: ${i.message}`) : console.error(`Unexpected error: ${i}`), i;
35825
+ return a.json();
35826
+ } catch (s) {
35827
+ throw s instanceof de ? console.error(`FetchError: ${s.message} (status: ${s.status})`) : s instanceof yn ? console.error(`AuthorizationError: ${s.message}`) : console.error(`Unexpected error: ${s}`), s;
35820
35828
  }
35821
35829
  }
35822
35830
  }
@@ -36619,71 +36627,72 @@ class hu {
36619
36627
  D && this.localCurrency && (D.innerHTML = an ? `${an} (${this.localCurrency})` : this.localCurrency), F && this.localCurrency && (F.innerHTML = an ? `${an} (${this.localCurrency})` : this.localCurrency), this.renderPaymentOptions(this.container), this.attachListeners();
36620
36628
  }
36621
36629
  renderPaymentOptions(e) {
36630
+ var s;
36622
36631
  const t = e.querySelector(".payment-options"), i = In(this.currency, this.localCurrency);
36623
36632
  if (t) {
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]);
36633
+ const a = this.merchantDetail.plan && !((s = this.metadata) != null && s.subscription_id) ? [se.mobile_money, se.card] : this.merchantDetail.paymentMethods.filter((o) => o !== "ussd").filter((o) => !(i !== "USD" && o === "stablecoin")).map((o) => se[o]);
36625
36634
  if (this.isMobile) {
36626
- let a = '<div class="">';
36627
- s.forEach((o) => {
36628
- a += `
36629
- <div key=${o.key}>
36630
- <button class="tab-button gap-2 mb-4 group" data-name="${o.key}">
36631
- <div class="lg:block">${o.icon}</div>
36635
+ let o = '<div class="">';
36636
+ a.forEach((l) => {
36637
+ o += `
36638
+ <div key=${l.key}>
36639
+ <button class="tab-button gap-2 mb-4 group" data-name="${l.key}">
36640
+ <div class="lg:block">${l.icon}</div>
36632
36641
  <div class="flex items-center gap-2">
36633
- <span class="pm-label" data-translate=${o.translateKey}>${o.label} </span>
36634
- ${o.key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36642
+ <span class="pm-label" data-translate=${l.translateKey}>${l.label} </span>
36643
+ ${l.key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36635
36644
  </div>
36636
36645
  </button>
36637
36646
  </div>
36638
36647
  `;
36639
- }), a += "</div>", t.innerHTML = a;
36648
+ }), o += "</div>", t.innerHTML = o;
36640
36649
  } else {
36641
- const a = s.length % 2 === 0;
36642
- let o = '<div class="grid gap-2">';
36643
- if (a)
36644
- o += '<div class="grid grid-cols-2 gap-2">', s.forEach((l) => {
36645
- o += `
36646
- <div key=${l.key}>
36647
- <button class="tab-button gap-2 group" data-name="${l.key}">
36648
- <div class="md:container-center lg:block">${l.icon}</div>
36650
+ const o = a.length % 2 === 0;
36651
+ let l = '<div class="grid gap-2">';
36652
+ if (o)
36653
+ l += '<div class="grid grid-cols-2 gap-2">', a.forEach((c) => {
36654
+ l += `
36655
+ <div key=${c.key}>
36656
+ <button class="tab-button gap-2 group" data-name="${c.key}">
36657
+ <div class="md:container-center lg:block">${c.icon}</div>
36649
36658
  <div class="flex items-center gap-2">
36650
- <span class="pm-label" data-translate=${l.translateKey}>${l.label} </span>
36651
- ${l.key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36659
+ <span class="pm-label" data-translate=${c.translateKey}>${c.label} </span>
36660
+ ${c.key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36652
36661
  </div>
36653
36662
  </button>
36654
36663
  </div>
36655
36664
  `;
36656
- }), o += "</div>";
36665
+ }), l += "</div>";
36657
36666
  else {
36658
- if (o += `
36667
+ if (l += `
36659
36668
  <div>
36660
- <button class="tab-button gap-2 group" data-name="${s[0].key}">
36661
- <div class="md:container-center lg:block"> ${s[0].icon}</div>
36669
+ <button class="tab-button gap-2 group" data-name="${a[0].key}">
36670
+ <div class="md:container-center lg:block"> ${a[0].icon}</div>
36662
36671
  <div class="flex items-center gap-2">
36663
- <span class="pm-label" data-translate=${s[0].translateKey}>${s[0].label} </span>
36664
- ${s[0].key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36672
+ <span class="pm-label" data-translate=${a[0].translateKey}>${a[0].label} </span>
36673
+ ${a[0].key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36665
36674
  </div>
36666
36675
  </button>
36667
36676
  </div>
36668
- `, s.length > 1) {
36669
- o += '<div class="grid grid-cols-2 gap-2">';
36670
- for (let l = 1; l < s.length; l++)
36671
- o += `
36677
+ `, a.length > 1) {
36678
+ l += '<div class="grid grid-cols-2 gap-2">';
36679
+ for (let c = 1; c < a.length; c++)
36680
+ l += `
36672
36681
  <div>
36673
- <button class="tab-button gap-2 group" data-name="${s[l].key}">
36674
- <div class="md:container-center lg:block">${s[l].icon}</div>
36682
+ <button class="tab-button gap-2 group" data-name="${a[c].key}">
36683
+ <div class="md:container-center lg:block">${a[c].icon}</div>
36675
36684
  <div class="flex items-center gap-2">
36676
- <span class="pm-label" data-translate=${s[l].translateKey}>${s[l].label} </span>
36677
- ${s[l].key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36685
+ <span class="pm-label" data-translate=${a[c].translateKey}>${a[c].label} </span>
36686
+ ${a[c].key === "card" ? ` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>` : ""}
36678
36687
  </div>
36679
36688
  </button>
36680
36689
  </div>
36681
36690
  `;
36682
- o += "</div>";
36691
+ l += "</div>";
36683
36692
  }
36684
- o += "</div>";
36693
+ l += "</div>";
36685
36694
  }
36686
- o += "</div>", t.innerHTML = o;
36695
+ l += "</div>", t.innerHTML = l;
36687
36696
  }
36688
36697
  }
36689
36698
  }
@@ -39677,7 +39686,8 @@ class Fu {
39677
39686
  d(this, "rawPaymentMethodTexts");
39678
39687
  // translatedPMTexts: Record<string, string>;
39679
39688
  d(this, "currentLanguage");
39680
- this.merchantKey = "", this.email = "", this.amount = 0, this.planId = "", this.encryption = "", this.phoneNumber = "", this.code = "", this.modalContainer = document.createElement("div"), this.rdtCode = "", this.reference = "", this.currency = "", this.url = "", this.callBackUrl = "", this.metadata = {}, this.localCurrency = "", this.countryCode = "", this.rawPaymentMethodTexts = ts, this.modalContainer.innerHTML = ll, this.currentLanguage = Cn, _.init("11162d9a0801daeaf786f1200cd3112b", { debug: !1 }), document.body.appendChild(this.modalContainer);
39689
+ d(this, "subscriptionId");
39690
+ this.merchantKey = "", this.email = "", this.amount = 0, this.planId = "", this.encryption = "", this.phoneNumber = "", this.code = "", this.modalContainer = document.createElement("div"), this.rdtCode = "", this.reference = "", this.currency = "", this.url = "", this.callBackUrl = "", this.metadata = {}, this.localCurrency = "", this.countryCode = "", this.rawPaymentMethodTexts = ts, this.modalContainer.innerHTML = ll, this.currentLanguage = Cn, this.subscriptionId = "", _.init("11162d9a0801daeaf786f1200cd3112b", { debug: !1 }), document.body.appendChild(this.modalContainer);
39681
39691
  const t = document.getElementById(
39682
39692
  "main-layout-container-screen"
39683
39693
  );
@@ -39727,6 +39737,7 @@ class Fu {
39727
39737
  phoneNumber: f,
39728
39738
  name: w,
39729
39739
  mode: A
39740
+ // subscriptionId,
39730
39741
  } = e;
39731
39742
  if (this.merchantKey = s || "", this.email = t || "", this.amount = o || 0, this.encryption = i || "", this.planId = a || "", this.rdtCode = l || "", this.reference = c || kl(), this.url = m || "", this.callBackUrl = g || "", this.metadata = b || {}, this.countryCode = S || "", this.phoneNumber = f || "", this.name = w || "", this.mode = A, !s || !t)
39732
39743
  throw this.mainError = new Qi(this.mainLayout), this.mainError.renderContent(
@@ -39779,7 +39790,11 @@ class Fu {
39779
39790
  }
39780
39791
  async getPlanDetails() {
39781
39792
  const e = this.currency === "USD" ? this.localCurrency : this.currency;
39782
- this.merchantConfigService.getMerchantConfig(this.planId, e).then(async (t) => {
39793
+ this.merchantConfigService.getMerchantConfig(
39794
+ this.planId,
39795
+ e,
39796
+ this.metadata.subscription_id
39797
+ ).then(async (t) => {
39783
39798
  var i, s;
39784
39799
  if (t.taxEnabled) {
39785
39800
  const a = await fl(
@@ -1565,7 +1565,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
1565
1565
  <path
1566
1566
  d="M4.66667 3.99992V1.99992C4.66667 1.82311 4.7369 1.65354 4.86193 1.52851C4.98695 1.40349 5.15652 1.33325 5.33333 1.33325H13.3333C13.5101 1.33325 13.6797 1.40349 13.8047 1.52851C13.9298 1.65354 14 1.82311 14 1.99992V11.3333C14 11.5101 13.9298 11.6796 13.8047 11.8047C13.6797 11.9297 13.5101 11.9999 13.3333 11.9999H11.3333V13.9999C11.3333 14.3679 11.0333 14.6666 10.662 14.6666H2.67133C2.58342 14.6671 2.49626 14.6503 2.41488 14.617C2.3335 14.5837 2.25949 14.5347 2.19711 14.4728C2.13472 14.4108 2.0852 14.3372 2.05137 14.256C2.01754 14.1749 2.00009 14.0878 2 13.9999L2.002 4.66659C2.002 4.29859 2.302 3.99992 2.67333 3.99992H4.66667ZM3.33533 5.33325L3.33333 13.3333H10V5.33325H3.33533ZM6 3.99992H11.3333V10.6666H12.6667V2.66659H6V3.99992Z"
1567
1567
  fill="#0D0716" />
1568
- </svg>`},1e3))})})}renderComponent(e){R()!=="en"&&e===1?(this.mainLoader=new ke(this.container),this.mainLoader.mountLoader("15dvh"),this.renderTranslatedText().then(()=>{this.mainLoader.unmountLoader(),this.container.innerHTML=this.render(),this.attachListener()})):(this.container.innerHTML=this.render(),this.attachListener())}async renderTranslatedText(){await Ks(R())}}function pc(n){n.classList.remove("hidden"),requestAnimationFrame(()=>{n.classList.remove("opacity-0","scale-95")})}function di(n){n.classList.add("opacity-0","scale-95"),n.addEventListener("transitionend",()=>n.classList.add("hidden"),{once:!0})}class ra{constructor({container:e,testCardContainer:t,keyEnvironment:i}){d(this,"container");d(this,"testCardContainer");d(this,"testCardInstance",null);d(this,"keyEnvironment",null);d(this,"isVisible",!1);d(this,"mainLoader");d(this,"testCardClicks");this.container=e,this.testCardContainer=t,this.keyEnvironment=i,this.isVisible=!1,this.testCardClicks=0}attachListener(){const e=this.container.querySelector("#test-cards-link"),t=this.container.querySelector("#terms-text"),i=this.container.querySelector("#privacy-text"),s=this.container.querySelector("#contact-text"),o=this.container.querySelector("#powered-by-text");if(t&&(t.innerHTML=q.terms),i&&(i.innerHTML=q.privacy),s&&(s.innerHTML=q.contact),o&&(o.innerHTML=q.powered),!!e){if(e.innerHTML=q["test-card"],this.keyEnvironment!=="test"){e.classList.add("hidden");return}e.addEventListener("click",async()=>{this.testCardClicks=this.testCardClicks+1,this.testCardInstance||(this.testCardInstance=new aa({container:this.testCardContainer,closeCallback:()=>{this.testCardContainer.innerHTML="",di(this.testCardContainer),e.classList.remove("text-tone-100","font-bold"),this.isVisible=!1}})),this.testCardInstance.renderComponent(this.testCardClicks),pc(this.testCardContainer),e.classList.add("text-tone-100","font-bold"),this.isVisible=!0})}}renderComponent(){this.container.innerHTML=this.render(),this.attachListener()}render(){return hc}}function ft(){return{httpBrowserLanguage:navigator.language||"en-US",httpBrowserJavaEnabled:!1,httpBrowserJavaScriptEnabled:!0,httpBrowserColorDepth:window.screen.colorDepth.toString(),httpBrowserScreenHeight:window.screen.height.toString(),httpBrowserScreenWidth:window.screen.width.toString(),httpBrowserTimeDifference:(-new Date().getTimezoneOffset()).toString(),userAgentBrowserValue:navigator.userAgent,deviceChannel:"Browser"}}function Hn(n,e){return e&&e!==n?e:n}class vc{constructor({amount:e,totalAmount:t,container:i,customer:s,encryption:o,planId:a,token:l,currency:c,rdtCode:p,url:m,reference:g,onSuccess:b,callBackUrl:y,metadata:w,localCurrency:f,hidePaymentMethods:k,showPaymentMethods:x,onClose:A,restartTransactionProcess:M,retryingPayment:E,keys:D,testcardIsVisible:F}){d(this,"contents");d(this,"cardDetailForm");d(this,"cardOtpValidationForm");d(this,"merchantPlanDetail",{});d(this,"cardPinForm");d(this,"avsForm");d(this,"isw3dsForm");d(this,"successScreen");d(this,"pageLoader");d(this,"warningScreen");d(this,"transactionIssuesScreen");d(this,"container");d(this,"onSuccess");d(this,"planId","");d(this,"customer");d(this,"token");d(this,"amount");d(this,"totalAmount");d(this,"encryption");d(this,"currency");d(this,"_currentStep");d(this,"activeRef");d(this,"rdtCode");d(this,"url");d(this,"reference");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"onClose");d(this,"cardResponse");d(this,"cardResponseHeader");d(this,"confirmationEnd");d(this,"confirmationProgress");d(this,"restartTransactionProcess");d(this,"retryingPayment");d(this,"isMaxRetriesReached");d(this,"isCancelledPlan");d(this,"isMobile",!1);d(this,"keys");d(this,"testcardIsVisible",!1);d(this,"errorText");d(this,"otpMessage");d(this,"rawAvsData");d(this,"translatedAvsData");this.currency=c,this.onSuccess=b||(()=>null),this.keys=D,this.testcardIsVisible=F,this.container=i,this.encryption=o,this.token=l,this.customer=s,this.planId=a,this.amount=e,this.totalAmount=t,this.rdtCode=p,this.url=m,this.reference=g,this.callBackUrl=y,this.metadata=w,this.localCurrency=f,this._currentStep=1,this.activeRef="",this.contents=this.container.querySelector("#payment-content-view"),this.cardResponse={},this.cardResponseHeader={},this.hidePaymentMethods=k,this.showPaymentMethods=x,this.onClose=A,this.restartTransactionProcess=M,this.retryingPayment=E,this.isMaxRetriesReached=!1,this.isCancelledPlan=!1,this.errorText="",this.otpMessage="",this.renderCardContent(),this.rawAvsData={"billing-address":"Billing address",address:"Address",city:"City",state:"State",country:"Country","zip-code":"Zip code",submit:"Submit"},this.translatedAvsData=this.rawAvsData,_.track("card_opens",{payment_method:"Card"}),this.isMobile=window.matchMedia("(max-width: 767px)").matches}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderCardContent()}fetchCurrentRegionDetails(){const e=this.localCurrency?this.localCurrency!==this.currency?this.localCurrency:this.currency:this.currency;return Ni(e)}cancellledPlanAction(){if(this.rdtCode)window.history.back();else{const e=document.getElementById("checkout-modal");e&&e.remove()}}async renderTranslatedText(e){if(Array.isArray(e))this.translatedAvsData=await Ae.translateRecord(this.rawAvsData,R());else if(e){const t=await z(e,R());this.otpMessage=t}else this.otpMessage=""}showLoader(){this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader()}async submitCardDetails(e,t){e.preventDefault(),_.track("input_cardDetails",{payment_method:"Card",authentication_type:"None"});const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#details-form-button-text"),o=await ar(JSON.stringify(t),this.encryption);i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden"));const a=ft();(()=>{var c,p,m,g,b;if(this.retryingPayment){const y={channel:"card",reference:this.reference,encryptedCard:o};return et(this.token,y,this.rdtCode,this.url)}else{const y={amount:((g=(m=(p=(c=this.merchantPlanDetail)==null?void 0:c.plan)==null?void 0:p.trial)==null?void 0:m.pricingList[0])==null?void 0:g.amount)??this.amount,channel:"card",applyDiscount:!0,currency:this.currency,planId:this.planId,customer:this.customer,reference:this.reference,encryptedCard:o,callBackUrl:this.callBackUrl,metadata:this.metadata,...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((b=this.merchantPlanDetail)==null?void 0:b.taxQuoteId)&&{taxQuoteId:this.merchantPlanDetail.taxQuoteId},deviceInformation:a};return Ha(this.token,y,this.rdtCode,this.url)}})().then(async({data:c,headers:p})=>{var m,g,b,y,w,f,k,x;if(c.providerMessage){const A=await z(c.providerMessage,R());this.errorText=A}if(c.status==="failed")this.currentStep=4,this.reference=c.reference,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"None"}),this.cardResponse=c,this.cardResponseHeader=p,c.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful"].includes(c.status))this.currentStep=5,this.cardResponse=c,this.cardResponseHeader=p,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN"}),this.redirectTo(c,p,"success");else if(!["success","successful"].includes(c.status)&&c.status!=="failed")if(this.cardResponse=c,this.cardResponseHeader=p,c!=null&&c.authorization){if(this.activeRef=c.reference,((m=c==null?void 0:c.authorization)==null?void 0:m.mode)==="pin"){this.currentStep=2;return}if(((g=c==null?void 0:c.authorization)==null?void 0:g.mode)==="3DS"){(b=c==null?void 0:c.authorization)!=null&&b.redirectUrl&&this.redirectTo3DS((y=c==null?void 0:c.authorization)==null?void 0:y.redirectUrl),(w=c==null?void 0:c.authorization)!=null&&w.embeddedHtml&&this.redirectToPreciumDoc((f=c==null?void 0:c.authorization)==null?void 0:f.embeddedHtml);return}if(((k=c==null?void 0:c.authorization)==null?void 0:k.mode)==="otp"){this.cardResponse=c,this.currentStep=3;return}if(((x=c==null?void 0:c.authorization)==null?void 0:x.mode)==="avs"){if(R()!=="en"){this.showLoader();const A=Object.values(this.rawAvsData);this.renderTranslatedText(A).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}}else this.currentStep=4,c.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["error-with-payment"]),this.warningScreen.hideReportIssue()}).catch(async c=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"None"}),c.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyPaymentProcess(),this.currentStep=4,_.track("max_retries_reached",{payment_method:"Card"}),this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else{if(c.message){const p=await z(c.message,R());this.errorText=p,c.code==="7137"?(this.isCancelledPlan=!0,this.currentStep=4,_.track("cancelled_plan",{payment_method:"Card"}),this.warningScreen.setPaymentError(this.errorText,"",q["merchant-back"])):(this.currentStep=4,this.warningScreen.setPaymentError(this.errorText))}else this.currentStep=4,this.warningScreen.setPaymentError(P["payment-failed"]);this.warningScreen.hideReportIssue()}}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}handlePinRequest(e){if(e.length===4){const t={authorization:{pin:e},reference:this.activeRef};_.track("input_cardPin",{payment_method:"Card",authentication_type:"PIN"}),setTimeout(()=>{const i=this.container.querySelector("#pin-loader"),s=this.container.querySelector("#cancel-payment");i&&(i.innerHTML=`<svg class="animate-spin" width="40" height="40" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
1568
+ </svg>`},1e3))})})}renderComponent(e){R()!=="en"&&e===1?(this.mainLoader=new ke(this.container),this.mainLoader.mountLoader("15dvh"),this.renderTranslatedText().then(()=>{this.mainLoader.unmountLoader(),this.container.innerHTML=this.render(),this.attachListener()})):(this.container.innerHTML=this.render(),this.attachListener())}async renderTranslatedText(){await Ks(R())}}function pc(n){n.classList.remove("hidden"),requestAnimationFrame(()=>{n.classList.remove("opacity-0","scale-95")})}function di(n){n.classList.add("opacity-0","scale-95"),n.addEventListener("transitionend",()=>n.classList.add("hidden"),{once:!0})}class ra{constructor({container:e,testCardContainer:t,keyEnvironment:i}){d(this,"container");d(this,"testCardContainer");d(this,"testCardInstance",null);d(this,"keyEnvironment",null);d(this,"isVisible",!1);d(this,"mainLoader");d(this,"testCardClicks");this.container=e,this.testCardContainer=t,this.keyEnvironment=i,this.isVisible=!1,this.testCardClicks=0}attachListener(){const e=this.container.querySelector("#test-cards-link"),t=this.container.querySelector("#terms-text"),i=this.container.querySelector("#privacy-text"),s=this.container.querySelector("#contact-text"),o=this.container.querySelector("#powered-by-text");if(t&&(t.innerHTML=q.terms),i&&(i.innerHTML=q.privacy),s&&(s.innerHTML=q.contact),o&&(o.innerHTML=q.powered),!!e){if(e.innerHTML=q["test-card"],this.keyEnvironment!=="test"){e.classList.add("hidden");return}e.addEventListener("click",async()=>{this.testCardClicks=this.testCardClicks+1,this.testCardInstance||(this.testCardInstance=new aa({container:this.testCardContainer,closeCallback:()=>{this.testCardContainer.innerHTML="",di(this.testCardContainer),e.classList.remove("text-tone-100","font-bold"),this.isVisible=!1}})),this.testCardInstance.renderComponent(this.testCardClicks),pc(this.testCardContainer),e.classList.add("text-tone-100","font-bold"),this.isVisible=!0})}}renderComponent(){this.container.innerHTML=this.render(),this.attachListener()}render(){return hc}}function ft(){return{httpBrowserLanguage:navigator.language||"en-US",httpBrowserJavaEnabled:!1,httpBrowserJavaScriptEnabled:!0,httpBrowserColorDepth:window.screen.colorDepth.toString(),httpBrowserScreenHeight:window.screen.height.toString(),httpBrowserScreenWidth:window.screen.width.toString(),httpBrowserTimeDifference:(-new Date().getTimezoneOffset()).toString(),userAgentBrowserValue:navigator.userAgent,deviceChannel:"Browser"}}function Hn(n,e){return e&&e!==n?e:n}class vc{constructor({amount:e,totalAmount:t,container:i,customer:s,encryption:o,planId:a,token:l,currency:c,rdtCode:p,url:m,reference:g,onSuccess:b,callBackUrl:y,metadata:w,localCurrency:f,hidePaymentMethods:k,showPaymentMethods:x,onClose:A,restartTransactionProcess:M,retryingPayment:E,keys:D,testcardIsVisible:F}){d(this,"contents");d(this,"cardDetailForm");d(this,"cardOtpValidationForm");d(this,"merchantPlanDetail",{});d(this,"cardPinForm");d(this,"avsForm");d(this,"isw3dsForm");d(this,"successScreen");d(this,"pageLoader");d(this,"warningScreen");d(this,"transactionIssuesScreen");d(this,"container");d(this,"onSuccess");d(this,"planId","");d(this,"customer");d(this,"token");d(this,"amount");d(this,"totalAmount");d(this,"encryption");d(this,"currency");d(this,"_currentStep");d(this,"activeRef");d(this,"rdtCode");d(this,"url");d(this,"reference");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"hidePaymentMethods");d(this,"showPaymentMethods");d(this,"onClose");d(this,"cardResponse");d(this,"cardResponseHeader");d(this,"confirmationEnd");d(this,"confirmationProgress");d(this,"restartTransactionProcess");d(this,"retryingPayment");d(this,"merchantDetails");d(this,"isMaxRetriesReached");d(this,"isCancelledPlan");d(this,"isMobile",!1);d(this,"keys");d(this,"testcardIsVisible",!1);d(this,"errorText");d(this,"otpMessage");d(this,"rawAvsData");d(this,"translatedAvsData");this.currency=c,this.onSuccess=b||(()=>null),this.keys=D,this.testcardIsVisible=F,this.metadata=w,this.container=i,this.encryption=o,this.token=l,this.customer=s,this.planId=a,this.merchantDetails={},this.amount=e,this.totalAmount=t,this.rdtCode=p,this.url=m,this.reference=g,this.callBackUrl=y,this.metadata=w,this.localCurrency=f,this._currentStep=1,this.activeRef="",this.contents=this.container.querySelector("#payment-content-view"),this.cardResponse={},this.cardResponseHeader={},this.hidePaymentMethods=k,this.showPaymentMethods=x,this.onClose=A,this.restartTransactionProcess=M,this.retryingPayment=E,this.isMaxRetriesReached=!1,this.isCancelledPlan=!1,this.errorText="",this.otpMessage="",this.renderCardContent(),this.rawAvsData={"billing-address":"Billing address",address:"Address",city:"City",state:"State",country:"Country","zip-code":"Zip code",submit:"Submit"},this.translatedAvsData=this.rawAvsData,_.track("card_opens",{payment_method:"Card"}),this.isMobile=window.matchMedia("(max-width: 767px)").matches}get currentStep(){return this._currentStep}set currentStep(e){this._currentStep=e,this.renderCardContent()}fetchCurrentRegionDetails(){const e=this.localCurrency?this.localCurrency!==this.currency?this.localCurrency:this.currency:this.currency;return Ni(e)}cancellledPlanAction(){if(this.rdtCode)window.history.back();else{const e=document.getElementById("checkout-modal");e&&e.remove()}}async renderTranslatedText(e){if(Array.isArray(e))this.translatedAvsData=await Ae.translateRecord(this.rawAvsData,R());else if(e){const t=await z(e,R());this.otpMessage=t}else this.otpMessage=""}showLoader(){this.pageLoader=new ke(this.contents),this.pageLoader.mountLoader()}async submitCardDetails(e,t){e.preventDefault(),_.track("input_cardDetails",{payment_method:"Card",authentication_type:"None"});const i=this.container.querySelector(".spinner"),s=this.container.querySelector("#details-form-button-text"),o=await ar(JSON.stringify(t),this.encryption);i&&s&&(i.classList.remove("hidden"),s.classList.add("hidden"));const a=ft();(()=>{var c,p,m,g,b,y,w;if(this.retryingPayment){const f={channel:"card",reference:this.reference,encryptedCard:o};return et(this.token,f,this.rdtCode,this.url)}else{const f={amount:((g=(m=(p=(c=this.merchantPlanDetail)==null?void 0:c.plan)==null?void 0:p.trial)==null?void 0:m.pricingList[0])==null?void 0:g.amount)??this.amount,channel:"card",applyDiscount:!0,currency:this.currency,planId:this.planId,customer:this.customer,reference:this.reference,encryptedCard:o,callBackUrl:this.callBackUrl,metadata:{...this.metadata,...((b=this.merchantDetails)==null?void 0:b.subscription_id)&&{subscription_id:(y=this.merchantDetails)==null?void 0:y.subscription_id}},...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((w=this.merchantPlanDetail)==null?void 0:w.taxQuoteId)&&{taxQuoteId:this.merchantPlanDetail.taxQuoteId},deviceInformation:a};return Ha(this.token,f,this.rdtCode,this.url)}})().then(async({data:c,headers:p})=>{var m,g,b,y,w,f,k,x;if(c.providerMessage){const A=await z(c.providerMessage,R());this.errorText=A}if(c.status==="failed")this.currentStep=4,this.reference=c.reference,_.track("verify_payment",{payment_method:"Card",verification_status:"Failed",authentication_type:"None"}),this.cardResponse=c,this.cardResponseHeader=p,c.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();else if(["success","successful"].includes(c.status))this.currentStep=5,this.cardResponse=c,this.cardResponseHeader=p,_.track("verify_payment",{payment_method:"Card",verification_status:"Success",authentication_type:"PIN"}),this.redirectTo(c,p,"success");else if(!["success","successful"].includes(c.status)&&c.status!=="failed")if(this.cardResponse=c,this.cardResponseHeader=p,c!=null&&c.authorization){if(this.activeRef=c.reference,((m=c==null?void 0:c.authorization)==null?void 0:m.mode)==="pin"){this.currentStep=2;return}if(((g=c==null?void 0:c.authorization)==null?void 0:g.mode)==="3DS"){(b=c==null?void 0:c.authorization)!=null&&b.redirectUrl&&this.redirectTo3DS((y=c==null?void 0:c.authorization)==null?void 0:y.redirectUrl),(w=c==null?void 0:c.authorization)!=null&&w.embeddedHtml&&this.redirectToPreciumDoc((f=c==null?void 0:c.authorization)==null?void 0:f.embeddedHtml);return}if(((k=c==null?void 0:c.authorization)==null?void 0:k.mode)==="otp"){this.cardResponse=c,this.currentStep=3;return}if(((x=c==null?void 0:c.authorization)==null?void 0:x.mode)==="avs"){if(R()!=="en"){this.showLoader();const A=Object.values(this.rawAvsData);this.renderTranslatedText(A).then(()=>{this.pageLoader.unmountLoader(),this.currentStep=7})}else this.currentStep=7;return}}else this.currentStep=4,c.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["error-with-payment"]),this.warningScreen.hideReportIssue()}).catch(async c=>{if(_.track("verify_payment",{payment_method:"Card",verification_status:"Null",authentication_type:"None"}),c.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyPaymentProcess(),this.currentStep=4,_.track("max_retries_reached",{payment_method:"Card"}),this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else{if(c.message){const p=await z(c.message,R());this.errorText=p,c.code==="7137"?(this.isCancelledPlan=!0,this.currentStep=4,_.track("cancelled_plan",{payment_method:"Card"}),this.warningScreen.setPaymentError(this.errorText,"",q["merchant-back"])):(this.currentStep=4,this.warningScreen.setPaymentError(this.errorText))}else this.currentStep=4,this.warningScreen.setPaymentError(P["payment-failed"]);this.warningScreen.hideReportIssue()}}).finally(()=>{i&&s&&(i.classList.add("hidden"),s.classList.remove("hidden"))})}handlePinRequest(e){if(e.length===4){const t={authorization:{pin:e},reference:this.activeRef};_.track("input_cardPin",{payment_method:"Card",authentication_type:"PIN"}),setTimeout(()=>{const i=this.container.querySelector("#pin-loader"),s=this.container.querySelector("#cancel-payment");i&&(i.innerHTML=`<svg class="animate-spin" width="40" height="40" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
1569
1569
  <path
1570
1570
  d="M62 32C62 38.6156 59.8132 45.0457 55.78 50.2897C51.7468 55.5336 46.0932 59.2974 39.6992 60.9952C33.3052 62.693 26.5293 62.2297 20.4258 59.6774C14.3224 57.1251 9.2338 52.6268 5.95186 46.8827C2.66993 41.1385 1.37873 34.4707 2.2792 27.9166C3.17967 21.3626 6.22129 15.29 10.9308 10.6438C15.6402 5.9976 21.7534 3.0384 28.3191 2.22668C34.8847 1.41496 41.5345 2.79623 47.2337 6.15557"
1571
1571
  stroke="black" stroke-width="4" stroke-linejoin="round" />
@@ -1771,7 +1771,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
1771
1771
  </div> -->
1772
1772
  </div>
1773
1773
  </div>
1774
- </div>`;class Sc{constructor(e){d(this,"container");this.container=e.container}attachListeners(){const e=this.container.querySelector("#payment-warning-text"),t=this.container.querySelector("#payment-warning-desc");e&&(e.innerHTML=Ve["account-expired"]),t&&(t.innerHTML=Ve["account-expired-desc"])}renderComponent(){this.container.innerHTML=this.render()}render(){return kc}}class xc{constructor({amount:e,totalAmount:t,closeModal:i,container:s,customer:o,token:a,currency:l,rdtCode:c,url:p,reference:m,callBackUrl:g,metadata:b,localCurrency:y,disablePaymentMethods:w,restartTransactionProcess:f,hidePaymentMethods:k,retryingPayment:x}){d(this,"container");d(this,"contents");d(this,"closeModal");d(this,"customer");d(this,"transferDetails");d(this,"transferConfirmationProgress");d(this,"transferConfirmationEnd");d(this,"transferExpired");d(this,"mainLoader");d(this,"warningScreen");d(this,"successScreen");d(this,"merchantPlanDetail",{});d(this,"token");d(this,"currency");d(this,"amount");d(this,"totalAmount");d(this,"rdtCode");d(this,"url");d(this,"reference");d(this,"_currentStep");d(this,"activeRef");d(this,"paymentResponse");d(this,"timerId");d(this,"abortController",null);d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"transactionIssuesScreen");d(this,"disablePaymentMethods");d(this,"paymentResponseHeaders");d(this,"restartTransactionProcess");d(this,"hidePaymentMethods");d(this,"retryingPayment");d(this,"isMaxRetriesReached");d(this,"isMobile",!1);d(this,"errorText");this.currency=l,this.container=s,this.contents=this.container.querySelector("#payment-content-view"),this.closeModal=i,this.token=a,this.customer=o,this.amount=e,this.totalAmount=t,this.rdtCode=c,this.url=p,this.reference=m,this._currentStep=1,this.callBackUrl=g,this.metadata=b,this.localCurrency=y,this.disablePaymentMethods=w,this.paymentResponse={},this.paymentResponseHeaders={},this.restartTransactionProcess=f,this.hidePaymentMethods=k,this.retryingPayment=x,this.isMaxRetriesReached=!1,this.renderTransferContent(),this.paymentResponse={},this.activeRef="",this.timerId=null,this.errorText="",this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),this.currentStep===1&&(this.abortController=new AbortController,this.createTransfer()),this.isMobile=window.matchMedia("(max-width: 767px)").matches}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"),t=this.container.querySelector("#transfer-sent"),i=this.container.querySelector(".success-button");e&&e.addEventListener("click",()=>{this.currentStep=1}),t&&t.addEventListener("click",()=>{this.abortController&&(this.abortController.abort(),this.currentStep=5)}),i&&i.addEventListener("click",()=>{this.closeModal(),_.track("checkout_closes")})}onSentVerify(e){e!==2?this.abortController&&(this.abortController.abort(),this.currentStep=e):this.currentStep=2}async verifyTransfer(){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=7}}async createTransfer(){requestAnimationFrame(()=>{const e=this.container.querySelector("#loader"),t=this.container.querySelector("#details-content");t&&(this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),t.classList.add("hidden")),_.track("start_payment",{payment_method:"Transfer"});const i=ft();(()=>{var o,a;if(this.retryingPayment){const l={channel:"bank_transfer",reference:this.reference};return et(this.token,l,this.rdtCode,this.url)}else{const l={amount:this.amount,channel:"bank_transfer",currency:this.currency,customer:this.customer,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((o=this.merchantPlanDetail)==null?void 0:o.taxQuoteId)&&{taxQuoteId:(a=this.merchantPlanDetail)==null?void 0:a.taxQuoteId},deviceInformation:i};return Ri(this.token,l,this.rdtCode,this.url)}})().then(async({data:o,headers:a})=>{if(this.paymentResponse=o,this.paymentResponseHeaders=a,o.providerMessage){const l=await z(o.providerMessage,R());this.errorText=l}if(o.status==="failed")this.currentStep=7,_.track("stop_transferProcess",{payment_method:"Transfer",verification_status:"Failed"}),o.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();else if(e&&t&&(e.classList.add("hidden"),t.classList.remove("hidden")),this.activeRef=o.reference,this.paymentResponse=o,o.bankDetails&&o.bankDetails.accountNumber)this.transferDetails=new ca({container:this.contents,onAction:l=>{this.onSentVerify.bind(this)(l)},onFail:async(l,c)=>{if(this.currentStep=l,l===7&&c){const p=await z(c,R());this.errorText=p,this.warningScreen.setPaymentError(this.errorText)}}}),this.transferDetails.renderComponent(this.paymentResponse||o);else if(o.providerMessage){const l=await z(o.providerMessage,R());this.errorText=l,this.currentStep=7,this.warningScreen.setPaymentError(this.errorText)}else{const l=await z("Error fetching bank details",R());this.currentStep=7,this.warningScreen.setPaymentError(l)}}).catch(async o=>{if(_.track("verify_payment",{payment_method:"Transfer",verification_status:"Null"}),o.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyTransfer(),this.currentStep=7,_.track("max_retries_reached",{payment_method:"Transfer"}),this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else if(o!=null&&o.message){const a=await z(o.message,R());this.errorText=a,this.currentStep=7,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=7,this.warningScreen.setPaymentError(P["payment-failed"]);this.warningScreen.hideReportIssue()})})}goBackToMerchant(){Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)}renderTransferContent(e){var i;e&&(this.merchantPlanDetail=e);const t=document.getElementById("go-back");if(this.isMobile&&this.hidePaymentMethods(),this.currentStep!==1?(t==null||t.classList.add("hidden"),this.disablePaymentMethods("bank_transfer")):t==null||t.addEventListener("click",()=>{this.restartTransactionProcess()}),this.contents){switch(this.currentStep){case 1:this.transferDetails=new ca({container:this.contents,onAction:s=>{this.onSentVerify.bind(this)(s)},onFail:async(s,o)=>{if(this.currentStep=s,s===7&&o){const a=await z(o,R());this.errorText=a,this.warningScreen.setPaymentError(this.errorText)}}});break;case 2:this.transferExpired=new Sc({container:this.contents}),this.transferExpired.renderComponent();break;case 5:this.transferConfirmationProgress=new wc({container:this.contents,onAction:async(s,o)=>{if(this.currentStep=s,s===7&&o){const a=await z(o,R());this.errorText=a,this.warningScreen.setPaymentError(this.errorText)}},ref:this.activeRef,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(s,o)=>{this.paymentResponse=s,this.paymentResponseHeaders=o}}),this.transferConfirmationProgress.renderComponent(this.paymentResponse);break;case 6:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(i=this.merchantPlanDetail)==null?void 0:i.rate.rate}),this.successScreen.renderComponent();break;case 7:this.warningScreen=new en({container:this.contents,onReportIssue:()=>this.currentStep=8,onAction:this.isMaxRetriesReached?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this)}),this.contents.innerHTML=this.warningScreen.render();break;case 8:this.transferConfirmationEnd=new oa({container:this.contents,onAction:s=>{this.currentStep=s},ref:this.reference,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders,paymentMethod:"Transfer"}),this.transferConfirmationEnd.renderComponent();break;case 9:this.transactionIssuesScreen=new st({container:this.contents,onAction:async()=>{var s,o;if(this.currentStep=7,(s=this.paymentResponse)!=null&&s.providerMessage){const a=await z((o=this.paymentResponse)==null?void 0:o.providerMessage,R());this.errorText=a}this.warningScreen.setPaymentError(this.errorText||P["payment-failed"])},token:this.token,rdtCode:this.rdtCode,url:this.url,paymentChannel:"bank_transfer",callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break}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,t){navigator.clipboard.writeText(e).then(()=>{t.innerHTML=P.copied}).catch(()=>{t.innerHTML=P["copy-fail"]})}destroyTimer(){this.stopTimer()}stopPolling(){this.abortController&&this.abortController.abort()}}function da(){return function(n,e){let t=n[e];Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:()=>t,set:o=>{t=o}})}}class ce extends Error{constructor(e,t){super(e),this.status=t,this.name="FetchError"}}class yn extends Error{constructor(e){super(e),this.name="AuthorizationError"}}class ms{constructor(e){d(this,"token");d(this,"baseurl","https://api.spotflow.co/api/v1");d(this,"headers");d(this,"rdtCode");d(this,"url");d(this,"getHeaders",(e,t)=>{if(!e)throw new yn("Missing authorization token");const i=new Headers;return i.append("Content-Type","application/json"),i.append("Authorization",`Bearer ${e}`),i.append("Origin","https://sdk.spotflow.co"),t&&i.append("Spotflow-Payment-Code",t),i});this.token=e.token,this.rdtCode=e.rdtCode,this.url=e.url,this.headers=this.getHeaders(this.token,this.rdtCode)}}class ua extends ms{constructor(e){super(e)}async createCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async createUssdPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return{data:await t.json(),headers:t.headers}}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async validateCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments/validate`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async authorizeCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments/authorize`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async createTransferPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async verifyPayment(e,t){try{const i=await fetch(`${ue(this.baseurl,this.url)}/payments/verify?reference=${e}`,{method:"GET",headers:this.headers,signal:t});if(!i.ok){const o=await i.json();throw o.message?new ce(o.message,i.status):new ce("Network response was not ok",i.status)}return{data:await i.json(),headers:i.headers}}catch(i){throw i instanceof ce?console.error(`FetchError: ${i.message} (status: ${i.status})`):i instanceof yn?console.error(`AuthorizationError: ${i.message}`):console.error(`Unexpected error: ${i}`),i}}}class Ac extends ms{constructor(e){super(e)}async getMerchantConfig(e,t){try{const i=await fetch(`${ue(this.baseurl,this.url)}/checkout-configurations?currency=${t}&planId=${e||""}`,{headers:this.headers,method:"GET"});if(!i.ok){const s=await i.json();throw s.message?new ce(s.message,i.status):new ce("Network response was not ok",i.status)}return i.json()}catch(i){throw i instanceof ce?console.error(`FetchError: ${i.message} (status: ${i.status})`):i instanceof yn?console.error(`AuthorizationError: ${i.message}`):console.error(`Unexpected error: ${i}`),i}}}class Mc extends ms{constructor(e){super(e)}async getBankList(){try{const e=await fetch(`${ue(this.baseurl,this.url)}/banks?ussd=true`,{headers:this.headers,method:"GET"});if(!e.ok){const t=await e.json();throw t.message?new ce(t.message,e.status):new ce("Network response was not ok",e.status)}return e.json()}catch(e){throw e instanceof ce?(Vt.showToast(e.message,"error",9e3),console.error(`FetchError: ${e.message} (status: ${e.status})`)):e instanceof yn?console.error(`AuthorizationError: ${e.message}`):console.error(`Unexpected error: ${e}`),e}}}const Lc=`<form id="ussdBanks">
1774
+ </div>`;class Sc{constructor(e){d(this,"container");this.container=e.container}attachListeners(){const e=this.container.querySelector("#payment-warning-text"),t=this.container.querySelector("#payment-warning-desc");e&&(e.innerHTML=Ve["account-expired"]),t&&(t.innerHTML=Ve["account-expired-desc"])}renderComponent(){this.container.innerHTML=this.render()}render(){return kc}}class xc{constructor({amount:e,totalAmount:t,closeModal:i,container:s,customer:o,token:a,currency:l,rdtCode:c,url:p,reference:m,callBackUrl:g,metadata:b,localCurrency:y,disablePaymentMethods:w,restartTransactionProcess:f,hidePaymentMethods:k,retryingPayment:x}){d(this,"container");d(this,"contents");d(this,"closeModal");d(this,"customer");d(this,"transferDetails");d(this,"transferConfirmationProgress");d(this,"transferConfirmationEnd");d(this,"transferExpired");d(this,"mainLoader");d(this,"warningScreen");d(this,"successScreen");d(this,"merchantPlanDetail",{});d(this,"token");d(this,"currency");d(this,"amount");d(this,"totalAmount");d(this,"rdtCode");d(this,"url");d(this,"reference");d(this,"_currentStep");d(this,"activeRef");d(this,"paymentResponse");d(this,"timerId");d(this,"abortController",null);d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"transactionIssuesScreen");d(this,"disablePaymentMethods");d(this,"paymentResponseHeaders");d(this,"restartTransactionProcess");d(this,"hidePaymentMethods");d(this,"retryingPayment");d(this,"isMaxRetriesReached");d(this,"isMobile",!1);d(this,"errorText");this.currency=l,this.container=s,this.contents=this.container.querySelector("#payment-content-view"),this.closeModal=i,this.token=a,this.customer=o,this.amount=e,this.totalAmount=t,this.rdtCode=c,this.url=p,this.reference=m,this._currentStep=1,this.callBackUrl=g,this.metadata=b,this.localCurrency=y,this.disablePaymentMethods=w,this.paymentResponse={},this.paymentResponseHeaders={},this.restartTransactionProcess=f,this.hidePaymentMethods=k,this.retryingPayment=x,this.isMaxRetriesReached=!1,this.renderTransferContent(),this.paymentResponse={},this.activeRef="",this.timerId=null,this.errorText="",this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),this.currentStep===1&&(this.abortController=new AbortController,this.createTransfer()),this.isMobile=window.matchMedia("(max-width: 767px)").matches}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"),t=this.container.querySelector("#transfer-sent"),i=this.container.querySelector(".success-button");e&&e.addEventListener("click",()=>{this.currentStep=1}),t&&t.addEventListener("click",()=>{this.abortController&&(this.abortController.abort(),this.currentStep=5)}),i&&i.addEventListener("click",()=>{this.closeModal(),_.track("checkout_closes")})}onSentVerify(e){e!==2?this.abortController&&(this.abortController.abort(),this.currentStep=e):this.currentStep=2}async verifyTransfer(){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=7}}async createTransfer(){requestAnimationFrame(()=>{const e=this.container.querySelector("#loader"),t=this.container.querySelector("#details-content");t&&(this.mainLoader=new ke(this.contents),this.mainLoader.mountLoader("25dvh"),t.classList.add("hidden")),_.track("start_payment",{payment_method:"Transfer"});const i=ft();(()=>{var o,a;if(this.retryingPayment){const l={channel:"bank_transfer",reference:this.reference};return et(this.token,l,this.rdtCode,this.url)}else{const l={amount:this.amount,channel:"bank_transfer",currency:this.currency,customer:this.customer,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,...this.localCurrency&&{localCurrency:this.localCurrency},isCheckout:!0,...((o=this.merchantPlanDetail)==null?void 0:o.taxQuoteId)&&{taxQuoteId:(a=this.merchantPlanDetail)==null?void 0:a.taxQuoteId},deviceInformation:i};return Ri(this.token,l,this.rdtCode,this.url)}})().then(async({data:o,headers:a})=>{if(this.paymentResponse=o,this.paymentResponseHeaders=a,o.providerMessage){const l=await z(o.providerMessage,R());this.errorText=l}if(o.status==="failed")this.currentStep=7,_.track("stop_transferProcess",{payment_method:"Transfer",verification_status:"Failed"}),o.providerMessage?this.warningScreen.setPaymentError(this.errorText):this.warningScreen.setPaymentError(P["payment-failed"]),this.warningScreen.hideReportIssue();else if(e&&t&&(e.classList.add("hidden"),t.classList.remove("hidden")),this.activeRef=o.reference,this.paymentResponse=o,o.bankDetails&&o.bankDetails.accountNumber)this.transferDetails=new ca({container:this.contents,onAction:l=>{this.onSentVerify.bind(this)(l)},onFail:async(l,c)=>{if(this.currentStep=l,l===7&&c){const p=await z(c,R());this.errorText=p,this.warningScreen.setPaymentError(this.errorText)}}}),this.transferDetails.renderComponent(this.paymentResponse||o);else if(o.providerMessage){const l=await z(o.providerMessage,R());this.errorText=l,this.currentStep=7,this.warningScreen.setPaymentError(this.errorText)}else{const l=await z("Error fetching bank details",R());this.currentStep=7,this.warningScreen.setPaymentError(l)}}).catch(async o=>{if(_.track("verify_payment",{payment_method:"Transfer",verification_status:"Null"}),o.code==="payment_max_retry_attempts")this.isMaxRetriesReached=!0,this.verifyTransfer(),this.currentStep=7,_.track("max_retries_reached",{payment_method:"Transfer"}),this.warningScreen.setPaymentError(P["maximum-retries"],P["maximum-retries-desc"],q["merchant-back"]);else if(o!=null&&o.message){const a=await z(o.message,R());this.errorText=a,this.currentStep=7,this.warningScreen.setPaymentError(this.errorText)}else this.currentStep=7,this.warningScreen.setPaymentError(P["payment-failed"]);this.warningScreen.hideReportIssue()})})}goBackToMerchant(){Pe(this.paymentResponse,this.paymentResponseHeaders,this.callBackUrl)}renderTransferContent(e){var i;e&&(this.merchantPlanDetail=e);const t=document.getElementById("go-back");if(this.isMobile&&this.hidePaymentMethods(),this.currentStep!==1?(t==null||t.classList.add("hidden"),this.disablePaymentMethods("bank_transfer")):t==null||t.addEventListener("click",()=>{this.restartTransactionProcess()}),this.contents){switch(this.currentStep){case 1:this.transferDetails=new ca({container:this.contents,onAction:s=>{this.onSentVerify.bind(this)(s)},onFail:async(s,o)=>{if(this.currentStep=s,s===7&&o){const a=await z(o,R());this.errorText=a,this.warningScreen.setPaymentError(this.errorText)}}});break;case 2:this.transferExpired=new Sc({container:this.contents}),this.transferExpired.renderComponent();break;case 5:this.transferConfirmationProgress=new wc({container:this.contents,onAction:async(s,o)=>{if(this.currentStep=s,s===7&&o){const a=await z(o,R());this.errorText=a,this.warningScreen.setPaymentError(this.errorText)}},ref:this.activeRef,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,setPaymentResponses:(s,o)=>{this.paymentResponse=s,this.paymentResponseHeaders=o}}),this.transferConfirmationProgress.renderComponent(this.paymentResponse);break;case 6:this.successScreen=new Fn({container:this.contents,amount:this.totalAmount,currency:this.currency,localCurrency:this.localCurrency,rate:(i=this.merchantPlanDetail)==null?void 0:i.rate.rate}),this.successScreen.renderComponent();break;case 7:this.warningScreen=new en({container:this.contents,onReportIssue:()=>this.currentStep=8,onAction:this.isMaxRetriesReached?this.goBackToMerchant.bind(this):this.restartTransactionProcess.bind(this)}),this.contents.innerHTML=this.warningScreen.render();break;case 8:this.transferConfirmationEnd=new oa({container:this.contents,onAction:s=>{this.currentStep=s},ref:this.reference,token:this.token,rdtCode:this.rdtCode,url:this.url,callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders,paymentMethod:"Transfer"}),this.transferConfirmationEnd.renderComponent();break;case 9:this.transactionIssuesScreen=new st({container:this.contents,onAction:async()=>{var s,o;if(this.currentStep=7,(s=this.paymentResponse)!=null&&s.providerMessage){const a=await z((o=this.paymentResponse)==null?void 0:o.providerMessage,R());this.errorText=a}this.warningScreen.setPaymentError(this.errorText||P["payment-failed"])},token:this.token,rdtCode:this.rdtCode,url:this.url,paymentChannel:"bank_transfer",callBackUrl:this.callBackUrl,paymentResponse:this.paymentResponse,paymentResponseHeaders:this.paymentResponseHeaders}),this.transactionIssuesScreen.renderTransactionIssuesComponent();break}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,t){navigator.clipboard.writeText(e).then(()=>{t.innerHTML=P.copied}).catch(()=>{t.innerHTML=P["copy-fail"]})}destroyTimer(){this.stopTimer()}stopPolling(){this.abortController&&this.abortController.abort()}}function da(){return function(n,e){let t=n[e];Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:()=>t,set:o=>{t=o}})}}class ce extends Error{constructor(e,t){super(e),this.status=t,this.name="FetchError"}}class yn extends Error{constructor(e){super(e),this.name="AuthorizationError"}}class ms{constructor(e){d(this,"token");d(this,"baseurl","https://api.spotflow.co/api/v1");d(this,"headers");d(this,"rdtCode");d(this,"url");d(this,"getHeaders",(e,t)=>{if(!e)throw new yn("Missing authorization token");const i=new Headers;return i.append("Content-Type","application/json"),i.append("Authorization",`Bearer ${e}`),i.append("Origin","https://sdk.spotflow.co"),t&&i.append("Spotflow-Payment-Code",t),i});this.token=e.token,this.rdtCode=e.rdtCode,this.url=e.url,this.headers=this.getHeaders(this.token,this.rdtCode)}}class ua extends ms{constructor(e){super(e)}async createCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async createUssdPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return{data:await t.json(),headers:t.headers}}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async validateCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments/validate`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async authorizeCardPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments/authorize`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async createTransferPayment(e){try{const t=await fetch(`${ue(this.baseurl,this.url)}/payments`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw s.message?new ce(s.message,t.status):new ce("Network response was not ok",t.status)}return await t.json()}catch(t){throw t instanceof ce?console.error(`FetchError: ${t.message} (status: ${t.status})`):t instanceof yn?console.error(`AuthorizationError: ${t.message}`):console.error(`Unexpected error: ${t}`),t}}async verifyPayment(e,t){try{const i=await fetch(`${ue(this.baseurl,this.url)}/payments/verify?reference=${e}`,{method:"GET",headers:this.headers,signal:t});if(!i.ok){const o=await i.json();throw o.message?new ce(o.message,i.status):new ce("Network response was not ok",i.status)}return{data:await i.json(),headers:i.headers}}catch(i){throw i instanceof ce?console.error(`FetchError: ${i.message} (status: ${i.status})`):i instanceof yn?console.error(`AuthorizationError: ${i.message}`):console.error(`Unexpected error: ${i}`),i}}}class Ac extends ms{constructor(e){super(e)}async getMerchantConfig(e,t,i){try{const s=new URLSearchParams;t&&s.append("currency",t),e&&s.append("planId",e),i&&s.append("subscriptionId",i);const o=await fetch(`${ue(this.baseurl,this.url)}/checkout-configurations?${s.toString()}`,{headers:this.headers,method:"GET"});if(!o.ok){const a=await o.json();throw a.message?new ce(a.message,o.status):new ce("Network response was not ok",o.status)}return o.json()}catch(s){throw s instanceof ce?console.error(`FetchError: ${s.message} (status: ${s.status})`):s instanceof yn?console.error(`AuthorizationError: ${s.message}`):console.error(`Unexpected error: ${s}`),s}}}class Mc extends ms{constructor(e){super(e)}async getBankList(){try{const e=await fetch(`${ue(this.baseurl,this.url)}/banks?ussd=true`,{headers:this.headers,method:"GET"});if(!e.ok){const t=await e.json();throw t.message?new ce(t.message,e.status):new ce("Network response was not ok",e.status)}return e.json()}catch(e){throw e instanceof ce?(Vt.showToast(e.message,"error",9e3),console.error(`FetchError: ${e.message} (status: ${e.status})`)):e instanceof yn?console.error(`AuthorizationError: ${e.message}`):console.error(`Unexpected error: ${e}`),e}}}const Lc=`<form id="ussdBanks">
1775
1775
  <div>
1776
1776
  <h5 class="text-grey-400 font-semibold text-sm">Please choose your bank to begin payment</h5>
1777
1777
  <div class="mt-2">
@@ -1991,47 +1991,47 @@ 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"),F=this.container.querySelector("#tooltip-localCurrency-mob"),Z=this.container.querySelector("#select-payment-method-text"),G=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),G&&(G.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),F&&this.localCurrency&&(F.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
- <div key=${a.key}>
1996
- <button class="tab-button gap-2 mb-4 group" data-name="${a.key}">
1997
- <div class="lg:block">${a.icon}</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"),F=this.container.querySelector("#tooltip-localCurrency-mob"),Z=this.container.querySelector("#select-payment-method-text"),G=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),G&&(G.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),F&&this.localCurrency&&(F.innerHTML=un?`${un} (${this.localCurrency})`:this.localCurrency),this.renderPaymentOptions(this.container),this.attachListeners()}renderPaymentOptions(e){var s;const t=e.querySelector(".payment-options"),i=Hn(this.currency,this.localCurrency);if(t){const o=this.merchantDetail.plan&&!((s=this.metadata)!=null&&s.subscription_id)?[se.mobile_money,se.card]:this.merchantDetail.paymentMethods.filter(a=>a!=="ussd").filter(a=>!(i!=="USD"&&a==="stablecoin")).map(a=>se[a]);if(this.isMobile){let a='<div class="">';o.forEach(l=>{a+=`
1995
+ <div key=${l.key}>
1996
+ <button class="tab-button gap-2 mb-4 group" data-name="${l.key}">
1997
+ <div class="lg:block">${l.icon}</div>
1998
1998
  <div class="flex items-center gap-2">
1999
- <span class="pm-label" data-translate=${a.translateKey}>${a.label} </span>
2000
- ${a.key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
1999
+ <span class="pm-label" data-translate=${l.translateKey}>${l.label} </span>
2000
+ ${l.key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2001
2001
  </div>
2002
2002
  </button>
2003
2003
  </div>
2004
- `}),o+="</div>",t.innerHTML=o}else{const o=s.length%2===0;let a='<div class="grid gap-2">';if(o)a+='<div class="grid grid-cols-2 gap-2">',s.forEach(l=>{a+=`
2005
- <div key=${l.key}>
2006
- <button class="tab-button gap-2 group" data-name="${l.key}">
2007
- <div class="md:container-center lg:block">${l.icon}</div>
2004
+ `}),a+="</div>",t.innerHTML=a}else{const a=o.length%2===0;let l='<div class="grid gap-2">';if(a)l+='<div class="grid grid-cols-2 gap-2">',o.forEach(c=>{l+=`
2005
+ <div key=${c.key}>
2006
+ <button class="tab-button gap-2 group" data-name="${c.key}">
2007
+ <div class="md:container-center lg:block">${c.icon}</div>
2008
2008
  <div class="flex items-center gap-2">
2009
- <span class="pm-label" data-translate=${l.translateKey}>${l.label} </span>
2010
- ${l.key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2009
+ <span class="pm-label" data-translate=${c.translateKey}>${c.label} </span>
2010
+ ${c.key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2011
2011
  </div>
2012
2012
  </button>
2013
2013
  </div>
2014
- `}),a+="</div>";else{if(a+=`
2014
+ `}),l+="</div>";else{if(l+=`
2015
2015
  <div>
2016
- <button class="tab-button gap-2 group" data-name="${s[0].key}">
2017
- <div class="md:container-center lg:block"> ${s[0].icon}</div>
2016
+ <button class="tab-button gap-2 group" data-name="${o[0].key}">
2017
+ <div class="md:container-center lg:block"> ${o[0].icon}</div>
2018
2018
  <div class="flex items-center gap-2">
2019
- <span class="pm-label" data-translate=${s[0].translateKey}>${s[0].label} </span>
2020
- ${s[0].key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2019
+ <span class="pm-label" data-translate=${o[0].translateKey}>${o[0].label} </span>
2020
+ ${o[0].key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2021
2021
  </div>
2022
2022
  </button>
2023
2023
  </div>
2024
- `,s.length>1){a+='<div class="grid grid-cols-2 gap-2">';for(let l=1;l<s.length;l++)a+=`
2024
+ `,o.length>1){l+='<div class="grid grid-cols-2 gap-2">';for(let c=1;c<o.length;c++)l+=`
2025
2025
  <div>
2026
- <button class="tab-button gap-2 group" data-name="${s[l].key}">
2027
- <div class="md:container-center lg:block">${s[l].icon}</div>
2026
+ <button class="tab-button gap-2 group" data-name="${o[c].key}">
2027
+ <div class="md:container-center lg:block">${o[c].icon}</div>
2028
2028
  <div class="flex items-center gap-2">
2029
- <span class="pm-label" data-translate=${s[l].translateKey}>${s[l].label} </span>
2030
- ${s[l].key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2029
+ <span class="pm-label" data-translate=${o[c].translateKey}>${o[c].label} </span>
2030
+ ${o[c].key==="card"?` <div class="bg-tone-100 rounded-[40px] h-[22px] text-xxs text-white align-center px-2"> ${i} </div>`:""}
2031
2031
  </div>
2032
2032
  </button>
2033
2033
  </div>
2034
- `;a+="</div>"}a+="</div>"}a+="</div>",t.innerHTML=a}}}render(){return Hc}}const Oc=`<div id="mobileConfirmationProgress" data-section="mobile_money">
2034
+ `;l+="</div>"}l+="</div>"}l+="</div>",t.innerHTML=l}}}render(){return Hc}}const Oc=`<div id="mobileConfirmationProgress" data-section="mobile_money">
2035
2035
  <div>
2036
2036
  <div>
2037
2037
  <div class=" grid grid-rows-[auto_1fr] gap-4 mx-5">
@@ -2455,4 +2455,4 @@ or you can use record.mirror to access the mirror instance during recording.`;le
2455
2455
 
2456
2456
  </div>
2457
2457
  </div>
2458
- `}}class rd{constructor(){d(this,"modalContainer");d(this,"mainLayout");d(this,"encryption");d(this,"mainScreen");d(this,"merchantConfigService");d(this,"mainError");d(this,"mainLoader");d(this,"merchantPlanDetail",{});d(this,"merchantKey");d(this,"planId");d(this,"email");d(this,"amount");d(this,"name");d(this,"rdtCode");d(this,"url");d(this,"phoneNumber");d(this,"code");d(this,"reference");d(this,"currency");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"countryCode");d(this,"mode");d(this,"rawPaymentMethodTexts");d(this,"currentLanguage");this.merchantKey="",this.email="",this.amount=0,this.planId="",this.encryption="",this.phoneNumber="",this.code="",this.modalContainer=document.createElement("div"),this.rdtCode="",this.reference="",this.currency="",this.url="",this.callBackUrl="",this.metadata={},this.localCurrency="",this.countryCode="",this.rawPaymentMethodTexts=Hi,this.modalContainer.innerHTML=$n,this.currentLanguage=pn,_.init("11162d9a0801daeaf786f1200cd3112b",{debug:!1}),document.body.appendChild(this.modalContainer);const t=document.getElementById("main-layout-container-screen");if(!t)throw new Error("SDK Layout not available");this.mainLayout=t}closePayment(){const e={reference:this.reference};Va(this.merchantKey,e,this.rdtCode,this.url).then(({headers:i})=>{const s=i.get("spf-redirect-url");this.callBackUrl=s||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const o=new URL(this.callBackUrl);o.searchParams.append("status","cancelled"),o.searchParams.append("reference",this.reference),window.location.href=o.toString()},1800):this.closeModal(),_.track("cancel_payment",{verification_status:"Cancelled"}),_.track("checkout_closes")}).catch(i=>{Vt.showToast(i.message,"error")})}getDeviceType(){const e=navigator.userAgent;return/mobile/i.test(e)?"Mobile":/tablet/i.test(e)?"Tablet":"Desktop"}setup(e){const{email:t,encryptionKey:i,merchantKey:s,planId:o,amount:a,rdtCode:l,reference:c,currency:p,url:m,callBackUrl:g,metadata:b,localCurrency:y,countryCode:w,phoneNumber:f,name:k,mode:x}=e;if(this.merchantKey=s||"",this.email=t||"",this.amount=a||0,this.encryption=i||"",this.planId=o||"",this.rdtCode=l||"",this.reference=c||Qa(),this.url=m||"",this.callBackUrl=g||"",this.metadata=b||{},this.countryCode=w||"",this.phoneNumber=f||"",this.name=k||"",this.mode=x,!s||!t)throw this.mainError=new ps(this.mainLayout),this.mainError.renderContent(q["merchant-email-required"],this.callBackUrl),this.showErrorIcon(),new Error("Merchant key or email is required");if(p==="USD"&&!y)throw this.mainError=new ps(this.mainLayout),this.mainError.renderContent(q["no-local-currency"],""),this.showErrorIcon(),new Error("Local currency is required for USD transactions");this.currency=p||"",this.merchantConfigService=new Ac({token:this.merchantKey,rdtCode:this.rdtCode,url:this.url}),this.localCurrency=y||"",this.mainScreen=new sd({container:this.mainLayout,modalContainer:this.modalContainer,merchantKey:s,encryption:this.encryption,planId:this.planId,amount:this.amount,rdtCode:this.rdtCode,url:this.url,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency,countryCode:this.countryCode,mode:this.mode,customerDetails:{email:t||this.email,...this.name?{name:this.name}:{},...this.phoneNumber?{phoneNumber:this.phoneNumber}:{}},closePayment:this.closePayment.bind(this)}),this.mainLoader=new ke(this.mainLayout),this.mainError=new ps(this.mainLayout),this.mainLoader.mountLoader(),this.getPlanDetails()}getAvailableChannels(){var o,a;const e=((o=this.merchantPlanDetail)==null?void 0:o.paymentMethods)??[],t=((a=this.merchantPlanDetail)==null?void 0:a.limits)??[],i=[],s=[];return e.forEach(l=>{const c=t.find(p=>p.channel===l);!c||this.amount<=c.amount?i.push(l):s.push(l)}),{validChannels:i,disabledChannels:s}}async getPlanDetails(){const e=this.currency==="USD"?this.localCurrency:this.currency;this.merchantConfigService.getMerchantConfig(this.planId,e).then(async t=>{var i,s;if(t.taxEnabled){const o=await Ga(this.merchantKey,this.localCurrency!==this.currency?this.amount*t.rate.rate:this.amount,e,this.rdtCode,this.url);this.merchantPlanDetail={...t,totalAmount:o.totalAmount,taxQuoteId:o.id}}else this.merchantPlanDetail=t;if(t.rate){if(sr(e,this.countryCode),this.currentLanguage=R(),this.currentLanguage!=="en"){await Us(this.currentLanguage),Ae.getTranslationError()&&it("en");const p=t.paymentMethods;this.updateMethodsOptionsTexts(["stablecoins",...p]),this.mainLoader.updateMessage(`${q.translating}...`),await Vs(this.currentLanguage)}_.register({device_type:this.getDeviceType(),session_id:this.reference,env:this.merchantKey.split("_")[1],checkout_env:this.rdtCode?"Redirect":"SDK",merchant:this.merchantPlanDetail.merchantName}),_.track("checkout_opens");const{validChannels:o,disabledChannels:a}=this.getAvailableChannels();if(((i=this.merchantPlanDetail)==null?void 0:i.limits)&&this.merchantPlanDetail.limits.length>0&&(o.length===0||o[0]==="ussd"&&o.length===1)){const c=new ad(this.mainLayout);this.mainError=c;let p=0;throw(s=this.merchantPlanDetail)!=null&&s.limits&&this.merchantPlanDetail.limits.length>0&&(p=Math.max(...this.merchantPlanDetail.limits.map(m=>m.amount))),c.setLimitInfo(e,p),this.mainError.renderContent(q["transaction-limit"],this.callBackUrl),this.showErrorIcon(),new Error("Transaction limit reached")}this.render(o,a)}else this.mainError.renderContent(q["rate-not-found"],this.callBackUrl),this.showErrorIcon()}).catch(t=>{throw this.mainError.renderContent(q["error-occured"],this.callBackUrl),this.showErrorIcon(),new Error(t)})}render(e,t){this.mainScreen.mountScreen(this.merchantPlanDetail,this.currency,e,t)}async updateMethodsOptionsTexts(e){let t=[];for(let i of e)switch(i){case"card":t.push(this.rawPaymentMethodTexts["pay-card"]);break;case"bank_transfer":t.push(this.rawPaymentMethodTexts["pay-transfer"]);break;case"mobile_money":t.push(this.rawPaymentMethodTexts["pay-momo"]);break;case"eft":t.push(this.rawPaymentMethodTexts["pay-eft"]);break;case"pay_with_opay":t.push(this.rawPaymentMethodTexts["pay-with-opay"]);break;case"stablecoin":t.push(this.rawPaymentMethodTexts["pay-stablecoin"]);break}await Os(this.currentLanguage),nt("card",rn["pay-card"]),nt("bank_transfer",rn["pay-transfer"]),nt("mobile_money",rn["pay-momo"]),nt("eft",rn["pay-eft"]),nt("pay_with_opay",rn["pay-with-opay"]),nt("stablecoin",rn["pay-stablecoin"])}showErrorIcon(){var t;const e=this.mainLayout.querySelector("#shared-error-container");e&&(e.classList.remove("hidden"),e.parentElement.classList.add("mx-auto"),e.classList.add("flex","flex-col","items-center","gap-2"),(t=e.querySelector("img"))==null||t.setAttribute("src",od))}closeModal(){this.modalContainer&&this.modalContainer.parentNode&&document.body.removeChild(this.modalContainer),this.mainScreen.closeModal()}}We.CheckoutForm=rd,Object.defineProperty(We,Symbol.toStringTag,{value:"Module"})});
2458
+ `}}class rd{constructor(){d(this,"modalContainer");d(this,"mainLayout");d(this,"encryption");d(this,"mainScreen");d(this,"merchantConfigService");d(this,"mainError");d(this,"mainLoader");d(this,"merchantPlanDetail",{});d(this,"merchantKey");d(this,"planId");d(this,"email");d(this,"amount");d(this,"name");d(this,"rdtCode");d(this,"url");d(this,"phoneNumber");d(this,"code");d(this,"reference");d(this,"currency");d(this,"callBackUrl");d(this,"metadata");d(this,"localCurrency");d(this,"countryCode");d(this,"mode");d(this,"rawPaymentMethodTexts");d(this,"currentLanguage");d(this,"subscriptionId");this.merchantKey="",this.email="",this.amount=0,this.planId="",this.encryption="",this.phoneNumber="",this.code="",this.modalContainer=document.createElement("div"),this.rdtCode="",this.reference="",this.currency="",this.url="",this.callBackUrl="",this.metadata={},this.localCurrency="",this.countryCode="",this.rawPaymentMethodTexts=Hi,this.modalContainer.innerHTML=$n,this.currentLanguage=pn,this.subscriptionId="",_.init("11162d9a0801daeaf786f1200cd3112b",{debug:!1}),document.body.appendChild(this.modalContainer);const t=document.getElementById("main-layout-container-screen");if(!t)throw new Error("SDK Layout not available");this.mainLayout=t}closePayment(){const e={reference:this.reference};Va(this.merchantKey,e,this.rdtCode,this.url).then(({headers:i})=>{const s=i.get("spf-redirect-url");this.callBackUrl=s||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const o=new URL(this.callBackUrl);o.searchParams.append("status","cancelled"),o.searchParams.append("reference",this.reference),window.location.href=o.toString()},1800):this.closeModal(),_.track("cancel_payment",{verification_status:"Cancelled"}),_.track("checkout_closes")}).catch(i=>{Vt.showToast(i.message,"error")})}getDeviceType(){const e=navigator.userAgent;return/mobile/i.test(e)?"Mobile":/tablet/i.test(e)?"Tablet":"Desktop"}setup(e){const{email:t,encryptionKey:i,merchantKey:s,planId:o,amount:a,rdtCode:l,reference:c,currency:p,url:m,callBackUrl:g,metadata:b,localCurrency:y,countryCode:w,phoneNumber:f,name:k,mode:x}=e;if(this.merchantKey=s||"",this.email=t||"",this.amount=a||0,this.encryption=i||"",this.planId=o||"",this.rdtCode=l||"",this.reference=c||Qa(),this.url=m||"",this.callBackUrl=g||"",this.metadata=b||{},this.countryCode=w||"",this.phoneNumber=f||"",this.name=k||"",this.mode=x,!s||!t)throw this.mainError=new ps(this.mainLayout),this.mainError.renderContent(q["merchant-email-required"],this.callBackUrl),this.showErrorIcon(),new Error("Merchant key or email is required");if(p==="USD"&&!y)throw this.mainError=new ps(this.mainLayout),this.mainError.renderContent(q["no-local-currency"],""),this.showErrorIcon(),new Error("Local currency is required for USD transactions");this.currency=p||"",this.merchantConfigService=new Ac({token:this.merchantKey,rdtCode:this.rdtCode,url:this.url}),this.localCurrency=y||"",this.mainScreen=new sd({container:this.mainLayout,modalContainer:this.modalContainer,merchantKey:s,encryption:this.encryption,planId:this.planId,amount:this.amount,rdtCode:this.rdtCode,url:this.url,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency,countryCode:this.countryCode,mode:this.mode,customerDetails:{email:t||this.email,...this.name?{name:this.name}:{},...this.phoneNumber?{phoneNumber:this.phoneNumber}:{}},closePayment:this.closePayment.bind(this)}),this.mainLoader=new ke(this.mainLayout),this.mainError=new ps(this.mainLayout),this.mainLoader.mountLoader(),this.getPlanDetails()}getAvailableChannels(){var o,a;const e=((o=this.merchantPlanDetail)==null?void 0:o.paymentMethods)??[],t=((a=this.merchantPlanDetail)==null?void 0:a.limits)??[],i=[],s=[];return e.forEach(l=>{const c=t.find(p=>p.channel===l);!c||this.amount<=c.amount?i.push(l):s.push(l)}),{validChannels:i,disabledChannels:s}}async getPlanDetails(){const e=this.currency==="USD"?this.localCurrency:this.currency;this.merchantConfigService.getMerchantConfig(this.planId,e,this.metadata.subscription_id).then(async t=>{var i,s;if(t.taxEnabled){const o=await Ga(this.merchantKey,this.localCurrency!==this.currency?this.amount*t.rate.rate:this.amount,e,this.rdtCode,this.url);this.merchantPlanDetail={...t,totalAmount:o.totalAmount,taxQuoteId:o.id}}else this.merchantPlanDetail=t;if(t.rate){if(sr(e,this.countryCode),this.currentLanguage=R(),this.currentLanguage!=="en"){await Us(this.currentLanguage),Ae.getTranslationError()&&it("en");const p=t.paymentMethods;this.updateMethodsOptionsTexts(["stablecoins",...p]),this.mainLoader.updateMessage(`${q.translating}...`),await Vs(this.currentLanguage)}_.register({device_type:this.getDeviceType(),session_id:this.reference,env:this.merchantKey.split("_")[1],checkout_env:this.rdtCode?"Redirect":"SDK",merchant:this.merchantPlanDetail.merchantName}),_.track("checkout_opens");const{validChannels:o,disabledChannels:a}=this.getAvailableChannels();if(((i=this.merchantPlanDetail)==null?void 0:i.limits)&&this.merchantPlanDetail.limits.length>0&&(o.length===0||o[0]==="ussd"&&o.length===1)){const c=new ad(this.mainLayout);this.mainError=c;let p=0;throw(s=this.merchantPlanDetail)!=null&&s.limits&&this.merchantPlanDetail.limits.length>0&&(p=Math.max(...this.merchantPlanDetail.limits.map(m=>m.amount))),c.setLimitInfo(e,p),this.mainError.renderContent(q["transaction-limit"],this.callBackUrl),this.showErrorIcon(),new Error("Transaction limit reached")}this.render(o,a)}else this.mainError.renderContent(q["rate-not-found"],this.callBackUrl),this.showErrorIcon()}).catch(t=>{throw this.mainError.renderContent(q["error-occured"],this.callBackUrl),this.showErrorIcon(),new Error(t)})}render(e,t){this.mainScreen.mountScreen(this.merchantPlanDetail,this.currency,e,t)}async updateMethodsOptionsTexts(e){let t=[];for(let i of e)switch(i){case"card":t.push(this.rawPaymentMethodTexts["pay-card"]);break;case"bank_transfer":t.push(this.rawPaymentMethodTexts["pay-transfer"]);break;case"mobile_money":t.push(this.rawPaymentMethodTexts["pay-momo"]);break;case"eft":t.push(this.rawPaymentMethodTexts["pay-eft"]);break;case"pay_with_opay":t.push(this.rawPaymentMethodTexts["pay-with-opay"]);break;case"stablecoin":t.push(this.rawPaymentMethodTexts["pay-stablecoin"]);break}await Os(this.currentLanguage),nt("card",rn["pay-card"]),nt("bank_transfer",rn["pay-transfer"]),nt("mobile_money",rn["pay-momo"]),nt("eft",rn["pay-eft"]),nt("pay_with_opay",rn["pay-with-opay"]),nt("stablecoin",rn["pay-stablecoin"])}showErrorIcon(){var t;const e=this.mainLayout.querySelector("#shared-error-container");e&&(e.classList.remove("hidden"),e.parentElement.classList.add("mx-auto"),e.classList.add("flex","flex-col","items-center","gap-2"),(t=e.querySelector("img"))==null||t.setAttribute("src",od))}closeModal(){this.modalContainer&&this.modalContainer.parentNode&&document.body.removeChild(this.modalContainer),this.mainScreen.closeModal()}}We.CheckoutForm=rd,Object.defineProperty(We,Symbol.toStringTag,{value:"Module"})});
@@ -65,6 +65,7 @@ declare class Card {
65
65
  private confirmationProgress;
66
66
  private restartTransactionProcess;
67
67
  private retryingPayment;
68
+ merchantDetails: GetMerchantDetailsTax;
68
69
  isMaxRetriesReached: boolean;
69
70
  isCancelledPlan: boolean;
70
71
  isMobile: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spot-flow/checkout-inline-js",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "dist/checkout-inline.js",
6
6
  "module": "dist/checkout-inline.es.js",