"use strict";(()=>{var e={};e.id=5613,e.ids=[5613],e.modules={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")},52538:(e,t,a)=>{a.r(t),a.d(t,{originalPathname:()=>y,patchFetch:()=>m,requestAsyncStorage:()=>l,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>d});var r={};a.r(r),a.d(r,{POST:()=>u});var o=a(49303),s=a(88716),n=a(60670),i=a(87070),p=a(57684);async function u(e){try{let{orderId:t}=await e.json();if(!t)return i.NextResponse.json({error:"Missing orderId"},{status:400});let a=await (0,p.A)(),r=await (0,p.x)(a),o=await fetch(`${a.baseUrl}/v2/checkout/orders/${t}/capture`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"}});if(!o.ok){let e=await o.json();return i.NextResponse.json({error:e.message??"Capture failed"},{status:500})}let s=await o.json(),n=s.purchase_units?.[0]?.payments?.captures?.[0]?.id??t;return i.NextResponse.json({success:!0,orderId:s.id,captureId:n,status:s.status})}catch(t){let e=t instanceof Error?t.message:"Internal error";return i.NextResponse.json({error:e},{status:500})}}let c=new o.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/paypal/capture-order/route",pathname:"/api/paypal/capture-order",filename:"route",bundlePath:"app/api/paypal/capture-order/route"},resolvedPagePath:"/Users/abhayraj/dev/Keyur/Doliplay/src/app/api/paypal/capture-order/route.ts",nextConfigOutput:"",userland:r}),{requestAsyncStorage:l,staticGenerationAsyncStorage:d,serverHooks:h}=c,y="/api/paypal/capture-order/route";function m(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:d})}},57684:(e,t,a)=>{async function r(){let e=process.env.API_BASE_URL??"https://stag.divinetechs.com/dttube/public/api/",t=await fetch(`${e}get_payment_option`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","Api-Token":""},body:JSON.stringify({}),cache:"no-store"});if(!t.ok)throw Error(`Failed to fetch payment options: ${t.status}`);let a=await t.json(),r=(a?.result??{}).paypal;if(!r||"1"!==r.visibility)throw Error("PayPal gateway is not enabled");let o=r.key_1,s=r.key_2;if(!o||!s)throw Error("PayPal credentials (key_1 / key_2) are not set in the admin panel");let n="1"===r.is_live;return{clientId:o,secret:s,isLive:n,baseUrl:n?"https://api-m.paypal.com":"https://api-m.sandbox.paypal.com"}}async function o(e){let t=Buffer.from(`${e.clientId}:${e.secret}`).toString("base64"),a=await fetch(`${e.baseUrl}/v1/oauth2/token`,{method:"POST",headers:{Authorization:`Basic ${t}`,"Content-Type":"application/x-www-form-urlencoded"},body:"grant_type=client_credentials"});if(!a.ok){let e=await a.text();throw Error(`PayPal auth failed (${a.status}): ${e}`)}return(await a.json()).access_token}a.d(t,{A:()=>r,x:()=>o})}};var t=require("../../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[8948,5972],()=>a(52538));module.exports=r})();