22 lines
705 B
TypeScript
22 lines
705 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { db } from '@/lib/db';
|
|
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const { stripe_id, customer_name, customer_phone } = await req.json();
|
|
|
|
if (!stripe_id) {
|
|
return NextResponse.json({ error: 'Missing stripe_id' }, { status: 400 });
|
|
}
|
|
|
|
await db.query(
|
|
'UPDATE transactions SET customer_name = $1, customer_phone = $2 WHERE stripe_pi_id = $3',
|
|
[customer_name, customer_phone, stripe_id]
|
|
);
|
|
|
|
return NextResponse.json({ success: true });
|
|
} catch (err: any) {
|
|
return NextResponse.json({ error: err.message }, { status: 500 });
|
|
}
|
|
}
|