23 lines
833 B
TypeScript
23 lines
833 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { db } from '@/lib/db';
|
|
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const { clientSecret, status, customer_name, customer_phone } = await req.json();
|
|
|
|
if (process.env.NEXT_PUBLIC_USE_MOCK_PAYMENTS !== 'true') {
|
|
return NextResponse.json({ error: 'Mock payments are disabled' }, { status: 403 });
|
|
}
|
|
|
|
// Update transaction in Postgres
|
|
await db.query(
|
|
'UPDATE transactions SET status = $1, customer_name = $2, customer_phone = $3 WHERE stripe_pi_id = $4',
|
|
[status, customer_name, customer_phone, clientSecret]
|
|
);
|
|
|
|
return NextResponse.json({ success: true });
|
|
} catch (err: any) {
|
|
return NextResponse.json({ error: err.message }, { status: 500 });
|
|
}
|
|
}
|