@spot-flow/checkout-inline-js 0.1.32-dev.6 → 0.1.32-dev.7

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.
@@ -35788,7 +35788,7 @@ class gu {
35788
35788
  merchant: this.merchantPlanDetail.merchantName
35789
35789
  }), P.track("checkout_opens");
35790
35790
  const { validChannels: t, disabledChannels: s } = this.getAvailableChannels();
35791
- if (t.length === 0) {
35791
+ if (t.length === 0 || t[0] === "ussd") {
35792
35792
  const r = new hu(this.mainLayout);
35793
35793
  this.mainError = r;
35794
35794
  let l = 0;
@@ -1410,4 +1410,4 @@ or you can use record.mirror to access the mirror instance during recording.`;le
1410
1410
 
1411
1411
  </div>
1412
1412
  </div>
1413
- `}}class vl{constructor(){m(this,"modalContainer");m(this,"mainLayout");m(this,"encryption");m(this,"mainScreen");m(this,"merchantConfigService");m(this,"mainError");m(this,"mainLoader");m(this,"merchantPlanDetail",{});m(this,"merchantKey");m(this,"planId");m(this,"email");m(this,"amount");m(this,"rdtCode");m(this,"url");m(this,"phoneNumber");m(this,"code");m(this,"reference");m(this,"currency");m(this,"callBackUrl");m(this,"metadata");m(this,"localCurrency");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.modalContainer.innerHTML=Ln,P.init("11162d9a0801daeaf786f1200cd3112b",{debug:!1}),document.body.appendChild(this.modalContainer);const i=document.getElementById("main-layout-container-screen");if(!i)throw new Error("SDK Layout not available");this.mainLayout=i}closePayment(){const e={reference:this.reference};ks(this.merchantKey,e,this.rdtCode,this.url).then(({headers:t})=>{const o=t.get("spf-redirect-url");this.callBackUrl=o||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const s=new URL(this.callBackUrl);s.searchParams.append("status","cancelled"),s.searchParams.append("reference",this.reference),window.location.href=s.toString()},1800):this.closeModal(),P.track("canel_payment",{verification_status:"Cancelled"}),P.track("checkout_closes")}).catch(t=>{li.showToast(t.message,"error")})}getDeviceType(){const e=navigator.userAgent;return/mobile/i.test(e)?"Mobile":/tablet/i.test(e)?"Tablet":"Desktop"}setup(e){const{email:i,encryptionKey:t,merchantKey:o,planId:s,amount:r,rdtCode:l,reference:c,currency:b,url:p,callBackUrl:g,metadata:f,localCurrency:y}=e;if(this.merchantKey=o||"",this.email=i||"",this.amount=r||0,this.encryption=t||"",this.planId=s||"",this.rdtCode=l||"",this.reference=c||_s(),this.url=p||"",this.callBackUrl=g||"",this.metadata=f||{},!o||!i)throw this.mainError=new Zo(this.mainLayout),this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error("Merchant key or email is required");this.currency=b||"",this.merchantConfigService=new Vr({token:this.merchantKey,rdtCode:this.rdtCode,url:this.url}),this.localCurrency=y||"",this.mainScreen=new hl({container:this.mainLayout,modalContainer:this.modalContainer,merchantKey:o,email:i,encryption:this.encryption,planId:this.planId,amount:this.amount,rdtCode:this.rdtCode,url:this.url,phoneNumber:this.phoneNumber,code:this.code,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency,closePayment:this.closePayment.bind(this)}),this.mainLoader=new Ie(this.mainLayout),this.mainError=new Zo(this.mainLayout),this.mainLoader.mountLoader(),this.getPlanDetails()}getAvailableChannels(){var s,r;const e=((s=this.merchantPlanDetail)==null?void 0:s.paymentMethods)??[],i=((r=this.merchantPlanDetail)==null?void 0:r.limits)??[],t=[],o=[];return e.forEach(l=>{const c=i.find(b=>b.channel===l);!c||this.amount<=c.amount?t.push(l):o.push(l)}),{validChannels:t,disabledChannels:o}}async getPlanDetails(){const e=this.currency==="USD"?this.localCurrency:this.currency;this.merchantConfigService.getMerchantConfig(this.planId,e).then(i=>{var s;this.merchantPlanDetail=i,P.register({device_type:this.getDeviceType(),session_id:this.reference,env:"Test",checkout_env:this.rdtCode?"Redirect":"SDK",merchant:this.merchantPlanDetail.merchantName}),P.track("checkout_opens");const{validChannels:t,disabledChannels:o}=this.getAvailableChannels();if(t.length===0){const r=new bl(this.mainLayout);this.mainError=r;let l=0;throw(s=this.merchantPlanDetail)!=null&&s.limits&&this.merchantPlanDetail.limits.length>0&&(l=Math.max(...this.merchantPlanDetail.limits.map(c=>c.amount))),r.setLimitInfo(e,l),this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error("Transaction limit reached")}i.rate?this.mainScreen.mountScreen(this.merchantPlanDetail,this.currency,t,o):(this.mainError.renderContent(this.callBackUrl),this.showErrorIcon())}).catch(i=>{throw this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error(i)})}showErrorIcon(){var i;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"),(i=e.querySelector("img"))==null||i.setAttribute("src",pl))}closeModal(){this.modalContainer&&this.modalContainer.parentNode&&document.body.removeChild(this.modalContainer),this.mainScreen.closeModal()}}Ne.CheckoutForm=vl,Object.defineProperty(Ne,Symbol.toStringTag,{value:"Module"})});
1413
+ `}}class vl{constructor(){m(this,"modalContainer");m(this,"mainLayout");m(this,"encryption");m(this,"mainScreen");m(this,"merchantConfigService");m(this,"mainError");m(this,"mainLoader");m(this,"merchantPlanDetail",{});m(this,"merchantKey");m(this,"planId");m(this,"email");m(this,"amount");m(this,"rdtCode");m(this,"url");m(this,"phoneNumber");m(this,"code");m(this,"reference");m(this,"currency");m(this,"callBackUrl");m(this,"metadata");m(this,"localCurrency");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.modalContainer.innerHTML=Ln,P.init("11162d9a0801daeaf786f1200cd3112b",{debug:!1}),document.body.appendChild(this.modalContainer);const i=document.getElementById("main-layout-container-screen");if(!i)throw new Error("SDK Layout not available");this.mainLayout=i}closePayment(){const e={reference:this.reference};ks(this.merchantKey,e,this.rdtCode,this.url).then(({headers:t})=>{const o=t.get("spf-redirect-url");this.callBackUrl=o||this.callBackUrl,this.callBackUrl?setTimeout(()=>{const s=new URL(this.callBackUrl);s.searchParams.append("status","cancelled"),s.searchParams.append("reference",this.reference),window.location.href=s.toString()},1800):this.closeModal(),P.track("canel_payment",{verification_status:"Cancelled"}),P.track("checkout_closes")}).catch(t=>{li.showToast(t.message,"error")})}getDeviceType(){const e=navigator.userAgent;return/mobile/i.test(e)?"Mobile":/tablet/i.test(e)?"Tablet":"Desktop"}setup(e){const{email:i,encryptionKey:t,merchantKey:o,planId:s,amount:r,rdtCode:l,reference:c,currency:b,url:p,callBackUrl:g,metadata:f,localCurrency:y}=e;if(this.merchantKey=o||"",this.email=i||"",this.amount=r||0,this.encryption=t||"",this.planId=s||"",this.rdtCode=l||"",this.reference=c||_s(),this.url=p||"",this.callBackUrl=g||"",this.metadata=f||{},!o||!i)throw this.mainError=new Zo(this.mainLayout),this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error("Merchant key or email is required");this.currency=b||"",this.merchantConfigService=new Vr({token:this.merchantKey,rdtCode:this.rdtCode,url:this.url}),this.localCurrency=y||"",this.mainScreen=new hl({container:this.mainLayout,modalContainer:this.modalContainer,merchantKey:o,email:i,encryption:this.encryption,planId:this.planId,amount:this.amount,rdtCode:this.rdtCode,url:this.url,phoneNumber:this.phoneNumber,code:this.code,reference:this.reference,callBackUrl:this.callBackUrl,metadata:this.metadata,localCurrency:this.localCurrency,closePayment:this.closePayment.bind(this)}),this.mainLoader=new Ie(this.mainLayout),this.mainError=new Zo(this.mainLayout),this.mainLoader.mountLoader(),this.getPlanDetails()}getAvailableChannels(){var s,r;const e=((s=this.merchantPlanDetail)==null?void 0:s.paymentMethods)??[],i=((r=this.merchantPlanDetail)==null?void 0:r.limits)??[],t=[],o=[];return e.forEach(l=>{const c=i.find(b=>b.channel===l);!c||this.amount<=c.amount?t.push(l):o.push(l)}),{validChannels:t,disabledChannels:o}}async getPlanDetails(){const e=this.currency==="USD"?this.localCurrency:this.currency;this.merchantConfigService.getMerchantConfig(this.planId,e).then(i=>{var s;this.merchantPlanDetail=i,P.register({device_type:this.getDeviceType(),session_id:this.reference,env:"Test",checkout_env:this.rdtCode?"Redirect":"SDK",merchant:this.merchantPlanDetail.merchantName}),P.track("checkout_opens");const{validChannels:t,disabledChannels:o}=this.getAvailableChannels();if(t.length===0||t[0]==="ussd"){const r=new bl(this.mainLayout);this.mainError=r;let l=0;throw(s=this.merchantPlanDetail)!=null&&s.limits&&this.merchantPlanDetail.limits.length>0&&(l=Math.max(...this.merchantPlanDetail.limits.map(c=>c.amount))),r.setLimitInfo(e,l),this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error("Transaction limit reached")}i.rate?this.mainScreen.mountScreen(this.merchantPlanDetail,this.currency,t,o):(this.mainError.renderContent(this.callBackUrl),this.showErrorIcon())}).catch(i=>{throw this.mainError.renderContent(this.callBackUrl),this.showErrorIcon(),new Error(i)})}showErrorIcon(){var i;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"),(i=e.querySelector("img"))==null||i.setAttribute("src",pl))}closeModal(){this.modalContainer&&this.modalContainer.parentNode&&document.body.removeChild(this.modalContainer),this.mainScreen.closeModal()}}Ne.CheckoutForm=vl,Object.defineProperty(Ne,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spot-flow/checkout-inline-js",
3
- "version": "0.1.32-dev.6",
3
+ "version": "0.1.32-dev.7",
4
4
  "description": "",
5
5
  "main": "dist/checkout-inline.js",
6
6
  "module": "dist/checkout-inline.es.js",