debug: add billing diagnostics to debug-migration GET (webhook events, subs, paid families)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
b5f1e5540b
commit
0c88058a79
1 changed files with 24 additions and 0 deletions
|
|
@ -53,6 +53,30 @@ export async function GET() {
|
|||
out.circleTablesError = String(e);
|
||||
}
|
||||
|
||||
// Billing diagnostics — last webhook events + subscription rows + family tiers
|
||||
try {
|
||||
out.webhookEvents = await sql.unsafe(
|
||||
`SELECT razorpay_event_id, event_type, received_at,
|
||||
payload->'payload'->'subscription'->'entity'->>'id' AS sub_id,
|
||||
payload->'payload'->'subscription'->'entity'->>'status' AS sub_status
|
||||
FROM razorpay_webhook_events ORDER BY received_at DESC LIMIT 10`
|
||||
);
|
||||
} catch (e) { out.webhookEventsError = String(e); }
|
||||
|
||||
try {
|
||||
out.subscriptions = await sql.unsafe(
|
||||
`SELECT razorpay_subscription_id, status, family_id, current_end, updated_at
|
||||
FROM family_subscriptions ORDER BY created_at DESC LIMIT 10`
|
||||
);
|
||||
} catch (e) { out.subscriptionsError = String(e); }
|
||||
|
||||
try {
|
||||
out.paidFamilies = await sql.unsafe(
|
||||
`SELECT id, tier, subscription_status, max_members, max_children
|
||||
FROM families WHERE tier != 'free' OR subscription_status IS NOT NULL LIMIT 10`
|
||||
);
|
||||
} catch (e) { out.paidFamiliesError = String(e); }
|
||||
|
||||
return NextResponse.json(out);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue