"use strict";(()=>{var e={};e.id=7916,e.ids=[7916,2331],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")},45987:(e,r,o)=>{o.r(r),o.d(r,{originalPathname:()=>h,patchFetch:()=>v,requestAsyncStorage:()=>l,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>c});var t={};o.r(t),o.d(t,{POST:()=>u});var n=o(49303),s=o(88716),a=o(60670),p=o(87070),i=o(72331);async function u(e){try{let{id:r,category:o,number:t,code:n,text:s,price:a,service:u,country:d,webhook:l}=await e.json();if(!r||"callback.number"!==o)return p.NextResponse.json({ok:!0});let c=await i.default.otpOrder.findUnique({where:{rumahOtpId:r}});if(!c)return console.warn("[OTP WEBHOOK] Order not found:",r),p.NextResponse.json({ok:!0});return await i.default.otpOrder.update({where:{id:c.id},data:{status:"received",otpCode:n||null,smsText:s||null,phoneNumber:t||c.phoneNumber,receivedAt:new Date}}),console.log(`[OTP WEBHOOK] OTP received for order ${r}: ${n}`),p.NextResponse.json({ok:!0})}catch(e){return console.error("[OTP WEBHOOK]",e),p.NextResponse.json({error:"Webhook error"},{status:500})}}let d=new n.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/otp/webhook/route",pathname:"/api/otp/webhook",filename:"route",bundlePath:"app/api/otp/webhook/route"},resolvedPagePath:"C:\\Users\\akmal\\OneDrive\\Documents\\AmaneNime Topup\\amanenime-topup\\app\\api\\otp\\webhook\\route.ts",nextConfigOutput:"standalone",userland:t}),{requestAsyncStorage:l,staticGenerationAsyncStorage:c,serverHooks:m}=d,h="/api/otp/webhook/route";function v(){return(0,a.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:c})}},72331:(e,r,o)=>{o.r(r),o.d(r,{default:()=>s,prisma:()=>n});var t=o(53524);let n=globalThis.prisma??new t.PrismaClient({datasources:{db:{url:(()=>{if(process.env.DATABASE_URL)return process.env.DATABASE_URL;let e=process.env.DB_USER||"root",r=process.env.DB_PASSWORD||"",o=process.env.DB_HOST||"127.0.0.1",t=process.env.DB_PORT||"3306",n=process.env.DB_NAME||"amanenime_topup";return`mysql://${e}:${r}@${o}:${t}/${n}`})()}},log:["error"]}),s=n}};var r=require("../../../../webpack-runtime.js");r.C(e);var o=e=>r(r.s=e),t=r.X(0,[8948,5972],()=>o(45987));module.exports=t})();