1import{j as n}from"./index-ByaUQ4Qy.js";import{h as P,b as a}from"./vendor-router-CJ8qbTQf.js";const _=()=>{const[t]=P(),[r,j]=a.useState(t.get("uid")),[i,v]=a.useState(t.get("amount")),[m,S]=a.useState(t.get("planId")),[s,R]=a.useState(t.get("typeId")),f=t.get("tutorId"),u=t.get("bookingDate"),y=t.get("startTime"),w=t.get("endTime"),[h,d]=a.useState(!0),c=a.useRef(!1),l="https://dev-dotnet.babblio.io",g="rzp_test_RwZ644vH4eWXAB";a.useEffect(()=>{c.current||(c.current=!0,b())},[]);const b=()=>{if(window.Razorpay){p();return}const e=document.createElement("script");e.src="https://checkout.razorpay.com/v1/checkout.js",e.async=!0,e.onload=p,document.body.appendChild(e)},p=async()=>{try{const e=await fetch(`${l}/payment/create-order`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:i,userId:r,typeId:s})});if(!e.ok)throw new Error("Order creation failed");const o=await e.json();z(o)}catch(e){console.error(e),alert("Unable to initiate payment. Please try again."),d(!1)}},x=()=>{if(window.Android&&typeof window.Android.closeWebView=="function"){window.Android.closeWebView();return}if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.closeWebView){window.webkit.messageHandlers.closeWebView.postMessage(null);return}window.location.href="babblio://payment-success",window.close()},z=e=>{const o={key:g,amount:e.amount,currency:e.currency||"INR",name:"Babblio Premium",description:"English Speaking Subscription",order_id:e.orderId,handler:function(k){I(k)},prefill:{email:e.email,contact:e.phone},theme:{color:"#6A00FF"},modal:{ondismiss:function(){x()}}};d(!1),new window.Razorpay(o).open()},I=async e=>{try{if(!(await fetch(`${l}/payment/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:e.razorpay_order_id,paymentId:e.razorpay_payment_id,signature:e.razorpay_signature,userId:r,planId:m,typeId:s,amount:i,tutorId:f,bookingDate:u,startTime:y,endTime:w})})).ok)throw new Error("Payment verification failed");window.location.href="babblio://payment-success"}catch(o){console.error(o),alert("Payment verification failed. Contact support.")}};return n.jsxs(n.Fragment,{children:[n.jsx("style",{children:` 2 .payment-bg { 3 min-height: 100vh; 4 background: linear-gradient(90deg, #faf4f7, #fdf8ef); 5 display: flex; 6 align-items: center; 7 justify-content: center; 8 font-family: Inter, sans-serif; 9 } 10 11 .loader-card { 12 background: #ffffff; 13 padding: 36px 40px; 14 border-radius: 16px; 15 box-shadow: 0 10px 30px rgba(106, 0, 255, 0.2); 16 text-align: center; 17 max-width: 420px; 18 width: 100%; 19 } 20 21 .spinner { 22 width: 48px; 23 height: 48px; 24 border: 4px solid #e5d9ff;
25 border-top: 4px solid #6A00FF; 26 border-radius: 50%; 27 animation: spin 1s linear infinite; 28 margin: 0 auto 20px; 29 } 30 31 @keyframes spin { 32 to { 33 transform: rotate(360deg); 34 } 35 } 36 37 .loader-title { 38 font-size: 22px; 39 font-weight: 700; 40 color: #6A00FF; 41 margin-bottom: 8px; 42 } 43 44 .loader-text { 45 font-size: 15px; 46 color: #555; 47 } 48 `}),n.jsx("div",{className:"payment-bg",children:h&&n.jsxs("div",{className:"loader-card",children:[n.jsx("div",{className:"spinner"}),n.jsx("div",{className:"loader-title",children:"Initializing Secure Payment"}),n.jsx("div",{className:"loader-text",children:"Please wait while we connect to Razorpayâ¦"})]})})]})};export{_ as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.