| Current Path : /home/users/unlimited/www/learnoid.codeskitter.site/public/build/assets/ |
| Current File : /home/users/unlimited/www/learnoid.codeskitter.site/public/build/assets/Checkout-D1Olj4ff.js |
import{_ as me,u as ve,E as fe,I as he,r as w,h as _e,i as ye,c as f,a as e,t as o,G as T,n as ne,d as b,w as be,b as ge,v as we,e as p,F as xe,A as ke,H as Ce,s as j,x as A,y as Te,z as D,f as $e,S as i,o as h}from"./app-DM0q11P6.js";/* empty css */const Pe={class:"bg-light py-5"},Be={class:"container"},De={class:"checkout-wizard bg-white theme-shadow my-4"},je={class:"fw-bold px-5 py-4 border-bottom mb-0"},Ae={class:"row"},Oe={class:"border rounded-3 p-2 p-lg-4 mb-4"},Ie={class:"row"},ze={class:"col-12 col-lg-4"},Ee=["src"],Me={class:"col-12 col-lg-8"},Re={class:"mt-4 mt-lg-0"},Se={class:"d-flex mt-3 pb-3"},Ne=["src"],Ve={class:"d-block"},Ue={class:"text-muted ms-2"},Le={class:"text-muted"},We={class:"border rounded-3 p-2 p-lg-4"},qe={class:"mb-4"},Fe={class:"bg-light rounded-3 p-4"},He={class:"price-breakdown mb-3"},Ge={key:0,class:"d-flex justify-content-between mb-4"},Je={key:1,class:"d-flex justify-content-between mb-4"},Ke={class:"d-flex justify-content-between mb-4 text-danger"},Qe={class:"mb-3"},Xe={type:"submit",class:"btn btn-primary"},Ye={key:3,class:"d-flex justify-content-between mb-3"},Ze={class:"me-3"},et={class:"d-flex justify-content-between flex-wrap"},tt={class:"fw-bold me-1"},st={class:"fw-bold"},ot={key:0,class:"my-3 d-flex justify-content-center"},at={key:0,class:"col-12 col-lg-4 ps-0 d-flex flex-column"},nt={class:"p-2 pe-2 pe-lg-5"},lt={class:"d-flex justify-content-between align-items-center mb-4"},rt={class:"fw-bold"},it={class:"bg-lightgreen text-success rounded px-2 py-1 text-center"},ct=["onClick"],ut=["src"],dt=["checked"],pt={class:"border-top p-4 d-flex align-items-start gap-3"},mt={class:"form-check-label",for:"exampleCheck1"},vt={class:"mt-auto border-top p-4"},ft={__name:"Checkout",setup(ht){const l=ve(),$=fe(),le=he(),O=$e(),C=le.params.id,g=w("stripe"),a=w({}),_=w(0),d=w(0),P=w(!1),x=w(""),B=w(!1);let k=w(!1);_e(()=>_.value,()=>{a.value.is_free?d.value=0:a.value.regular_price&&!a.value.price?d.value=a.value.regular_price-_.value:d.value=a.value.price-_.value});const re=async()=>{try{const s=await D.get("/coupon/validate",{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${$.authToken}`},params:{coupon_code:x.value}});_.value=s.data.data.discount,B.value=!0,i.mixin({toast:!0,position:"top-end",showConfirmButton:!1,timer:1500,timerProgressBar:!0,didOpen:n=>{n.onmouseenter=i.stopTimer,n.onmouseleave=i.resumeTimer}}).fire({icon:"success",title:"Coupon applied successfully"})}catch{i.mixin({toast:!0,position:"top-end",showConfirmButton:!1,timer:1500,timerProgressBar:!0,didOpen:n=>{n.onmouseenter=i.stopTimer,n.onmouseleave=i.resumeTimer}}).fire({icon:"error",title:"Oops...",text:"Coupon code is invalid"})}},ie=async()=>{try{const s=await D.get(`/course/show/${C}`,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${$.authToken}`}});a.value=s.data.data.course,a.value.is_free?d.value=0:a.value.regular_price&&!a.value.price?d.value=a.value.regular_price-_.value:d.value=a.value.price-_.value}catch(s){console.error("Error fetching course data:",s)}},ce=()=>{k.value&&g.value?ue():i.mixin({toast:!0,position:"bottom-end",showConfirmButton:!1,timer:2e3,timerProgressBar:!0,didOpen:t=>{t.onmouseenter=i.stopTimer,t.onmouseleave=i.resumeTimer}}).fire({icon:"error",title:"Oops...",text:"Please select a payment method and agree to the terms and conditions"})},ue=async()=>{var s,t,n,y,u,c;if(a.value.is_free?d.value=0:a.value.regular_price&&!a.value.price?d.value=a.value.regular_price-_.value:d.value=a.value.price-_.value,g.value=="stripe"||g.value=="paypal"||g.value=="razorpay"){if(((s=l==null?void 0:l.masterData)==null?void 0:s.currency)!="USD"&&d.value<((t=l==null?void 0:l.masterData)==null?void 0:t.minimum_amount)){i.mixin({toast:!0,position:"top-end",showConfirmButton:!1,timer:1500,timerProgressBar:!0,didOpen:m=>{m.onmouseenter=i.stopTimer,m.onmouseleave=i.resumeTimer}}).fire({icon:"error",title:"Oops...",text:`Please note that a minimum of grand total of ${(n=l==null?void 0:l.masterData)==null?void 0:n.minimum_amount} is required for transaction.`});return}if(((y=l==null?void 0:l.masterData)==null?void 0:y.currency)=="BDT"){i.mixin({toast:!0,position:"top-end",showConfirmButton:!1,timer:1500,timerProgressBar:!0,didOpen:m=>{m.onmouseenter=i.stopTimer,m.onmouseleave=i.resumeTimer}}).fire({icon:"error",title:"Oops...",text:"BDT is not supported at the moment"});return}}try{const r=await D.get(`/enroll/${C}`,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${$.authToken}`},params:{payment_gateway:g.value,coupon_code:x.value,total_amount:d.value}});pe(r.data.data.payment_webview_url)}catch(r){i.fire({icon:"error",title:"Oops...",text:((c=(u=r.response)==null?void 0:u.data)==null?void 0:c.message)||"Something went wrong. Please try again."})}},de=async()=>{var s,t,n,y,u,c;try{const r=await D.get(`/free/enroll/${C}`,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${$.authToken}`}});if(((t=(s=r==null?void 0:r.data)==null?void 0:s.data)==null?void 0:t.status)=="success"){let m=(y=(n=r==null?void 0:r.data)==null?void 0:n.data)==null?void 0:y.status;O.push(`/enroll_status?status=${m}&course_id=${C}`)}}catch(r){i.fire({icon:"error",title:"Oops...",text:((c=(u=r.response)==null?void 0:u.data)==null?void 0:c.message)||"Something went wrong. Please try again."})}};ye(async()=>{await ie()});const pe=s=>{console.log(s);let t=window.open(s,"_blank");t.title="Payment Window Screen - Make Payment";const n=c=>{t&&!t.closed&&t.close(),O.push(`/enroll_status?course_id=${C}&status=${c}`)},u=setInterval(()=>{try{if(!t||t.closed){clearInterval(u),n("fail");return}const c=t.location.pathname.replace(/\/payment\/\d+/,"");c.includes("payment/cancel")?(clearInterval(u),n("cancel"),t.close()):c.includes("payment/success")?(clearInterval(u),n("success"),t.close()):c.includes("payment/fail")&&(clearInterval(u),n("fail"),t.close())}catch{}},1e3);t.focus(),setTimeout(()=>{clearInterval(u),t&&!t.closed&&(n("timeout"),t.close())},18e4)};return(s,t)=>{var y,u,c,r,m,I,z,E,M,R,S,N,V,U,L,W,q,F,H,G,J,K,Q,X,Y,Z,ee,te,se,oe,ae;const n=Te("router-link");return h(),f("section",Pe,[e("section",Be,[e("section",De,[e("h3",je,o(s.$t("Checkout")),1),e("div",Ae,[e("div",{class:ne((y=a.value)!=null&&y.is_free?"col-12":"col-12 col-lg-8 border-end p-4 ps-4 ps-lg-5")},[e("div",Oe,[e("div",Ie,[e("div",ze,[e("img",{src:(u=a.value)==null?void 0:u.thumbnail,width:"100%",alt:"",height:"140px",class:"object-fit-cover rounded-3"},null,8,Ee)]),e("div",Me,[e("h5",Re,o((c=a.value)==null?void 0:c.title),1),e("div",Se,[e("img",{src:(m=(r=a.value)==null?void 0:r.instructor)==null?void 0:m.profile_picture,class:"rounded-circle object-fit-cover me-3",height:"30px",width:"30px"},null,8,Ne),e("div",null,[e("span",Ve,o((z=(I=a.value)==null?void 0:I.instructor)==null?void 0:z.name),1)])]),e("div",null,[t[4]||(t[4]=e("i",{class:"bi bi-star-fill text-warning me-2"},null,-1)),e("strong",null,o((E=a.value)==null?void 0:E.average_rating),1),e("span",Ue,"("+o((M=a.value)==null?void 0:M.review_count)+" "+o(s.$t("Reviews"))+")",1),t[5]||(t[5]=e("span",{class:"text-muted mx-1"},[e("i",{class:"bi bi-dot"})],-1)),e("span",Le,o((R=a.value)==null?void 0:R.student_count)+" "+o(s.$t("Enrolled")),1)])])])]),e("div",We,[e("h5",qe,o(s.$t("Order Details")),1),e("div",Fe,[e("div",He,[(S=a.value)!=null&&S.price?(h(),f("div",Ge,[e("span",null,o(s.$t("Course Price")),1),e("strong",null,o((V=(N=b(l))==null?void 0:N.masterData)==null?void 0:V.currency_symbol)+o((U=a.value)!=null&&U.is_free?0:(L=a.value)==null?void 0:L.price),1)])):(h(),f("div",Je,[e("span",null,o(s.$t("Course Price")),1),e("strong",null,o((q=(W=b(l))==null?void 0:W.masterData)==null?void 0:q.currency_symbol)+o((F=a.value)!=null&&F.is_free?0:(H=a.value)==null?void 0:H.regular_price),1)])),e("div",Ke,[e("span",null,o(s.$t("Discount")),1),e("strong",null,"-"+o((J=(G=b(l))==null?void 0:G.masterData)==null?void 0:J.currency_symbol)+o(_.value),1)]),e("div",Qe,[P.value?T("",!0):(h(),f("span",{key:0,onClick:t[0]||(t[0]=v=>P.value=!0),class:"text-primary text-decoration-underline cursor-pointer"},o(s.$t("Have any coupon"))+"?",1))]),!B.value&&P.value?(h(),f("form",{key:2,onSubmit:be(re,["prevent"]),class:"bg-white d-flex rounded-3 p-4 mb-3"},[ge(e("input",{type:"text","onUpdate:modelValue":t[1]||(t[1]=v=>x.value=v),class:"form-control me-3",placeholder:"Enter coupon code"},null,512),[[we,x.value]]),e("button",Xe,o(s.$t("Apply")),1)],32)):T("",!0),B.value?(h(),f("div",Ye,[e("div",null,[t[7]||(t[7]=e("i",{class:"ri-checkbox-circle-fill text-success me-1"},null,-1)),e("span",Ze,o(s.$t("Coupon Applied")),1),e("small",{onClick:t[2]||(t[2]=v=>{B.value=!1,P.value=!0,x.value=null}),class:"text-success bg-lightgreen px-2 py-1 rounded cursor-pointer"},[p(o(x.value)+" ",1),t[6]||(t[6]=e("i",{class:"ri-edit-line"},null,-1))])])])):T("",!0)]),e("div",et,[e("span",null,[e("span",tt,o(s.$t("Subtotal")),1),e("span",null,"("+o(s.$t("Payable"))+")",1)]),e("span",st,o((Q=(K=b(l))==null?void 0:K.masterData)==null?void 0:Q.currency_symbol)+o(d.value),1)])])]),(X=a.value)!=null&&X.is_free?(h(),f("div",ot,[e("button",{onClick:de,class:"d-flex justify-content-center gap-2 btn btn-primary rounded-pill fw-bold w-50"},t[8]||(t[8]=[p(" Enroll Now "),e("i",{class:"bi bi-arrow-right float-end"},null,-1)]))])):T("",!0)],2),(Y=a.value)!=null&&Y.is_free?T("",!0):(h(),f("div",at,[e("div",nt,[e("div",lt,[e("h5",rt,o(s.$t("Payment Method")),1),e("small",it,[t[9]||(t[9]=e("i",{class:"ri-shield-check-fill me-1"},null,-1)),p(" "+o(s.$t("100% Secure Payment")),1)])]),(h(!0),f(xe,null,ke((ee=(Z=b(l))==null?void 0:Z.masterData)==null?void 0:ee.payment_methods,v=>(h(),f("div",{key:v.id},[e("div",{onClick:_t=>g.value=v.gateway,class:ne("border d-flex justify-content-between align-items-center px-3 mb-3 rounded payment-method mx-auto"+(g.value==v.gateway?" selected":""))},[e("img",{src:v.logo,class:"col-3 py-3"},null,8,ut),e("input",{class:"form-check-input",type:"radio",checked:g.value==v.gateway},null,8,dt)],10,ct)]))),128))]),e("div",pt,[e("input",{type:"checkbox",class:"form-check-input",id:"exampleCheck1",required:"",onChange:t[3]||(t[3]=v=>Ce(k)?k.value=!b(k):k=!b(k))},null,32),e("label",mt,[p(o(s.$t("By proceeding, you agree to the"))+" ",1),j(n,{to:"/page/terms_and_conditions",class:"text-decoration-none bg-transparent border-0 text-primary"},{default:A(()=>[p(o(s.$t("Terms & Condition")),1)]),_:1}),t[10]||(t[10]=p(",")),j(n,{to:"/page/privacy_policy",class:"text-decoration-none bg-transparent border-0 text-primary"},{default:A(()=>[p(o(s.$t("Privacy Policy")),1)]),_:1}),p(" "+o(s.$t("and"))+" ",1),j(n,{to:"/page/refund_policy",class:"text-decoration-none bg-transparent border-0 text-primary"},{default:A(()=>[p(o(s.$t("Refund Policy")),1)]),_:1}),p(" of "+o((se=(te=b(l))==null?void 0:te.masterData)==null?void 0:se.name),1)])]),e("div",vt,[e("button",{onClick:ce,class:"btn btn-primary rounded-pill fw-bold w-100"},[p(o(s.$t("Pay"))+" "+o((ae=(oe=b(l))==null?void 0:oe.masterData)==null?void 0:ae.currency_symbol)+o(d.value)+" ",1),t[11]||(t[11]=e("i",{class:"bi bi-arrow-right float-end"},null,-1))])])]))])])])])}}},gt=me(ft,[["__scopeId","data-v-43f6e3a3"]]);export{gt as default};