1var A=Object.defineProperty;var T=(r,t,a)=>t in r?A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var w=(r,t,a)=>T(r,typeof t!="symbol"?t+"":t,a);import{w as _,b as O,d as V,j as e,m as l,A as E,L as B,a9 as F,l as d,a6 as N,as as L,s as Y}from"./App-Cg173DAt.js";import{r as o}from"./index-caxmlYbZ.js";import{C as k}from"./circle-x-Bszi4MIT.js";import{R as v}from"./refresh-cw-DgG-yFTe.js";import"./index--RATyRBH.js";import"./index-DIE_uK0V.js";import"./i18nInstance-C81hCH34.js";const M=3e3,C=40;class U extends o.Component{constructor(){super(...arguments);w(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(a){console.error("[PaymentReturn] inner render error (suppressed):",a)}render(){return this.state.failed?e.jsx(e.Fragment,{children:this.props.fallback}):e.jsx(e.Fragment,{children:this.props.children})}}function J(){const[r]=_(),t=O(),{user:a}=V(),[i,c]=o.useState("loading"),[m,h]=o.useState(null),[u,x]=o.useState(!1),p=o.useRef(!1),y=r.get("pendingId"),g=r.get("orderId"),P=r.get("status"),S=()=>
1{if(y)return y;try{return sessionStorage.getItem("slickpay_pending_id")}catch{return null}},I=async f=>{const{data:n,error:s}=await Y.functions.invoke("slickpay-verify-payment",{body:{pendingId:f}});if(s)throw s;if(n!=null&&n.error)throw new Error(n.error);return n},j=async()=>{if(p.current=!1,P==="paid"&&g){h(g),c("paid");try{sessionStorage.removeItem("slickpay_pending_id")}catch{}return}const f=S();if(!f){c("error");return}for(let n=0;n<C;n++){if(p.current)return;try{const s=await I(f);if(s.paid&&s.orderId){h(s.orderId),c("paid");try{sessionStorage.removeItem("slickpay_pending_id")}catch{}return}}catch(s){console.error("Verify attempt failed:",s)}n<C-1&&await new Promise(s=>setTimeout(s,M))}p.current||c("unpaid")};o.useEffect(()=>(j(),()=>{p.current=!0}),[]);const b=async()=>{x(!0),c("loading"),await j(),x(!1)},R=e.jsxs("div",{style:{textAlign:"center",color:"#fff"},children:[e.jsx("h2",{style:{fontSize:24,fontWeight:700,marginBottom:12},children:i==="paid"?"Payment Successful":i==="unpaid"?"Payment Still Processing":i==="error"?"Verification In Progress":"Verifying Payment..."}),e.jsx("p",{style:{color:"#a0a0a0",marginBottom:16},children:i==="paid"?"Your order has been confirmed. You'll receive details shortly.":"We're confirming your payment with the bank. This can take up to 2 minutes â please keep this page open. Your order will be created automatically."}),m&&e.jsxs("p",{style:{fontFamily:"monospace",fontSize:14},children:["Order: ",m.slice(0,8).toUpperCase()]}),e.jsxs("div",{style:{marginTop:20,display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>t(a?"/dashboard":"/auth"),style:{padding:"10px 18px",background:"#3b82f6",color:"#fff",border:0,borderRadius:8,cursor:"pointer"},children:a?"View Orders":"Create Account"}),e.jsx("button",{onClick:()=>t("/"),style:{padding:"10px 18px",background:"#27272a",color:"#fff",border:"1px solid #3f3f46",borderRadius:8,cursor:"pointer"},children:"Continue Shopping"})]})]});return e.jsxs("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",translate:"no",notranslate:"",children:[e.jsx("meta",{name:"google",content:"notranslate"}),e.jsx(U,{fallback:R,children:e.jsxs(l.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},className:"max-w-md w-full text-center space-y-6",children:[e.jsxs(E,{mode:"wait",initial:!1,children:[i==="loading"&&e.jsxs(l.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"space-y-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:e.jsx(B,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"Verifying Payment..."}),e.jsx("p",{className:"text-muted-foreground",children:"Please wait while we confirm your payment with the bank. This can take up to 2 minutes."})]},"loading"),i==="paid"&&e.jsxs(l.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-6",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-green-500/20 flex items-center justify-center mx-auto",children:e.jsx(F,{className:"w-12 h-12 text-green-500"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"Payment Successful!"}),e.jsx("p",{className:"text-muted-foreground",children:"Your payment has been confirmed. Your order is now being processed."}),m&&e.jsxs("div",{className:"p-4 rounded-xl bg-muted/50 border border-border inline-block",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Order ID"}),e.jsx("code",{className:"text-lg font-mono font-bold text-primary",children:m.slice(0,8).toUpperCase()})]})]},"paid"),i==="unpaid"&&e.jsxs(l.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"space-y-6",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-amber-500/20 flex items-center justify-center mx-auto",children:e.jsx(k,{className:"w-12 h-12 text-amber-500"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"Payment Still Processing"}),e.jsx("p",{className:"text-muted-foreground",children:"The bank is taking longer than usual to confirm your payment. If you completed it on the SATIM page, your order will appear in your dashboard within a few minutes â no need to pay again."}),e.jsxs(d,{onClick:b,disabled:u,variant:"outline",className:"gap-2",children:[e.jsx(v,{className:`w-4 h-4 ${u?"animate-spin":""}`}),"Check Again"]})]},"unpaid"),i==="error"&&e.jsxs(l.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-6",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-destructive/20 flex items-center justify-center mx-auto",children:e.jsx(k,{className:"w-12 h-12 text-destructive"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"Verification In Progress"}),e.jsx("p",{className:"text-muted-foreground",children:"We're still confirming your payment in the background. If you were charged, your order will appear in your dashboard shortly. Contact support if it doesn't."}),e.jsxs(d,{onClick:b,disabled:u,variant:"outline",className:"gap-2",children:[e.jsx(v,{className:`w-4 h-4 ${u?"animate-spin":""}`}),"Try Again"]})]},"error")]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center pt-4",children:[a?e.jsxs(d,{onClick:()=>t("/dashboard"),className:"gap-2 bg-gradient-primary",children:[e.jsx(N,{className:"w-4 h-4"}),"View Orders"]}):e.jsxs(d,{onClick:()=>t("/auth"),className:"gap-2 bg-gradient-primary",children:[e.jsx(N,{className:"w-4 h-4"}),"Create Account"]}),e.jsxs(d,{variant:"outline",onClick:()=>t("/"),className:"gap-2",children:[e.jsx(L,{className:"w-4 h-4"}),"Continue Shopping"]})]})]})})]})}export{J 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.