nomadro/app/book/api/pay/ipn/route.ts
eric 9928c5185b Mount nav/book/community as native App Router routes in one Next process.
Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:49:16 -05:00

35 lines
977 B
TypeScript

import { NextResponse } from 'next/server';
import { verifyIpnSignature } from '@ebook/lib/nowpayments';
export async function POST(req: Request) {
const raw = await req.text();
const signature = req.headers.get('x-nowpayments-sig');
if (!verifyIpnSignature(raw, signature)) {
return NextResponse.json({ ok: false }, { status: 401 });
}
try {
const payload = JSON.parse(raw) as {
payment_status?: string;
order_id?: string;
price_amount?: number;
pay_currency?: string;
actually_paid?: number;
invoice_id?: string | number;
};
console.info('NOWPayments IPN', {
status: payload.payment_status,
orderId: payload.order_id,
amount: payload.price_amount,
payCurrency: payload.pay_currency,
paid: payload.actually_paid,
invoiceId: payload.invoice_id,
});
} catch {
return NextResponse.json({ ok: false }, { status: 400 });
}
return NextResponse.json({ ok: true });
}