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>
35 lines
977 B
TypeScript
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 });
|
|
}
|