(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4228],{1662:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>c});var s=a(5155),n=a(2115),i=a(7368),l=a(5855);let r=(0,i.c)("pk_test_51SIT8KPznDOle2DT0PvS07xiBy2SHQ89kmcV4dCyP96XeQknMhblp1IJEjR80Qsjh0yjRaFwA1z3uFA3Xu78vHIA00OiEIaAsZ");function o(e){let{clientSecret:t}=e,a=(0,l.useStripe)(),i=(0,l.useElements)(),[r,o]=(0,n.useState)(""),[c,u]=(0,n.useState)(!1),p=async e=>{if(e.preventDefault(),!a||!i)return;u(!0);let{error:t}=await a.confirmPayment({elements:i,confirmParams:{return_url:"".concat(window.location.origin,"/payment-success")}});t&&o(t.message||"Payment failed."),u(!1)};return(0,s.jsxs)("form",{onSubmit:p,children:[(0,s.jsx)(l.PaymentElement,{options:{layout:"tabs",defaultValues:{billingDetails:{email:""}},fields:{billingDetails:"auto"}}}),r&&(0,s.jsx)("p",{style:{color:"red"},children:r}),(0,s.jsx)("button",{type:"submit",disabled:!a||c,style:{marginTop:"16px",background:"#f97316",color:"white",padding:"10px 20px",borderRadius:"6px"},children:c?"Processing...":"Complete Payment"})]})}function c(){let[e,t]=(0,n.useState)(null);return((0,n.useEffect)(()=>{(async()=>{let e=await fetch("/api/stripe/create-subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({priceId:"price_1SIC6gSu5FfZAHjvtycZLpc6",email:"mahesh@example.com",name:"Mahesh Yadav",address:{line1:"123 MG Road",city:"Jaipur",state:"Rajasthan",postal_code:"302001",country:"IN"}})});t((await e.json()).clientSecret)})()},[]),e)?(0,s.jsx)(l.Elements,{stripe:r,options:{clientSecret:e},children:(0,s.jsx)(o,{clientSecret:e})}):(0,s.jsx)("p",{children:"Loading payment form..."})}},7691:(e,t,a)=>{Promise.resolve().then(a.bind(a,1662))}},e=>{e.O(0,[1834,8441,5964,7358],()=>e(e.s=7691)),_N_E=e.O()}]);