"use strict";(()=>{var e={};e.id=9958,e.ids=[9958],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},98422:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>w,requestAsyncStorage:()=>c,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>l});var s={};r.r(s),r.d(s,{POST:()=>p});var a=r(49303),n=r(88716),o=r(60670),i=r(87070),u=r(72331);async function p(e){try{let{searchParams:t}=new URL(e.url),r=t.get("secret"),s=process.env.PAYMENT_WEBHOOK_SECRET||"ganti-secret-ini-di-env";if(r!==s)return i.NextResponse.json({error:"Unauthorized: Invalid Secret"},{status:403});let a=await e.json(),n=a.order_id||a.reference_id||a.external_id,o=a.status;if(!n)return i.NextResponse.json({error:"No transaction ID provided"},{status:400});let p=await u._.transaction.findUnique({where:{id:n},include:{user:!0}});if(!p)return i.NextResponse.json({error:"Transaction not found"},{status:404});if("SUCCESS"===p.status)return i.NextResponse.json({message:"Already processed"});if("PAID"===o||"SUCCESS"===o||"completed"===o)return await u._.transaction.update({where:{id:n},data:{status:"SUCCESS"}}),await u._.user.update({where:{id:p.userId},data:{coins:{increment:p.coins}}}),i.NextResponse.json({success:!0});if("FAILED"===o||"EXPIRED"===o)return await u._.transaction.update({where:{id:n},data:{status:"FAILED"}}),i.NextResponse.json({success:!0,status:"marked_failed"});return i.NextResponse.json({message:"Status ignored"})}catch(e){return i.NextResponse.json({error:"Internal Server Error"},{status:500})}}let d=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/payment/webhook/route",pathname:"/api/payment/webhook",filename:"route",bundlePath:"app/api/payment/webhook/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\payment\\webhook\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:l,serverHooks:m}=d,h="/api/payment/webhook/route";function w(){return(0,o.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:l})}},72331:(e,t,r)=>{r.d(t,{_:()=>a});var s=r(53524);let a=global.prisma||new s.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972],()=>r(98422));module.exports=s})();