feat: YuKassa checkout button on /plans + API route

/plans: кнопка Подключить → fetch /api/billing/checkout → redirect to ЮKassa
app/api/billing/checkout/route.js — прокси к engine
This commit is contained in:
Ник (Claude)
2026-06-11 18:45:32 +03:00
parent 9bd38bc645
commit 18613eee77
2 changed files with 26 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
import { NextResponse } from 'next/server';
import { requireUser } from '@/lib/session';
import { engine } from '@/lib/engine';
export async function POST(req) {
const user = await requireUser();
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
try {
const { plan_code } = await req.json();
const data = await engine.call('/api/billing/checkout', {
userId: user.id, method: 'POST', body: { plan_code },
});
return NextResponse.json(data);
} catch (err) { return NextResponse.json({ error: err.message }, { status: 500 }); }
}