PageSourceSearch

https://bytical.ai/assets/PaymentPage-B5QtdPsq.js

js bytical.ai collected 2026-10-05 15:29:11 UTC 11,710 bytes, 1 lines download raw bytes

1import{j as e}from"./motion-Cj3iODHr.js";import{d as k,a as y,u as T}from"./react-BRgkvuuS.js";import{u as $}from"./redux-BPGFuQZw.js";import{E as d,y as h}from"./index-Dmosp5jH.js";import{f as M}from"./payments-Cyy91hyg.js";import{F as O,f as D}from"./index-BrYMAauv.js";function Y(s){const c=new URLSearchParams(s),n={};for(const[t,g]of c.entries())try{n[t]=decodeURIComponent(g)}catch(b){console.error(`Error decoding URL parameter "${t}":`,b),n[t]=g}return n}function V(){const s=k();return y.useMemo(()=>{const n=Y(s.search);return console.log("URL query parameters parsed:",n),n},[s.search])}const z=88.19,R=(s,c=z)=>{if(typeof s!="number"||isNaN(s))return console.warn("Invalid USD amount provided:",s),0;const n=s*c;return Math.round(n*100)/100},L=({planDetails:s})=>{if(!s)return null;const{name:c,price:n,billingCycle:t,credits:g}=s,b=n==="0"||n===0,I=typeof n=="string"?parseFloat(n):n,N=()=>{const x=["AI Avatar Videos","AI Presentation Generation"];switch(s.planKey){case"free":return[...x,"150 Lifetime Credits","Basic Support"];case"growth":return[...x,"More Monthly Credits","Priority Support","Advanced Customization"];case"premium":return[...x,"Maximum Credits","Priority Support","Advanced Customization","Team Collaboration","API Access"];default:return x}};return e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden",children:[e.jsx("div",{className:"px-2 py-3 bg-gradient-to-r from-brand to-brand-light",children:e.jsxs("h2",{className:"text-xl font-bold text-white text-center",children:[c," Plan"]})}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-baseline justify-center",children:[e.jsxs("span",{className:"text-4xl font-extrabold text-gray-900",children:["$",I.toFixed(2)]}),t!=="lifetime"&&e.jsxs("span",{className:"ml-1 text-xl text-gray-500",children:["/",t==="yearly"?"year":"month"]})]}),t==="yearly"&&!b&&e.jsx("p",{className:"text-sm text-green-600 mt-1 text-center",children:"Save 20% with yearly billing"})]}),e.jsxs("div",{className:"mb-6 pt-4 border-t border-gray-200",children:[e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Credits"}),e.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[typeof g=="number"?g.toLocaleString():g,t==="lifetime"&&" (Lifetime)"]})]}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Billing"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:t==="lifetime"?"One-time (Lifetime)":t==="yearly"?"Annual":"Monthly"})]})]}),e.jsxs("div",{className:"pt-4 border-t border-gray-200",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Included Features:"}),e.jsx("ul",{className:"space-y-2",children:N().map((x,P)=>e.jsxs("li",{className:"flex items-start",children:[e.jsx(O,{icon:D,className:"text-green-500 mt-0.5 mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600",children:x})]},P))})]}),!b&&t!=="lifetime"&&e.jsx("div",{className:"mt-6 text-sm text-gray-500",children:e.jsxs("p",{children:["Your subscription will automatically renew every ",t==="yearly"?"year":"month",". You can cancel anytime."]})}),t==="lifetime"&&e.jsx("div",{className:"mt-6 text-sm text-gray-500",children:e.jsx("p",{children:"Your free plan includes 150 lifetime credits that never expire."})})]})]})};L.propTypes={planDetails:d.shape({planKey:d.string,name:d.string,price:d.oneOfType([d.string,d.number]),billingCycle:d.oneOf(["monthly","yearly","lifetime"]),credits:d.oneOfType([d.string,d.number]),description:d.string})};const X=()=>{const s=T(),c=k(),n=V(),t=$(l=>l.login.userInfo),[g,b]=y.useState(!0),[I,N]=y.useState(null),[x,P]=y.useState(null),[o,_]=y.useState(null),[w,q]=y.useState(null),m=y.useRef(null),S=y.useRef(!1),E=l=>{if(!l)return null;const r={...l};console.log("Validating PayU parameters:",r);const a=["key","txnid","amount","productinfo","firstname","email","phone","surl","furl","hash"],u=[];a.forEach(i=>
1{if(!r[i])switch(u.push(i),i){case"key":r.key="9CoYVo",console.log("Adding default key: 9CoYVo");break;case"phone":r.phone="1234567890",console.log("Adding default phone: 1234567890");break;case"firstname":r.firstname=r.first_name||"User",console.log(`Adding default firstname: ${r.firstname}`);break;case"surl":r.surl=window.location.origin+"/payment/success",console.log(`Adding success URL: ${r.surl}`);break;case"furl":r.furl=window.location.origin+"/payment/failure",console.log(`Adding failure URL: ${r.furl}`);break;default:console.warn(`Missing required parameter: ${i} with no default value`)}}),u.length>0&&console.warn("Fixed missing PayU parameters:",u),Object.keys(r).forEach(i=>{r[i]===null||r[i]===void 0?(r[i]="",console.log(`Converting null/undefined value for ${i} to empty string`)):typeof r[i]!="string"&&(r[i]=String(r[i]),console.log(`Converting non-string value for ${i} to string: ${r[i]}`))});const p=a.filter(i=>!r[i]);return p.length>0?console.error("Still missing required PayU parameters after fixes:",p):console.log("All mandatory PayU parameters are present"),r};return y.useEffect(()=>{if(S.current||o)return;const{plan:l,billing:r,price:a,type:u,package:p,credits:i}=n;if(console.log("Current URL:",window.location.href),console.log("Search string:",c.search),console.log("Payment parameters from hook:",n),console.log("query params",n),c.search&&Object.keys(n).length===0){console.log("URL has search parameters but hook returned empty object. Waiting for parameters to load...");return}if(!t||!t.success){h.error("Please log in to subscribe to a plan."),s("/signin",{state:{from:c.pathname+c.search}});return}if(u==="credits"){if(!p||!a){h.error("Invalid payment request. Missing credit package details."),s("/pricing");return}}else if(!l||!r||a===void 0){h.error("Invalid payment request. Missing plan details."),s("/pricing");return}console.log(t),(async()=>{var C,F,A;try{S.current=!0,b(!0),console.log("Preparing payment data with:",{type:u,plan:l,billing:r,price:a,packageId:p,credits:i,userId:(t==null?void 0:t._id)||((C=t==null?void 0:t.user)==null?void 0:C._id)});let v;if(u==="credits"){const j=typeof a=="number"?a:parseFloat(a),U=Number.isFinite(j)?R(j):0;v={type:"credits",packageId:p,price:U,credits:i,userId:(t==null?void 0:t._id)||((F=t==null?void 0:t.user)==null?void 0:F._id)}}else{const j=typeof a=="number"?a:parseFloat(a),U=Number.isFinite(j)?R(j):0;v={type:"subscription",planKey:l,billingCycle:r,price:U,userId:(t==null?void 0:t._id)||((A=t==null?void 0:t.user)==null?void 0:A._id)}}console.log("Sending payment intent request with data:",v);const f=await M(v);if(f.success){if(N(f.paymentId),P({planKey:l,billingCycle:r,price:a,name:f.planName,description:f.planDescription,credits:f.credits}),f.isFree){h.success("Free plan activated successfully!"),s("/payment/success",{state:{subscriptionId:"free_plan",planName:f.planName,billingCycle:r}});return}const j=E(f.payuFormParams);_(j),q(f.payuUrl)}else h.error("Failed to initialize payment. Please try again."),s("/pricing")}catch(v){console.error("Payment initialization error:",v),h.error("Unable to process payment request. Please try again later."),s("/pricing")}finally{b(!1)}})()},[n,s,t,c.pathname,c.search,o]),y.useEffect(()=>{if(!o||!m.current)return;let l=!1;try{if(console.log("Submitting PayU form...",o),!w&&m.current){const a="https://test.payu.in/_payment";m.current.setAttribute("action",a),console.log("Using default PayU URL:",a)}const r=setTimeout(()=>{if(!l&&(l=!0,m.current)){m.current.getAttribute("action")||m.current.setAttribute("action","https://test.payu.in/_payment"),m.current.querySelectorAll('input[type="hidden"]').forEach(p=>{(p.value===null||p.value==="null")&&(p.value="")});const a=m.current.getAttribute("action"),u=m.current.querySelectorAll("input").length;console.log(`Form ready with action: ${a||"none"}, inputs: ${u}`),a&&u>0?m.current.submit():(console.error("Form is missing action or inputs"),h.error("Payment form error. Please try again."),s("/pricing"))}},2e3);return()=>clearTimeout(r)}catch(r){console.error("Error submitting form:",r),h.error("Failed to process payment. Please try again."),s("/pricing")}},[o,w,s]),g?e.jsxs("div",{className:"min-h-screen flex justify-center items-center flex-col gap-4 -mt-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-[var(--color-brand-accent)]"}),e.jsx("span",{className:"text-neutral-800 font-bold",children:"Loading..."})]}):o?e.jsx("div",{className:"min-h-screen py-12",children:e.jsx("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"bg-gray-50 rounded-xl shadow-sm border border-gray-200",children:e.jsxs("div",{className:"px-6 py-8 sm:p-10 text-center",children:[e.jsx("h1",{className:"text-3xl font-extrabold text-gray-900 mb-6",children:"Redirecting to Payment Gateway"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"You will be redirected to the payment gateway to complete your payment. Please do not refresh this page."}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-[var(--color-brand-accent)]"})}),e.jsxs("form",{ref:m,method:"post",action:w||"https://test.payu.in/_payment",className:"space-y-4",children:[o&&Object.entries(o).map(([l,r])=>e.jsx("input",{type:"hidden",name:l,value:r??""}
1,l)),o&&e.jsxs(e.Fragment,{children:[!o.key&&e.jsx("input",{type:"hidden",name:"key",value:o.merchant_id||"9CoYVo"}),!o.phone&&e.jsx("input",{type:"hidden",name:"phone",value:""}),!o.productinfo&&o.description&&e.jsx("input",{type:"hidden",name:"productinfo",value:o.description}),!o.surl&&e.jsx("input",{type:"hidden",name:"surl",value:window.location.origin+"/payment/success"}),!o.furl&&e.jsx("input",{type:"hidden",name:"furl",value:window.location.origin+"/payment/failure"})]}),e.jsx("button",{type:"submit",className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-brand hover:bg-brand-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand",children:"Continue to Payment"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-4",children:"If you are not redirected automatically, click the button above."}),e.jsx("div",{className:"mt-6 pt-6 border-t border-gray-200",children:e.jsx("button",{onClick:()=>s("/pricing"),className:"w-full flex justify-center py-3 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-500 bg-white hover:bg-gray-50 focus:outline-none",children:"Return to Pricing Page"})})]})})})}):e.jsx("div",{className:"min-h-screen bg-gray-50 py-12",children:e.jsx("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-8 sm:p-10",children:[e.jsx("h1",{className:"text-3xl font-extrabold text-gray-900 text-center mb-8",children:"Your Subscription Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-8",children:e.jsx(L,{planDetails:x})})]}),e.jsx("div",{className:"bg-gray-50 px-6 py-4 sm:px-10",children:e.jsxs("p",{className:"text-xs text-gray-500",children:["By completing this purchase, you agree to our"," ",e.jsx("a",{href:"/term-conditions",className:"font-medium text-brand hover:text-brand-dark",children:"Terms and Conditions"})," ","and"," ",e.jsx("a",{href:"/privacy-policy",className:"font-medium text-brand hover:text-brand-dark",children:"Privacy Policy"}),"."]})})]})})})};export{X 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.