(()=>{var e={};e.id=4924,e.ids=[4924],e.modules={10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},79646:e=>{"use strict";e.exports=require("child_process")},55511:e=>{"use strict";e.exports=require("crypto")},94735:e=>{"use strict";e.exports=require("events")},81630:e=>{"use strict";e.exports=require("http")},55591:e=>{"use strict";e.exports=require("https")},28354:e=>{"use strict";e.exports=require("util")},11256:(e,t,s)=>{"use strict";s.r(t),s.d(t,{patchFetch:()=>x,routeModule:()=>l,serverHooks:()=>m,workAsyncStorage:()=>d,workUnitAsyncStorage:()=>c});var r={};s.r(r),s.d(r,{GET:()=>p});var a=s(42706),o=s(28203),n=s(45994),i=s(39187);let u=new(s(37915)).A(process.env.STRIPE_SECRET_KEY||"",{apiVersion:"2025-10-29.clover"});async function p(e){try{let t=e.nextUrl.searchParams.get("session_id");if(!t)return i.NextResponse.json({error:"Session ID is required"},{status:400});let s=await u.checkout.sessions.retrieve(t,{expand:["line_items","total_details","total_details.breakdown.discounts"]}),r=s.amount_total||0,a=s.amount_subtotal||0;s.total_details?.amount_discount;let o=s.metadata?.discount_applied?parseFloat(s.metadata.discount_applied):0,n=s.metadata?.wallet_balance?parseFloat(s.metadata.wallet_balance):0,p=s.metadata?.original_amount?parseFloat(s.metadata.original_amount):a/100,l=null,d=null,c=0;if(s.total_details?.breakdown?.discounts&&s.total_details.breakdown.discounts.length>0){let e=s.total_details.breakdown.discounts[0];if(e.discount&&"object"==typeof e.discount){let t=e.discount;t.coupon&&(l=t.coupon.id,t.coupon.percent_off&&(d=t.coupon.percent_off),t.coupon.amount_off&&(c=t.coupon.amount_off/100))}c||d||(c=e.amount/100)}let m=o+c;return i.NextResponse.json({sessionId:s.id,paymentStatus:s.payment_status,amount:p,discount:m,walletDiscount:o,stripeDiscount:c,walletBalance:n,finalAmount:r/100,couponCode:l,discountPercentage:d,currency:s.currency,metadata:s.metadata})}catch(e){return console.error("Error retrieving session details:",e),i.NextResponse.json({error:e.message||"Failed to retrieve session details"},{status:500})}}let l=new a.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/payment/session-details/route",pathname:"/api/payment/session-details",filename:"route",bundlePath:"app/api/payment/session-details/route"},resolvedPagePath:"/Users/user/Desktop/nestjs/self sever portal/src/app/api/payment/session-details/route.ts",nextConfigOutput:"",userland:r}),{workAsyncStorage:d,workUnitAsyncStorage:c,serverHooks:m}=l;function x(){return(0,n.patchFetch)({workAsyncStorage:d,workUnitAsyncStorage:c})}},96487:()=>{},78335:()=>{}};var t=require("../../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),r=t.X(0,[638,8312,7915],()=>s(11256));module.exports=r})();