3dct-client-mirror/snapshot-2026-08-15/home-weddingcaketopper/app/api/payments/session/route.ts
Mannu 596cfcca34 snapshot(2026-08-15): client production system, pre-engagement baseline
Read-only mirror of the client's existing system as it stood before our
work began. Taken from matthijsexpand@149.210.159.152 (TransIP VPS,
Lelystad NL) with the client's written permission.

Contents:
- home-weddingcaketopper/  Next.js app, proxy.py, supabase schema
- var-www/                 static webroots for all three domains
- etc-nginx/               vhost configs (previously unversioned, server-only)

Excluded: node_modules (704M, regenerable), .next (17M, regenerable),
and env file contents (present on local disk, gitignored — see README).

Not our IP. Not covered by the proposal's assignment clause.
2026-08-15 08:57:40 +05:30

12 lines
1 KiB
TypeScript

import { NextResponse } from 'next/server';
import { Client, CheckoutAPI } from '@adyen/api-library';
import { supabaseAdmin } from '@/lib/supabase';
export async function POST(req:Request){
try{ const {orderId}=await req.json(); if(!orderId) return NextResponse.json({error:'Order ontbreekt.'},{status:400});
const site=process.env.NEXT_PUBLIC_SITE_URL!; const sb=supabaseAdmin();
const client=new Client({apiKey:process.env.ADYEN_API_KEY!, environment:(process.env.ADYEN_ENVIRONMENT as any)||'TEST'}); const checkout=new CheckoutAPI(client);
const session=await checkout.PaymentsApi.sessions({merchantAccount:process.env.ADYEN_MERCHANT_ACCOUNT!, amount:{currency:'EUR',value:1995}, reference:orderId, returnUrl:`${site}/payment-result?orderId=${orderId}`, countryCode:'NL', shopperLocale:'nl-NL'} as any);
await sb.from('orders').update({adyen_session_id:(session as any).id}).eq('id',orderId);
return NextResponse.json({session});
}catch(e:any){return NextResponse.json({error:e.message||'Adyen fout'},{status:500})}
}